Added about page (just a copy of the README).
This commit is contained in:
parent
c5757d79a7
commit
526e299731
0
src/about/__init__.py
Normal file
0
src/about/__init__.py
Normal file
8
src/about/urls.py
Normal file
8
src/about/urls.py
Normal 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
20
src/about/utils.py
Normal 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
16
src/about/views.py
Normal 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
|
||||
|
||||
|
||||
@ -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')),
|
||||
)
|
||||
|
||||
9
src/templates/about/about.html
Normal file
9
src/templates/about/about.html
Normal file
@ -0,0 +1,9 @@
|
||||
{% extends "base_site.html" %}
|
||||
|
||||
{% block title %}
|
||||
About
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{{about_md | safe}}
|
||||
{% endblock %}
|
||||
Loading…
x
Reference in New Issue
Block a user