From b4aa431f4d0afef8bb04576ef7cd95fd76bccb73 Mon Sep 17 00:00:00 2001 From: Akbar Rahman Date: Tue, 2 Jan 2024 03:50:43 +0000 Subject: [PATCH] update templates --- gronk.py | 13 +- .../{textarticle.html => article-text.html} | 2 +- templates/article.html | 114 ++++++++---------- templates/base.html | 18 +++ templates/home.html | 18 +++ templates/home_index.html | 27 ----- templates/index.html | 21 +--- templates/permalink.html | 10 ++ templates/permalink_index.html | 19 --- 9 files changed, 110 insertions(+), 132 deletions(-) rename templates/{textarticle.html => article-text.html} (91%) create mode 100644 templates/base.html create mode 100644 templates/home.html delete mode 100644 templates/home_index.html create mode 100644 templates/permalink.html delete mode 100644 templates/permalink_index.html diff --git a/gronk.py b/gronk.py index 4e0f61e..e6941c7 100755 --- a/gronk.py +++ b/gronk.py @@ -28,18 +28,15 @@ CSS_DIR = Path(os.getenv("CSS_DIR", "/opt/gronk/css")) JS_DIR = Path(os.getenv("JS_DIR", "/opt/gronk/js")) TEMPLATES_DIR = Path(os.getenv("TEMPLATES_DIR", "/opt/gronk/templates")) - -JINJA_ENV = jinja2.Environment( - loader=jinja2.PackageLoader("gronk", str(TEMPLATES_DIR)), - autoescape=jinja2.select_autoescape - ) +JINJA_ENV = jinja2.Environment(loader=jinja2.PackageLoader("gronk"), + autoescape=jinja2.select_autoescape) JINJA_TEMPLATES = {} -JINJA_TEMPLATE_TEXTARTICLE = JINJA_ENV.get_template("textarticle.html") -JINJA_TEMPLATE_HOME_INDEX = JINJA_ENV.get_template("home_index.html") +JINJA_TEMPLATE_TEXTARTICLE = JINJA_ENV.get_template("article-text.html") +JINJA_TEMPLATE_HOME_INDEX = JINJA_ENV.get_template("home.html") JINJA_TEMPLATE_INDEX = JINJA_ENV.get_template("index.html") JINJA_TEMPLATE_ARTICLE = JINJA_ENV.get_template("article.html") - +JINJA_TEMPLATE_PERMALINK = JINJA_ENV.get_template("permalink.html") LICENSE = None GIT_REPO = None diff --git a/templates/textarticle.html b/templates/article-text.html similarity index 91% rename from templates/textarticle.html rename to templates/article-text.html index 568a4cc..76977ed 100644 --- a/templates/textarticle.html +++ b/templates/article-text.html @@ -1,5 +1,5 @@ {% extends "article.html" %} -{% block body %} +{% block body_content %}

This file was not rendered by gronk because it is a plaintext file, not a markdown file. You access the raw file here. diff --git a/templates/article.html b/templates/article.html index 20b1bd0..1b5b4be 100644 --- a/templates/article.html +++ b/templates/article.html @@ -1,8 +1,5 @@ - - - - - +{% extends "base.html" %} +{% block head %} -{{ title }} - +{% endblock %} - -

-
- - {% if lecture_slides %} - - {% endif %} - {% if lecture_notes %} - - {% endif %} +{% block content %} + +{% if lecture_slides %} + +{% endif %} +{% if lecture_notes %} + +{% endif %} - {% if uuid %} - - {% endif %} +{% if uuid %} + +{% endif %} - - - - - {% if license %} -
- - License - -
{{ license }}
-
- {% endif %} - {% block body %} - {{ content }} - {% endblock %} -
-
- +

tags: [ + {% for tag in tags %} + {{ tag }}{% if loop.nextitem %},{% endif %} + {% endfor %} +]

+

+{% if author is string %} +written by: {{ author }} +{% elif author is iterable %} +written by: [ {% for auth in author %}{{ auth }}{% if loop.nextitem %}, {% endif %}{% endfor %} ] +{% endif %} +

+

+ syntax highlighting based on Pygments' default + colors +

+

+ page generated by gronk +

+{% if license %} +
+ + License + +
{{ license }}
+
+{% endif %} +{% block body_content %} + {{ content|safe }} +{% endblock %} +{% endblock %} diff --git a/templates/base.html b/templates/base.html new file mode 100644 index 0000000..f8c92a9 --- /dev/null +++ b/templates/base.html @@ -0,0 +1,18 @@ + + + + + + +{{ title }} +{% block head %} +{% endblock %} + + + +
+ {% block content %} + {% endblock %} +

page generated by gronk (commit {{ gronk_commit }}) {% if notes_git_head_sha1 %}notes commit {{ notes_git_head_sha1 }}{% endif %}

+
+ diff --git a/templates/home.html b/templates/home.html new file mode 100644 index 0000000..2af8a50 --- /dev/null +++ b/templates/home.html @@ -0,0 +1,18 @@ +{% extends "article.html" %} +{% block content %} +{{ post['content']|safe }} +

+Browse here or by tag here. +

+ +
+ +
+

Press Enter to open first result or Shift+Enter to open in new tab

+
+
+ + + + +{% endblock %} diff --git a/templates/home_index.html b/templates/home_index.html deleted file mode 100644 index eda9000..0000000 --- a/templates/home_index.html +++ /dev/null @@ -1,27 +0,0 @@ - - - - - -{{ post['content'] }} - - -
-{{ post['content']|safe }} -

-Browse here or by tag here. -

- -
- -
-

Press Enter to open first result or Shift+Enter to open in new tab

-
-
- -

page generated by gronk (commit {{ n2w_commit }}) {% if notes_git_head_sha1 %}notes commit {{ notes_git_head_sha1 }}{% endif %}

-
- - - - diff --git a/templates/index.html b/templates/index.html index d4dc7f0..adb65a5 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1,17 +1,9 @@ - - - - - -{{ title }} - - - -
+{% extends "base.html" %} +{% block content %}

{{ title }}

{% if not content_after_search %} - {{ content }} + {{ content|safe }} {% endif %} {% if automatic_index %} @@ -33,12 +25,9 @@ {% endif %} {% if content_after_search %} - {{ content }} + {{ content|safe }} {% endif %} -

page generated by gronk

-
- - +{% endblock %} diff --git a/templates/permalink.html b/templates/permalink.html new file mode 100644 index 0000000..8cbf637 --- /dev/null +++ b/templates/permalink.html @@ -0,0 +1,10 @@ +{% block content %} +

+You should be being redirected... +Otherwise, click here. +

+ +

page generated by gronk

+ + +{% endblock %} diff --git a/templates/permalink_index.html b/templates/permalink_index.html deleted file mode 100644 index 4d5e88b..0000000 --- a/templates/permalink_index.html +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - -
-

-You should be being redirected... -Otherwise, click here. -

- -

page generated by gronk

-
- - -