update templates

This commit is contained in:
Akbar Rahman 2024-01-02 03:50:43 +00:00
parent 49a215a587
commit b4aa431f4d
Signed by: alvierahman90
GPG Key ID: 6217899F07CA2BDF
9 changed files with 110 additions and 132 deletions

View File

@ -28,18 +28,15 @@ CSS_DIR = Path(os.getenv("CSS_DIR", "/opt/gronk/css"))
JS_DIR = Path(os.getenv("JS_DIR", "/opt/gronk/js")) JS_DIR = Path(os.getenv("JS_DIR", "/opt/gronk/js"))
TEMPLATES_DIR = Path(os.getenv("TEMPLATES_DIR", "/opt/gronk/templates")) TEMPLATES_DIR = Path(os.getenv("TEMPLATES_DIR", "/opt/gronk/templates"))
JINJA_ENV = jinja2.Environment(loader=jinja2.PackageLoader("gronk"),
JINJA_ENV = jinja2.Environment( autoescape=jinja2.select_autoescape)
loader=jinja2.PackageLoader("gronk", str(TEMPLATES_DIR)),
autoescape=jinja2.select_autoescape
)
JINJA_TEMPLATES = {} JINJA_TEMPLATES = {}
JINJA_TEMPLATE_TEXTARTICLE = JINJA_ENV.get_template("textarticle.html") JINJA_TEMPLATE_TEXTARTICLE = JINJA_ENV.get_template("article-text.html")
JINJA_TEMPLATE_HOME_INDEX = JINJA_ENV.get_template("home_index.html") JINJA_TEMPLATE_HOME_INDEX = JINJA_ENV.get_template("home.html")
JINJA_TEMPLATE_INDEX = JINJA_ENV.get_template("index.html") JINJA_TEMPLATE_INDEX = JINJA_ENV.get_template("index.html")
JINJA_TEMPLATE_ARTICLE = JINJA_ENV.get_template("article.html") JINJA_TEMPLATE_ARTICLE = JINJA_ENV.get_template("article.html")
JINJA_TEMPLATE_PERMALINK = JINJA_ENV.get_template("permalink.html")
LICENSE = None LICENSE = None
GIT_REPO = None GIT_REPO = None

View File

@ -1,5 +1,5 @@
{% extends "article.html" %} {% extends "article.html" %}
{% block body %} {% block body_content %}
<p> This file was not rendered by gronk because it is a plaintext file, not a markdown <p> This file was not rendered by gronk because it is a plaintext file, not a markdown
file. file.
You access the raw file <a href="{{ raw_link }}">here</a>. You access the raw file <a href="{{ raw_link }}">here</a>.

View File

@ -1,8 +1,5 @@
<head> {% extends "base.html" %}
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> {% block head %}
<meta charset="utf-8">
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Open+Sans&display=swap" />
<link rel="stylesheet" type="text/css" href="/css/styles.css" />
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script> <script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script> <script>
MathJax = { MathJax = {
@ -12,12 +9,9 @@
} }
</script> </script>
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script> <script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
<title>{{ title }}</title> {% endblock %}
</head>
<body> {% block content %}
<div id="contentWrapper">
<div id="content">
<p class="smallText metadata"> title: {{ title }} </p> <p class="smallText metadata"> title: {{ title }} </p>
{% if lecture_slides %} {% if lecture_slides %}
<p class="smallText metadata"> lecture_slides: [ <p class="smallText metadata"> lecture_slides: [
@ -44,10 +38,10 @@
{% endfor %} {% endfor %}
]</p> ]</p>
<p class="smallText metadata"> <p class="smallText metadata">
{% if author is iterable %} {% if author is string %}
written by {{ author }} written by: {{ author }}
{% else %} {% elif author is iterable %}
written by {% for auth in author %}{{ auth }}{% if loop.nextitem %}, {% endif %}{% endfor %} written by: [ {% for auth in author %}{{ auth }}{% if loop.nextitem %}, {% endif %}{% endfor %} ]
{% endif %} {% endif %}
</p> </p>
<p class="smallText metadata"> <p class="smallText metadata">
@ -65,9 +59,7 @@
<pre>{{ license }}</pre> <pre>{{ license }}</pre>
</details> </details>
{% endif %} {% endif %}
{% block body %} {% block body_content %}
{{ content }} {{ content|safe }}
{% endblock %}
{% endblock %} {% endblock %}
</div>
</div>
</body>

18
templates/base.html Normal file
View File

