12 Commits
blog ... main

Author SHA1 Message Date
Akbar Rahman
fa8840d25e Update indexsearch.js 2024-11-13 12:14:19 +00:00
Akbar Rahman
07ece47980 fix indexsearch.js using wrong variable 2024-11-13 12:13:40 +00:00
6638c72230 include styling to permalink redirect page 2024-04-14 16:01:30 +01:00
44e5da27cc feed at second url 2024-04-13 21:15:42 +01:00
41cadb0354 update blog_index title handling 2024-04-13 21:02:53 +01:00
a7fc67ee00 styling tweaks 2024-04-13 20:51:38 +01:00
f94fd769cc make start and end of posts more clear 2024-04-13 20:49:41 +01:00
2b2cdcef79 update readme 2024-04-13 20:37:53 +01:00
aa159369fd fix sorting 2024-04-13 20:36:24 +01:00
7bee57bcd5 sort posts in rss feed by date 2024-04-13 20:28:46 +01:00
8300c4ba45 add base_url documentation for blog mode 2024-04-13 20:16:23 +01:00
390f5a789f fix double h1 on index with readme contents 2024-04-13 20:14:03 +01:00
7 changed files with 57 additions and 18 deletions

View File

@@ -104,6 +104,12 @@ mjx-container {
p.metadata { margin: 0 } p.metadata { margin: 0 }
.blog_inline_post {
border-left: 1em solid var(--fg-lc);
padding: 0 1em 0 1em;
margin-bottom: 5em;
}
@media (max-width: 80em) { @media (max-width: 80em) {
/* CSS that should be displayed if width is equal to or less than 60em goes here */ /* CSS that should be displayed if width is equal to or less than 60em goes here */
#contentWrapper { flex-direction: column } #contentWrapper { flex-direction: column }

View File

@@ -14,6 +14,7 @@ import time
import magic import magic
import regex as re import regex as re
import pprint import pprint
from datetime import datetime as dt
import frontmatter import frontmatter
import jinja2 import jinja2
@@ -59,7 +60,6 @@ class FileMap:
def get_base_url(self): def get_base_url(self):
props = self.get(self.input_dir.joinpath('readme.md')) props = self.get(self.input_dir.joinpath('readme.md'))
print(props)
return props['base_url'] return props['base_url']
@staticmethod @staticmethod
@@ -246,6 +246,15 @@ class FileMap:
return d return d
def rfc822_date_sorter_key(date):
if date is None:
ret = 0
else:
ret = int(dt.strptime(date, '%a, %d %b %Y %H:%M:%S %z').timestamp())
return ret
def update_required(src_filepath, output_filepath): def update_required(src_filepath, output_filepath):
""" """
check if file requires an update, check if file requires an update,
@@ -434,7 +443,8 @@ def generate_permalink_page(output_dir):
dir = output_dir.joinpath('permalink') dir = output_dir.joinpath('permalink')
dir.mkdir(exist_ok=True) dir.mkdir(exist_ok=True)
dir.joinpath('index.html').write_text( dir.joinpath('index.html').write_text(
JINJA_TEMPLATE_PERMALINK.render(gronk_commit=GRONK_COMMIT, JINJA_TEMPLATE_PERMALINK.render(title="redirecting... | gronk",
gronk_commit=GRONK_COMMIT,
data=FILEMAP.get_uuid_map())) data=FILEMAP.get_uuid_map()))
@@ -531,6 +541,23 @@ def main(args):
} }
posts.append(post) posts.append(post)
posts.sort(
key=lambda p: rfc822_date_sorter_key(p.get('pub_date')),
reverse=True
)
# render rss feed
rss = JINJA_TEMPLATE_BLOG_FEED.render(
title=root_properties.get('title', ''),
description=root_properties.get('content', ''),
base_url=FILEMAP.get_base_url(),
link=f"{FILEMAP.get_base_url()}{root_properties['dst_path']['web']}",
language='en-GB',
posts=posts,
)
root_properties['dst_path']['raw'].joinpath('feed.xml').write_text(rss)
root_properties['dst_path']['raw'].joinpath('rss.xml').write_text(rss)
#pprint.pprint(root_properties) #pprint.pprint(root_properties)
# render index # render index
html = (JINJA_TEMPLATE_BLOGINDEX if root_properties['blog'] else JINJA_TEMPLATE_INDEX).render( html = (JINJA_TEMPLATE_BLOGINDEX if root_properties['blog'] else JINJA_TEMPLATE_INDEX).render(
@@ -549,18 +576,6 @@ def main(args):
) )
root_properties['dst_path']['raw'].joinpath('index.html').write_text(html) root_properties['dst_path']['raw'].joinpath('index.html').write_text(html)
# render rss feed if blog
if root_properties['blog']:
rss = JINJA_TEMPLATE_BLOG_FEED.render(
title=root_properties.get('title', ''),
description=root_properties.get('content', ''),
base_url=FILEMAP.get_base_url(),
link=f"{FILEMAP.get_base_url()}{root_properties['dst_path']['web']}",
language='en-GB',
posts=posts,
)
root_properties['dst_path']['raw'].joinpath('feed.xml').write_text(rss)
# render each file # render each file
for file in files: for file in files:
render_file(root.joinpath(file)) render_file(root.joinpath(file))

View File

@@ -6,7 +6,7 @@ const TITLE = "title"
const SEARCH_TIMEOUT_MS = 100 const SEARCH_TIMEOUT_MS = 100
var SEARCH_TIMEOUT_ID = -1 var SEARCH_TIMEOUT_ID = -1
const fuse = new Fuse(data, { const fuse = new Fuse(search_data, {
keys: [ 'title' ], keys: [ 'title' ],
ignoreLocation: true, ignoreLocation: true,
threshhold: 0.4, threshhold: 0.4,
@@ -30,7 +30,7 @@ function updateResults() {
console.log("updating results") console.log("updating results")
resultsDiv.innerHTML = '' resultsDiv.innerHTML = ''
if (searchBar.value) results = fuse.search(searchBar.value, { limit: RESULTS_MAX }).map(r => r.item) if (searchBar.value) results = fuse.search(searchBar.value, { limit: RESULTS_MAX }).map(r => r.item)
else results = data else results = search_data
results.forEach(r => { results.forEach(r => {
wrapper = document.createElement('li') wrapper = document.createElement('li')

View File

@@ -74,7 +74,7 @@ gronk reads the following YAML [frontmatter](https://jekyllrb.com/docs/front-mat
| variable | description | | variable | description |
|------------------|---------------------------------------------------------------------------------------| |------------------|---------------------------------------------------------------------------------------|
| `author` | The person(s) who wrote the article | | `author` | The person(s) who wrote the article |
| `pub_date` | set the publish date of an article/post/note | | `pub_date` | (for blog mode) set the publish date of an article/post/note (MUST be RFC822 format) |
| `tags` | A YAML list of tags which the article relates to - this is used for browsing and also | | `tags` | A YAML list of tags which the article relates to - this is used for browsing and also |
| `title` | The title of the article | | `title` | The title of the article |
| `uuid` | A unique identifier used for permalinks. | | `uuid` | A unique identifier used for permalinks. |
@@ -88,6 +88,16 @@ This can be done by setting the `blog` variable to `true` in the `readme.md` [cu
Notes under this directory will be published to a blog, whose feed is accesible at `https://notes.alv.cx/notes/<directory..>/feed.xml`. Notes under this directory will be published to a blog, whose feed is accesible at `https://notes.alv.cx/notes/<directory..>/feed.xml`.
When blog mode is enabled, it is required that the `base_url` property is set in the top level `readme.md` file.
Note that there should be no trailing slash.
If a `readme.md` file does not exist, then an empty one can be created:
```md
---
base_url: https://notes.alv.cx
---
```
## Permalinks ## Permalinks

View File

@@ -31,7 +31,10 @@
<pre>{{ license }}</pre> <pre>{{ license }}</pre>
</details> </details>
{% endif %} {% endif %}
{% if not content %}
<h1>{{ title }}</h1> <h1>{{ title }}</h1>
{% endif %}
{% if not content_after_search %} {% if not content_after_search %}
{{ content|safe }} {{ content|safe }}
@@ -44,7 +47,7 @@
{% if automatic_index %} {% if automatic_index %}
<details> <details>
<summary> <summary>
<h2> List of posts </h2> <h4> List of posts </h4>
</summary> </summary>
{% if search_bar %} {% if search_bar %}
<div id="searchWrapper"> <div id="searchWrapper">
@@ -68,7 +71,9 @@
{{ content|safe }} {{ content|safe }}
{% for post in posts %} {% for post in posts %}
<div class="blog_inline_post">
{{ post['description']|safe }} {{ post['description']|safe }}
</div>
{% endfor %} {% endfor %}
{% endif %} {% endif %}

View File

@@ -1,6 +1,8 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block content %} {% block content %}
{% if not content %}
<h1>{{ title }}</h1> <h1>{{ title }}</h1>
{% endif %}
{% if not content_after_search %} {% if not content_after_search %}
{{ content|safe }} {{ content|safe }}

View File

@@ -1,3 +1,4 @@
{% extends "base.html" %}
{% block content %} {% block content %}
<p> <p>
You should be being redirected... You should be being redirected...