12 Commits

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 }
.blog_inline_post {
border-left: 1em solid var(--fg-lc);
padding: 0 1em 0 1em;
margin-bottom: 5em;
}
@media (max-width: 80em) {
/* CSS that should be displayed if width is equal to or less than 60em goes here */
#contentWrapper { flex-direction: column }

View File

@@ -14,6 +14,7 @@ import time
import magic
import regex as re
import pprint
from datetime import datetime as dt
import frontmatter
import jinja2
@@ -59,7 +60,6 @@ class FileMap:
def get_base_url(self):
props = self.get(self.input_dir.joinpath('readme.md'))
print(props)
return props['base_url']
@staticmethod
@@ -246,6 +246,15 @@ class FileMap:
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):
"""
check if file requires an update,
@@ -434,7 +443,8 @@ def generate_permalink_page(output_dir):
dir = output_dir.joinpath('permalink')
dir.mkdir(exist_ok=True)
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()))
@@ -531,6 +541,23 @@ def main(args):
}
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)
# render index
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)
# 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
for file in files:
render_file(root.joinpath(file))

View File

@@ -6,7 +6,7 @@ const TITLE = "title"
const SEARCH_TIMEOUT_MS = 100
var SEARCH_TIMEOUT_ID = -1
const fuse = new Fuse(data, {
const fuse = new Fuse(search_data, {
keys: [ 'title' ],
ignoreLocation: true,
threshhold: 0.4,
@@ -30,7 +30,7 @@ function updateResults() {
console.log("updating results")
resultsDiv.innerHTML = ''
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 => {
wrapper = document.createElement('li')

View File

@@ -74,7 +74,7 @@ gronk reads the following YAML [frontmatter](https://jekyllrb.com/docs/front-mat
| variable | description |
|------------------|---------------------------------------------------------------------------------------|
| `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 |
| `title` | The title of the article |
| `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`.
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

View File

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

View File

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

View File

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