-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merged FAQ and About into the same template, and added a special fold…
…er markdownext which gets added to the path dinamically so we can put normal markdown extensions there. Made the settings markdown parser abble to parse any setting. git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@263 0cfe37f9-358a-4d5e-be75-b63607b5c754
- Loading branch information
hernani
committed
May 13, 2010
1 parent
ea47e47
commit 9e75f1e
Showing
11 changed files
with
74 additions
and
102 deletions.
There are no files selected for viewing
Empty file.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
from os import linesep | ||
from csv import reader, QUOTE_NONE | ||
import markdown | ||
from markdown import Extension | ||
from markdown.preprocessors import Preprocessor | ||
import re | ||
|
||
from forum import settings | ||
|
||
class SettingsExtension(markdown.Extension): | ||
def __init__(self, configs): | ||
self.configs = {} # settings.REP_TO_VOTE_UP} | ||
for key, value in configs: | ||
self.config[key] = value | ||
|
||
# self.extendMarkdown(markdown.Markdown()., config) | ||
|
||
def reset(self): | ||
pass | ||
|
||
def extendMarkdown(self, md, md_globals): | ||
md.registerExtension(self) | ||
self.parser = md.parser | ||
md.preprocessors.add('MinRep', SettingsPre(self), '_begin') | ||
|
||
SETTING_RE = re.compile(r'\|[A-Z_]+\|') | ||
|
||
def setting_rep_callback(m): | ||
setting_name = m.group(0).strip('|') | ||
if hasattr(settings, setting_name): | ||
return unicode(getattr(settings, setting_name)) | ||
else: | ||
return '' | ||
|
||
|
||
class SettingsPre(Preprocessor): | ||
def run(self, lines): | ||
new_lines = [] | ||
for line in lines: | ||
new_lines.append(SETTING_RE.sub(setting_rep_callback, line)) | ||
|
||
return new_lines | ||
|
||
|
||
def makeExtension(configs=None) : | ||
return SettingsExtension(configs=configs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{% extends "base_content.html" %} | ||
{% load i18n %} | ||
{% load markup %} | ||
{% block title %}{% spaceless %}{{ title }}{% endspaceless %}{% endblock %} | ||
|
||
{% block content %} | ||
<div class="headNormal">{{ title }}</div> | ||
<div class="content"> | ||
{{ content|markdown:"settingsparser" }} | ||
</div> | ||
{% endblock %} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters