diff --git a/common/lib/mitxmako/mitxmako/makoloader.py b/common/lib/mitxmako/mitxmako/makoloader.py index fc1633c35a..53334d1a1b 100644 --- a/common/lib/mitxmako/mitxmako/makoloader.py +++ b/common/lib/mitxmako/mitxmako/makoloader.py @@ -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() diff --git a/common/lib/mitxmako/mitxmako/template.py b/common/lib/mitxmako/mitxmako/template.py index fa6b1293f8..65328ae830 100644 --- a/common/lib/mitxmako/mitxmako/template.py +++ b/common/lib/mitxmako/mitxmako/template.py @@ -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) diff --git a/common/lib/mitxmako/mitxmako/templatetag_helpers.py b/common/lib/mitxmako/mitxmako/templatetag_helpers.py index 10c502fbfe..6742f3ee1c 100644 --- a/common/lib/mitxmako/mitxmako/templatetag_helpers.py +++ b/common/lib/mitxmako/mitxmako/templatetag_helpers.py @@ -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, diff --git a/lms/envs/common.py b/lms/envs/common.py index 6354d58bdf..af5e3184a3 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -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' diff --git a/lms/envs/devplus.py b/lms/envs/devplus.py index b15322c2c7..bb4524a1ab 100644 --- a/lms/envs/devplus.py +++ b/lms/envs/devplus.py @@ -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 diff --git a/lms/templates/wiki/article.html b/lms/templates/wiki/article.html index 3a2c9653fa..0dfb9cb4bd 100644 --- a/lms/templates/wiki/article.html +++ b/lms/templates/wiki/article.html @@ -27,7 +27,7 @@ ${breadcrumbs.body(article, urlpath)}
- ${ render_inclusion(wiki_render, 'wiki/includes/render.html', article ) } + ${ render_inclusion(wiki_render, 'wiki/includes/render.html', False, django_context, article ) }
diff --git a/lms/templates/wiki/article/create_root.html b/lms/templates/wiki/article/create_root.html new file mode 100644 index 0000000000..0032a30b71 --- /dev/null +++ b/lms/templates/wiki/article/create_root.html @@ -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">Create root article + +<%block name="wiki_headextra"> + %for js in editor.Media.js: + + %endfor + + %for media, srcs in editor.Media.css.items(): + %for src in srcs: + + %endfor + %endfor + + +<%block name="wiki_contents"> +

Congratulations!

+

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. +

+ + + +
+ ${ render_inclusion(wiki_form, 'wiki/includes/form.html', True, django_context, create_form ) } +
+ +
+
+ + diff --git a/lms/templates/wiki/create.html b/lms/templates/wiki/create.html new file mode 100644 index 0000000000..af1579d2de --- /dev/null +++ b/lms/templates/wiki/create.html @@ -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">Add new article + +<%block name="wiki_contents"> +${django_template_include("wiki/includes/editormedia.html", context)} +

Add new article

+ +
+ ${ render_inclusion(wiki_form, 'wiki/includes/form.html', True, django_context, create_form ) } +
+ + + Go back + + +
+
+ diff --git a/lms/templates/wiki/edit.html b/lms/templates/wiki/edit.html index 6ee1490148..a801243970 100644 --- a/lms/templates/wiki/edit.html +++ b/lms/templates/wiki/edit.html @@ -30,11 +30,11 @@ ${breadcrumbs.body(article, urlpath)}
${django_template_include("wiki/includes/editor.html", context)}
- - @@ -54,7 +54,7 @@ ${breadcrumbs.body(article, urlpath)} Back to editor - diff --git a/lms/templates/wiki/includes/article_menu.html b/lms/templates/wiki/includes/article_menu.html index 0e5af642e6..30d96613b2 100644 --- a/lms/templates/wiki/includes/article_menu.html +++ b/lms/templates/wiki/includes/article_menu.html @@ -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"): -
  • - +
  • + ${plugin.article_tab[0]} @@ -25,26 +18,26 @@
  • %if not user.is_anonymous: - + Settings %endif
  • - + Changes
  • - + Edit
  • - + View diff --git a/lms/templates/wiki/includes/breadcrumbs.html b/lms/templates/wiki/includes/breadcrumbs.html index 3edd9bf0a8..44a85f7573 100644 --- a/lms/templates/wiki/includes/breadcrumbs.html +++ b/lms/templates/wiki/includes/breadcrumbs.html @@ -6,10 +6,10 @@
    @@ -22,7 +22,7 @@ %if len(urlpath.get_children()) > 0: %for child in urlpath.get_children():
  • - + ${child.article.current_revision.title}
  • @@ -38,7 +38,7 @@
    - + Add article diff --git a/lms/templates/wiki/mako_base.html b/lms/templates/wiki/mako_base.html index e8e6b3664b..8bb3fa9fac 100644 --- a/lms/templates/wiki/mako_base.html +++ b/lms/templates/wiki/mako_base.html @@ -4,6 +4,9 @@ <%block name="headextra"> <%static:css group='course'/> + + <%block name="wiki_headextra" /> + <%block name="bodyextra">