Move doc_url function out of edxmako middleware

This commit is contained in:
David Baumgold
2014-01-28 16:59:49 -05:00
parent bf1b75f5c1
commit b25b3e1bef
3 changed files with 21 additions and 20 deletions

View File

@@ -0,0 +1,20 @@
import ConfigParser
from django.conf import settings
def doc_url(request):
config_file = open(settings.REPO_ROOT / "docs" / "config.ini")
config = ConfigParser.ConfigParser()
config.readfp(config_file)
# in the future, we will detect the locale; for now, we will
# hardcode en_us, since we only have English documentation
locale = "en_us"
def get_doc_url(token):
try:
return config.get(locale, token)
except ConfigParser.NoOptionError:
return config.get(locale, "default")
return {"doc_url": get_doc_url}