1
Fork 0

Added markdown content for project pages

This commit is contained in:
Jake Howard 2016-01-18 22:24:25 +00:00
parent 36ff669a00
commit c261a3c928
8 changed files with 57 additions and 4 deletions

View file

@ -24,11 +24,10 @@
"bootstrap": "=3.3.5", "bootstrap": "=3.3.5",
"ionicons": "=2.0.1", "ionicons": "=2.0.1",
"jquery": "=2.1.4", "jquery": "=2.1.4",
"markdown": "=0.5.0",
"normalize.css": "=3.0.3", "normalize.css": "=3.0.3",
"react": "=0.13.3", "react": "=0.13.3",
"react-bootstrap": "=0.25.1", "react-bootstrap": "=0.25.1",
"whatwg-fetch": "^0.10.1" "whatwg-fetch": "=0.10.1"
}, },
"devDependencies": { "devDependencies": {
"babel-preset-es2015": "=6.1.18", "babel-preset-es2015": "=6.1.18",

View file

@ -1,5 +1,7 @@
from django.views.generic import TemplateView, FormView from django.views.generic import TemplateView, FormView
from django.template import loader, Context, TemplateDoesNotExist
from django.http import Http404
import markdown2
class CustomTemplate(TemplateView): class CustomTemplate(TemplateView):
html_title = "" html_title = ""
@ -23,3 +25,22 @@ class CustomFormTemplate(FormView):
context['body_class'] = self.body_class context['body_class'] = self.body_class
context['js_redirect'] = True context['js_redirect'] = True
return context return context
class MarkdownView(CustomTemplate):
template_name = 'markdown_content.html'
page_title = ""
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['page_title'] = self.page_title
try:
markdown_template = loader.get_template(self.markdown)
except TemplateDoesNotExist:
raise Http404
c = Context(self.get_markdown_context().update(context))
context['markdown_content'] = markdown2.markdown(markdown_template.render(c))
return context
def get_markdown_context(self):
return {}

View file

@ -6,5 +6,6 @@ urlpatterns = [
url(r'^about/website/$', views.AboutWebsiteView.as_view(), name='about-website'), url(r'^about/website/$', views.AboutWebsiteView.as_view(), name='about-website'),
url(r'^about/me/$', views.AboutMeView.as_view(), name='about-me'), url(r'^about/me/$', views.AboutMeView.as_view(), name='about-me'),
url(r'^about/$', views.AboutIndexView.as_view(), name='about'), url(r'^about/$', views.AboutIndexView.as_view(), name='about'),
url(r'^projects/(?P<project>.+)/$', views.ProjectsView.as_view(), name="projects"),
url(r'^$', views.IndexView.as_view(), name='index') url(r'^$', views.IndexView.as_view(), name='index')
] ]

View file

@ -1,4 +1,4 @@
from project.common.views import CustomTemplate, CustomFormTemplate from project.common.views import CustomTemplate, CustomFormTemplate, MarkdownView
from project.common.forms import ContactForm from project.common.forms import ContactForm
@ -39,3 +39,13 @@ class AboutIndexView(CustomFormTemplate):
class AboutMeView(CustomTemplate): class AboutMeView(CustomTemplate):
template_name = 'about/me.html' template_name = 'about/me.html'
html_title = "About Me" html_title = "About Me"
class AllProjectsView(CustomTemplate):
template_name = 'projects/all.html'
class ProjectsView(MarkdownView):
def dispatch(self, request, *args, **kwargs):
self.markdown = 'projects/{0}.md'.format(kwargs['project'])
return super().dispatch(request, *args, **kwargs)

View file

@ -6,6 +6,7 @@ django-bootstrap-form==3.2
git+https://github.com/RealOrangeOne/django-client-reverse git+https://github.com/RealOrangeOne/django-client-reverse
django-flat-theme==1.1.3 django-flat-theme==1.1.3
djangorestframework==3.3.2 djangorestframework==3.3.2
markdown2==2.3.0
flake8==2.5.0 flake8==2.5.0
whitenoise==2.0.6 whitenoise==2.0.6
waitress==0.8.10 waitress==0.8.10

View file

@ -0,0 +1,10 @@
{% extends 'content_base.html' %}
{% block pageTitle %}{{ page_title }}{% endblock %}
{% block content %}
<div class="container">
{{ markdown_content | safe }}
</div>
{% endblock %}

View file

@ -0,0 +1,10 @@
{% extends 'content_base.html' %}
{% block pageTitle %}All Projects{% endblock %}
{% block content %}
<div class="container">
<p>Stuff</p>
</div>
{% endblock %}

View file

@ -0,0 +1 @@
# Test!