changeset 409:7981f2140c14

web: Move custom head stuff to the front-end.
author Ludovic Chabant <ludovic@chabant.com>
date Thu, 12 Jan 2017 08:54:09 -0800
parents a2ed337652e7
children c93ac92aef5b
files wikked/views/read.py wikked/webimpl/read.py
diffstat 2 files changed, 9 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/wikked/views/read.py	Thu Jan 12 08:44:02 2017 -0800
+++ b/wikked/views/read.py	Thu Jan 12 08:54:09 2017 -0800
@@ -25,6 +25,11 @@
     user = current_user.get_id()
     no_redirect = 'no_redirect' in request.args
     data = read_page(wiki, user, url, no_redirect=no_redirect)
+
+    if data['format']:
+        custom_head = wiki.custom_heads.get(data['format'], '')
+        data['custom_head'] = custom_head
+
     add_auth_data(data)
     add_navigation_data(
             url, data,
--- a/wikked/webimpl/read.py	Thu Jan 12 08:44:02 2017 -0800
+++ b/wikked/webimpl/read.py	Thu Jan 12 08:54:09 2017 -0800
@@ -25,10 +25,9 @@
             additional_info['redirected_from'] = visited_paths[:-1]
 
         ext = os.path.splitext(page.path)[1].lstrip('.')
-        custom_head = wiki.custom_heads.get(ext)
 
         result = {'meta': get_page_meta(page), 'text': page.text,
-                  'page_title': page.title, 'custom_head': custom_head}
+                  'page_title': page.title, 'format': ext}
         result.update(additional_info)
         return result
 
@@ -54,10 +53,9 @@
                     fields=['url', 'path', 'title', 'text', 'meta'],
                     check_perms=(user, CHECK_FOR_READ))
 
-    custom_head = None
+    ext = None
     if info_page is not None:
         ext = os.path.splitext(info_page.path)[1].lstrip('.')
-        custom_head = wiki.custom_heads.get(ext)
 
     if (endpoint_info is not None and
             not endpoint_info.query
@@ -69,7 +67,7 @@
                 'meta': get_page_meta(info_page),
                 'text': info_page.text,
                 'page_title': info_page.title,
-                'custom_head': custom_head}
+                'format': ext}
         result.update(additional_info)
         return result
 
@@ -105,7 +103,7 @@
                     'title': value
                     },
             'page_title': page_title,
-            'custom_head': custom_head
+            'format': ext
             }
     if info_page:
         result['text'] = info_page.text