mirror of
https://github.com/alvierahman90/gronk.git
synced 2025-10-13 07:54:31 +00:00
Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
fa8840d25e | ||
|
07ece47980 | ||
6638c72230
|
|||
44e5da27cc
|
|||
41cadb0354
|
|||
a7fc67ee00
|
|||
f94fd769cc
|
|||
2b2cdcef79
|
|||
aa159369fd
|
|||
7bee57bcd5
|
|||
8300c4ba45
|
|||
390f5a789f
|
@@ -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 }
|
||||
|
43
gronk.py
43
gronk.py
@@ -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))
|
||||
|
@@ -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')
|
||||
|
12
readme.md
12
readme.md
@@ -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
|
||||
|
||||
|
@@ -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 %}
|
||||
|
||||
|
@@ -1,6 +1,8 @@
|
||||
{% extends "base.html" %}
|
||||
{% block content %}
|
||||
{% if not content %}
|
||||
<h1>{{ title }}</h1>
|
||||
{% endif %}
|
||||
|
||||
{% if not content_after_search %}
|
||||
{{ content|safe }}
|
||||
|
@@ -1,3 +1,4 @@
|
||||
{% extends "base.html" %}
|
||||
{% block content %}
|
||||
<p>
|
||||
You should be being redirected...
|
||||
|
Reference in New Issue
Block a user