From 99ffe7a2a170473cbb32f38dc6f9f4f638251435 Mon Sep 17 00:00:00 2001 From: Gabor Szabo Date: Sat, 22 Jan 2022 15:47:31 +0200 Subject: [PATCH] feat(devtool): show markdown, link words in skills to word-page --- apps/tools/librelingo_tools/lili.py | 5 +- .../templates/incl/header.html | 3 + .../librelingo_tools/templates/skill.html | 59 ++++++++++++++----- 3 files changed, 50 insertions(+), 17 deletions(-) diff --git a/apps/tools/librelingo_tools/lili.py b/apps/tools/librelingo_tools/lili.py index a4bde07f5ba2..3a5f09d79f04 100755 --- a/apps/tools/librelingo_tools/lili.py +++ b/apps/tools/librelingo_tools/lili.py @@ -4,8 +4,9 @@ import json import logging import os -import sys import re +import sys +import markdown from jinja2 import Environment, FileSystemLoader from librelingo_yaml_loader.yaml_loader import load_course @@ -87,6 +88,8 @@ def render(template_file, **args): templates_dir = os.path.join(root, "templates") env = Environment(loader=FileSystemLoader(templates_dir), autoescape=True) env.filters["skillfile"] = skillfile_filter + env.filters["yaml2md"] = lambda path: re.sub(r"\.yaml$", ".md", path) + env.filters["md2html"] = markdown.markdown template = env.get_template(template_file) html = template.render(**args) return html diff --git a/apps/tools/librelingo_tools/templates/incl/header.html b/apps/tools/librelingo_tools/templates/incl/header.html index d06548042551..0061310865dd 100644 --- a/apps/tools/librelingo_tools/templates/incl/header.html +++ b/apps/tools/librelingo_tools/templates/incl/header.html @@ -14,6 +14,9 @@ .warning { background-color: #FF5555; } + #introduction { + background-color: gray; + } diff --git a/apps/tools/librelingo_tools/templates/skill.html b/apps/tools/librelingo_tools/templates/skill.html index 66498307ea34..7ebb3856a898 100644 --- a/apps/tools/librelingo_tools/templates/skill.html +++ b/apps/tools/librelingo_tools/templates/skill.html @@ -10,28 +10,55 @@

{{ skill.name }}

Introduction

- {{skill.introduction}} + {% if skill.introduction %} +
+ {{ skill.introduction | md2html | safe }} +
+ +
source
+ + {% else %} + Each skill can have an introduction in Markdown file. This skill could have it in source + + {% endif %}

Words

- - {% for word in skill.words %} + {% if skill.words %} +
+ + {% for words in skill.words %} - - - + + + - {% endfor %} -
{{ course.target_language.name }}{{ course.source_language.name }}Images
{{word.in_target_language}}{{word.in_source_language}}{{word.pictures}}{% for word in words.in_target_language %}{{ word }}{%- if not loop.last %},{%- endif %}{% endfor %}{% for word in words.in_source_language %}{{ word }}{%- if not loop.last %},{%- endif %}{% endfor %}{{words.pictures}}
+ {% endfor %} + + {% else %} + There are no entries in the Words section. + {% endif %}

Phrases

- - {% for phrase in skill.phrases %} - - - - - {% endfor %} -
{{phrase.in_target_language}}{{phrase.in_source_language}}
+ {% if skill.phrases %} + + {% for phrase in skill.phrases %} + + + + + {% endfor %} +
+ {% for phrs in phrase.in_target_language %} + {{ phrs }}
+ {% endfor %} +
+ {% for phrs in phrase.in_source_language %} + {{ phrs }}
+ {% endfor %} +
+ {% else %} + There are no entries in the Phrases section. + {% endif %}

Dictionary