2 from csv import reader, QUOTE_NONE
4 from markdown import Extension
5 from markdown.preprocessors import Preprocessor
8 #from django.conf import settings
9 from forum import settings
11 class SettingsExtension(markdown.Extension):
12 def __init__(self, configs):
13 self.configs = {} # settings.REP_TO_VOTE_UP}
14 for key, value in configs:
15 self.config[key] = value
17 # self.extendMarkdown(markdown.Markdown()., config)
22 def extendMarkdown(self, md, md_globals):
23 md.registerExtension(self)
24 self.parser = md.parser
25 md.preprocessors.add('MinRep', SettingsPre(self), '_begin')
27 class SettingsPre(Preprocessor):
32 # tags relating to the minrip.py settings
33 line = line.replace('REP_TO_VOTE_UP', '%d' % settings.REP_TO_VOTE_UP)
34 line = line.replace('REP_TO_VOTE_DOWN', '%d' % settings.REP_TO_VOTE_DOWN)
35 line = line.replace('REP_TO_FLAG', '%d' % settings.REP_TO_FLAG)
36 line = line.replace('REP_TO_COMMENT', '%d' % settings.REP_TO_COMMENT)
37 line = line.replace('REP_TO_LIKE_COMMENT', '%d' % settings.REP_TO_LIKE_COMMENT)
38 line = line.replace('REP_TO_CLOSE_OWN', '%d' % settings.REP_TO_CLOSE_OWN)
39 line = line.replace('REP_TO_REOPEN_OWN', '%d' % settings.REP_TO_REOPEN_OWN)
40 line = line.replace('REP_TO_RETAG', '%d' % settings.REP_TO_RETAG)
41 line = line.replace('REP_TO_EDIT_WIKI', '%d' % settings.REP_TO_EDIT_WIKI)
42 line = line.replace('REP_TO_EDIT_OTHERS', '%d' % settings.REP_TO_EDIT_OTHERS)
43 line = line.replace('REP_TO_CLOSE_OTHERS', '%d' % settings.REP_TO_CLOSE_OTHERS)
44 line = line.replace('REP_TO_DELETE_COMMENTS', '%d' % settings.REP_TO_DELETE_COMMENTS)
45 line = line.replace('REP_TO_VIEW_FLAGS', '%d' % settings.REP_TO_VIEW_FLAGS)
47 new_lines.append(line)
51 def makeSettingsExtension(configs={}) :
52 return MinRepExtension(configs=configs)