[#891] Jinja templates for the wiki

Jenny Steele Jenny Steele 2010-09-08

added ForgeWiki/forgewiki/templates/jinja_wiki_master.html
changed Allura/allura/config/app_cfg.py
changed Allura/allura/templates/jinja_master/master.html
changed ForgeWiki/forgewiki/templates/admin_home.html
changed ForgeWiki/forgewiki/templates/admin_options.html
changed ForgeWiki/forgewiki/templates/browse.html
changed ForgeWiki/forgewiki/templates/browse_tags.html
changed ForgeWiki/forgewiki/templates/page_diff.html
changed ForgeWiki/forgewiki/templates/page_edit.html
changed ForgeWiki/forgewiki/templates/page_history.html
changed ForgeWiki/forgewiki/templates/page_view.html
changed ForgeWiki/forgewiki/templates/wiki_help.html
changed ForgeWiki/forgewiki/wiki_main.py
copied ForgeWiki/forgewiki/templates/markdown_syntax.html -> ForgeWiki/forgewiki/templates/wiki_search.html
copied ForgeWiki/forgewiki/templates/search.html -> Allura/allura/templates/jinja_master/lib.html
copied ForgeWiki/forgewiki/templates/wiki_master.html -> ForgeWiki/forgewiki/templates/wiki_markdown_syntax.html
ForgeWiki/forgewiki/templates/jinja_wiki_master.html Diff Switch to side-by-side view
Loading...
Allura/allura/config/app_cfg.py Diff Switch to side-by-side view
Loading...
Allura/allura/templates/jinja_master/master.html Diff Switch to side-by-side view
Loading...
ForgeWiki/forgewiki/templates/admin_home.html Diff Switch to side-by-side view
Loading...
ForgeWiki/forgewiki/templates/admin_options.html Diff Switch to side-by-side view
Loading...
ForgeWiki/forgewiki/templates/browse.html Diff Switch to side-by-side view
Loading...
ForgeWiki/forgewiki/templates/browse_tags.html Diff Switch to side-by-side view
Loading...
ForgeWiki/forgewiki/templates/page_diff.html Diff Switch to side-by-side view
Loading...
ForgeWiki/forgewiki/templates/page_edit.html Diff Switch to side-by-side view
Loading...
ForgeWiki/forgewiki/templates/page_history.html Diff Switch to side-by-side view
Loading...
ForgeWiki/forgewiki/templates/page_view.html Diff Switch to side-by-side view
Loading...
ForgeWiki/forgewiki/templates/wiki_help.html Diff Switch to side-by-side view
Loading...
ForgeWiki/forgewiki/wiki_main.py Diff Switch to side-by-side view
Loading...
ForgeWiki/forgewiki/templates/markdown_syntax.html to ForgeWiki/forgewiki/templates/wiki_search.html
--- a/ForgeWiki/forgewiki/templates/markdown_syntax.html
+++ b/ForgeWiki/forgewiki/templates/wiki_search.html
@@ -1,31 +1,34 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
-                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml"
-      xmlns:py="http://genshi.edgewall.org/"
-      xmlns:xi="http://www.w3.org/2001/XInclude">
+{% extends 'jinja_wiki_master.html' %}
 
-  <xi:include href="wiki_master.html"/>
+{% block title %}{{c.project.name}} / {{c.app.config.options.mount_label}} / Search{% endblock %}
 
-  <head>
-    <meta content="text/html; charset=UTF-8" http-equiv="content-type" py:replace="''"/>
-    <title>$c.project.name / $c.app.config.options.mount_label / Markdown Syntax</title>
-  </head>
+{% block header %}Search {{c.app.config.options.mount_point}}: {{q}}{% endblock %}
 
-  <body>
-    <h1 class="title">Markdown Syntax</h1>
-    <div class="content">
-      <div class="row">
-        <div class="column grid_12">
-          <p>You can use
-            <a href="http://daringfireball.net/projects/markdown/">MarkDown</a>
-            Syntax here</p>
-          <h4>Example Input</h4>
-          <pre style="background-color:#fff">$example</pre>
-          <h4>Example Rendering</h4>
-          <div style="background-color:#fff">${Markup(g.markdown.convert(example))}</div>
-          <a href="http://daringfireball.net/projects/markdown/syntax">More Examples</a>
-        </div>
-      </div>
-    </div>
-  </body>
-</html>
+{% block wiki_content %}
+<form method="GET" action=".">
+  <input type="text" name="q" value="{{q}}" class="defaultText" title="Search App"/><br/>
+  <input type="submit" value="Search App"/>
+  <input type="submit" name="project" value="Search Entire Project"
+        /><br/>
+  Search history? <input type="checkbox" name="history"{% if history %} checked="checked"{% endif %}/><br/>
+</form>
+
+{% if q %}
+  {% if count==0 %}
+    <p>No results.</p>
+  {% elif count==1 %}
+    <p>{{count}} result.</p>
+  {% else %}
+    <p>{{count}} results.</p>
+  {% endif %}
+{% endif %}  
+{% for doc in results %}
+  <div>
+    <a href="{{doc['url_s']}}">{{doc.title_s}}</a><br/>
+    {% if doc.get('snippet') %}
+      <p>{{doc.snippet}}</p>
+    {% endif %}
+    <hr/>
+  </div>
+{% endfor %}
+{% endblock %}
ForgeWiki/forgewiki/templates/search.html to Allura/allura/templates/jinja_master/lib.html
--- a/ForgeWiki/forgewiki/templates/search.html
+++ b/Allura/allura/templates/jinja_master/lib.html
@@ -1,39 +1,27 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
-                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml"
-      xmlns:py="http://genshi.edgewall.org/"
-      xmlns:xi="http://www.w3.org/2001/XInclude">
-  <?python from pprint import pformat ?>
-
-  <xi:include href="wiki_master.html" />
-
-  <head>
-    <meta content="text/html; charset=UTF-8" http-equiv="content-type" py:replace="''"/>
-    <title>$c.project.name / $c.app.config.options.mount_label / Search</title>
-  </head>
-  <body>
-    <h1 class="title">Search $c.app.config.options.mount_point: $q</h1>
-    <div class="content">
-      <div class="row">
-        <div class="column grid_12">
-          <form method="GET" action=".">
-            <input type="text" name="q" value="$q" class="defaultText" title="Search App"/><br/>
-            <input type="submit" value="Search App"/>
-            <input type="submit" name="project" value="Search Entire Project"
-                  /><br/>
-            Search history? <input type="checkbox" name="history" checked="${history or None}"/><br/>
-          </form>
-          <p py:if="count==0 and q">No results.</p>
-          <p py:if="count==1 and q">$count result.</p>
-          <p py:if="count > 1 and q">$count results.</p>
-          <div py:for="doc in results">
-            <a href="${doc['url_s']}">$doc.title_s</a><br/>
-            <p py:if="doc.get('snippet')">$doc.snippet</p>
-            <hr/>
-          </div>
-        </div>
-      </div>
-    </div>
-  </body>
-  
-</html>
+{% macro gravatar(user, size) -%}
+  {% if user.preferences.email_address %}
+    {% if size %}
+      <img src="{{g.gravatar(user.preferences.email_address, default=g.url('/u/'+user.username.replace('_', '-')+'/user_icon'))}}"
+           alt="{{user.display_name}}"
+           title="{{user.display_name}}"
+           height="{{size}}"
+           width="{{size}}"/>
+    {% else %}
+      <img src="{{g.gravatar(user.preferences.email_address, default=g.url('/u/'+user.username.replace('_', '-')+'/user_icon'))}}"
+           alt="{{user.display_name}}"
+           title="{{user.display_name}}"/>
+    {% endif %}
+  {% else %}
+    {% if size %}
+      <img src="{{'/u/'+user.username.replace('_', '-')+'/user_icon'}}"
+           alt="{{user.display_name}}"
+           title="{{user.display_name}}"
+           height="{{size}}"
+           width="{{size}}"/>
+    {% else %}
+      <img src="{{'/u/'+user.username.replace('_', '-')+'/user_icon'}}"
+           alt="{{user.display_name}}"
+           title="{{user.display_name}}"/>
+    {% endif %}
+  {% endif %}
+{%- endmacro %}
ForgeWiki/forgewiki/templates/wiki_master.html to ForgeWiki/forgewiki/templates/wiki_markdown_syntax.html
--- a/ForgeWiki/forgewiki/templates/wiki_master.html
+++ b/ForgeWiki/forgewiki/templates/wiki_markdown_syntax.html
@@ -1,33 +1,30 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
-                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml"
-      xmlns:py="http://genshi.edgewall.org/"
-      xmlns:xi="http://www.w3.org/2001/XInclude">
-  <xi:include href="${g.allura_templates}/master.html"/>
+{% extends 'jinja_master/master.html' %}
 
-  <head py:match="head" py:attrs="select('@*')">
-    <meta content="text/html; charset=UTF-8" http-equiv="content-type" py:replace="''"/>
-    <title py:replace="''">Your title goes here</title>
-    <meta py:replace="select('*')"/>
-    <py:for each="blob in g.resource_manager.emit('head_css')">$blob</py:for>
-    <py:for each="blob in g.resource_manager.emit('head_js')">$blob</py:for>
-    <link rel="stylesheet" type="text/css" href="${g.app_static('css/wiki.css')}" />
-  </head>
+{% block title %}{{c.project.name}} / {{c.app.config.options.mount_label}} / Markdown Syntax{% endblock %}
 
-  <body py:match="body" py:attrs="select('@*')">
-    <py:for each="blob in g.resource_manager.emit('body_top_js')">$blob</py:for>
-    <div py:replace="select('*|text()')"/>
-    <div id="create_wiki_page_holder" title="Create New Page" style="display:none">
-      <form>
-        <ol>
-          <li>
-            <label>Name</label>
-            <input type="text" name="name"/>
-          </li>
-        </ol>
-      </form>
-    </div>
-    <py:for each="blob in g.resource_manager.emit('body_js')">$blob</py:for>
-    <script type="text/javascript" src="${g.app_static('js/wiki.js')}"></script>
-  </body>
-</html>
+{% block header %}Markdown Syntax{% endblock %}
+
+{% block content %}
+<p>You can use
+  <a href="http://daringfireball.net/projects/markdown/">MarkDown</a>
+  Syntax here</p>
+<h4>Example Input</h4>
+<pre style="background-color:#fff">
+# First-level heading
+
+Some *emphasized* and **strong** text
+
+#### Fourth-level heading
+
+</pre>
+<h4>Example Rendering</h4>
+<div style="background-color:#fff">{{g.markdown.convert('''
+# First-level heading
+
+Some *emphasized* and **strong** text
+
+#### Fourth-level heading
+
+''')}}</div>
+<a href="http://daringfireball.net/projects/markdown/syntax">More Examples</a>
+{% endblock %}