Compare commits
6 Commits
3571b643d4
...
969d7ee5c1
Author | SHA1 | Date | |
---|---|---|---|
|
969d7ee5c1 | ||
|
64938e2bbb | ||
|
6a9f8572c9 | ||
|
5cc4ff44a6 | ||
|
fde6cfe644 | ||
|
590f344c6d |
@ -1,5 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
|
set +e
|
||||||
|
|
||||||
mkdir -p ./html/articles
|
mkdir -p ./html/articles
|
||||||
|
|
||||||
./tools/main_page_generator.py ./articles | ./tools/mmd/build/multimarkdown > ./html/index.html
|
./tools/main_page_generator.py ./articles | ./tools/mmd/build/multimarkdown > ./html/index.html
|
||||||
@ -9,3 +11,5 @@ for d in ./articles/*; do
|
|||||||
./tools/article_wrapper.py "$d/page.mmd" | ./tools/mmd/build/multimarkdown > "./html/articles/$(basename -- $d).html"
|
./tools/article_wrapper.py "$d/page.mmd" | ./tools/mmd/build/multimarkdown > "./html/articles/$(basename -- $d).html"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
./tools/feed_generator.py ./articles/ https://mjestecko.neocities.org/ > ./html/feed.xml
|
||||||
|
@ -1,20 +1,5 @@
|
|||||||
import time, subprocess
|
import time, subprocess
|
||||||
|
|
||||||
MONTHS = {
|
|
||||||
1: "January",
|
|
||||||
2: "February",
|
|
||||||
3: "March",
|
|
||||||
4: "April",
|
|
||||||
5: "May",
|
|
||||||
6: "June",
|
|
||||||
7: "July",
|
|
||||||
8: "August",
|
|
||||||
9: "September",
|
|
||||||
10: "October",
|
|
||||||
11: "November",
|
|
||||||
12: "December"
|
|
||||||
}
|
|
||||||
|
|
||||||
def the_line_after_metadata(lines: []) -> int:
|
def the_line_after_metadata(lines: []) -> int:
|
||||||
i = 0
|
i = 0
|
||||||
while lines[i].strip():
|
while lines[i].strip():
|
||||||
|
@ -5,8 +5,8 @@
|
|||||||
from sys import argv, exit
|
from sys import argv, exit
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from article_utils import the_line_after_metadata, parse_metadata, MONTHS
|
from article_utils import the_line_after_metadata, parse_metadata
|
||||||
from page_shares import wrap_page
|
from page_shares import wrap_page, MONTHS
|
||||||
|
|
||||||
if len(argv) <= 1:
|
if len(argv) <= 1:
|
||||||
print("No file was supplied")
|
print("No file was supplied")
|
||||||
|
64
tools/feed_generator.py
Executable file
64
tools/feed_generator.py
Executable file
@ -0,0 +1,64 @@
|
|||||||
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
from sys import argv, exit
|
||||||
|
from os import walk, path
|
||||||
|
from random import choice, seed
|
||||||
|
from textwrap import indent
|
||||||
|
import time, urllib.parse, re, subprocess
|
||||||
|
|
||||||
|
from article_utils import parse_metadata
|
||||||
|
from page_shares import ADJECTIVES
|
||||||
|
from rfc822 import stringify_date
|
||||||
|
|
||||||
|
if len(argv) <= 1:
|
||||||
|
print("No directory was supplied")
|
||||||
|
exit(-1)
|
||||||
|
|
||||||
|
if len(argv) <= 2:
|
||||||
|
print("No address was supplied")
|
||||||
|
exit(-1)
|
||||||
|
|
||||||
|
seed()
|
||||||
|
|
||||||
|
address = argv[2]
|
||||||
|
|
||||||
|
# todo: Find the latest pubDate
|
||||||
|
feed = f"""<rss version="2.0">
|
||||||
|
<channel>
|
||||||
|
<title>mjestečko</title>
|
||||||
|
<link>{address}</link>
|
||||||
|
<description>Personal blog of one {choice(ADJECTIVES)} Veclav Talica</description>
|
||||||
|
<language>en</language>
|
||||||
|
<lastBuildDate>{stringify_date(time.gmtime(int(time.time())))}</lastBuildDate>
|
||||||
|
"""
|
||||||
|
|
||||||
|
body_taker = re.compile(r"<body>(.*)</body>", re.DOTALL)
|
||||||
|
|
||||||
|
for root, dirs, _ in walk(argv[1]):
|
||||||
|
for d in dirs:
|
||||||
|
metadata = parse_metadata(path.abspath(root + '/' + d + "/page.mmd"))
|
||||||
|
feed += (
|
||||||
|
" <item>\n"
|
||||||
|
f""" <title>{metadata.get("Title", "No title!? ;-;")}</title>\n"""
|
||||||
|
)
|
||||||
|
body = subprocess.getoutput(f"./tools/mmd/build/multimarkdown {root}/{d}/page.mmd")
|
||||||
|
feed += (
|
||||||
|
" <description>\n"
|
||||||
|
" <![CDATA[\n"
|
||||||
|
f"{indent(body_taker.search(body)[1], ' ' * 12)}\n"
|
||||||
|
" ]]>\n"
|
||||||
|
" </description>\n"
|
||||||
|
)
|
||||||
|
if "Date" in metadata:
|
||||||
|
feed += \
|
||||||
|
f""" <pubDate>{stringify_date(metadata["Date"])}</pubDate>\n"""
|
||||||
|
feed += (
|
||||||
|
f""" <guid>/articles/{d}</guid>\n"""
|
||||||
|
f""" <link>{address}/articles/{urllib.parse.quote(d)}</link>\n"""
|
||||||
|
" </item>\n"
|
||||||
|
)
|
||||||
|
|
||||||
|
feed += """ </channel>
|
||||||
|
</rss>"""
|
||||||
|
|
||||||
|
print(feed)
|
@ -2,24 +2,24 @@
|
|||||||
|
|
||||||
from sys import argv, exit
|
from sys import argv, exit
|
||||||
from os import walk, path
|
from os import walk, path
|
||||||
from random import choice
|
from random import choice, seed
|
||||||
import time, urllib.parse
|
import time, urllib.parse
|
||||||
|
|
||||||
from article_utils import parse_metadata, MONTHS
|
from article_utils import parse_metadata
|
||||||
from page_shares import wrap_page
|
from page_shares import wrap_page, ADJECTIVES, MONTHS
|
||||||
|
|
||||||
if len(argv) <= 1:
|
if len(argv) <= 1:
|
||||||
print("No directory was supplied")
|
print("No directory was supplied")
|
||||||
exit(-1)
|
exit(-1)
|
||||||
|
|
||||||
|
seed()
|
||||||
|
|
||||||
page_metadata = """Title: mjestečko
|
page_metadata = """Title: mjestečko
|
||||||
CSS: /style.css
|
CSS: /style.css
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
adjectives = ["*wild*", "**wacky**", "very humble", "**most serious**"]
|
page = f"""Personal blog of one {choice(ADJECTIVES)} Veclav Talica.
|
||||||
|
|
||||||
page = f"""Personal blog of one {choice(adjectives)} Veclav Talica.
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ HEAD_EMBED = """
|
|||||||
<ul class="nav">
|
<ul class="nav">
|
||||||
<li><a href="/">main page</a></li>
|
<li><a href="/">main page</a></li>
|
||||||
<li><a href="https://git.poto.cafe/veclavtalica/mjestecko">source</a></li>
|
<li><a href="https://git.poto.cafe/veclavtalica/mjestecko">source</a></li>
|
||||||
|
<li><a href="/feed.xml">rss</a></li>
|
||||||
<li><a href="/articles/mjestečko.html">about</a></li>
|
<li><a href="/articles/mjestečko.html">about</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
@ -26,5 +27,32 @@ TAIL_EMBED = """
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
ADJECTIVES = ["*wild*", "**wacky**", "very humble", "**most serious**"]
|
||||||
|
|
||||||
|
MONTHS = {
|
||||||
|
1: "January",
|
||||||
|
2: "February",
|
||||||
|
3: "March",
|
||||||
|
4: "April",
|
||||||
|
5: "May",
|
||||||
|
6: "June",
|
||||||
|
7: "July",
|
||||||
|
8: "August",
|
||||||
|
9: "September",
|
||||||
|
10: "October",
|
||||||
|
11: "November",
|
||||||
|
12: "December"
|
||||||
|
}
|
||||||
|
|
||||||
|
WEEKDAYS = {
|
||||||
|
0: "Monday",
|
||||||
|
1: "Tuesday",
|
||||||
|
2: "Wednesday",
|
||||||
|
3: "Thursday",
|
||||||
|
4: "Friday",
|
||||||
|
5: "Saturday",
|
||||||
|
6: "Sunday"
|
||||||
|
}
|
||||||
|
|
||||||
def wrap_page(page: str) -> str:
|
def wrap_page(page: str) -> str:
|
||||||
return HEAD_EMBED + page + TAIL_EMBED
|
return HEAD_EMBED + page + TAIL_EMBED
|
||||||
|
4
tools/rfc822.py
Normal file
4
tools/rfc822.py
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
from page_shares import MONTHS, WEEKDAYS
|
||||||
|
|
||||||
|
def stringify_date(date) -> str:
|
||||||
|
return f"{WEEKDAYS[date.tm_wday][:3]}, {date.tm_mday} {MONTHS[date.tm_mon][:3]} {date.tm_year} {date.tm_hour:02d}:{date.tm_min:02d}:{date.tm_sec:02d} GMT"
|
Loading…
Reference in New Issue
Block a user