forked from expo/troggle
[svn] * wikilink to html for subcaves and cave descriptions
* fix header regex
This commit is contained in:
parent
4a073ea161
commit
18e61d19f5
@ -541,9 +541,11 @@ class CaveDescription(TroggleModel):
|
|||||||
return urlparse.urljoin(settings.URL_ROOT, reverse('cavedescription', args=(self.short_name,)))
|
return urlparse.urljoin(settings.URL_ROOT, reverse('cavedescription', args=(self.short_name,)))
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
|
"""
|
||||||
|
Overridden save method which stores wikilinks in text as links in database.
|
||||||
|
"""
|
||||||
super(CaveDescription, self).save()
|
super(CaveDescription, self).save()
|
||||||
qm_list=get_related_by_wikilinks(self.description)
|
qm_list=get_related_by_wikilinks(self.description)
|
||||||
print qm_list
|
|
||||||
for qm in qm_list:
|
for qm in qm_list:
|
||||||
self.linked_qms.add(qm)
|
self.linked_qms.add(qm)
|
||||||
super(CaveDescription, self).save()
|
super(CaveDescription, self).save()
|
||||||
|
@ -65,10 +65,7 @@ def wiki_to_html_short(value, autoescape=None):
|
|||||||
value = re.sub("''''([^']+)''''", r"<b><i>\1</i></b>", value, re.DOTALL)
|
value = re.sub("''''([^']+)''''", r"<b><i>\1</i></b>", value, re.DOTALL)
|
||||||
value = re.sub("'b''([^']+)'''", r"<b>\1</b>", value, re.DOTALL)
|
value = re.sub("'b''([^']+)'''", r"<b>\1</b>", value, re.DOTALL)
|
||||||
value = re.sub("''([^']+)''", r"<i>\1</i>", value, re.DOTALL)
|
value = re.sub("''([^']+)''", r"<i>\1</i>", value, re.DOTALL)
|
||||||
#make cave links
|
|
||||||
value = re.sub("\[\[\s*cave:([^\s]+)\s*\s*\]\]", r'<a href="%s/cave/\1/">\1</a>' % url_root, value, re.DOTALL)
|
|
||||||
#make people links
|
|
||||||
value = re.sub("\[\[\s*person:(.+)\]\]",r'<a href="%s/person/\1/">\1</a>' % url_root, value, re.DOTALL)
|
|
||||||
#make headers
|
#make headers
|
||||||
def headerrepl(matchobj):
|
def headerrepl(matchobj):
|
||||||
number=len(matchobj.groups()[0])
|
number=len(matchobj.groups()[0])
|
||||||
@ -78,8 +75,7 @@ def wiki_to_html_short(value, autoescape=None):
|
|||||||
else:
|
else:
|
||||||
print 'morethanone'
|
print 'morethanone'
|
||||||
return matchobj.group()
|
return matchobj.group()
|
||||||
value = re.sub(r"(=+)([^=]+)(=+)",headerrepl,value)
|
value = re.sub(r"(?m)^(=+)([^=]+)(=+)$",headerrepl,value)
|
||||||
|
|
||||||
|
|
||||||
#make qm links. this takes a little doing
|
#make qm links. this takes a little doing
|
||||||
qmMatchPattern=settings.QM_PATTERN
|
qmMatchPattern=settings.QM_PATTERN
|
||||||
@ -141,7 +137,17 @@ def wiki_to_html_short(value, autoescape=None):
|
|||||||
return res
|
return res
|
||||||
value = re.sub(photoLinkPattern,photoLinkRepl, value, re.DOTALL)
|
value = re.sub(photoLinkPattern,photoLinkRepl, value, re.DOTALL)
|
||||||
value = re.sub(photoSrcPattern,photoSrcRepl, value, re.DOTALL)
|
value = re.sub(photoSrcPattern,photoSrcRepl, value, re.DOTALL)
|
||||||
|
|
||||||
|
#make cave links
|
||||||
|
value = re.sub("\[\[\s*cave:([^\s]+)\s*\s*\]\]", r'<a href="%s/cave/\1/">\1</a>' % url_root, value, re.DOTALL)
|
||||||
|
#make people links
|
||||||
|
value = re.sub("\[\[\s*person:(.+)\|(.+)\]\]",r'<a href="%s/person/\1/">\2</a>' % url_root, value, re.DOTALL)
|
||||||
|
#make subcave links
|
||||||
|
value = re.sub("\[\[\s*subcave:(.+)\|(.+)\]\]",r'<a href="%s/subcave/\1/">\2</a>' % url_root, value, re.DOTALL)
|
||||||
|
#make cavedescription links
|
||||||
|
value = re.sub("\[\[\s*cavedescription:(.+)\|(.+)\]\]",r'<a href="%s/cavedescription/\2/">\1</a>' % url_root, value, re.DOTALL)
|
||||||
|
|
||||||
|
|
||||||
#Make lists from lines starting with lists of [stars and hashes]
|
#Make lists from lines starting with lists of [stars and hashes]
|
||||||
outValue = ""
|
outValue = ""
|
||||||
listdepth = []
|
listdepth = []
|
||||||
|
2
utils.py
2
utils.py
@ -99,7 +99,7 @@ re_subs = [(re.compile(r"\<b[^>]*\>(.*?)\</b\>", re.DOTALL), r"'''\1'''"),
|
|||||||
(re.compile(r"\<h4[^>]*\>(.*?)\</h4\>", re.DOTALL), r"====\1===="),
|
(re.compile(r"\<h4[^>]*\>(.*?)\</h4\>", re.DOTALL), r"====\1===="),
|
||||||
(re.compile(r"\<h5[^>]*\>(.*?)\</h5\>", re.DOTALL), r"=====\1====="),
|
(re.compile(r"\<h5[^>]*\>(.*?)\</h5\>", re.DOTALL), r"=====\1====="),
|
||||||
(re.compile(r"\<h6[^>]*\>(.*?)\</h6\>", re.DOTALL), r"======\1======"),
|
(re.compile(r"\<h6[^>]*\>(.*?)\</h6\>", re.DOTALL), r"======\1======"),
|
||||||
(re.compile(r"\<a\s+id=['\"]([^'\"]*)['\"]\s*\>(.*?)\</a\>", re.DOTALL), r"[subcave:\1|\2]"),
|
(re.compile(r"\<a\s+id=['\"]([^'\"]*)['\"]\s*\>(.*?)\</a\>", re.DOTALL), r"[[subcave:\1|\2]]"),
|
||||||
#interpage link needed
|
#interpage link needed
|
||||||
(re.compile(r"\<a\s+href=['\"]#([^'\"]*)['\"]\s*\>(.*?)\</a\>", re.DOTALL), r"[[cavedescription:\1|\2]]"),
|
(re.compile(r"\<a\s+href=['\"]#([^'\"]*)['\"]\s*\>(.*?)\</a\>", re.DOTALL), r"[[cavedescription:\1|\2]]"),
|
||||||
(re.compile(r"\[\<a\s+href=['\"][^'\"]*['\"]\s+id=['\"][^'\"]*['\"]\s*\>([^\s]*).*?\</a\>\]", re.DOTALL), r"[[qm:\1]]"),
|
(re.compile(r"\[\<a\s+href=['\"][^'\"]*['\"]\s+id=['\"][^'\"]*['\"]\s*\>([^\s]*).*?\</a\>\]", re.DOTALL), r"[[qm:\1]]"),
|
||||||
|
Loading…
Reference in New Issue
Block a user