About Social Code
summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/front_page.lua6
-rw-r--r--tools/link_gen.lua19
-rwxr-xr-xtools/rss_gen.py54
3 files changed, 74 insertions, 5 deletions
diff --git a/tools/front_page.lua b/tools/front_page.lua
index 9557a53..6a7cf4d 100644
--- a/tools/front_page.lua
+++ b/tools/front_page.lua
@@ -36,7 +36,11 @@ function Pandoc(doc)
local header = pandoc.Header(2, note.title)
table.insert(out_list, header)
- table.insert(out_list, pandoc.Para(string.format("%s...", note.preview)))
+ if note["cover_image"] == nil then
+ table.insert(out_list, pandoc.Para(string.format("%s...", note.long_preview)))
+ else
+ table.insert(out_list, pandoc.Para(string.format("%s...", note.preview)))
+ end
local out = pandoc.MetaBlocks(out_list)
output:insert(pandoc.MetaMap({link=string.format("/notes/%s.html", note.note_name), note=out}))
diff --git a/tools/link_gen.lua b/tools/link_gen.lua
index fb53b53..04729d3 100644
--- a/tools/link_gen.lua
+++ b/tools/link_gen.lua
@@ -4,11 +4,13 @@ local meta_tools = require("tools/meta_tools")
local meta = PANDOC_DOCUMENT.meta
local preview = ""
+local long_preview = ""
local internal_links = {}
local max_string_length = 100
+local max_long_string_length = 500
-local function append_str(buf, s)
- if (#buf + #s) < max_string_length then
+local function append_str(buf, s, max_length)
+ if (#buf + #s) < max_length then
buf = buf .. s
end
@@ -66,6 +68,7 @@ function Doc(body, metadata, variables)
end
values["preview"] = preview
+ values["long_preview"] = long_preview
for k,v in pairs(values) do
output = output .. string.format("%s,%s\n", k, v)
end
@@ -73,13 +76,21 @@ function Doc(body, metadata, variables)
return output
end
+function Header(s)
+ preview = append_str(preview, " - ", max_string_length)
+ long_preview = append_str(long_preview, " - ", max_long_string_length)
+ return ""
+end
+
function Str(s)
- preview = append_str(preview, s)
+ preview = append_str(preview, s, max_string_length)
+ long_preview = append_str(long_preview, s, max_long_string_length)
return ""
end
function Space()
- preview = append_str(preview, " ")
+ preview = append_str(preview, " ", max_long_string_length)
+ long_preview = append_str(long_preview, " ", max_long_string_length)
return ""
end
diff --git a/tools/rss_gen.py b/tools/rss_gen.py
new file mode 100755
index 0000000..c4cc1b0
--- /dev/null
+++ b/tools/rss_gen.py
@@ -0,0 +1,54 @@
+#!/usr/bin/env python3
+
+from lxml import etree as ET
+import datetime
+import time
+import email.utils
+import os
+
+today = email.utils.formatdate()
+url = "https://fryzekconcepts.com"
+personal_author_string = "lucas.fryzek@fryzekconcepts.com (Lucas Fryzek)"
+
+xmlns_uris = {"atom" : "http://www.w3.org/2005/Atom"}
+
+rss = ET.Element("rss", version="2.0", nsmap=xmlns_uris)
+channel = ET.SubElement(rss, "channel")
+ET.SubElement(channel, "title").text = "Fryzek Concepts"
+ET.SubElement(channel, "{{{}}}link".format(xmlns_uris["atom"]), href="{}/feed.xml".format(url), rel="self", type="application/rss+xml")
+ET.SubElement(channel, "link").text = url
+ET.SubElement(channel, "description").text = "Lucas is a developer working on cool things"
+#ET.SubElement(channel, "pubData").text = today
+ET.SubElement(channel, "lastBuildDate").text = today
+
+notes = []
+
+build_dir = "./build"
+for file in os.listdir(build_dir):
+ if file.endswith(".meta"):
+ path = os.path.join(build_dir, file)
+ f = open(path, "r")
+ note = {"name" : "".join(file.split(".")[:-1])}
+ for line in f:
+ line_split = line.strip().split(",")
+ note[line_split[0]] = "".join(line_split[1:])
+ f.close()
+
+ notes.append(note)
+
+for note in notes:
+ post_time = datetime.datetime.strptime("2022-10-30", "%Y-%m-%d")
+ post_rfc_time = email.utils.formatdate(timeval=time.mktime(post_time.timetuple()))
+ post_url = "{}/notes/{}".format(url, note["name"])
+ item = ET.SubElement(channel, "item")
+ ET.SubElement(item, "title").text = note["title"]
+ ET.SubElement(item, "link").text = post_url
+ ET.SubElement(item, "description").text = note["preview"]
+ if "categories" in note:
+ ET.SubElement(item, "category").text = note["categories"]
+
+ ET.SubElement(item, "pubDate").text = post_rfc_time
+ ET.SubElement(item, "guid").text = post_url
+
+tree = ET.ElementTree(rss)
+tree.write("html/feed.xml", encoding='utf-8', xml_declaration=True)