Commit 064274a7 by Bridger Maxwell

Most of the wiki pages are now loading without errors.

parent baa2c068
......@@ -3,7 +3,7 @@ var schematic_width = 640;
$(function(){
$(document).ready(function() {
$("a[rel*=leanModal]").leanModal();
//$("a[rel*=leanModal]").leanModal(); //TODO: Make this work with the new modal library. Try and integrate this with the "slices"
$("body").append('<div id="circuit_editor" class="leanModal_box" style="z-index: 11000; left: 50%; margin-left: -250px; position: absolute; top: 100px; opacity: 1; "><div align="center">'+
'<input class="schematic" height="' + schematic_height + '" width="' + schematic_width + '" id="schematic_editor" name="schematic" type="hidden" value=""/>' +
......@@ -88,15 +88,20 @@ CodeMirror.defineMode("mitx_markdown", function(cmCfg, modeCfg) {
return {width: schematic_width, height:schematic_height};
},
callback: function(node, line) {
update_schematics();
var schmInput = node.firstChild.firstChild;
schmInput.codeMirrorLine = line;
if (schmInput.schematic) { //This is undefined if there was an error making the schematic
schmInput.schematic.canvas.style.display = "block"; //Otherwise, it gets line height and is a weird size
schmInput.schematic.always_draw_grid = true;
schmInput.schematic.redraw_background();
try {
update_schematics();
var schmInput = node.firstChild.firstChild;
schmInput.codeMirrorLine = line;
if (schmInput.schematic) { //This is undefined if there was an error making the schematic
schmInput.schematic.canvas.style.display = "block"; //Otherwise, it gets line height and is a weird size
schmInput.schematic.always_draw_grid = true;
schmInput.schematic.redraw_background();
}
$(node.firstChild).leanModal();
} catch (err) {
console.log("Error in mitx_markdown callback: " + err);
}
$(node.firstChild).leanModal();
}
};
......
......@@ -5,14 +5,11 @@
<%!
from django.core.urlresolvers import reverse
from simplewiki.views import wiki_article_reverse, wiki_namespace_reverse
%>
## A convenience function that calls reverse with the kwargs course_id, namespace, and slug
<%def name="wiki_reverse(wiki_page, args=[], kwargs={})">
${reverse(wiki_page, kwargs=dict({'course_id': course.id, 'article_path' : wiki_article.get_path()}, **kwargs), args=args) }
</%def>
<%block name="headextra">
<script type="text/javascript" src="${static.url('js/simplewiki/bsn.AutoSuggest_c_2.0.js')}"></script>
<script type="text/javascript" src="${static.url('js/simplewiki-AutoSuggest_c_2.0.js')}"></script>
<script type="text/javascript">
function set_related_article_id(s) {
......@@ -23,7 +20,7 @@
var x = window.onload;
window.onload = function(){
var options = {
script: "${ wiki_reverse('search_related')}/?self=${wiki_article.pk}&",
script: "${ wiki_article_reverse('search_related', wiki_article, course)}/?self=${wiki_article.pk}&",
json: true,
varname: "query",
maxresults: 35,
......@@ -83,7 +80,7 @@
<ul class="action">
<li>
<h3>
<a href="${reverse("wiki_list_articles", args=[course.id])}">All Articles</a>
<a href="${wiki_namespace_reverse("wiki_list_articles", namespace, course)}">All Articles</a>
</h3>
</li>
......@@ -93,32 +90,26 @@
</h3>
<div id="wiki_create_form">
<form method="GET" action="${reverse("wiki_create", args=[course.id])}">
<%
baseURL = reverse("wiki_create", kwargs={"course_id" : course.id, "article_path" : course.wiki_namespace + "/" })
%>
<form method="GET" onsubmit="this.action='${baseURL}' + this.wiki_article_name.value.replace(/([^a-zA-Z0-9\-])/g, '');">
<div>
<label for="id_wiki_article_name">Title of article</label>
<input type="text" name="wiki_article_name" id="id_wiki_article_name" /><br/>
<!-- <label for="id_wiki_article_is_child">Create as a child of current article</label> -->
<!-- <input type="checkbox" name="wiki_article_is_child" id="id_wiki_artcile_is_child" disabled="true" ${ 'checked="checked"' if wiki_article is not UNDEFINED else ""}> -->
</div>
<ul>
<li>
<input type="submit" class="button" value="Create" style="display: inline-block; margin-right: 2px; font-weight: bold;" />
</li>
</ul>
</form>
</div>
</li>
<li class="search">
<form method="POST" action='${reverse("wiki_search_articles", args=[course.id])}'>
<form method="GET" action='${wiki_namespace_reverse("wiki_search_articles", namespace, course)}'>
<label class="wiki_box_title">Search</label>
<div style="display:none">
<input type="hidden" name="csrfmiddlewaretoken" value="${csrf_token}"/>
</div>
<input type="text" placeholder="Search" name="value" id="wiki_search_input" style="width: 71%" value="${wiki_search_query if wiki_search_query is not UNDEFINED else '' |h}"/>
<input type="submit" id="wiki_search_input_submit" value="Go!" style="width: 20%" />
</form>
......@@ -141,15 +132,15 @@
<ul>
<li>
<a href="${ wiki_reverse('wiki_view')}" class="view">View</a>
<a href="${ wiki_article_reverse('wiki_view', wiki_article, course)}" class="view">View</a>
</li>
<li>
<a href="${ wiki_reverse('wiki_edit')}" class="edit">Edit</a>
<a href="${ wiki_article_reverse('wiki_edit', wiki_article, course)}" class="edit">Edit</a>
</li>
<li>
<a href="${ wiki_reverse('wiki_history')}" class="history">History</a>
<a href="${ wiki_article_reverse('wiki_history', wiki_article, course)}" class="history">History</a>
</li>
</ul>
</header>
......
......@@ -20,11 +20,11 @@ ${"Edit " + wiki_title + " - " if wiki_title is not UNDEFINED else ""}MITx 6.002
</%block>
<%block name="wiki_head">
<script type="text/javascript" src="${ settings.LIB_URL }CodeMirror/codemirror.js"></script>
<link rel="stylesheet" href="${ settings.LIB_URL }CodeMirror/codemirror.css" />
<script type="text/javascript" src="${ settings.LIB_URL }vendor/CodeMirror/codemirror.js"></script>
<link rel="stylesheet" href="${ settings.LIB_URL }vendor/CodeMirror/codemirror.css" />
<script type="text/javascript" src="${ settings.LIB_URL }CodeMirror/xml.js"></script>
<script type="text/javascript" src="${ settings.LIB_URL }CodeMirror/mitx_markdown.js"></script>
<script type="text/javascript" src="${ settings.LIB_URL }vendor/CodeMirror/xml.js"></script>
<script type="text/javascript" src="${ settings.LIB_URL }vendor/CodeMirror/mitx_markdown.js"></script>
<script>
$(function(){
......
......@@ -41,10 +41,13 @@ ${wiki_error}
does not exist. Click <a href="${reverse("wiki_create", args=[wiki_url_parent])}">here</a>
to create it.
</p>
%else:
%if wiki_err_keyword is not UNDEFINED and wiki_err_keyword:
%elif wiki_err_no_namespace is not UNDEFINED and wiki_err_no_namespace:
<p>
You must specify a namespace to create an article in.
</p>
%elif wiki_err_bad_namespace is not UNDEFINED and wiki_err_bad_namespace:
<p>
The page you're trying to create <b>${wiki_url}</b> starts with <b>_</b>, which is reserved for internal use.
The namespace for this article does not exist. This article cannot be created.
</p>
%elif wiki_err_locked is not UNDEFINED and wiki_err_locked:
<p>
......@@ -87,7 +90,6 @@ ${wiki_error}
</p>
%endif
%endif
%endif
</div>
</%block>
......
......@@ -6,6 +6,7 @@
<%!
from django.core.urlresolvers import reverse
from simplewiki.views import wiki_article_reverse
%>
<%block name="wiki_page_title">
......@@ -64,10 +65,10 @@ ${ wiki_article.title }
<tr>
<td colspan="4">
%if wiki_prev_page:
<a href="${self.wiki_reverse('wiki_history', kwargs={'page' : wiki_prev_page})}">Previous page</a>
<a href="${wiki_article_reverse('wiki_history', wiki_article, course, kwargs={'page' : wiki_prev_page})}">Previous page</a>
%endif
%if wiki_next_page:
<a href="${self.wiki_reverse('wiki_history', kwargs={'page' : wiki_next_page})}">Next page</a>
<a href="${wiki_article_reverse('wiki_history', wiki_article, course, kwargs={'page' : wiki_next_page})}">Next page</a>
%endif
</td>
</tr>
......
......@@ -5,7 +5,7 @@
<%block name="title"><title>Wiki - Search Results - MITx 6.002x</title></%block>
<%!
from django.core.urlresolvers import reverse
from simplewiki.views import wiki_article_reverse
%>
<%block name="wiki_page_title">
......@@ -23,7 +23,7 @@ Displaying all articles
<ul class="article-list">
%for article in wiki_search_results:
<% article_deleted = not article.current_revision.deleted == 0 %>
<li><h3><a href="${reverse("wiki_view", args=[article.get_url()])}">${article.title} ${'(Deleted)' if article_deleted else ''}</a></h3></li>
<li><h3><a href="${wiki_article_reverse("wiki_view", article, course)}">${article.title} ${'(Deleted)' if article_deleted else ''}</a></h3></li>
%endfor
%if not wiki_search_results:
......
......@@ -85,19 +85,21 @@ if settings.COURSEWARE_ENABLED:
)
# Multicourse wiki
article_slug = r"/(?P<article_path>[a-zA-Z\d_-]+/[a-zA-Z\d_-]*)"
namespace_regex = r"[a-zA-Z\d_-]+"
article_slug = r'/(?P<article_path>' + namespace_regex + r'/[a-zA-Z\d_-]*)'
namespace = r'/(?P<namespace>' + namespace_regex + r')'
urlpatterns += (
url(r'^courses/(?P<course_id>[^/]*)/wiki/$', 'simplewiki.views.root_redirect', name='wiki_root'),
url(r'^courses/(?P<course_id>[^/]*)/wiki/view' + article_slug + r'/?$', 'simplewiki.views.view', name='wiki_view'),
url(r'^courses/(?P<course_id>[^/]*)/wiki/view_revision/(?P<revision_number>[0-9]+)' + article_slug + r'/?$', 'simplewiki.views.view_revision', name='wiki_view_revision'),
url(r'^courses/(?P<course_id>[^/]*)/wiki/edit' + article_slug + r'/?$', 'simplewiki.views.edit', name='wiki_edit'),
url(r'^courses/(?P<course_id>[^/]*)/wiki/create/?$', 'simplewiki.views.create', name='wiki_create'),
url(r'^courses/(?P<course_id>[^/]*)/wiki/create' + article_slug + r'/?$', 'simplewiki.views.create', name='wiki_create'),
url(r'^courses/(?P<course_id>[^/]*)/wiki/history' + article_slug + r'(?:/(?P<page>[0-9]+))?/?$', 'simplewiki.views.history', name='wiki_history'),
url(r'^courses/(?P<course_id>[^/]*)/wiki/search_related' + article_slug + r'/?$', 'simplewiki.views.search_add_related', name='search_related'),
url(r'^courses/(?P<course_id>[^/]*)/wiki/random/?$', 'simplewiki.views.random_article', name='wiki_random'),
url(r'^courses/(?P<course_id>[^/]*)/wiki/revision_feed/([0-9]+)/?$', 'simplewiki.views.revision_feed', name='wiki_revision_feed'),
url(r'^courses/(?P<course_id>[^/]*)/wiki/search/?$', 'simplewiki.views.search_articles', name='wiki_search_articles'),
url(r'^courses/(?P<course_id>[^/]*)/wiki/list/?$', 'simplewiki.views.search_articles', name='wiki_list_articles'), #Just an alias for the search, but you usually don't submit a search term
url(r'^courses/(?P<course_id>[^/]*)/wiki/search' + namespace + r'?/?$', 'simplewiki.views.search_articles', name='wiki_search_articles'),
url(r'^courses/(?P<course_id>[^/]*)/wiki/list' + namespace + r'?/?$', 'simplewiki.views.search_articles', name='wiki_list_articles'), #Just an alias for the search, but you usually don't submit a search term
)
......
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