Added markdown content for project pages
This commit is contained in:
parent
36ff669a00
commit
c261a3c928
8 changed files with 57 additions and 4 deletions
|
@ -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",
|
||||||
|
|
|
@ -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 {}
|
||||||
|
|
|
@ -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')
|
||||||
]
|
]
|
||||||
|
|
|
@ -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)
|
||||||
|
|
|
@ -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
|
||||||
|
|
10
templates/markdown_content.html
Normal file
10
templates/markdown_content.html
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
{% extends 'content_base.html' %}
|
||||||
|
|
||||||
|
{% block pageTitle %}{{ page_title }}{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="container">
|
||||||
|
{{ markdown_content | safe }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% endblock %}
|
10
templates/projects/all.html
Normal file
10
templates/projects/all.html
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
{% extends 'content_base.html' %}
|
||||||
|
|
||||||
|
{% block pageTitle %}All Projects{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<p>Stuff</p>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
1
templates/projects/test.md
Normal file
1
templates/projects/test.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
# Test!
|
Reference in a new issue