Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: sitescripts/web/utils.py

Issue 17817001: Simple CMS as Anwiki replacement (Closed)
Patch Set: Completed functionality Created Oct. 24, 2013, 9:32 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« sitescripts/web/sources.py ('K') | « sitescripts/web/sources.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sitescripts/web/utils.py
===================================================================
new file mode 100644
--- /dev/null
+++ b/sitescripts/web/utils.py
@@ -0,0 +1,54 @@
+# coding: utf-8
+
+# This file is part of the Adblock Plus web scripts,
+# Copyright (C) 2006-2013 Eyeo GmbH
+#
+# Adblock Plus is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 3 as
+# published by the Free Software Foundation.
+#
+# Adblock Plus 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 Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
+
+from .converters import converters, TemplateConverter
+
+def process_page(source, locale, page, format):
+ params = {
+ "source": source,
+ "template": "default",
+ "locale": locale,
+ "title": "title",
+ "page": page,
+ "pagedata": source.read_page(page, format),
+ "config": source.read_config(),
+ }
+
+ localefile = page
+ if params["config"].has_option("locale_overrides", page):
+ localefile = params["config"].get("locale_overrides", page)
+ params["localedata"] = source.read_locale(params["locale"], localefile)
+
+ try:
+ converter = converters[format](params)
+ except KeyError:
+ raise Exception("Page %s uses unknown format %s" % (page, format))
+
+ # Note: The converter might change some parameters so we can only read in
+ # template data here.
+ params["templatedata"] = source.read_template(params["template"])
+ template_converter = TemplateConverter(params, key="templatedata")
+
+ params["available_locales"] = sorted(
+ filter(
+ lambda locale: source.has_locale(locale, localefile),
+ source.list_locales()
+ )
+ )
+
+ params["head"], params["body"] = converter()
+ return template_converter()
« sitescripts/web/sources.py ('K') | « sitescripts/web/sources.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld