diff --git a/src/about/__init__.py b/src/about/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/about/urls.py b/src/about/urls.py new file mode 100644 index 0000000..2a8e6ee --- /dev/null +++ b/src/about/urls.py @@ -0,0 +1,8 @@ + +from django.conf.urls import patterns, url + +from .views import AboutView + +urlpatterns = patterns('', + url(r'^$', AboutView.as_view(), name='index'), +) diff --git a/src/about/utils.py b/src/about/utils.py new file mode 100644 index 0000000..8491eeb --- /dev/null +++ b/src/about/utils.py @@ -0,0 +1,20 @@ + +import codecs +from os import path + +import markdown as md + +from django.conf import settings + + +def markdown(text): + # In case I would ever switch to some other markdown lib. + return md.markdown(text) + +def load_readme(): + '''Read the contents of the project README and return it as markdown html.''' + readme_path = path.abspath(path.join(settings.BASE_DIR, '..', 'README.md')) + with codecs.open(readme_path, mode='r', encoding='utf-8') as f: + tmp = f.read() + return markdown(tmp) + diff --git a/src/about/views.py b/src/about/views.py new file mode 100644 index 0000000..9ebd907 --- /dev/null +++ b/src/about/views.py @@ -0,0 +1,16 @@ + +from django.views import generic + +from .utils import load_readme + + +class AboutView(generic.TemplateView): + template_name = 'about/about.html' + readme_md = load_readme() + + def get_context_data(self, **kwargs): + context = super(AboutView, self).get_context_data(**kwargs) + context['about_md'] = self.readme_md + return context + + diff --git a/src/src/urls.py b/src/src/urls.py index 3c3983d..f9933ef 100644 --- a/src/src/urls.py +++ b/src/src/urls.py @@ -9,4 +9,5 @@ urlpatterns = patterns('', # HACK: redirect root index. Might have to do something about it soon.. url(r'^$', RedirectView.as_view(url='/servers', permanent=False), name='index'), url(r'^servers/', include('gameservers.urls', namespace='gameservers')), + url(r'^about/', include('about.urls', namespace='about')), ) diff --git a/src/templates/about/about.html b/src/templates/about/about.html new file mode 100644 index 0000000..019ff4d --- /dev/null +++ b/src/templates/about/about.html @@ -0,0 +1,9 @@ +{% extends "base_site.html" %} + +{% block title %} + About +{% endblock %} + +{% block content %} + {{about_md | safe}} +{% endblock %}