Merge branch 'master' into production
This commit is contained in:
commit
7e259dd463
3 changed files with 47 additions and 15 deletions
|
|
@ -1,6 +1,4 @@
|
||||||
import os
|
import os
|
||||||
import random
|
|
||||||
import re
|
|
||||||
|
|
||||||
import markdown2
|
import markdown2
|
||||||
|
|
||||||
|
|
@ -13,13 +11,9 @@ from blog.models import Topic, Tag, Blogpost
|
||||||
from django.template import Template, Context
|
from django.template import Template, Context
|
||||||
from django.views.decorators.csrf import csrf_exempt
|
from django.views.decorators.csrf import csrf_exempt
|
||||||
|
|
||||||
from markdownblog import settings
|
|
||||||
|
|
||||||
|
def render_md_file(path) -> Template:
|
||||||
def viewblog(request, title) -> HttpResponse:
|
with open(path, 'r') as mdfile:
|
||||||
post = Blogpost.objects.get(title=title)
|
|
||||||
filepath = os.path.join(os.environ.get("MD_FILE_PATH"), title + ".md")
|
|
||||||
with open(filepath, 'r') as mdfile:
|
|
||||||
md_file_content = mdfile.read()
|
md_file_content = mdfile.read()
|
||||||
mdfile.close()
|
mdfile.close()
|
||||||
|
|
||||||
|
|
@ -31,6 +25,16 @@ def viewblog(request, title) -> HttpResponse:
|
||||||
'{% autoescape off %}' +
|
'{% autoescape off %}' +
|
||||||
html_form_md +
|
html_form_md +
|
||||||
'{% endautoescape %}').render(Context({}))
|
'{% endautoescape %}').render(Context({}))
|
||||||
|
|
||||||
|
return rendered_html
|
||||||
|
|
||||||
|
|
||||||
|
def viewblog(request, title) -> HttpResponse:
|
||||||
|
post = Blogpost.objects.get(title=title)
|
||||||
|
filepath = os.path.join(os.environ.get("MD_FILE_PATH"), title + ".md")
|
||||||
|
|
||||||
|
rendered_html = render_md_file(filepath)
|
||||||
|
|
||||||
context = {'post': post, 'html': rendered_html, 'roottopics': Topic.objects.all().filter(rootTopic=None),
|
context = {'post': post, 'html': rendered_html, 'roottopics': Topic.objects.all().filter(rootTopic=None),
|
||||||
'allposts': Blogpost.objects.all()}
|
'allposts': Blogpost.objects.all()}
|
||||||
|
|
||||||
|
|
@ -38,8 +42,13 @@ def viewblog(request, title) -> HttpResponse:
|
||||||
|
|
||||||
|
|
||||||
def index(request) -> HttpResponse:
|
def index(request) -> HttpResponse:
|
||||||
context = {'roottopics': Topic.objects.all().filter(rootTopic=None), 'allposts': Blogpost.objects.all(),
|
filepath = os.path.join(os.environ.get("MD_FILE_PATH"), 'indexpage/index.md')
|
||||||
'debug': settings.DEBUG}
|
|
||||||
|
rendered_html = render_md_file(filepath)
|
||||||
|
|
||||||
|
context = {'html': rendered_html, 'roottopics': Topic.objects.all().filter(rootTopic=None),
|
||||||
|
'allposts': Blogpost.objects.all()}
|
||||||
|
|
||||||
return render(request, 'blog/index.html', context)
|
return render(request, 'blog/index.html', context)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,32 @@
|
||||||
{% extends 'base/base.html' %}
|
{% extends 'base/base.html' %}
|
||||||
|
{% load static %}
|
||||||
{% block title %}
|
{% block title %}
|
||||||
Willkommen!
|
Welcome!
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block includehere %}
|
{% block includehere %}
|
||||||
|
<script src="{% static 'fontawesomefree/js/all.min.js' %}"></script>
|
||||||
|
<link rel="stylesheet" href="{% static 'viewblog.css' %}">
|
||||||
|
<link rel="stylesheet"
|
||||||
|
href="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.5.1/build/styles/default.min.css">
|
||||||
|
<link rel="stylesheet" href="{% static 'pygments/tango.css' %}">
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h1>Willkommen!</h1>
|
{% autoescape off %}
|
||||||
|
<div class="col s10 offset-s1">
|
||||||
|
{{ html }}
|
||||||
|
</div>
|
||||||
|
{% endautoescape %}
|
||||||
|
<script>
|
||||||
|
MathJax = {
|
||||||
|
tex: {
|
||||||
|
inlineMath: [['$', '$'], ['\\(', '\\)']]
|
||||||
|
},
|
||||||
|
svg: {
|
||||||
|
fontCache: 'global'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.5.1/build/highlight.min.js"></script>
|
||||||
|
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
|
||||||
|
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue