diff --git a/common/lib/mitxmako/mitxmako/template.py b/common/lib/mitxmako/mitxmako/template.py index e8fc24a4be..fa6b1293f8 100644 --- a/common/lib/mitxmako/mitxmako/template.py +++ b/common/lib/mitxmako/mitxmako/template.py @@ -20,7 +20,7 @@ from mitxmako import middleware django_variables = ['lookup', 'output_encoding', 'module_directory', 'encoding_errors'] - +# TODO: We should make this a Django Template subclass that simply has the MakoTemplate inside of it? (Intead of inheriting from MakoTemplate) class Template(MakoTemplate): """ This bridges the gap between a Mako template and a djano template. It can diff --git a/common/lib/mitxmako/mitxmako/templatetag_helpers.py b/common/lib/mitxmako/mitxmako/templatetag_helpers.py new file mode 100644 index 0000000000..0c66cea090 --- /dev/null +++ b/common/lib/mitxmako/mitxmako/templatetag_helpers.py @@ -0,0 +1,23 @@ +from django.template.base import Template, Context +from django.template.loader import get_template, select_template + + +def render_inclusion(func, file_name, *args, **kwargs): + _dict = func(*args, **kwargs) + if isinstance(file_name, Template): + t = file_name + elif not isinstance(file_name, basestring) and is_iterable(file_name): + t = select_template(file_name) + else: + t = get_template(file_name) + + nodelist = t.nodelist + + new_context = Context(_dict) + # **{ + # 'autoescape': context.autoescape, + # 'current_app': context.current_app, + # 'use_l10n': context.use_l10n, + # 'use_tz': context.use_tz, + # }) + return nodelist.render(new_context) diff --git a/lms/templates/wiki/article.html b/lms/templates/wiki/article.html index 45b3071141..bedeb368d0 100644 --- a/lms/templates/wiki/article.html +++ b/lms/templates/wiki/article.html @@ -1,48 +1,51 @@ ## mako -<%inherit file="../main.html"/> -<%namespace name='static' file='../static_content.html'/> +<%inherit file="mako_base.html"/> -<%block name="bodyextra"> +<%! + from wiki.templatetags.wiki_tags import wiki_render + from mitxmako.templatetag_helpers import render_inclusion +%> -This is a mako template with inheritance! +<%namespace name="article_menu" file="includes/article_menu.html"/> + + +<%block name="title">${article.current_revision.title} + + +<%doc> +<%block name="wiki_breadcrumbs"> +Render "wiki/includes/breadcrumbs.html" +## {% include "wiki/includes/breadcrumbs.html" %} + + + + + +<%block name="wiki_contents"> + +
+ + +
+ ${ render_inclusion(wiki_render, 'wiki/includes/render.html', article ) } +
+
+ +
+ <%doc> + + +
- - - diff --git a/lms/templates/wiki/includes/article_menu.html b/lms/templates/wiki/includes/article_menu.html new file mode 100644 index 0000000000..0e5af642e6 --- /dev/null +++ b/lms/templates/wiki/includes/article_menu.html @@ -0,0 +1,51 @@ +## mako +<%page args="selected, article, plugins" /> +<%! from django.core.urlresolvers import reverse %> + +<% + if urlpath: + tab_reverse = lambda name, kwargs={}: reverse(name, kwargs=dict({'path' : urlpath.path}, **kwargs)) + else: + tab_reverse = lambda name, kwargs={}: reverse(name, kwargs=dict({'article_id' : article.id}, **kwargs)) +%> + + +%for plugin in plugins: + %if hasattr(plugin, "article_tab"): +
  • + + + ${plugin.article_tab[0]} + +
  • + %endif +%endfor + + + +
  • + %if not user.is_anonymous: + + + Settings + + %endif +
  • +
  • + + + Changes + +
  • +
  • + + + Edit + +
  • +
  • + + + View + +
  • diff --git a/lms/templates/wiki/mako_base.html b/lms/templates/wiki/mako_base.html new file mode 100644 index 0000000000..e8e6b3664b --- /dev/null +++ b/lms/templates/wiki/mako_base.html @@ -0,0 +1,41 @@ +## mako +<%inherit file="../main.html"/> +<%namespace name='static' file='../static_content.html'/> + +<%block name="headextra"> + <%static:css group='course'/> + + +<%block name="bodyextra"> + +## %if course: +## <%include file="../course_navigation.html" args="active_page='wiki'" /> +## %endif + +
    + <%doc> + {% if messages %} + {% for message in messages %} +
    + × + {{ message }} +
    + {% endfor %} + {% endif %} + + + <%block name="wiki_breadcrumbs" /> + <%block name="wiki_contents" /> + +
    + +
    + +
    + +