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/'
......
@charset "UTF-8";
/*
html5doctor.com Reset Stylesheet
v1.6.1
......@@ -440,7 +439,7 @@ img {
max-width: 100%;
height: auto; }
input[type="email"], input[type="number"], input[type="password"], input[type="search"], input[type="tel"], input[type="text"], input[type="url"], input[type="color"], input[type="date"], input[type="datetime"], input[type="datetime-local"], input[type="month"], input[type="time"], input[type="week"], textarea {
input[type="email"], input[type="number"], input[type="password"], input[type="search"], input[type="tel"], input[type="text"], input[type="url"], input[type="color"], input[type="date"], input[type="datetime"], input[type="datetime-local"], input[type="month"], input[type="time"], input[type="week"], textarea, form#wiki_revision .CodeMirror {
-webkit-box-shadow: 0 -1px 0 white;
-moz-box-shadow: 0 -1px 0 white;
box-shadow: 0 -1px 0 white;
......@@ -454,7 +453,7 @@ input[type="email"], input[type="number"], input[type="password"], input[type="s
border: 1px solid #999;
font: 14px "Open Sans", "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Geneva, Verdana, sans-serif;
padding: 4px; }
input[type="email"]:focus, input[type="number"]:focus, input[type="password"]:focus, input[type="search"]:focus, input[type="tel"]:focus, input[type="text"]:focus, input[type="url"]:focus, input[type="color"]:focus, input[type="date"]:focus, input[type="datetime"]:focus, input[type="datetime-local"]:focus, input[type="month"]:focus, input[type="time"]:focus, input[type="week"]:focus, textarea:focus {
input[type="email"]:focus, input[type="number"]:focus, input[type="password"]:focus, input[type="search"]:focus, input[type="tel"]:focus, input[type="text"]:focus, input[type="url"]:focus, input[type="color"]:focus, input[type="date"]:focus, input[type="datetime"]:focus, input[type="datetime-local"]:focus, input[type="month"]:focus, input[type="time"]:focus, input[type="week"]:focus, textarea:focus, form#wiki_revision .CodeMirror:focus {
border-color: #993333; }
a {
......@@ -962,7 +961,7 @@ div.leanModal_box form ol li.honor-code {
div.leanModal_box form ol li label {
display: block;
font-weight: bold; }
div.leanModal_box form ol li input[type="email"], div.leanModal_box form ol li input[type="number"], div.leanModal_box form ol li input[type="password"], div.leanModal_box form ol li input[type="search"], div.leanModal_box form ol li input[type="tel"], div.leanModal_box form ol li input[type="text"], div.leanModal_box form ol li input[type="url"], div.leanModal_box form ol li input[type="color"], div.leanModal_box form ol li input[type="date"], div.leanModal_box form ol li input[type="datetime"], div.leanModal_box form ol li input[type="datetime-local"], div.leanModal_box form ol li input[type="month"], div.leanModal_box form ol li input[type="time"], div.leanModal_box form ol li input[type="week"], div.leanModal_box form ol li textarea {
div.leanModal_box form ol li input[type="email"], div.leanModal_box form ol li input[type="number"], div.leanModal_box form ol li input[type="password"], div.leanModal_box form ol li input[type="search"], div.leanModal_box form ol li input[type="tel"], div.leanModal_box form ol li input[type="text"], div.leanModal_box form ol li input[type="url"], div.leanModal_box form ol li input[type="color"], div.leanModal_box form ol li input[type="date"], div.leanModal_box form ol li input[type="datetime"], div.leanModal_box form ol li input[type="datetime-local"], div.leanModal_box form ol li input[type="month"], div.leanModal_box form ol li input[type="time"], div.leanModal_box form ol li input[type="week"], div.leanModal_box form ol li textarea, div.leanModal_box form#wiki_revision ol li .CodeMirror {
width: 100%;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
......@@ -1055,13 +1054,13 @@ div#apply_name_change ul, div#change_email ul, div#unenroll ul, div#deactivate-a
list-style: none; }
div#apply_name_change ul li, div#change_email ul li, div#unenroll ul li, div#deactivate-account ul li {
margin-bottom: 11.326px; }
div#apply_name_change ul li textarea, div#apply_name_change ul li input[type="email"], div#apply_name_change ul li input[type="number"], div#apply_name_change ul li input[type="password"], div#apply_name_change ul li input[type="search"], div#apply_name_change ul li input[type="tel"], div#apply_name_change ul li input[type="text"], div#apply_name_change ul li input[type="url"], div#apply_name_change ul li input[type="color"], div#apply_name_change ul li input[type="date"], div#apply_name_change ul li input[type="datetime"], div#apply_name_change ul li input[type="datetime-local"], div#apply_name_change ul li input[type="month"], div#apply_name_change ul li input[type="time"], div#apply_name_change ul li input[type="week"], div#change_email ul li textarea, div#change_email ul li input[type="email"], div#change_email ul li input[type="number"], div#change_email ul li input[type="password"], div#change_email ul li input[type="search"], div#change_email ul li input[type="tel"], div#change_email ul li input[type="text"], div#change_email ul li input[type="url"], div#change_email ul li input[type="color"], div#change_email ul li input[type="date"], div#change_email ul li input[type="datetime"], div#change_email ul li input[type="datetime-local"], div#change_email ul li input[type="month"], div#change_email ul li input[type="time"], div#change_email ul li input[type="week"], div#unenroll ul li textarea, div#unenroll ul li input[type="email"], div#unenroll ul li input[type="number"], div#unenroll ul li input[type="password"], div#unenroll ul li input[type="search"], div#unenroll ul li input[type="tel"], div#unenroll ul li input[type="text"], div#unenroll ul li input[type="url"], div#unenroll ul li input[type="color"], div#unenroll ul li input[type="date"], div#unenroll ul li input[type="datetime"], div#unenroll ul li input[type="datetime-local"], div#unenroll ul li input[type="month"], div#unenroll ul li input[type="time"], div#unenroll ul li input[type="week"], div#deactivate-account ul li textarea, div#deactivate-account ul li input[type="email"], div#deactivate-account ul li input[type="number"], div#deactivate-account ul li input[type="password"], div#deactivate-account ul li input[type="search"], div#deactivate-account ul li input[type="tel"], div#deactivate-account ul li input[type="text"], div#deactivate-account ul li input[type="url"], div#deactivate-account ul li input[type="color"], div#deactivate-account ul li input[type="date"], div#deactivate-account ul li input[type="datetime"], div#deactivate-account ul li input[type="datetime-local"], div#deactivate-account ul li input[type="month"], div#deactivate-account ul li input[type="time"], div#deactivate-account ul li input[type="week"] {
div#apply_name_change ul li textarea, div#apply_name_change ul li form#wiki_revision .CodeMirror, form#wiki_revision div#apply_name_change ul li .CodeMirror, div#apply_name_change ul li input[type="email"], div#apply_name_change ul li input[type="number"], div#apply_name_change ul li input[type="password"], div#apply_name_change ul li input[type="search"], div#apply_name_change ul li input[type="tel"], div#apply_name_change ul li input[type="text"], div#apply_name_change ul li input[type="url"], div#apply_name_change ul li input[type="color"], div#apply_name_change ul li input[type="date"], div#apply_name_change ul li input[type="datetime"], div#apply_name_change ul li input[type="datetime-local"], div#apply_name_change ul li input[type="month"], div#apply_name_change ul li input[type="time"], div#apply_name_change ul li input[type="week"], div#change_email ul li textarea, div#change_email ul li form#wiki_revision .CodeMirror, form#wiki_revision div#change_email ul li .CodeMirror, div#change_email ul li input[type="email"], div#change_email ul li input[type="number"], div#change_email ul li input[type="password"], div#change_email ul li input[type="search"], div#change_email ul li input[type="tel"], div#change_email ul li input[type="text"], div#change_email ul li input[type="url"], div#change_email ul li input[type="color"], div#change_email ul li input[type="date"], div#change_email ul li input[type="datetime"], div#change_email ul li input[type="datetime-local"], div#change_email ul li input[type="month"], div#change_email ul li input[type="time"], div#change_email ul li input[type="week"], div#unenroll ul li textarea, div#unenroll ul li form#wiki_revision .CodeMirror, form#wiki_revision div#unenroll ul li .CodeMirror, div#unenroll ul li input[type="email"], div#unenroll ul li input[type="number"], div#unenroll ul li input[type="password"], div#unenroll ul li input[type="search"], div#unenroll ul li input[type="tel"], div#unenroll ul li input[type="text"], div#unenroll ul li input[type="url"], div#unenroll ul li input[type="color"], div#unenroll ul li input[type="date"], div#unenroll ul li input[type="datetime"], div#unenroll ul li input[type="datetime-local"], div#unenroll ul li input[type="month"], div#unenroll ul li input[type="time"], div#unenroll ul li input[type="week"], div#deactivate-account ul li textarea, div#deactivate-account ul li form#wiki_revision .CodeMirror, form#wiki_revision div#deactivate-account ul li .CodeMirror, div#deactivate-account ul li input[type="email"], div#deactivate-account ul li input[type="number"], div#deactivate-account ul li input[type="password"], div#deactivate-account ul li input[type="search"], div#deactivate-account ul li input[type="tel"], div#deactivate-account ul li input[type="text"], div#deactivate-account ul li input[type="url"], div#deactivate-account ul li input[type="color"], div#deactivate-account ul li input[type="date"], div#deactivate-account ul li input[type="datetime"], div#deactivate-account ul li input[type="datetime-local"], div#deactivate-account ul li input[type="month"], div#deactivate-account ul li input[type="time"], div#deactivate-account ul li input[type="week"] {
display: block;
width: 100%;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box; }
div#apply_name_change ul li textarea, div#change_email ul li textarea, div#unenroll ul li textarea, div#deactivate-account ul li textarea {
div#apply_name_change ul li textarea, div#apply_name_change ul li form#wiki_revision .CodeMirror, form#wiki_revision div#apply_name_change ul li .CodeMirror, div#change_email ul li textarea, div#change_email ul li form#wiki_revision .CodeMirror, form#wiki_revision div#change_email ul li .CodeMirror, div#unenroll ul li textarea, div#unenroll ul li form#wiki_revision .CodeMirror, form#wiki_revision div#unenroll ul li .CodeMirror, div#deactivate-account ul li textarea, div#deactivate-account ul li form#wiki_revision .CodeMirror, form#wiki_revision div#deactivate-account ul li .CodeMirror {
height: 60px; }
div#apply_name_change ul li input[type="submit"], div#change_email ul li input[type="submit"], div#unenroll ul li input[type="submit"], div#deactivate-account ul li input[type="submit"] {
white-space: normal; }
......@@ -1069,7 +1068,7 @@ div#apply_name_change ul li input[type="submit"], div#change_email ul li input[t
div#feedback_div form ol li {
float: none;
width: 100%; }
div#feedback_div form ol li textarea#feedback_message {
div#feedback_div form ol li textarea#feedback_message, div#feedback_div form#wiki_revision ol li #feedback_message.CodeMirror {
height: 100px; }
/*
......@@ -1172,7 +1171,7 @@ div#feedback_div form ol li textarea#feedback_message {
.ui-widget .ui-widget {
font-size: 1em; }
.ui-widget input, .ui-widget select, .ui-widget textarea, .ui-widget button {
.ui-widget input, .ui-widget select, .ui-widget textarea, .ui-widget form#wiki_revision .CodeMirror, form#wiki_revision .ui-widget .CodeMirror, .ui-widget button {
font-family: Helvetica, Arial, sans-serif;
font-size: 1em; }
......@@ -4097,7 +4096,7 @@ section.wiki-body div#wiki_article pre, section.wiki-body div#wiki_article tt, s
font-family: monospace; }
section.wiki-body div#wiki_article pre {
white-space: pre; }
section.wiki-body div#wiki_article button, section.wiki-body div#wiki_article textarea, section.wiki-body div#wiki_article input, section.wiki-body div#wiki_article select {
section.wiki-body div#wiki_article button, section.wiki-body div#wiki_article textarea, section.wiki-body div#wiki_article form#wiki_revision .CodeMirror, form#wiki_revision section.wiki-body div#wiki_article .CodeMirror, section.wiki-body div#wiki_article input, section.wiki-body div#wiki_article select {
display: inline-block; }
section.wiki-body div#wiki_article big {
font-size: 1.17em; }
......@@ -4208,7 +4207,16 @@ form#wiki_revision {
form#wiki_revision label {
display: block;
margin-bottom: 7px; }
form#wiki_revision textarea {
form#wiki_revision .CodeMirror-scroll {
min-height: 550px;
width: 100%; }
form#wiki_revision .CodeMirror {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
font-family: monospace;
margin-bottom: 20px; }
form#wiki_revision textarea, form#wiki_revision .CodeMirror {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
......@@ -6294,7 +6302,7 @@ form.answer-form, form.question-form {
border-top: 1px solid #ddd;
overflow: hidden;
padding-left: 7.328%; }
form.answer-form textarea, form.question-form textarea {
form.answer-form textarea, form.question-form textarea, form.answer-form form#wiki_revision .CodeMirror, form#wiki_revision form.answer-form .CodeMirror, form.question-form form#wiki_revision .CodeMirror, form#wiki_revision form.question-form .CodeMirror {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
......
.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.
var schematic_height = 300;
var schematic_width = 500;
$(function(){
$(document).ready(function() {
$("a[rel*=leanModal]").leanModal();
$("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=""/>' +
'<button type="button" id="circuit_save_btn">save</button></div></div>');
//This is the editor that pops up as a modal
var editorCircuit = $("#schematic_editor").get(0);
//This is the circuit that they last clicked. The one being edited.
var editingCircuit = null;
//Notice we use live, because new circuits can be inserted
$(".schematic_open").live("click", function() {
//Find the new editingCircuit. Transfer its contents to the editorCircuit
editingCircuit = $(this).children("input.schematic").get(0);
editingCircuit.schematic.update_value();
var circuit_so_far = $(editingCircuit).val();
var n = editorCircuit.schematic.components.length;
for (var i = 0; i < n; i++)
editorCircuit.schematic.components[n - 1 - i].remove();
editorCircuit.schematic.load_schematic(circuit_so_far, "");
});
$("#circuit_save_btn").click(function () {
//Take the circuit from the editor and put it back into editingCircuit
editorCircuit.schematic.update_value();
var saving_circuit = $(editorCircuit).val();
var n = editingCircuit.schematic.components.length;
for (var i = 0; i < n; i++)
editingCircuit.schematic.components[n - 1 - i].remove();
editingCircuit.schematic.load_schematic(saving_circuit, "");
if (editingCircuit.codeMirrorLine) {
editingCircuit.codeMirrorLine.replace(0, null, "circuit-schematic:" + saving_circuit);
}
$(".modal_close").first().click();
});
});
});
CodeMirror.defineMode("mitx_markdown", function(cmCfg, modeCfg) {
var htmlMode = CodeMirror.getMode(cmCfg, { name: 'xml', htmlMode: true });
var header = 'header'
, code = 'comment'
, quote = 'quote'
, list = 'string'
, hr = 'hr'
, linktext = 'link'
, linkhref = 'string'
, em = 'em'
, strong = 'strong'
, emstrong = 'emstrong';
function escapeHtml(unsafe) {
return unsafe
.replace(/&/g, "&amp;")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;")
.replace(/"/g, "&quot;")
.replace(/'/g, "&#039;");
}
var circuit_formatter = {
creator: function(text) {
var circuit_value = text.match(circuitRE)[1]
circuit_value = escapeHtml(circuit_value);
var html = "<div style='display:block;line-height:0;' class='schematic_container'><a href='#circuit_editor' rel='leanModal' class='schematic_open' style='display:inline-block;'>" +
"<input type='hidden' parts='' value='" + circuit_value + "' width='" + schematic_width + "' height='" + schematic_height + "' analyses='' class='schematic ctrls'/></a></div>";
return html;
},
size: function(text) {
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();
}
$(node.firstChild).leanModal();
}
};
var hrRE = /^[*-=_]/
, ulRE = /^[*-+]\s+/
, olRE = /^[0-9]+\.\s+/
, headerRE = /^(?:\={3,}|-{3,})$/
, codeRE = /^(k:\t|\s{4,})/
, textRE = /^[^\[*_\\<>`]+/
, circuitRE = /^circuit-schematic:(.*)$/;
function switchInline(stream, state, f) {
state.f = state.inline = f;
return f(stream, state);
}
function switchBlock(stream, state, f) {
state.f = state.block = f;
return f(stream, state);
}
// Blocks
function blockNormal(stream, state) {
var match;
if (stream.match(circuitRE)) {
stream.skipToEnd();
return circuit_formatter;
} else if (stream.match(codeRE)) {
stream.skipToEnd();
return code;
} else if (stream.eatSpace()) {
return null;
} else if (stream.peek() === '#' || stream.match(headerRE)) {
state.header = true;
} else if (stream.eat('>')) {
state.indentation++;
state.quote = true;
} else if (stream.peek() === '[') {
return switchInline(stream, state, footnoteLink);
} else if (hrRE.test(stream.peek())) {
var re = new RegExp('(?:\s*['+stream.peek()+']){3,}$');
if (stream.match(re, true)) {
return hr;
}
} else if (match = stream.match(ulRE, true) || stream.match(olRE, true)) {
state.indentation += match[0].length;
return list;
}
return switchInline(stream, state, state.inline);
}
function htmlBlock(stream, state) {
var style = htmlMode.token(stream, state.htmlState);
if (style === 'tag' && state.htmlState.type !== 'openTag' && !state.htmlState.context) {
state.f = inlineNormal;
state.block = blockNormal;
}
return style;
}
// Inline
function getType(state) {
// Set defaults
returnValue = '';
// Strong / Emphasis
if(state.strong){
if(state.em){
returnValue += (returnValue ? ' ' : '') + emstrong;
} else {
returnValue += (returnValue ? ' ' : '') + strong;
}
} else {
if(state.em){
returnValue += (returnValue ? ' ' : '') + em;
}
}
// Header
if(state.header){
returnValue += (returnValue ? ' ' : '') + header;
}
// Quotes
if(state.quote){
returnValue += (returnValue ? ' ' : '') + quote;
}
// Check valud and return
if(!returnValue){
returnValue = null;
}
return returnValue;
}
function handleText(stream, state) {
if (stream.match(textRE, true)) {
return getType(state);
}
return undefined;
}
function inlineNormal(stream, state) {
var style = state.text(stream, state)
if (typeof style !== 'undefined')
return style;
var ch = stream.next();
if (ch === '\\') {
stream.next();
return getType(state);
}
if (ch === '`') {
return switchInline(stream, state, inlineElement(code, '`'));
}
if (ch === '[') {
return switchInline(stream, state, linkText);
}
if (ch === '<' && stream.match(/^\w/, false)) {
stream.backUp(1);
return switchBlock(stream, state, htmlBlock);
}
var t = getType(state);
if (ch === '*' || ch === '_') {
if (stream.eat(ch)) {
return (state.strong = !state.strong) ? getType(state) : t;
}
return (state.em = !state.em) ? getType(state) : t;
}
return getType(state);
}
function linkText(stream, state) {
while (!stream.eol()) {
var ch = stream.next();
if (ch === '\\') stream.next();
if (ch === ']') {
state.inline = state.f = linkHref;
return linktext;
}
}
return linktext;
}
function linkHref(stream, state) {
stream.eatSpace();
var ch = stream.next();
if (ch === '(' || ch === '[') {
return switchInline(stream, state, inlineElement(linkhref, ch === '(' ? ')' : ']'));
}
return 'error';
}
function footnoteLink(stream, state) {
if (stream.match(/^[^\]]*\]:/, true)) {
state.f = footnoteUrl;
return linktext;
}
return switchInline(stream, state, inlineNormal);
}
function footnoteUrl(stream, state) {
stream.eatSpace();
stream.match(/^[^\s]+/, true);
state.f = state.inline = inlineNormal;
return linkhref;
}
function inlineRE(endChar) {
if (!inlineRE[endChar]) {
// match any not-escaped-non-endChar and any escaped char
// then match endChar or eol
inlineRE[endChar] = new RegExp('^(?:[^\\\\\\' + endChar + ']|\\\\.)*(?:\\' + endChar + '|$)');
}
return inlineRE[endChar];
}
function inlineElement(type, endChar, next) {
next = next || inlineNormal;
return function(stream, state) {
stream.match(inlineRE(endChar));
state.inline = state.f = next;
return type;
};
}
return {
startState: function() {
return {
f: blockNormal,
block: blockNormal,
htmlState: htmlMode.startState(),
indentation: 0,
inline: inlineNormal,
text: handleText,
em: false,
strong: false,
header: false,
quote: false
};
},
copyState: function(s) {
return {
f: s.f,
block: s.block,
htmlState: CodeMirror.copyState(htmlMode, s.htmlState),
indentation: s.indentation,
inline: s.inline,
text: s.text,
em: s.em,
strong: s.strong,
header: s.header,
quote: s.quote
};
},
token: function(stream, state) {
if (stream.sol()) {
// Reset EM state
state.em = false;
// Reset STRONG state
state.strong = false;
// Reset state.header
state.header = false;
// Reset state.quote
state.quote = false;
state.f = state.block;
var previousIndentation = state.indentation
, currentIndentation = 0;
while (previousIndentation > 0) {
if (stream.eat(' ')) {
previousIndentation--;
currentIndentation++;
} else if (previousIndentation >= 4 && stream.eat('\t')) {
previousIndentation -= 4;
currentIndentation += 4;
} else {
break;
}
}
state.indentation = currentIndentation;
if (currentIndentation > 0) return null;
}
return state.f(stream, state);
},
getType: getType
};
});
CodeMirror.defineMIME("text/x-markdown", "markdown");
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