Commit 3f4c4d74 by Bridger Maxwell

Got most of the wiki article page working. It shows the article menu now.

parent 45baccae
......@@ -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
......
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)
## 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"><title>${article.current_revision.title}</title></%block>
<%doc>
<%block name="wiki_breadcrumbs">
Render "wiki/includes/breadcrumbs.html"
## {% include "wiki/includes/breadcrumbs.html" %}
</%block>
</%doc>
<!-- {% extends "wiki/base.html" %}
{% load wiki_tags i18n %}
{% load url from future %}
{% block pagetitle %}{{ article.current_revision.title }}{% endblock %}
{% block wiki_breadcrumbs %}
{% include "wiki/includes/breadcrumbs.html" %}
{% endblock %}
{% block wiki_contents %}
<h1> Did it work? </h1>
<div class="tabbable tabs-top" style="margin-top: 20px;">
<ul class="nav nav-tabs">
<li style="float: left">
<h1 style="margin-top: -10px;">{{ article.current_revision.title }}</h1>
</li>
{% with "view" as selected %}
{% include "wiki/includes/article_menu.html" %}
{% endwith %}
</ul>
<div class="tab-content">
{% wiki_render article %}
</div>
</div>
<div class="tabbable tabs-below" style="margin-top: 20px;">
<ul class="nav nav-tabs">
{% with "view" as selected %}
{% include "wiki/includes/article_menu.html" %}
{% endwith %}
<li style="margin-top: 10px;"><em>{% trans "Article last modified:" %} {{ article.current_revision.modified }}</em></li>
</ul>
<%block name="wiki_contents">
<div class="tabbable tabs-top" style="margin-top: 20px;">
<ul class="nav nav-tabs">
<li style="float: left">
<h1 style="margin-top: -10px;">${article.current_revision.title}</h1>
</li>
${article_menu.body('view', article, plugins)}
</ul>
<div class="tab-content">
${ render_inclusion(wiki_render, 'wiki/includes/render.html', article ) }
</div>
{% endblock %} -->
</div>
<div class="tabbable tabs-below" style="margin-top: 20px;">
<%doc>
<ul class="nav nav-tabs">
{% with "view" as selected %}
{% include "wiki/includes/article_menu.html" %}
{% endwith %}
<li style="margin-top: 10px;"><em>{% trans "Article last modified:" %} {{ article.current_revision.modified }}</em></li>
</ul>
</%doc>
</div>
</%block>
## 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"):
<li class="pull-right{% if selected == plugin.slug %} active{% endif %}">
<a href="${tab_reverse('wiki:plugin_url', kwargs={'slug' : plugin.slug}) }">
<span class="${plugin.article_tab[1]}"></span>
${plugin.article_tab[0]}
</a>
</li>
%endif
%endfor
<li class="pull-right${"active" if selected == "settings" else ""}">
%if not user.is_anonymous:
<a href="${tab_reverse('wiki:settings_url')}">
<span class="icon-wrench"></span>
Settings
</a>
%endif
</li>
<li class="pull-right${"active" if selected == "history" else ""}">
<a href="${tab_reverse('wiki:history_url')}">
<span class="icon-time"></span>
Changes
</a>
</li>
<li class="pull-right${"active" if selected == "edit" else ""}">
<a href="${tab_reverse('wiki:edit_url')}">
<span class="icon-edit"></span>
Edit
</a>
</li>
<li class="pull-right${"active" if selected == "view" else ""}">
<a href="${tab_reverse('wiki:get_url')}">
<span class="icon-home"></span>
View
</a>
</li>
## mako
<%inherit file="../main.html"/>
<%namespace name='static' file='../static_content.html'/>
<%block name="headextra">
<%static:css group='course'/>
</%block>
<%block name="bodyextra">
## %if course:
## <%include file="../course_navigation.html" args="active_page='wiki'" />
## %endif
<div class="container" style="margin-top: 60px;">
<%doc>
{% if messages %}
{% for message in messages %}
<div class="alert alert-{{ message.tags }}">
<a class="close" data-dismiss="alert" href="#">&times;</a>
{{ message }}
</div>
{% endfor %}
{% endif %}
</%doc>
<%block name="wiki_breadcrumbs" />
<%block name="wiki_contents" />
<div style="padding: 50px 0;">
<footer>
<hr />
<a href="https://github.com/benjaoming/django-wiki" class="pull-right"><img src="{{ STATIC_URL }}wiki/img/github_icon.png" /></a>
<p>Powered by <a href="http://www.django-wiki.org">django-wiki</a>, an open source application under the <a href="http://www.gnu.org/licenses/quick-guide-gplv3.html">GPLv3</a> license. Let knowledge be the cure.</p>
<div style="clear: both"></div>
</footer>
</div>
</div> <!-- /container -->
</%block>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment