Merge branch 'master' of git.qabel.de:Qabel/schickmacher

This commit is contained in:
Niklas rust 2019-09-12 12:02:57 +02:00
commit d7d8d8dc61
3 changed files with 11 additions and 16 deletions

View file

@ -1,9 +1,10 @@
from django.urls import path
from schickmacher.renderer.views import form_view, RenderView
from schickmacher.renderer.views import form_view, RenderView, HtmlRenderView
app_name = 'renderer'
urlpatterns = [
path("", view=form_view, name="form"),
path("render", view=RenderView.as_view(), name="render")
path("render", view=RenderView.as_view(), name="render"),
path("renderhtml", view=HtmlRenderView.as_view(), name="renderhtml"),
]

View file

@ -1,6 +1,6 @@
from django.core.handlers.wsgi import WSGIRequest
from django.shortcuts import render
from django.views.generic import FormView
from django.views.generic import FormView, TemplateView
from django_weasyprint import WeasyTemplateView
from markdownx.utils import markdownify
@ -8,21 +8,11 @@ from schickmacher.renderer.forms import RendererForm
def form_view(request: WSGIRequest):
if request.method == 'POST':
form = RendererForm(request.POST)
if form.is_valid():
return render(request, 'renderer/rendered.html', {
'date': form.cleaned_data['date'],
'content': markdownify(form.cleaned_data['render_content']),
'title': form.cleaned_data['title']
})
else:
form = RendererForm()
ctx = {"form": form}
ctx = {"form": (RendererForm())}
return render(request, 'renderer/render_form.html', ctx)
class RenderView(WeasyTemplateView):
class HtmlRenderView(TemplateView):
template_name = 'renderer/rendered.html'
def get_context_data(self, **kwargs):
@ -42,3 +32,7 @@ class RenderView(WeasyTemplateView):
def post(self, request, *args, **kwargs):
return self.get(request, *args, **kwargs)
class RenderView(HtmlRenderView, WeasyTemplateView):
pass

View file

@ -5,7 +5,7 @@
<title>{{ title }}</title>
<link href="{% static 'css/render.css' %}" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro&display=swap" rel="stylesheet">
</head>
<style>
@page{