Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
schilder2000
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
schilder
schilder2000
Commits
32596c9e
Commit
32596c9e
authored
9 months ago
by
Thomas Schneider
Browse files
Options
Downloads
Patches
Plain Diff
instance: Add sample (template) preview
parent
2ad0c556
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
schilder2000/instance.py
+17
-0
17 additions, 0 deletions
schilder2000/instance.py
with
17 additions
and
0 deletions
schilder2000/instance.py
+
17
−
0
View file @
32596c9e
...
...
@@ -2,6 +2,8 @@ from . import db
from
.models
import
Schild
from
.helpers
import
Blueprint
,
get_template_attribute
import
textwrap
from
flask
import
url_for
from
flask_weasyprint
import
render_pdf
...
...
@@ -27,6 +29,21 @@ def schild_pdf(ident):
return
render_pdf
(
url_for
(
"
.schild_html
"
,
ident
=
ident
))
@bp.route
(
"
/sample/<template>.html
"
)
def
sample_html
(
template
):
lipsum
=
textwrap
.
dedent
(
"""
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua.
"""
)
return
bp
.
render_template
(
template
,
schild
=
dict
(
title
=
"
Überschrift
"
,
text
=
lipsum
,
image
=
"
sample.png
"
)
)
@bp.route
(
"
/sample/<template>.pdf
"
)
def
sample_pdf
(
template
):
return
render_pdf
(
url_for
(
"
.sample_html
"
,
template
=
template
))
def
list_templates
():
schild
=
Schild
()
loader
=
bp
.
jinja_loader
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment