Added about page (just a copy of the README).

This commit is contained in:
A. Svensson 2015-05-24 14:41:20 +02:00
parent c5757d79a7
commit 526e299731
6 changed files with 54 additions and 0 deletions

0
src/about/__init__.py Normal file
View File

8
src/about/urls.py Normal file
View File

@ -0,0 +1,8 @@
from django.conf.urls import patterns, url
from .views import AboutView
urlpatterns = patterns('',
url(r'^$', AboutView.as_view(), name='index'),
)

20
src/about/utils.py Normal file
View File

@ -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)

16
src/about/views.py Normal file
View File

@ -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

View File

@ -9,4 +9,5 @@ urlpatterns = patterns('',
# HACK: redirect root index. Might have to do something about it soon.. # 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'^$', RedirectView.as_view(url='/servers', permanent=False), name='index'),
url(r'^servers/', include('gameservers.urls', namespace='gameservers')), url(r'^servers/', include('gameservers.urls', namespace='gameservers')),
url(r'^about/', include('about.urls', namespace='about')),
) )

View File

@ -0,0 +1,9 @@
{% extends "base_site.html" %}
{% block title %}
About
{% endblock %}
{% block content %}
{{about_md | safe}}
{% endblock %}