Commit c6d973bd by Bridger Maxwell

Fixed the markdown extensions to work with wiki namespaces.

parent e1225834
...@@ -17,8 +17,6 @@ circuit-schematic:[["r",[128,48,0],{"r":"1","_json_":0},["2","1"]],["view",0,0,2 ...@@ -17,8 +17,6 @@ circuit-schematic:[["r",[128,48,0],{"r":"1","_json_":0},["2","1"]],["view",0,0,2
import markdown import markdown
import re import re
import simplewiki.settings as settings
from django.utils.html import escape from django.utils.html import escape
try: try:
...@@ -68,5 +66,7 @@ class CircuitLink(markdown.inlinepatterns.Pattern): ...@@ -68,5 +66,7 @@ class CircuitLink(markdown.inlinepatterns.Pattern):
return etree.fromstring("<div align='center'><input type='hidden' parts='' value='" + data + "' analyses='' class='schematic ctrls' width='640' height='480'/></div>") return etree.fromstring("<div align='center'><input type='hidden' parts='' value='" + data + "' analyses='' class='schematic ctrls' width='640' height='480'/></div>")
def makeExtension(configs=None) : def makeExtension(configs=None):
return CircuitExtension(configs=configs) to_return = CircuitExtension(configs=configs)
print "circuit returning " , to_return
return to_return
...@@ -33,7 +33,7 @@ class WikiPathExtension(markdown.Extension): ...@@ -33,7 +33,7 @@ class WikiPathExtension(markdown.Extension):
def __init__(self, configs): def __init__(self, configs):
# set extension defaults # set extension defaults
self.config = { self.config = {
'base_url' : ['/', 'String to append to beginning or URL.'], 'default_namespace' : ['edX', 'Default namespace for when one isn\'t specified.'],
'html_class' : ['wikipath', 'CSS hook. Leave blank for none.'] 'html_class' : ['wikipath', 'CSS hook. Leave blank for none.']
} }
...@@ -62,7 +62,10 @@ class WikiPath(markdown.inlinepatterns.Pattern): ...@@ -62,7 +62,10 @@ class WikiPath(markdown.inlinepatterns.Pattern):
if article_title.startswith("/"): if article_title.startswith("/"):
article_title = article_title[1:] article_title = article_title[1:]
url = self.config['base_url'][0] + article_title if not "/" in article_title:
article_title = self.config['default_namespace'][0] + "/" + article_title
url = "../" + article_title
label = m.group('linkTitle') label = m.group('linkTitle')
a = etree.Element('a') a = etree.Element('a')
a.set('href', url) a.set('href', url)
......
...@@ -270,7 +270,7 @@ class Revision(models.Model): ...@@ -270,7 +270,7 @@ class Revision(models.Model):
# Create pre-parsed contents - no need to parse on-the-fly # Create pre-parsed contents - no need to parse on-the-fly
ext = WIKI_MARKDOWN_EXTENSIONS ext = WIKI_MARKDOWN_EXTENSIONS
ext += ["wikipath(base_url=%s)" % reverse('wiki_view', args=('/',))] ext += ["wikipath(default_namespace=%s)" % self.article.namespace.name ]
self.contents_parsed = markdown(self.contents, self.contents_parsed = markdown(self.contents,
extensions=ext, extensions=ext,
safe_mode='escape',) safe_mode='escape',)
......
form { form {
font-size: 0em; font-size: 1em;
label { label {
color: $base-font-color; color: $base-font-color;
......
...@@ -1167,7 +1167,7 @@ p.ie-warning { ...@@ -1167,7 +1167,7 @@ p.ie-warning {
text-align: left; } text-align: left; }
form { form {
font-size: 0em; } font-size: 1em; }
form label { form label {
color: #3c3c3c; color: #3c3c3c;
font: normal 1.2rem/1.6rem Georgia, Cambria, "Times New Roman", Times, serif; font: normal 1.2rem/1.6rem Georgia, Cambria, "Times New Roman", Times, serif;
......
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