Commit fcdda4cf by bridger

Merge pull request #10 from MITx/wikieditor

Wikieditor
parents 125057f7 003fd8ea
......@@ -3,14 +3,24 @@
Image Circuit Extension for Python-Markdown
======================================
circuit:name becomes the circuit.
Any single line beginning with circuit-schematic: and followed by data (which should be json data, but this
is not enforced at this level) will be displayed as a circuit schematic. This is simply an input element with
the value set to the data. It is left to javascript on the page to render that input as a circuit schematic.
ex:
circuit-schematic:[["r",[128,48,0],{"r":"1","_json_":0},["2","1"]],["view",0,0,2,null,null,null,null,null,null,null],["dc",{"0":0,"1":1,"I(_3)":-1}]]
(This is a schematic with a single one-ohm resistor. Note that this data is not meant to be user-editable.)
'''
import markdown
import re
import simplewiki.settings as settings
from mitxmako.shortcuts import render_to_response, render_to_string
from django.utils.html import escape
import markdown
try:
# Markdown 2.1.0 changed from 2.0.3. We try importing the new version first,
# but import the 2.0.3 version if it fails
......@@ -22,23 +32,40 @@ class CircuitExtension(markdown.Extension):
def __init__(self, configs):
for key, value in configs :
self.setConfig(key, value)
def add_inline(self, md, name, klass, re):
pattern = klass(re)
def extendMarkdown(self, md, md_globals):
## Because Markdown treats contigous lines as one block of text, it is hard to match
## a regex that must occupy the whole line (like the circuit regex). This is why we have
## a preprocessor that inspects the lines and replaces the matched lines with text that is
## easier to match
md.preprocessors.add('circuit', CircuitPreprocessor(md), "_begin")
pattern = CircuitLink(r'processed-schematic:(?P<data>.*?)processed-schematic-end')
pattern.md = md
pattern.ext = self
md.inlinePatterns.add(name, pattern, "<reference")
md.inlinePatterns.add('circuit', pattern, "<reference")
class CircuitPreprocessor(markdown.preprocessors.Preprocessor):
preRegex = re.compile(r'^circuit-schematic:(?P<data>.*)$')
def extendMarkdown(self, md, md_globals):
self.add_inline(md, 'circuit', CircuitLink, r'^circuit:(?P<name>[a-zA-Z0-9]*)$')
def run(self, lines):
def convertLine(line):
m = self.preRegex.match(line)
if m:
return 'processed-schematic:{0}processed-schematic-end'.format( m.group('data') )
else:
return line
return [ convertLine(line) for line in lines ]
class CircuitLink(markdown.inlinepatterns.Pattern):
def handleMatch(self, m):
name = m.group('name')
if not name.isalnum():
return etree.fromstring("<div>Circuit name must be alphanumeric</div>")
return etree.fromstring(render_to_string('show_circuit.html', {'name':name}))
data = m.group('data')
data = escape(data)
return etree.fromstring("<div align='center'><input type='hidden' parts='' value='" + data + "' analyses='' class='schematic ctrls' width='500' height='300'/></div>")
def makeExtension(configs=None) :
......
/*
================================================
autosuggest, inquisitor style
================================================
*/
body
{
position: relative;
}
div.autosuggest
{
position: absolute;
background-image: url(img_inquisitor/as_pointer.gif);
background-position: top;
background-repeat: no-repeat;
padding: 10px 0 0 0;
}
div.autosuggest div.as_header,
div.autosuggest div.as_footer
{
position: relative;
height: 6px;
padding: 0 6px;
background-image: url(img_inquisitor/ul_corner_tr.gif);
background-position: top right;
background-repeat: no-repeat;
overflow: hidden;
}
div.autosuggest div.as_footer
{
background-image: url(img_inquisitor/ul_corner_br.gif);
}
div.autosuggest div.as_header div.as_corner,
div.autosuggest div.as_footer div.as_corner
{
position: absolute;
top: 0;
left: 0;
height: 6px;
width: 6px;
background-image: url(img_inquisitor/ul_corner_tl.gif);
background-position: top left;
background-repeat: no-repeat;
}
div.autosuggest div.as_footer div.as_corner
{
background-image: url(img_inquisitor/ul_corner_bl.gif);
}
div.autosuggest div.as_header div.as_bar,
div.autosuggest div.as_footer div.as_bar
{
height: 6px;
overflow: hidden;
background-color: #333;
}
div.autosuggest ul
{
list-style: none;
margin: 0 0 -4px 0;
padding: 0;
overflow: hidden;
background-color: #333;
}
div.autosuggest ul li
{
color: #ccc;
padding: 0;
margin: 0 4px 4px;
text-align: left;
}
div.autosuggest ul li a
{
color: #ccc;
display: block;
text-decoration: none;
background-color: transparent;
text-shadow: #000 0px 0px 5px;
position: relative;
padding: 0;
width: 100%;
}
div.autosuggest ul li a:hover
{
background-color: #444;
}
div.autosuggest ul li.as_highlight a:hover
{
background-color: #1B5CCD;
}
div.autosuggest ul li a span
{
display: block;
padding: 3px 6px;
font-weight: bold;
}
div.autosuggest ul li a span small
{
font-weight: normal;
color: #999;
}
div.autosuggest ul li.as_highlight a span small
{
color: #ccc;
}
div.autosuggest ul li.as_highlight a
{
color: #fff;
background-color: #1B5CCD;
background-image: url(img_inquisitor/hl_corner_br.gif);
background-position: bottom right;
background-repeat: no-repeat;
}
div.autosuggest ul li.as_highlight a span
{
background-image: url(img_inquisitor/hl_corner_bl.gif);
background-position: bottom left;
background-repeat: no-repeat;
}
div.autosuggest ul li a .tl,
div.autosuggest ul li a .tr
{
background-image: transparent;
background-repeat: no-repeat;
width: 6px;
height: 6px;
position: absolute;
top: 0;
padding: 0;
margin: 0;
}
div.autosuggest ul li a .tr
{
right: 0;
}
div.autosuggest ul li.as_highlight a .tl
{
left: 0;
background-image: url(img_inquisitor/hl_corner_tl.gif);
background-position: bottom left;
}
div.autosuggest ul li.as_highlight a .tr
{
right: 0;
background-image: url(img_inquisitor/hl_corner_tr.gif);
background-position: bottom right;
}
div.autosuggest ul li.as_warning
{
font-weight: bold;
text-align: center;
}
div.autosuggest ul em
{
font-style: normal;
color: #6EADE7;
}
\ No newline at end of file
body
{
font-family: 'Lucida Sans', 'Sans';
}
a img
{
border: 0;
}
div#wiki_article a {
color: #06d;
text-decoration: none;
}
div#wiki_article a:hover {
color: #f82;
text-decoration: underline;
}
hr
{
background-color: #def;
height: 2px;
border: 0;
}
div#wiki_article .toc a
{
color: #025
}
div#wiki_article p
{
/* font-size: 90%; looks funny when combined with lists/tables */
line-height: 140%;
}
div#wiki_article h1
{
font-size: 200%;
font-weight: normal;
color: #048;
}
div#wiki_article h2
{
font-size: 150%;
font-weight: normal;
color: #025;
}
div#wiki_article h3
{
font-size: 120%;
font-weight: bold;
color: #000;
}
table
{
border: 1px solid black;
border-collapse: collapse;
margin: 12px;
}
table tr.dark
{
background-color: #F3F3F3;
}
table thead tr
{
background-color: #def;
border-bottom: 2px solid black;
}
table td, th
{
padding: 6px 10px 6px 10px;
border: 1px solid black;
}
table thead th
{
padding-bottom: 8px;
padding-top: 8px;
}
div#wiki_panel
{
float: right;
}
div.wiki_box
{
width: 230px;
padding: 10px;
color: #fff;
font-size: 80%;
}
div.wiki_box div.wiki_box_contents
{ background-color: #222;
padding: 5px 10px;}
div.wiki_box div.wiki_box_header,
div.wiki_box div.wiki_box_footer
{
position: relative;
height: 6px;
padding: 0 6px;
background-image: url(../img/box_corner_tr.gif);
background-position: top right;
background-repeat: no-repeat;
overflow: hidden;
}
div.wiki_box div.wiki_box_footer
{
background-image: url(../img/box_corner_br.gif);
}
div.wiki_box div.wiki_box_header div.wiki_box_corner,
div.wiki_box div.wiki_box_footer div.wiki_box_corner
{
position: absolute;
top: 0;
left: 0;
height: 6px;
width: 6px;
background-image: url(../img/box_corner_tl.gif);
background-position: top left;
background-repeat: no-repeat;
}
div.wiki_box div.wiki_box_footer div.wiki_box_corner
{
background-image: url(../img/box_corner_bl.gif);
}
div.wiki_box div.wiki_box_header div.wiki_box_bar,
div.wiki_box div.wiki_box_footer div.wiki_box_bar
{
height: 6px;
overflow: hidden;
background-color: #222;
}
div.wiki_box a
{
color: #acf;
}
div.wiki_box p
{
margin: 5px 0;
}
div.wiki_box ul
{
padding-left: 20px;
margin-left: 0;
}
div.wiki_box div.wiki_box_title
{
margin-bottom: 5px;
font-size: 140%;
}
form#wiki_revision #id_contents
{
width:500px;
height: 400px;
font-family: monospace;
}
form#wiki_revision #id_title
{
width: 500px;
}
form#wiki_revision #id_revision_text
{
width: 500px;
}
table#wiki_revision_table
{
border: none;
border-collapse: collapse;
padding-right: 250px;
}
table#wiki_revision_table th
{
border: none;
text-align: left;
vertical-align: top;
}
table#wiki_revision_table td
{
border: none;
}
table#wiki_history_table
{
border-collapse: collapse;
border-spacing: 0;
padding-right: 250px;
}
table#wiki_history_table th#modified
{
width: 220px;
}
table#wiki_history_table td
{
border: none;
}
table#wiki_history_table tbody tr
{
border-bottom: 1px solid black;
}
table#wiki_history_table tbody td
{
vertical-align: top;
padding: 5px;
}
table#wiki_history_table tfoot td
{
border: none;
}
table#wiki_history_table tbody td.diff
{
font-family: monospace;
overflow: hidden;
border-left: 1px dotted black;
border-right: 1px dotted black;
}
table#wiki_history_table th
{
text-align: left;
}
div#wiki_attach_progress_container
{
background-color: #333;
width: 100%;
height: 20px;
display: none;
}
div#wiki_attach_progress
{
width: 25%;
background-color: #999;
}
blockquote {
margin-top: 15px;
margin-bottom: 15px;
margin-left: 50px;
padding-left: 15px;
border-left: 3px solid #666;
color: #999;
max-width: 400px ;
}
blockquote p {
margin-top: 8px;
margin-bottom: 8px;
}
......@@ -276,7 +276,6 @@ class Revision(models.Model):
# Create pre-parsed contents - no need to parse on-the-fly
ext = WIKI_MARKDOWN_EXTENSIONS
ext += ["wikipath(base_url=%s)" % reverse('wiki_view', args=('/',))]
print ext
self.contents_parsed = markdown(self.contents,
extensions=ext,
safe_mode='escape',)
......
......@@ -154,10 +154,11 @@ def create(request, wiki_url):
d = {'wiki_form': f,
'wiki_write': True,
'create_article' : True,
}
d.update(csrf(request))
return render_to_response('simplewiki_create.html', d)
return render_to_response('simplewiki_edit.html', d)
def edit(request, wiki_url):
if not request.user.is_authenticated():
......@@ -207,6 +208,7 @@ def edit(request, wiki_url):
'wiki_article': article,
'wiki_title' : article.title,
'wiki_attachments_write': article.can_attach(request.user),
'create_article' : False,
}
d.update(csrf(request))
......
......@@ -12,7 +12,7 @@ DEFAULT_GROUPS = []
STATIC_GRAB = False
DEV_CONTENT = True
LIB_URL = '/static/lib/'
LIB_URL = '/static/js/'
LIB_URL = 'https://mitxstatic.s3.amazonaws.com/js/'
BOOK_URL = '/static/book/'
BOOK_URL = 'https://mitxstatic.s3.amazonaws.com/book_images/'
......
.CodeMirror {
line-height: 1em;
font-family: monospace;
}
.CodeMirror-scroll {
overflow: auto;
height: 300px;
/* This is needed to prevent an IE[67] bug where the scrolled content
is visible outside of the scrolling box. */
position: relative;
outline: none;
}
.CodeMirror-gutter {
position: absolute; left: 0; top: 0;
z-index: 10;
background-color: #f7f7f7;
border-right: 1px solid #eee;
min-width: 2em;
height: 100%;
}
.CodeMirror-gutter-text {
color: #aaa;
text-align: right;
padding: .4em .2em .4em .4em;
white-space: pre !important;
}
.CodeMirror-lines {
padding: .4em;
white-space: pre;
}
.CodeMirror pre {
-moz-border-radius: 0;
-webkit-border-radius: 0;
-o-border-radius: 0;
border-radius: 0;
border-width: 0; margin: 0; padding: 0; background: transparent;
font-family: inherit;
font-size: inherit;
padding: 0; margin: 0;
white-space: pre;
word-wrap: normal;
}
.CodeMirror-wrap pre {
word-wrap: break-word;
white-space: pre-wrap;
}
.CodeMirror-wrap .CodeMirror-scroll {
overflow-x: hidden;
}
.CodeMirror textarea {
outline: none !important;
}
.CodeMirror pre.CodeMirror-cursor {
z-index: 10;
position: absolute;
visibility: hidden;
border-left: 1px solid black;
border-right:none;
width:0;
}
.CodeMirror pre.CodeMirror-cursor.CodeMirror-overwrite {}
.CodeMirror-focused pre.CodeMirror-cursor {
visibility: visible;
}
div.CodeMirror-selected { background: #d9d9d9; }
.CodeMirror-focused div.CodeMirror-selected { background: #d7d4f0; }
.CodeMirror-searching {
background: #ffa;
background: rgba(255, 255, 0, .4);
}
/* Default theme */
.cm-s-default span.cm-keyword {color: #708;}
.cm-s-default span.cm-atom {color: #219;}
.cm-s-default span.cm-number {color: #164;}
.cm-s-default span.cm-def {color: #00f;}
.cm-s-default span.cm-variable {color: black;}
.cm-s-default span.cm-variable-2 {color: #05a;}
.cm-s-default span.cm-variable-3 {color: #085;}
.cm-s-default span.cm-property {color: black;}
.cm-s-default span.cm-operator {color: black;}
.cm-s-default span.cm-comment {color: #a50;}
.cm-s-default span.cm-string {color: #a11;}
.cm-s-default span.cm-string-2 {color: #f50;}
.cm-s-default span.cm-meta {color: #555;}
.cm-s-default span.cm-error {color: #f00;}
.cm-s-default span.cm-qualifier {color: #555;}
.cm-s-default span.cm-builtin {color: #30a;}
.cm-s-default span.cm-bracket {color: #cc7;}
.cm-s-default span.cm-tag {color: #170;}
.cm-s-default span.cm-attribute {color: #00c;}
.cm-s-default span.cm-header {color: #a0a;}
.cm-s-default span.cm-quote {color: #090;}
.cm-s-default span.cm-hr {color: #999;}
.cm-s-default span.cm-link {color: #00c;}
span.cm-header, span.cm-strong {font-weight: bold;}
span.cm-em {font-style: italic;}
span.cm-emstrong {font-style: italic; font-weight: bold;}
span.cm-link {text-decoration: underline;}
div.CodeMirror span.CodeMirror-matchingbracket {color: #0f0;}
div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
This source diff could not be displayed because it is too large. You can view the blob instead.
CodeMirror.defineMode("xml", function(config, parserConfig) {
var indentUnit = config.indentUnit;
var Kludges = parserConfig.htmlMode ? {
autoSelfClosers: {"br": true, "img": true, "hr": true, "link": true, "input": true,
"meta": true, "col": true, "frame": true, "base": true, "area": true},
doNotIndent: {"pre": true},
allowUnquoted: true,
allowMissing: false
} : {autoSelfClosers: {}, doNotIndent: {}, allowUnquoted: false, allowMissing: false};
var alignCDATA = parserConfig.alignCDATA;
// Return variables for tokenizers
var tagName, type;
function inText(stream, state) {
function chain(parser) {
state.tokenize = parser;
return parser(stream, state);
}
var ch = stream.next();
if (ch == "<") {
if (stream.eat("!")) {
if (stream.eat("[")) {
if (stream.match("CDATA[")) return chain(inBlock("atom", "]]>"));
else return null;
}
else if (stream.match("--")) return chain(inBlock("comment", "-->"));
else if (stream.match("DOCTYPE", true, true)) {
stream.eatWhile(/[\w\._\-]/);
return chain(doctype(1));
}
else return null;
}
else if (stream.eat("?")) {
stream.eatWhile(/[\w\._\-]/);
state.tokenize = inBlock("meta", "?>");
return "meta";
}
else {
type = stream.eat("/") ? "closeTag" : "openTag";
stream.eatSpace();
tagName = "";
var c;
while ((c = stream.eat(/[^\s\u00a0=<>\"\'\/?]/))) tagName += c;
state.tokenize = inTag;
return "tag";
}
}
else if (ch == "&") {
var ok;
if (stream.eat("#")) {
if (stream.eat("x")) {
ok = stream.eatWhile(/[a-fA-F\d]/) && stream.eat(";");
} else {
ok = stream.eatWhile(/[\d]/) && stream.eat(";");
}
} else {
ok = stream.eatWhile(/[\w\.\-:]/) && stream.eat(";");
}
return ok ? "atom" : "error";
}
else {
stream.eatWhile(/[^&<]/);
return null;
}
}
function inTag(stream, state) {
var ch = stream.next();
if (ch == ">" || (ch == "/" && stream.eat(">"))) {
state.tokenize = inText;
type = ch == ">" ? "endTag" : "selfcloseTag";
return "tag";
}
else if (ch == "=") {
type = "equals";
return null;
}
else if (/[\'\"]/.test(ch)) {
state.tokenize = inAttribute(ch);
return state.tokenize(stream, state);
}
else {
stream.eatWhile(/[^\s\u00a0=<>\"\'\/?]/);
return "word";
}
}
function inAttribute(quote) {
return function(stream, state) {
while (!stream.eol()) {
if (stream.next() == quote) {
state.tokenize = inTag;
break;
}
}
return "string";
};
}
function inBlock(style, terminator) {
return function(stream, state) {
while (!stream.eol()) {
if (stream.match(terminator)) {
state.tokenize = inText;
break;
}
stream.next();
}
return style;
};
}
function doctype(depth) {
return function(stream, state) {
var ch;
while ((ch = stream.next()) != null) {
if (ch == "<") {
state.tokenize = doctype(depth + 1);
return state.tokenize(stream, state);
} else if (ch == ">") {
if (depth == 1) {
state.tokenize = inText;
break;
} else {
state.tokenize = doctype(depth - 1);
return state.tokenize(stream, state);
}
}
}
return "meta";
};
}
var curState, setStyle;
function pass() {
for (var i = arguments.length - 1; i >= 0; i--) curState.cc.push(arguments[i]);
}
function cont() {
pass.apply(null, arguments);
return true;
}
function pushContext(tagName, startOfLine) {
var noIndent = Kludges.doNotIndent.hasOwnProperty(tagName) || (curState.context && curState.context.noIndent);
curState.context = {
prev: curState.context,
tagName: tagName,
indent: curState.indented,
startOfLine: startOfLine,
noIndent: noIndent
};
}
function popContext() {
if (curState.context) curState.context = curState.context.prev;
}
function element(type) {
if (type == "openTag") {
curState.tagName = tagName;
return cont(attributes, endtag(curState.startOfLine));
} else if (type == "closeTag") {
var err = false;
if (curState.context) {
err = curState.context.tagName != tagName;
} else {
err = true;
}
if (err) setStyle = "error";
return cont(endclosetag(err));
}
return cont();
}
function endtag(startOfLine) {
return function(type) {
if (type == "selfcloseTag" ||
(type == "endTag" && Kludges.autoSelfClosers.hasOwnProperty(curState.tagName.toLowerCase())))
return cont();
if (type == "endTag") {pushContext(curState.tagName, startOfLine); return cont();}
return cont();
};
}
function endclosetag(err) {
return function(type) {
if (err) setStyle = "error";
if (type == "endTag") { popContext(); return cont(); }
setStyle = "error";
return cont(arguments.callee);
}
}
function attributes(type) {
if (type == "word") {setStyle = "attribute"; return cont(attribute, attributes);}
if (type == "endTag" || type == "selfcloseTag") return pass();
setStyle = "error";
return cont(attributes);
}
function attribute(type) {
if (type == "equals") return cont(attvalue, attributes);
if (!Kludges.allowMissing) setStyle = "error";
return (type == "endTag" || type == "selfcloseTag") ? pass() : cont();
}
function attvalue(type) {
if (type == "string") return cont(attvaluemaybe);
if (type == "word" && Kludges.allowUnquoted) {setStyle = "string"; return cont();}
setStyle = "error";
return (type == "endTag" || type == "selfCloseTag") ? pass() : cont();
}
function attvaluemaybe(type) {
if (type == "string") return cont(attvaluemaybe);
else return pass();
}
return {
startState: function() {
return {tokenize: inText, cc: [], indented: 0, startOfLine: true, tagName: null, context: null};
},
token: function(stream, state) {
if (stream.sol()) {
state.startOfLine = true;
state.indented = stream.indentation();
}
if (stream.eatSpace()) return null;
setStyle = type = tagName = null;
var style = state.tokenize(stream, state);
state.type = type;
if ((style || type) && style != "comment") {
curState = state;
while (true) {
var comb = state.cc.pop() || element;
if (comb(type || style)) break;
}
}
state.startOfLine = false;
return setStyle || style;
},
indent: function(state, textAfter, fullLine) {
var context = state.context;
if ((state.tokenize != inTag && state.tokenize != inText) ||
context && context.noIndent)
return fullLine ? fullLine.match(/^(\s*)/)[0].length : 0;
if (alignCDATA && /<!\[CDATA\[/.test(textAfter)) return 0;
if (context && /^<\//.test(textAfter))
context = context.prev;
while (context && !context.startOfLine)
context = context.prev;
if (context) return context.indent + indentUnit;
else return 0;
},
compareStates: function(a, b) {
if (a.indented != b.indented || a.tokenize != b.tokenize) return false;
for (var ca = a.context, cb = b.context; ; ca = ca.prev, cb = cb.prev) {
if (!ca || !cb) return ca == cb;
if (ca.tagName != cb.tagName) return false;
}
},
electricChars: "/"
};
});
CodeMirror.defineMIME("application/xml", "xml");
CodeMirror.defineMIME("text/html", {name: "xml", htmlMode: true});
......@@ -10,9 +10,12 @@
closeButton:'.modal_close'
}
var overlay = $("<div id='lean_overlay'></div>");
var overlay = $("#lean_overlay");
if (overlay.length == 0) {
overlay = $("<div id='lean_overlay'></div>");
$("body").append(overlay);
}
$("body").append(overlay);
options = $.extend(defaults, options);
......
(function(a){a.fn.extend({leanModal:function(b){function e(b){a("#lean_overlay").fadeOut(200);a(b).css({display:"none"})}var c={top:100,overlay:.5,closeButton:".modal_close"};var d=a("<div id='lean_overlay'></div>");a("body").append(d);b=a.extend(c,b);return this.each(function(){var c=b;a(this).click(function(b){var f=a(this).attr("href");a(".leanModal_box").css({display:"none"});a("body").append(d);a(".leanModal_box").append('<a class="modal_close" href="#">&#10006;</a>');a("#lean_overlay").click(function(){e(f)});a(c.closeButton).click(function(){e(f)});var g=a(f).outerHeight();var h=a(f).outerWidth();a("#lean_overlay").css({display:"block",opacity:0});a("#lean_overlay").fadeTo(200,c.overlay);a(f).css({display:"block",position:"fixed",opacity:0,"z-index":11e3,left:50+"%","margin-left":-(h/2)+"px",top:c.top+"px"});var i=a(f).offset().top+"px";a(f).css({position:"absolute",top:i});a(f).fadeTo(200,1);b.preventDefault()})})}})})(jQuery)
(function(a){a.fn.extend({leanModal:function(c){function g(d){a("#lean_overlay").fadeOut(200);a(d).css({display:"none"})}var e=a("#lean_overlay");0==e.length&&(e=a("<div id='lean_overlay'></div>"),a("body").append(e));c=a.extend({top:100,overlay:0.5,closeButton:".modal_close"},c);return this.each(function(){var d=c;a(this).click(function(c){var b=a(this).attr("href");a(".leanModal_box").css({display:"none"});a("body").append(e);a(".leanModal_box").append('<a class="modal_close" href="#">&#10006;</a>');
a("#lean_overlay").click(function(){g(b)});a(d.closeButton).click(function(){g(b)});a(b).outerHeight();var f=a(b).outerWidth();a("#lean_overlay").css({display:"block",opacity:0});a("#lean_overlay").fadeTo(200,d.overlay);a(b).css({display:"block",position:"fixed",opacity:0,"z-index":11E3,left:"50%","margin-left":-(f/2)+"px",top:d.top+"px"});f=a(b).offset().top+"px";a(b).css({position:"absolute",top:f});a(b).fadeTo(200,1);c.preventDefault()})})}})})(jQuery);
\ No newline at end of file
......@@ -7,7 +7,18 @@ form#wiki_revision {
display: block;
margin-bottom: 7px ;
}
.CodeMirror-scroll {
min-height: 550px;
width: 100%;
}
.CodeMirror {
@extend textarea;
@include box-sizing(border-box);
font-family: monospace;
margin-bottom: 20px;
}
textarea {
@include box-sizing(border-box);
margin-bottom: 20px;
......
......@@ -7,7 +7,7 @@
<!-- <link rel="stylesheet" media="print" href="/static/simplewiki/css/base_print.css" /> -->
<!-- <link rel="stylesheet" href="/static/simplewiki/css/autosuggest_inquisitor.css" /> -->
<!-- <link rel="stylesheet" href="/static/css/local.css" type="text/css" media="all" /> -->
<script type="text/javascript" src="/static/simplewiki/js/bsn.AutoSuggest_c_2.0.js"></script>
<script type="text/javascript" src="/static/js/simplewiki/bsn.AutoSuggest_c_2.0.js"></script>
<%!
from django.core.urlresolvers import reverse
......
##This file is based on the template from the SimpleWiki source which carries the GPL license
<%inherit file="simplewiki_base.html"/>
<%block name="title"><title>Wiki – Create Article – MITx 6.002x</title></%block>
<%block name="wiki_page_title">
<h1>Create article</h1>
</%block>
<%block name="wiki_body">
<form method="POST" id="wiki_revision">
<div style="display:none">
<input type="hidden" name="csrfmiddlewaretoken" value="${csrf_token}"/>
</div>
${ wiki_form }
<input type="submit" value="Create article" /></td>
</form>
<%include file="simplewiki_instructions.html"/>
</%block>
......@@ -2,29 +2,58 @@
<%inherit file="simplewiki_base.html"/>
<%block name="title"><title>${"Edit " + wiki_title + " - " if wiki_title is not UNDEFINED else ""}MITx 6.002x Wiki</title></%block>
<%block name="title">
<title>
%if create_article:
Wiki – Create Article – MITx 6.002x
%else:
${"Edit " + wiki_title + " - " if wiki_title is not UNDEFINED else ""}MITx 6.002x Wiki
%endif
</title></%block>
<%block name="wiki_page_title">
%if create_article:
<h1>Create article</h1>
%else:
<h1>${ wiki_article.title }</h1>
%endif
</%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 }CodeMirror/xml.js"></script>
<script type="text/javascript" src="${ settings.LIB_URL }CodeMirror/mitx_markdown.js"></script>
<script>
$(function() {
//Store the initial contents of #id_contents (the wiki body field) so we can compare for unsaved changes
$("#id_contents").data('initial_contents', $("#id_contents").val());
window.onbeforeunload = function askConfirm() { //Warn the user before they navigate away
if ( $("#id_contents").val() != $("#id_contents").data('initial_contents') ) {
return "You have made changes to the article that have not been saved yet.";
}
};
$("#submit_edit").click(function() {
$("#id_contents").data('initial_contents', $("#id_contents").val());
$(function(){
$(document).ready(function() {
var editor = CodeMirror.fromTextArea(document.getElementById("id_contents"), {
mode: 'mitx_markdown',
matchBrackets: true,
theme: "default",
lineWrapping: true,
});
//Store the inital contents so we can compare for unsaved changes
var initial_contents = editor.getValue();
window.onbeforeunload = function askConfirm() { //Warn the user before they navigate away
if ( editor.getValue() != initial_contents ) {
return "You have made changes to the article that have not been saved yet.";
}
};
$("#submit_edit").click(function() {
initial_contents = editor.getValue();
});
});
});
</script>
</%block>
......@@ -35,8 +64,12 @@
<input type="hidden" name="csrfmiddlewaretoken" value="${csrf_token}"/>
</div>
${wiki_form}
%if create_article:
<input type="submit" id="submit_edit" value="Create article" /></td>
%else:
<input type="submit" id="submit_edit" name="edit" value="Save Changes" />
<input type="submit" id="submit_delete" name="delete" value="Delete article" />
%endif
</form>
<%include file="simplewiki_instructions.html"/>
......
......@@ -2,7 +2,7 @@
This wiki uses <strong>Markdown</strong> for styling. There are several <a href="http://daringfireball.net/projects/markdown/basics">useful</a> <a href="http://greg.vario.us/doc/markdown.txt">guides</a> <a href="http://www.lowendtalk.com/discussion/6/miniature-markdown-guide">online</a>.
<br>
<br>MITx Additions:
<p class="markdown-example">circuit:basic</p>
<p class="markdown-example">circuit-schematic:</p>
<p class="markdown-example"><span>$</span>LaTeX Math Expression<span>$</span></p>
To create a new wiki article, create a link to it. Clicking the link gives you the creation page.
<p class="markdown-example">[Article Name](wiki:ArticleName)</p>
......
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