added defined output and improved rendering

This commit is contained in:
L3D 2023-03-04 05:18:15 +01:00
parent 3fcc461573
commit d7ac72283f
Signed by: l3d
GPG key ID: CD08445BFF4313D1
3 changed files with 13 additions and 4 deletions

View file

@ -10,16 +10,26 @@ def generate_from_template(inputname, **options):
# Setup Lektor Env # Setup Lektor Env
project = Project.discover() project = Project.discover()
env = project.make_env() env = project.make_env()
# Setup CTX # Setup CTX
ctx = get_ctx() ctx = get_ctx()
if ctx is not None: if ctx is not None:
pad = ctx.pad pad = ctx.pad
else: else:
pad = env.new_pad() pad = env.new_pad()
# Prepare Variables
rendered_title = f"Ansible Role: {inputname}"
rendered_sizes = f"width=\"{int(118+(len(inputname)*6))}\" height=\"20\""
orange_box_width = str(int(20+len(inputname)*6))
orange_position = str(int(114+(len(inputname)*6)))
# Create File # Create File
file = f"assets/svg/{inputname}.svg" file = f"assets/svg/{inputname}.svg"
with open(file, 'w', encoding='UTF-8') as outputfile: with open(file, 'w', encoding='UTF-8') as outputfile:
outputfile.write(env.render_template('galaxy.svg', pad=pad, this={'title': 'Demo Object'})) outputfile.write(env.render_template('galaxy.svg', pad=pad, this={'title': rendered_title, 'name': inputname, "sizes": rendered_sizes, "orange_box_width": orange_box_width, "orange_position": orange_position}))
returnvalue = f"/svg/{inputname}.svg"
return returnvalue
class RenderTemplatePlugin(Plugin): class RenderTemplatePlugin(Plugin):
""" Create Plugin and listen to Filter Keyword """ """ Create Plugin and listen to Filter Keyword """

View file

@ -1,2 +0,0 @@
[bdist_wheel]
universal=1

View file

@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
import ast import ast
import io import io
import re import re
@ -24,7 +25,7 @@ setup(
name='lektor-render-template', name='lektor-render-template',
packages=find_packages(), packages=find_packages(),
py_modules=['lektor_render_template'], py_modules=['lektor_render_template'],
url='[https://backwesen.de/l3d/lektor-render-template.git]', # url='https://backwesen.de/l3d/lektor-render-template.git',
version='0.2', version='0.2',
classifiers=[ classifiers=[
'Framework :: Lektor', 'Framework :: Lektor',