Commit e462fad3 by Bridger Maxwell

Converted wiki edit page and breadcrumbs.

parent 3f4c4d74
from django.template import loader
from django.template.base import Template, Context from django.template.base import Template, Context
from django.template.loader import get_template, select_template from django.template.loader import get_template, select_template
...@@ -21,3 +22,7 @@ def render_inclusion(func, file_name, *args, **kwargs): ...@@ -21,3 +22,7 @@ def render_inclusion(func, file_name, *args, **kwargs):
# 'use_tz': context.use_tz, # 'use_tz': context.use_tz,
# }) # })
return nodelist.render(new_context) return nodelist.render(new_context)
def django_template_include(file_name, mako_context):
dictionary = dict( mako_context )
return loader.render_to_string(file_name, dictionary=dictionary)
...@@ -7,23 +7,18 @@ ...@@ -7,23 +7,18 @@
%> %>
<%namespace name="article_menu" file="includes/article_menu.html"/> <%namespace name="article_menu" file="includes/article_menu.html"/>
<%namespace name="breadcrumbs" file="includes/breadcrumbs.html"/>
<%block name="title"><title>${article.current_revision.title}</title></%block> <%block name="title"><title>${article.current_revision.title}</title></%block>
<%doc>
<%block name="wiki_breadcrumbs"> <%block name="wiki_breadcrumbs">
Render "wiki/includes/breadcrumbs.html" ${breadcrumbs.body(article, urlpath)}
## {% include "wiki/includes/breadcrumbs.html" %}
</%block> </%block>
</%doc>
<%block name="wiki_contents"> <%block name="wiki_contents">
<div class="tabbable tabs-top" style="margin-top: 20px;">
<div class="tabbable tabs-top" style="margin-top: 20px;">
<ul class="nav nav-tabs"> <ul class="nav nav-tabs">
<li style="float: left"> <li style="float: left">
<h1 style="margin-top: -10px;">${article.current_revision.title}</h1> <h1 style="margin-top: -10px;">${article.current_revision.title}</h1>
...@@ -34,18 +29,13 @@ Render "wiki/includes/breadcrumbs.html" ...@@ -34,18 +29,13 @@ Render "wiki/includes/breadcrumbs.html"
<div class="tab-content"> <div class="tab-content">
${ render_inclusion(wiki_render, 'wiki/includes/render.html', article ) } ${ render_inclusion(wiki_render, 'wiki/includes/render.html', article ) }
</div> </div>
</div> </div>
<div class="tabbable tabs-below" style="margin-top: 20px;"> <div class="tabbable tabs-below" style="margin-top: 20px;">
<%doc>
<ul class="nav nav-tabs"> <ul class="nav nav-tabs">
{% with "view" as selected %} ${article_menu.body('view', article, plugins)}
{% include "wiki/includes/article_menu.html" %} <li style="margin-top: 10px;"><em>Article last modified: ${ article.current_revision.modified }</em></li>
{% endwith %}
<li style="margin-top: 10px;"><em>{% trans "Article last modified:" %} {{ article.current_revision.modified }}</em></li>
</ul> </ul>
</%doc> </div>
</div>
</%block> </%block>
## mako
<%inherit file="mako_base.html"/>
<%!
from django.core.urlresolvers import reverse
from mitxmako.templatetag_helpers import django_template_include
%>
<%namespace name="article_menu" file="includes/article_menu.html"/>
<%namespace name="breadcrumbs" file="includes/breadcrumbs.html"/>
<%block name="title"><title>Edit: ${article.current_revision.title}</title></%block>
<%block name="wiki_breadcrumbs">
${breadcrumbs.body(article, urlpath)}
</%block>
<%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('edit', article, plugins)}
</ul>
<div class="tab-content">
<form method="POST" class="form-horizontal">
${django_template_include("wiki/includes/editor.html", context)}
<div class="form-actions">
<button type="submit" name="preview" value="1" class="btn btn-large" onclick="$('#previewModal').modal('show'); this.form.target='previewWindow'; this.form.action='${reverse('wiki:preview_url', kwargs={'path' : urlpath.path})}'">
<span class="icon-eye-open"></span>
Preview
</button>
<button type="submit" name="save" value="1" class="btn btn-large btn-primary" onclick="this.form.target=''; this.form.action='${reverse('wiki:edit_url', kwargs={'path' : urlpath.path})}'">
<span class="icon-ok"></span>
Save changes
</button>
<a class="pull-right btn btn-danger">
<span class="icon-trash"></span>
Delete article
</a>
</div>
<div class="modal hide fade" id="previewModal" style="width: 80%; min-height: 500px; margin-left: -40%;">
<div class="modal-body">
<iframe name="previewWindow" style="width: 100%; min-height: 400px; border: 0;" frameborder="0"></iframe>
</div>
<div class="modal-footer">
<a href="#" class="btn btn-large" data-dismiss="modal">
<span class="icon-circle-arrow-left"></span>
Back to editor
</a>
<button type="submit" name="save" value="1" class="btn btn-large btn-primary" onclick="this.form.target=''; this.form.action='${reverse('wiki:edit_url', kwargs={'path' : urlpath.path})}'">
<span class="icon-ok"></span>
Save changes
</button>
</div>
</div>
</form>
</div>
</div>
<div class="tabbable tabs-below" style="margin-top: 20px;">
<ul class="nav nav-tabs">
${article_menu.body('edit', article, plugins)}
<li style="margin-top: 10px;"><em>Article last modified: ${ article.current_revision.modified }</em></li>
</ul>
</div>
</%block>
## mako
<%page args="article, urlpath" />
<%! from django.core.urlresolvers import reverse %>
%if urlpath:
<ul class="breadcrumb pull-left" class="">
%for ancestor in urlpath.get_ancestors():
<span class="divider">/</span>
<li><a href="${reverse('wiki:get_url', ancestor.path)}">${ ancestor.article.current_revision.title }</a></li>
%endfor
<span class="divider">/</span>
<li class="active"><a href="${reverse('wiki:get_url', kwargs={'path' : urlpath.path})}">${ article.current_revision.title }</a></li>
<span class="divider">/</span>
</ul>
<div class="pull-left" style="margin-left: 10px;">
<div class="btn-group">
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#" style="padding: 7px;" title="Sub-articles for ${ article.current_revision.title }">
<span class="icon-list"></span>
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
%if len(urlpath.get_children()) > 0:
%for child in urlpath.get_children():
<li>
<a href="${reverse('wiki:get_url', child.path)}">
${child.article.current_revision.title}
</a>
</li>
%endfor
%else:
<li><a href="#"><em>No sub-articles</em></a></li>
%endif
<li class="divider"></li>
<li>
<a href="" onclick="alert('TODO')">List sub-pages &raquo;</a>
</li>
</ul>
</div>
</div>
<div class="pull-left" style="margin-left: 10px;">
<a class="btn" href="${reverse('wiki:create_url', kwargs={'path' : urlpath.path})}" style="padding: 7px;">
<span class="icon-plus"></span>
Add article
</a>
</div>
<div style="clear: both"></div>
%endif
\ No newline at end of file
...@@ -152,6 +152,8 @@ if settings.WIKI_ENABLED: ...@@ -152,6 +152,8 @@ if settings.WIKI_ENABLED:
# ) # )
urlpatterns += ( urlpatterns += (
#url(r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/wiki/', include('simplewiki.urls')),
url(r'wiki/', include(wiki_pattern())), url(r'wiki/', include(wiki_pattern())),
url(r'^notify/', include(notify_pattern())), url(r'^notify/', include(notify_pattern())),
) )
......
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