--- /dev/null
+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)
\ No newline at end of file
For example, if you ask an interesting question or give a helpful answer, your input will be upvoted. On the other hand if the answer is misleading - it will be downvoted. Each vote in favor will generate 10 points, each vote against will subtract 2 points. There is a limit of 200 points that can be accumulated per question or answer. The table below explains reputation point requirements for each type of moderation task.
-* add comments -> REP_TO_COMMENT
-* delete comments -> REP_TO_DELETE_COMMENTS
-* close own questions -> REP_TO_CLOSE_OWN
-* reopen own questions -> REP_TO_REOPEN_OWN
-* retag questions -> REP_TO_RETAG
-* edit any answer -> REP_TO_EDIT_OTHERS
-* open any closed question -> REP_TO_CLOSE_OTHERS
-* delete any comment -> REP_TO_DELETE_COMMENTS
+* add comments -> |REP_TO_COMMENT|
+* delete comments -> |REP_TO_DELETE_COMMENTS|
+* close own questions -> |REP_TO_CLOSE_OWN|
+* reopen own questions -> |REP_TO_REOPEN_OWN|
+* retag questions -> |REP_TO_RETAG|
+* edit any answer -> |REP_TO_EDIT_OTHERS|
+* open any closed question -> |REP_TO_CLOSE_OTHERS|
+* delete any comment -> |REP_TO_DELETE_COMMENTS|
**What is gravatar?**
+++ /dev/null
-from os import linesep
-from csv import reader, QUOTE_NONE
-import markdown
-from markdown import Extension
-from markdown.preprocessors import Preprocessor
-import re
-
-#from django.conf import settings
-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')
-
-class SettingsPre(Preprocessor):
- def run(self, lines):
- new_lines = []
- for line in lines:
-
- # tags relating to the minrip.py settings
- line = line.replace('REP_TO_VOTE_UP', '%d' % settings.REP_TO_VOTE_UP)
- line = line.replace('REP_TO_VOTE_DOWN', '%d' % settings.REP_TO_VOTE_DOWN)
- line = line.replace('REP_TO_FLAG', '%d' % settings.REP_TO_FLAG)
- line = line.replace('REP_TO_COMMENT', '%d' % settings.REP_TO_COMMENT)
- line = line.replace('REP_TO_LIKE_COMMENT', '%d' % settings.REP_TO_LIKE_COMMENT)
- line = line.replace('REP_TO_CLOSE_OWN', '%d' % settings.REP_TO_CLOSE_OWN)
- line = line.replace('REP_TO_REOPEN_OWN', '%d' % settings.REP_TO_REOPEN_OWN)
- line = line.replace('REP_TO_RETAG', '%d' % settings.REP_TO_RETAG)
- line = line.replace('REP_TO_EDIT_WIKI', '%d' % settings.REP_TO_EDIT_WIKI)
- line = line.replace('REP_TO_EDIT_OTHERS', '%d' % settings.REP_TO_EDIT_OTHERS)
- line = line.replace('REP_TO_CLOSE_OTHERS', '%d' % settings.REP_TO_CLOSE_OTHERS)
- line = line.replace('REP_TO_DELETE_COMMENTS', '%d' % settings.REP_TO_DELETE_COMMENTS)
- line = line.replace('REP_TO_VIEW_FLAGS', '%d' % settings.REP_TO_VIEW_FLAGS)
- line = line.replace('REP_TO_UPLOAD', '%d' % settings.REP_TO_UPLOAD)
-
- new_lines.append(line)
-
- return new_lines
-
-def makeSettingsExtension(configs={}) :
- return MinRepExtension(configs=configs)
+++ /dev/null
-{% extends "base_content.html" %}
-<!-- template about.html -->
-{% load i18n %}
-{% load markup %}
-{% block title %}{% spaceless %}{% trans "About" %}{% endspaceless %}{% endblock %}
-
-{% block content %}
-<div class="headNormal">
-{% trans "About" %}
-</div>
-<div class="content">
-{{ text|markdown }}
-</div>
-{% endblock %}
-<!-- end template about.html -->
+++ /dev/null
-{% extends "base_content.html" %}
-<!-- template faq.html -->
-{% load i18n %}
-{% load markup %}
-{% block title %}{% spaceless %}{% trans "FAQ" %}{% endspaceless %}{% endblock %}
-
-{% block content %}
-<div class="headNormal">
-{% trans "FAQ" %}
- </div>
-<div class="content">
-{{ text|markdown }}
-</div>
-{% endblock %}
-<!-- end template faq.html -->
--- /dev/null
+{% 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 %}
+
+import sys
+import os
+sys.path.append(os.path.join(os.path.dirname(__file__),'markdownext'))
+
import forum.views
import forum.badges
name='uploaded_file',
),
#url(r'^%s/$' % _('signin/'), 'django_authopenid.views.signin', name='signin'),
- url(r'^%s$' % _('about/'), app.meta.about, name='about'),
- url(r'^%s$' % _('faq/'), app.meta.faq, name='faq'),
+ url(r'^%s$' % _('faq/'), app.meta.static, {'content': settings.FAQ_PAGE_TEXT, 'title': _('FAQ')}, name='faq'),
+ url(r'^%s$' % _('about/'), app.meta.static, {'content': settings.ABOUT_PAGE_TEXT, 'title': _('About')}, name='about'),
url(r'^opensearch\.xml$', app.meta.opensearch, name='opensearch'),
url(r'^%s$' % _('privacy/'), app.meta.privacy, name='privacy'),
url(r'^%s$' % _('logout/'), app.meta.logout, name='logout'),
def favicon(request):
return HttpResponseRedirect(str(settings.APP_FAVICON))
-def about(request):
- return render_to_response('about.html', {'text': settings.ABOUT_PAGE_TEXT.value }, context_instance=RequestContext(request))
-
-def faq(request):
- md = markdown.Markdown([SettingsExtension({})])
- text = md.convert(settings.FAQ_PAGE_TEXT.value)
-
- return render_to_response('faq.html', {'text' : text}, context_instance=RequestContext(request))
-
+def static(request, title, content):
+ return render_to_response('static.html', {'content' : content, 'title': title}, context_instance=RequestContext(request))
def opensearch(request):
return render_to_response('opensearch.html', {'settings' : settings}, context_instance=RequestContext(request))