Skip to content

Commit

Permalink
Implements handler_xslt for Cherokee. There can still be done some po…
Browse files Browse the repository at this point in the history
…lishing, especially in the admin part regarding what does what. In the automake part.

But the thing seems to actually work.
  • Loading branch information
skinkie committed Oct 23, 2011
1 parent fda6ff4 commit 2f32dac
Show file tree
Hide file tree
Showing 7 changed files with 613 additions and 2 deletions.
1 change: 1 addition & 0 deletions admin/consts.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
('empty_gif', N_('1x1 Transparent GIF')), ('empty_gif', N_('1x1 Transparent GIF')),
('drop', N_('Drop Connection')), ('drop', N_('Drop Connection')),
('tile', N_('Renderd Frontend')), ('tile', N_('Renderd Frontend')),
('xslt', N_('XSLT')),
] ]


ERROR_HANDLERS = [ ERROR_HANDLERS = [
Expand Down
3 changes: 2 additions & 1 deletion admin/plugins/Makefile.am
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ uwsgi.py \
wildcard.py \ wildcard.py \
gzip.py \ gzip.py \
deflate.py \ deflate.py \
drop.py drop.py \
xslt.py


EXTRA_DIST = \ EXTRA_DIST = \
$(adminplugins_DATA) $(adminplugins_DATA)
70 changes: 70 additions & 0 deletions admin/plugins/xslt.py
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,70 @@
# -*- coding: utf-8 -*-
#
# Cherokee-admin
#
# Authors:
# Alvaro Lopez Ortega <alvaro@alobbs.com>
#
# Copyright (C) 2010 Alvaro Lopez Ortega
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of version 2 of the GNU General Public
# License as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
#

import CTK
import Handler

from util import *
from consts import *

URL_APPLY = '/plugin/xslt/apply'
HELPS = [('modules_handlers_xslt', N_("XSLT"))]

OPTIONS = [
('', N_("None")),
('novalid', N_("No valid")),
('nodtdattr', N_("No DTD Attribute"))
]

NOTE_OPTIONS = N_('How the XML should be parsed.')
NOTE_NODICT = N_('Disable dictionary.')
NOTE_CATALOGS = N_('Enable SGML Catalog Files.')
NOTE_XINCLUDE = N_('Enable XInclude.')
NOTE_XINCLUDESTYLE = N_('Enable XInclude style.')
NOTE_CONTENTTYPE = N_('The Content-Type the file should be send as.')
NOTE_STYLESHEET = N_('The XSL stylesheet to be used for any transformation.')


class Plugin_xslt (Handler.PluginHandler):
def __init__ (self, key, **kwargs):
Handler.PluginHandler.__init__ (self, key, **kwargs)
Handler.PluginHandler.AddCommon (self)

table = CTK.PropsTable()
table.Add (_("Options"), CTK.ComboCfg('%s!options'%(key), trans_options(OPTIONS)), _(NOTE_OPTIONS))
table.Add (_("No dictionary"), CTK.CheckCfgText("%s!nodict"%(self.key), True, ''), _(NOTE_NODICT))
table.Add (_("Catalogs"), CTK.CheckCfgText("%s!catalogs"%(self.key), True, ''), _(NOTE_CATALOGS))
table.Add (_("XInclude"), CTK.CheckCfgText("%s!xinclude"%(self.key), True, _('Enabled')), _(NOTE_XINCLUDE))
table.Add (_("XincludeStyle"), CTK.CheckCfgText("%s!xincludestyle"%(self.key), True, _('Enabled')), _(NOTE_XINCLUDESTYLE))
table.Add (_("Content-Type"), CTK.TextCfg ('%s!contenttype'%(key), True), _(NOTE_CONTENTTYPE))
table.Add (_("Stylesheet"), CTK.TextCfg ('%s!stylesheet'%(key), True), _(NOTE_STYLESHEET))

submit = CTK.Submitter (URL_APPLY)
submit += table

self += CTK.RawHTML ("<h2>%s</h2>" %(_('XML Parser Settings')))
self += CTK.Indenter (submit)

VALS = [("%s!stylesheet"%(self.key), validations.is_local_file_exists)]
CTK.publish ('^%s'%(URL_APPLY), CTK.cfg_apply_post, validation=VALS, method="POST")
19 changes: 19 additions & 0 deletions cherokee/Makefile.am
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -532,6 +532,23 @@ else
dynamic_handler_post_report_lib = libplugin_post_report.la dynamic_handler_post_report_lib = libplugin_post_report.la
endif endif


#
# Handler xslt
#
handler_xslt = \
handler_xslt.c \
handler_xslt.h \
logo.inc

libplugin_xslt_la_LDFLAGS = $(module_ldflags) `pkg-config libxslt libexslt --libs`
libplugin_xslt_la_SOURCES = $(handler_xslt)
libplugin_xslt_la_CFLAGS = `pkg-config libxslt libexslt --cflags`

if STATIC_HANDLER_SERVER_INFO
static_handler_xslt_src = $(handler_xslt)
else
dynamic_handler_xslt_lib = libplugin_xslt.la
endif


# #
# Handler server_info # Handler server_info
Expand Down Expand Up @@ -1622,6 +1639,7 @@ $(static_handler_custom_error_src) \
$(static_handler_server_info_src) \ $(static_handler_server_info_src) \
$(static_handler_render_rrd_src) \ $(static_handler_render_rrd_src) \
$(static_handler_dbslayer_src) \ $(static_handler_dbslayer_src) \
$(static_handler_xslt_src) \
$(static_handler_admin_src) \ $(static_handler_admin_src) \
\ \
$(static_logger_ncsa_src) \ $(static_logger_ncsa_src) \
Expand Down Expand Up @@ -1815,6 +1833,7 @@ $(dynamic_handler_error_redir_lib) \
$(dynamic_handler_error_nn_lib) \ $(dynamic_handler_error_nn_lib) \
$(dynamic_handler_common_lib) \ $(dynamic_handler_common_lib) \
$(dynamic_handler_dbslayer_lib) \ $(dynamic_handler_dbslayer_lib) \
$(dynamic_handler_xslt_lib) \
$(dynamic_handler_admin_lib) \ $(dynamic_handler_admin_lib) \
$(dynamic_encoder_gzip_lib) \ $(dynamic_encoder_gzip_lib) \
$(dynamic_encoder_deflate_lib) \ $(dynamic_encoder_deflate_lib) \
Expand Down
Loading

0 comments on commit 2f32dac

Please sign in to comment.