Added wiki create and create_root. Fixed some mitxmako bugs.
This commit is contained in:
@@ -23,7 +23,7 @@ class MakoLoader(object):
|
||||
return self.load_template(template_name, template_dirs)
|
||||
|
||||
def load_template(self, template_name, template_dirs=None):
|
||||
source, display_name = self.base_loader.load_template_source(template_name, template_dirs)
|
||||
source, display_name = self.load_template_source(template_name, template_dirs)
|
||||
|
||||
if source.startswith("## mako\n"):
|
||||
# This is a mako template
|
||||
@@ -42,9 +42,9 @@ class MakoLoader(object):
|
||||
# not exist.
|
||||
return source, display_name
|
||||
|
||||
def load_template_source(self):
|
||||
def load_template_source(self, template_name, template_dirs=None):
|
||||
# Just having this makes the template load as an instance, instead of a class.
|
||||
raise NotImplementedError
|
||||
return self.base_loader.load_template_source(template_name, template_dirs)
|
||||
|
||||
def reset(self):
|
||||
self.base_loader.reset()
|
||||
|
||||
@@ -53,6 +53,7 @@ class Template(MakoTemplate):
|
||||
context_dictionary.update(d)
|
||||
context_dictionary['settings'] = settings
|
||||
context_dictionary['MITX_ROOT_URL'] = settings.MITX_ROOT_URL
|
||||
|
||||
context_dictionary['django_context'] = context_instance
|
||||
|
||||
return super(Template, self).render(**context_dictionary)
|
||||
|
||||
|
||||
@@ -3,7 +3,10 @@ from django.template.base import Template, Context
|
||||
from django.template.loader import get_template, select_template
|
||||
|
||||
|
||||
def render_inclusion(func, file_name, *args, **kwargs):
|
||||
def render_inclusion(func, file_name, takes_context, django_context, *args, **kwargs):
|
||||
if takes_context:
|
||||
args = [django_context] + list(args)
|
||||
|
||||
_dict = func(*args, **kwargs)
|
||||
if isinstance(file_name, Template):
|
||||
t = file_name
|
||||
@@ -15,6 +18,10 @@ def render_inclusion(func, file_name, *args, **kwargs):
|
||||
nodelist = t.nodelist
|
||||
|
||||
new_context = Context(_dict)
|
||||
csrf_token = django_context.get('csrf_token', None)
|
||||
if csrf_token is not None:
|
||||
new_context['csrf_token'] = csrf_token
|
||||
|
||||
# **{
|
||||
# 'autoescape': context.autoescape,
|
||||
# 'current_app': context.current_app,
|
||||
|
||||
@@ -274,6 +274,9 @@ djcelery.setup_loader()
|
||||
SIMPLE_WIKI_REQUIRE_LOGIN_EDIT = True
|
||||
SIMPLE_WIKI_REQUIRE_LOGIN_VIEW = False
|
||||
|
||||
################################# WIKI ###################################
|
||||
WIKI_ACCOUNT_HANDLING = False
|
||||
|
||||
################################# Jasmine ###################################
|
||||
JASMINE_TEST_DIRECTORY = PROJECT_ROOT + '/static/coffee'
|
||||
|
||||
|
||||
@@ -65,5 +65,7 @@ DEBUG_TOOLBAR_PANELS = (
|
||||
# Django=1.3.1/1.4 where requests to views get duplicated (your method gets
|
||||
# hit twice). So you can uncomment when you need to diagnose performance
|
||||
# problems, but you shouldn't leave it on.
|
||||
# 'debug_toolbar.panels.profiling.ProfilingDebugPanel',
|
||||
'debug_toolbar.panels.profiling.ProfilingDebugPanel',
|
||||
)
|
||||
|
||||
#PIPELINE = True
|
||||
|
||||
@@ -27,7 +27,7 @@ ${breadcrumbs.body(article, urlpath)}
|
||||
</ul>
|
||||
|
||||
<div class="tab-content">
|
||||
${ render_inclusion(wiki_render, 'wiki/includes/render.html', article ) }
|
||||
${ render_inclusion(wiki_render, 'wiki/includes/render.html', False, django_context, article ) }
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
38
lms/templates/wiki/article/create_root.html
Normal file
38
lms/templates/wiki/article/create_root.html
Normal file
@@ -0,0 +1,38 @@
|
||||
## mako
|
||||
<%inherit file="../mako_base.html"/>
|
||||
<%namespace name='static' file='../../static_content.html'/>
|
||||
|
||||
<%!
|
||||
from wiki.templatetags.wiki_tags import wiki_form
|
||||
from mitxmako.templatetag_helpers import django_template_include, render_inclusion
|
||||
%>
|
||||
|
||||
<%block name="title"><title>Create root article</title></%block>
|
||||
|
||||
<%block name="wiki_headextra">
|
||||
%for js in editor.Media.js:
|
||||
<script type="text/javascript" src="${static.url(js)}"></script>
|
||||
%endfor
|
||||
|
||||
%for media, srcs in editor.Media.css.items():
|
||||
%for src in srcs:
|
||||
<link rel="stylesheet" media="${ media }" href="${static.url(src)}" />
|
||||
%endfor
|
||||
%endfor
|
||||
</%block>
|
||||
|
||||
<%block name="wiki_contents">
|
||||
<h1>Congratulations!</h1>
|
||||
<p class="lead"> You have django-wiki installed... but there are no articles. So it's time to create the first one, the root article. In the beginning, it will only be editable by administrators, but you can define permissions after.
|
||||
</p>
|
||||
|
||||
<h2 class="page-header">Root article</h2>
|
||||
|
||||
<form method="POST" class="form-horizontal">
|
||||
${ render_inclusion(wiki_form, 'wiki/includes/form.html', True, django_context, create_form ) }
|
||||
<div class="form-actions">
|
||||
<input type="submit" name="save_changes" value="Create root »" class="btn btn-primary btn-large" />
|
||||
</div>
|
||||
</form>
|
||||
</%block>
|
||||
|
||||
29
lms/templates/wiki/create.html
Normal file
29
lms/templates/wiki/create.html
Normal file
@@ -0,0 +1,29 @@
|
||||
## mako
|
||||
<%inherit file="mako_base.html"/>
|
||||
|
||||
<%!
|
||||
from django.core.urlresolvers import reverse
|
||||
from mitxmako.templatetag_helpers import django_template_include, render_inclusion
|
||||
from wiki.templatetags.wiki_tags import wiki_form
|
||||
%>
|
||||
|
||||
<%block name="title"><title>Add new article</title></%block>
|
||||
|
||||
<%block name="wiki_contents">
|
||||
${django_template_include("wiki/includes/editormedia.html", context)}
|
||||
<h1 class="page-header">Add new article</h1>
|
||||
|
||||
<form method="POST" class="form-horizontal">
|
||||
${ render_inclusion(wiki_form, 'wiki/includes/form.html', True, django_context, create_form ) }
|
||||
<div class="form-actions">
|
||||
<a href="${reverse('wiki:get', kwargs={'path' : parent_urlpath.path})}" class="btn btn-large">
|
||||
<span class="icon-circle-arrow-left"></span>
|
||||
Go back
|
||||
</a>
|
||||
<button type="submit" name="save_changes" class="btn btn-primary btn-large">
|
||||
<span class="icon-plus"></span>
|
||||
Create article
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</%block>
|
||||
@@ -30,11 +30,11 @@ ${breadcrumbs.body(article, urlpath)}
|
||||
<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})}'">
|
||||
<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', 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})}'">
|
||||
<button type="submit" name="save" value="1" class="btn btn-large btn-primary" onclick="this.form.target=''; this.form.action='${reverse('wiki:edit', kwargs={'path' : urlpath.path})}'">
|
||||
<span class="icon-ok"></span>
|
||||
Save changes
|
||||
</button>
|
||||
@@ -54,7 +54,7 @@ ${breadcrumbs.body(article, urlpath)}
|
||||
<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})}'">
|
||||
<button type="submit" name="save" value="1" class="btn btn-large btn-primary" onclick="this.form.target=''; this.form.action='${reverse('wiki:edit', kwargs={'path' : urlpath.path})}'">
|
||||
<span class="icon-ok"></span>
|
||||
Save changes
|
||||
</button>
|
||||
|
||||
@@ -2,18 +2,11 @@
|
||||
<%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:
|
||||
%for plugin in article_tabs:
|
||||
%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}) }">
|
||||
<li class="pull-right${"active" if selected == plugin.slug else ""}">
|
||||
<a href="${reverse('wiki:plugin', kwargs={'slug' : plugin.slug, 'article_id' : article.id, 'path' : urlpath.path}) }">
|
||||
<span class="${plugin.article_tab[1]}"></span>
|
||||
${plugin.article_tab[0]}
|
||||
</a>
|
||||
@@ -25,26 +18,26 @@
|
||||
|
||||
<li class="pull-right${"active" if selected == "settings" else ""}">
|
||||
%if not user.is_anonymous:
|
||||
<a href="${tab_reverse('wiki:settings_url')}">
|
||||
<a href="${reverse('wiki:settings', kwargs={'article_id' : article.id, 'path' : urlpath.path})}">
|
||||
<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')}">
|
||||
<a href="${reverse('wiki:history', kwargs={'article_id' : article.id, 'path' : urlpath.path})}">
|
||||
<span class="icon-time"></span>
|
||||
Changes
|
||||
</a>
|
||||
</li>
|
||||
<li class="pull-right${"active" if selected == "edit" else ""}">
|
||||
<a href="${tab_reverse('wiki:edit_url')}">
|
||||
<a href="${reverse('wiki:edit', kwargs={'article_id' : article.id, 'path' : urlpath.path})}">
|
||||
<span class="icon-edit"></span>
|
||||
Edit
|
||||
</a>
|
||||
</li>
|
||||
<li class="pull-right${"active" if selected == "view" else ""}">
|
||||
<a href="${tab_reverse('wiki:get_url')}">
|
||||
<a href="${reverse('wiki:get', kwargs={'article_id' : article.id, 'path' : urlpath.path})}">
|
||||
<span class="icon-home"></span>
|
||||
View
|
||||
</a>
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
<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>
|
||||
<li><a href="${reverse('wiki:get', 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>
|
||||
<li class="active"><a href="${reverse('wiki:get', kwargs={'path' : urlpath.path})}">${ article.current_revision.title }</a></li>
|
||||
<span class="divider">/</span>
|
||||
</ul>
|
||||
<div class="pull-left" style="margin-left: 10px;">
|
||||
@@ -22,7 +22,7 @@
|
||||
%if len(urlpath.get_children()) > 0:
|
||||
%for child in urlpath.get_children():
|
||||
<li>
|
||||
<a href="${reverse('wiki:get_url', child.path)}">
|
||||
<a href="${reverse('wiki:get', child.path)}">
|
||||
${child.article.current_revision.title}
|
||||
</a>
|
||||
</li>
|
||||
@@ -38,7 +38,7 @@
|
||||
</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;">
|
||||
<a class="btn" href="${reverse('wiki:create', kwargs={'path' : urlpath.path})}" style="padding: 7px;">
|
||||
<span class="icon-plus"></span>
|
||||
Add article
|
||||
</a>
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
|
||||
<%block name="headextra">
|
||||
<%static:css group='course'/>
|
||||
|
||||
<%block name="wiki_headextra" />
|
||||
|
||||
</%block>
|
||||
|
||||
<%block name="bodyextra">
|
||||
|
||||
Reference in New Issue
Block a user