@ -0,0 +1,18 @@
<!DOCTYPE html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta charset="UTF-8">
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Open+Sans&display=swap" />
<link rel="stylesheet" type="text/css" href="/css/styles.css" />
<title>{{ title }}</title>
{% block head %}
{% endblock %}
</head>
<body>
<div id="content">
{% block content %}
{% endblock %}
<p class="smallText"> page generated by <a href="https://github.com/alvierahman90/gronk">gronk</a> (commit {{ gronk_commit }}) {% if notes_git_head_sha1 %}notes commit {{ notes_git_head_sha1 }}{% endif %}</p>
</div>
</body>

18
templates/home.html Normal file
View File

@ -0,0 +1,18 @@
{% extends "article.html" %}
{% block content %}
{{ post['content']|safe }}
<p>
Browse <a href="/notes">here</a> or by tag <a href="/tags">here</a>.
</p>
<div id="searchWrapper">
<input autocomplete="off" placeholder="search" id="search" autofocus>
</div>
<p class="smallText" style="margin-top: 0; text-align: center;"> Press <kbd>Enter</kbd> to open first result or <kbd>Shift</kbd>+<kbd>Enter</kbd> to open in new tab</p>
<div id="results">
</div>
<script src="/js/fuse.js"> </script>
<script> const search_data = {{ search_data|tojson }} </script>
<script src="/js/search.js"> </script>
{% endblock %}

View File

@ -1,27 +0,0 @@
<head>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta charset="utf-8">
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Open+Sans&display=swap" />
<link rel="stylesheet" type="text/css" href="/css/styles.css" />
<title>{{ post['content'] }}</title>
</head>
<body>
<div id="content">
{{ post['content']|safe }}
<p>
Browse <a href="/notes">here</a> or by tag <a href="/tags">here</a>.
</p>
<div id="searchWrapper">
<input autocomplete="off" placeholder="search" id="search" autofocus>
</div>
<p class="smallText" style="margin-top: 0; text-align: center;"> Press <kbd>Enter</kbd> to open first result or <kbd>Shift</kbd>+<kbd>Enter</kbd> to open in new tab</p>
<div id="results">
</div>
<p class="smallText"> page generated by <a href="https://github.com/alvierahman90/gronk">gronk</a> (commit {{ n2w_commit }}) {% if notes_git_head_sha1 %}notes commit {{ notes_git_head_sha1 }}{% endif %}</p>
</div>
<script src="/js/fuse.js"> </script>
<script> const search_data = {{ search_data|tojson }} </script>
<script src="/js/search.js"> </script>
</body>

View File

@ -1,17 +1,9 @@
<head> {% extends "base.html" %}
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> {% block content %}
<meta charset="utf-8">
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Open+Sans&display=swap" />
<link rel="stylesheet" type="text/css" href="/css/styles.css" />
<title>{{ title }}</title>
</head>
<body>
<div id="content">
<h1>{{ title }}</h1> <h1>{{ title }}</h1>
{% if not content_after_search %} {% if not content_after_search %}
{{ content }} {{ content|safe }}
{% endif %} {% endif %}
{% if automatic_index %} {% if automatic_index %}
@ -33,12 +25,9 @@
{% endif %} {% endif %}
{% if content_after_search %} {% if content_after_search %}
{{ content }} {{ content|safe }}
{% endif %} {% endif %}
<p style="font-size: 0.7em;"> page generated by <a href="https://github.com/alvierahman90/gronk">gronk</a></p>
</div>
<script src="/js/fuse.js"> </script> <script src="/js/fuse.js"> </script>
<script> const search_data = {{ index_entries|tojson }} </script> <script> const search_data = {{ index_entries|tojson }} </script>
<script src="/js/indexsearch.js"> </script> <script src="/js/indexsearch.js"> </script>
</body> {% endblock %}

10
templates/permalink.html Normal file
View File

@ -0,0 +1,10 @@
{% block content %}
<p>
You should be being redirected...
Otherwise, click <a id="manual_redirect">here</a>.
</p>
<p class="smallText"> page generated by <a href="https://github.com/alvierahman90/gronk">gronk</a></p>
<script> const data = {{ data|tojson }} </script>
<script src="/js/permalink.js"> </script>
{% endblock %}

View File

@ -1,19 +0,0 @@
<head>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta charset="utf-8">
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Open+Sans&display=swap" />
<link rel="stylesheet" type="text/css" href="/css/styles.css" />
<title></title>
</head>
<body>
<div id="content">
<p>
You should be being redirected...
Otherwise, click <a id="manual_redirect">here</a>.
</p>
<p class="smallText"> page generated by <a href="https://github.com/alvierahman90/gronk">gronk</a></p>
</div>
<script> const data = {{ data|tojson }} </script>
<script src="/js/permalink.js"> </script>
</body>