Fixed the markdown extensions to work with wiki namespaces.

This commit is contained in:
Bridger Maxwell
2012-07-03 12:40:39 -07:00
parent e122583440
commit c6d973bda9
5 changed files with 12 additions and 9 deletions

View File

@@ -17,8 +17,6 @@ circuit-schematic:[["r",[128,48,0],{"r":"1","_json_":0},["2","1"]],["view",0,0,2
import markdown
import re
import simplewiki.settings as settings
from django.utils.html import escape
try:
@@ -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>")
def makeExtension(configs=None) :
return CircuitExtension(configs=configs)
def makeExtension(configs=None):
to_return = CircuitExtension(configs=configs)
print "circuit returning " , to_return
return to_return

View File

@@ -33,7 +33,7 @@ class WikiPathExtension(markdown.Extension):
def __init__(self, configs):
# set extension defaults
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.']
}
@@ -62,7 +62,10 @@ class WikiPath(markdown.inlinepatterns.Pattern):
if article_title.startswith("/"):
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')
a = etree.Element('a')
a.set('href', url)

View File

@@ -270,7 +270,7 @@ 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=('/',))]
ext += ["wikipath(default_namespace=%s)" % self.article.namespace.name ]
self.contents_parsed = markdown(self.contents,
extensions=ext,
safe_mode='escape',)

View File

@@ -1,5 +1,5 @@
form {
font-size: 0em;
font-size: 1em;
label {
color: $base-font-color;

View File

@@ -1167,7 +1167,7 @@ p.ie-warning {
text-align: left; }
form {
font-size: 0em; }
font-size: 1em; }
form label {
color: #3c3c3c;
font: normal 1.2rem/1.6rem Georgia, Cambria, "Times New Roman", Times, serif;