diff --git a/schickmacher/renderer/urls.py b/schickmacher/renderer/urls.py index 2513f13..c518bdb 100644 --- a/schickmacher/renderer/urls.py +++ b/schickmacher/renderer/urls.py @@ -1,10 +1,13 @@ from django.urls import path -from schickmacher.renderer.views import form_view, RenderView, HtmlRenderView +from schickmacher.renderer.views import form_view, RenderView,\ + HtmlRenderView, SampleHTMLView, SamplePDFView app_name = 'renderer' urlpatterns = [ path("", view=form_view, name="form"), path("render", view=RenderView.as_view(), name="render"), path("renderhtml", view=HtmlRenderView.as_view(), name="renderhtml"), + path("samplehtml", view=SampleHTMLView.as_view(), name="samplehtml"), + path("samplepdf", view=SamplePDFView.as_view(), name="samplepdf"), ] diff --git a/schickmacher/renderer/views.py b/schickmacher/renderer/views.py index 09ceb40..b0b34ea 100644 --- a/schickmacher/renderer/views.py +++ b/schickmacher/renderer/views.py @@ -1,7 +1,8 @@ from django.core.handlers.wsgi import WSGIRequest from django.shortcuts import render -from django.views.generic import FormView, TemplateView +from django.views.generic import TemplateView from django_weasyprint import WeasyTemplateView +from django.utils.timezone import datetime from markdownx.utils import markdownify from schickmacher.renderer.forms import RendererForm @@ -36,3 +37,22 @@ class HtmlRenderView(TemplateView): class RenderView(HtmlRenderView, WeasyTemplateView): pass + + +class SampleHTMLView(TemplateView): + template_name = 'renderer/rendered.html' + + sample_title = 'Test Title 123' + sample_date = datetime.now() + sample_content = markdownify(open('test.md').read()) + + def get_context_data(self, **kwargs): + return { + 'title': self.sample_title, + 'date': self.sample_date, + 'content': self.sample_content + } + + +class SamplePDFView(SampleHTMLView, WeasyTemplateView): + pass diff --git a/schickmacher/templates/base.html b/schickmacher/templates/base.html index 3e64059..d44cadd 100644 --- a/schickmacher/templates/base.html +++ b/schickmacher/templates/base.html @@ -49,6 +49,12 @@ + + {% if request.user.is_authenticated %}