article listing in plaintext
This commit is contained in:
parent
fc14d99c92
commit
6a7a5f091c
@ -37,6 +37,8 @@ done
|
|||||||
|
|
||||||
./tools/feed_generator.py ./articles/ $URL > ./html/feed.xml
|
./tools/feed_generator.py ./articles/ $URL > ./html/feed.xml
|
||||||
|
|
||||||
|
./tools/plaintext_article_listing_generator.py ./articles/ > ./html/articles.txt
|
||||||
|
|
||||||
mkdir -p "./html/markdown/"
|
mkdir -p "./html/markdown/"
|
||||||
for d in ./articles/*/; do
|
for d in ./articles/*/; do
|
||||||
if [ -d "$d" ]; then
|
if [ -d "$d" ]; then
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
import time, subprocess
|
import time, subprocess
|
||||||
|
from os import walk, path
|
||||||
|
import urllib.parse
|
||||||
|
|
||||||
def the_line_after_metadata(lines: []) -> int:
|
def the_line_after_metadata(lines: []) -> int:
|
||||||
i = 0
|
i = 0
|
||||||
@ -24,3 +26,18 @@ def parse_metadata(filepath: str) -> {}:
|
|||||||
result["Last Edit"] = time.gmtime(int(subprocess.getoutput(r"stat -c %Y " + filepath)))
|
result["Last Edit"] = time.gmtime(int(subprocess.getoutput(r"stat -c %Y " + filepath)))
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
def parse_article_directory(directory: str) -> {}:
|
||||||
|
articles = {}
|
||||||
|
for root, dirs, _ in walk(directory):
|
||||||
|
for d in dirs:
|
||||||
|
metadata = parse_metadata(path.abspath(root + '/' + d + "/page.mmd"))
|
||||||
|
article = urllib.parse.quote(d)
|
||||||
|
articles[article] = {
|
||||||
|
"metadata": metadata
|
||||||
|
}
|
||||||
|
break
|
||||||
|
return articles
|
||||||
|
|
||||||
|
def sort_titles_by_date(articles: {}) -> []:
|
||||||
|
return sorted(articles.keys(), key=lambda a: articles[a]["metadata"].get("Date", time.gmtime(0)), reverse=True)
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
|
|
||||||
from sys import argv, exit
|
from sys import argv, exit
|
||||||
from os import walk, path
|
|
||||||
from random import choice, seed
|
from random import choice, seed
|
||||||
import time, urllib.parse
|
import time
|
||||||
|
|
||||||
from article_utils import parse_metadata
|
from article_utils import parse_article_directory, sort_titles_by_date
|
||||||
from page_shares import wrap_page, ADJECTIVES, MONTHS
|
from page_shares import wrap_page, ADJECTIVES, MONTHS
|
||||||
|
|
||||||
if len(argv) <= 1:
|
if len(argv) <= 1:
|
||||||
@ -28,17 +27,9 @@ Personal blog of one {choice(ADJECTIVES)} Veclav Talica.
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
artciles = {}
|
artciles = parse_article_directory(argv[1])
|
||||||
for root, dirs, _ in walk(argv[1]):
|
|
||||||
for d in dirs:
|
|
||||||
metadata = parse_metadata(path.abspath(root + '/' + d + "/page.mmd"))
|
|
||||||
article = urllib.parse.quote(d)
|
|
||||||
artciles[article] = {
|
|
||||||
"metadata": metadata
|
|
||||||
}
|
|
||||||
break
|
|
||||||
|
|
||||||
for title in sorted(artciles.keys(), key=lambda a: artciles[a]["metadata"].get("Date", time.gmtime(0)), reverse=True):
|
for title in sort_titles_by_date(artciles):
|
||||||
article = artciles[title]
|
article = artciles[title]
|
||||||
metadata = article["metadata"]
|
metadata = article["metadata"]
|
||||||
page += (
|
page += (
|
||||||
|
15
tools/plaintext_article_listing_generator.py
Executable file
15
tools/plaintext_article_listing_generator.py
Executable file
@ -0,0 +1,15 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
from sys import argv, exit
|
||||||
|
|
||||||
|
from article_utils import parse_article_directory, sort_titles_by_date
|
||||||
|
|
||||||
|
if len(argv) <= 1:
|
||||||
|
print("No directory was supplied")
|
||||||
|
exit(-1)
|
||||||
|
|
||||||
|
articles = parse_article_directory(argv[1])
|
||||||
|
|
||||||
|
result = '\n'.join(sort_titles_by_date(articles))
|
||||||
|
|
||||||
|
print(result)
|
Loading…
Reference in New Issue
Block a user