aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornathansmith <nathansmith@posteo.com>2025-05-07 09:44:57 -0600
committernathansmith <nathansmith@posteo.com>2025-05-07 09:44:57 -0600
commit1cb2b2d6241b6dc88d1f5e5dcc128841e154a1d7 (patch)
tree5a2adfcc87a609ad98938171e477bfffe89ac838
parentad77b98eb20b1abec23940a14512e07255b222ef (diff)
Changed the blog html generater to scheme as well
-rw-r--r--blog/Makefile4
-rwxr-xr-xblog/generate_html.py68
-rwxr-xr-xblog/generate_html.scm71
-rw-r--r--blog/index.html132
-rw-r--r--blog/template.html16
5 files changed, 143 insertions, 148 deletions
diff --git a/blog/Makefile b/blog/Makefile
index 3b3341e..4e13f8c 100644
--- a/blog/Makefile
+++ b/blog/Makefile
@@ -3,8 +3,8 @@ all:
@echo Generating feed
./generate_feed.scm > feed.xml
@echo Generating html
- ./generate_html.py > index.html
+ ./generate_html.scm > index.html
.PHONY: clean
clean:
- rm feed.rss index.html
+ rm feed.xml index.html
diff --git a/blog/generate_html.py b/blog/generate_html.py
deleted file mode 100755
index ce50032..0000000
--- a/blog/generate_html.py
+++ /dev/null
@@ -1,68 +0,0 @@
-#! /usr/bin/python3
-
-"""
-A script to generate html from the rss feed
-"""
-
-import xml.etree.ElementTree as et
-
-# Generates a html table for the article
-# I use table layout because fuck you
-def make_article_table(article_info, article):
- return """
- <table border="1" width="60%">
- <tr><td><h2 id=\"{name}\">{title}</h2>--- {date}</td></tr>
- <tr><td>{article}</td></tr>
- </table>
- """.format(
- name=article_info["name"],
- title=article_info["title"],
- date=article_info["pubDate"],
- article=article
- )
-
-def main():
- tree = et.parse("articles.xml")
- root = tree.getroot()
-
- template = ""
-
- # Open html template
- with open("template.html", "r") as fp:
- template = fp.read()
-
- article_list = "<ul>\n"
- article_html = ""
-
- # Get articles from rss
- for item in root:
- article_info = {
- "title": item.find("title").text,
- "name": item.find("name").text,
- "pubDate": item.find("pubDate").text
- }
-
- article = ""
-
- with open(item.find("file").text, "r") as fp:
- article = fp.read()
-
- # Remove article tags.
- article = article[article.find("<article>")+9::]
- article = article[:article.find("</article>"):]
-
- # Add article table to html
- article_html += make_article_table(article_info, article)
-
- # Add article to list.
- article_list += \
- f"<li><a href=\"#{article_info['name']}\">{article_info['title']}</a></li>\n"
-
- article_list += "</ul>"
-
- # Format the articles into the html
- template = template.format(article_list=article_list, articles=article_html)
- print(template)
-
-if __name__ == "__main__":
- main()
diff --git a/blog/generate_html.scm b/blog/generate_html.scm
new file mode 100755
index 0000000..2d9baeb
--- /dev/null
+++ b/blog/generate_html.scm
@@ -0,0 +1,71 @@
+#! /usr/bin/guile \
+-e main -s
+!#
+
+(use-modules (sxml simple))
+
+;; Loads an entire text file into a string
+(define (read-entire-file file)
+ (call-with-input-file file
+ (lambda (fp)
+ (letrec ((read-characters
+ (lambda (fp)
+ (let ((character (read-char fp)))
+ (cond
+ ((eof-object? character) "")
+ (else (string-append (string character)
+ (read-characters fp))))))))
+ (read-characters fp)))))
+
+;; Make a link for the article
+(define (make-article-list-link article)
+ (let ((title (cadr (list-ref article 0)))
+ (name (cadr (list-ref article 2))))
+ (string-append " <li><a href=\"#" name "\">" title "</a></li/>\n")))
+
+;; Reads the article file and formats some stuff out
+(define (get-raw-article file)
+ (letrec ((article (read-entire-file file))
+ (article-open (string-contains article "<article>"))
+ (article-close (string-contains article "</article>")))
+ (substring article (+ article-open 9) article-close)))
+
+;; Makes a card for the article
+(define (make-article-card article)
+ (let ((title (cadr (list-ref article 0)))
+ (name (cadr (list-ref article 2)))
+ (pub-date (cadr (list-ref article 4)))
+ (file (cadr (list-ref article 6))))
+ (string-append
+ "\n<table border=\"1\" width=\"60%\">\n"
+ " <tr><td><h2 id=\"" name "\">" title "</h2>--- " pub-date
+ "</td></tr>\n"
+ " <tr><td>" (get-raw-article file) " </td></tr>\n"
+ "</table>\n")))
+
+;; Generates a html blog from xml data
+(define (generate-html)
+ (let ((template (read-entire-file "template.html"))
+ (article-list "<ul>\n")
+ (article-cards "")
+ (articles (call-with-input-file "articles.xml"
+ (lambda (fp)
+ (xml->sxml fp)))))
+ (for-each (lambda (article)
+ (when (list? article)
+ ;; Add a article link
+ (set! article-list
+ (string-append article-list
+ (make-article-list-link
+ (cddr article))))
+ ;; Add article card
+ (set! article-cards
+ (string-append article-cards
+ (make-article-card
+ (cddr article))))))
+ (cdr (cadr articles)))
+ (set! article-list (string-append article-list "</ul>\n"))
+ (format #t template article-list article-cards)))
+
+(define (main args)
+ (generate-html))
diff --git a/blog/index.html b/blog/index.html
index e30b487..233ec2e 100644
--- a/blog/index.html
+++ b/blog/index.html
@@ -7,9 +7,6 @@
<style>
- /* the weird formating is because its going to be used in a python format
- string.
- */
body {
color: black;
background-image: url('../images/blog_background.png');
@@ -51,25 +48,25 @@ table {
<tr>
<td>
<ul>
-<li><a href="#second_place">Second place</a></li>
-<li><a href="#case_against_identity">Case against identity</a></li>
-<li><a href="#the_project">The project</a></li>
-<li><a href="#fakism">Fakism</a></li>
-<li><a href="#fuck_aba_therapy">Fuck aba therapy</a></li>
-<li><a href="#dogs_against_doge">Dogs against doge</a></li>
-<li><a href="#wikipedia">On the issue of wikipedia</a></li>
-<li><a href="#dreamlog1">Dream log 1</a></li>
-<li><a href="#overthinking">Overthinking</a></li>
+ <li><a href="#second_place">Second place</a></li/>
+ <li><a href="#case_against_identity">Case against identity</a></li/>
+ <li><a href="#the_project">The project</a></li/>
+ <li><a href="#fakism">Fakism</a></li/>
+ <li><a href="#fuck_aba_therapy">Fuck aba therapy</a></li/>
+ <li><a href="#dogs_against_doge">Dogs against doge</a></li/>
+ <li><a href="#wikipedia">On the issue of wikipedia</a></li/>
+ <li><a href="#dreamlog1">Dream log 1</a></li/>
+ <li><a href="#overthinking">Overthinking</a></li/>
</ul>
+
</td>
</tr>
</table>
- <!-- Python will insert the articles from rss here -->
- <table border="1" width="60%">
- <tr><td><h2 id="second_place">Second place</h2>--- Wed, 30 Apr 2025 10:23:12 GMT</td></tr>
- <tr><td>
+<table border="1" width="60%">
+ <tr><td><h2 id="second_place">Second place</h2>--- Wed, 30 Apr 2025 10:23:12 GMT</td></tr>
+ <tr><td>
<p>
Here in the americas I keep hearing people shit on china for spying on its people.
Indeed there are many reasons china does indeed suck for that but have you ever
@@ -192,12 +189,12 @@ table {
<li><a href="https://digdeeper.club/articles/technological_slavery.xhtml"
target="_blank">Technological slavery</a></li>
</ul>
-</td></tr>
- </table>
-
- <table border="1" width="60%">
- <tr><td><h2 id="case_against_identity">Case against identity</h2>--- Thu, 24 Apr 2025 19:20:02 GMT</td></tr>
- <tr><td>
+ </td></tr>
+</table>
+
+<table border="1" width="60%">
+ <tr><td><h2 id="case_against_identity">Case against identity</h2>--- Thu, 24 Apr 2025 19:20:02 GMT</td></tr>
+ <tr><td>
<p>
The modern day world is quite identity focused I would say. Identity is
something I both eat up and puke out, something I have my own version of but
@@ -257,12 +254,12 @@ table {
ADHD lol. To top things off they make it so peoples entire self worth is
centered around their job they <s>picked</s> got forced into.
</p>
-</td></tr>
- </table>
-
- <table border="1" width="60%">
- <tr><td><h2 id="the_project">The project</h2>--- Sun, 20 Apr 2025 23:05:22 GMT</td></tr>
- <tr><td>
+ </td></tr>
+</table>
+
+<table border="1" width="60%">
+ <tr><td><h2 id="the_project">The project</h2>--- Sun, 20 Apr 2025 23:05:22 GMT</td></tr>
+ <tr><td>
<p>
A long time ago a few people started a mass project, one with no end. This project spans life times and demands
everyone born is forced into it at birth and they dedicate every cell of their body, every living breathing
@@ -284,12 +281,12 @@ table {
it down is the concept that better projects can take its place. The idea that not only our very understanding of facts
and logic are twisted by a mass project but that new ways of understanding can replace it.
</p>
-</td></tr>
- </table>
-
- <table border="1" width="60%">
- <tr><td><h2 id="fakism">Fakism</h2>--- Mon, 14 Apr 2025 05:58:51 GMT</td></tr>
- <tr><td>
+ </td></tr>
+</table>
+
+<table border="1" width="60%">
+ <tr><td><h2 id="fakism">Fakism</h2>--- Mon, 14 Apr 2025 05:58:51 GMT</td></tr>
+ <tr><td>
<p>
Imagine a fake american. There are american flags everywhere, pictures of the founding fathers everywhere, american themed everything. But it lacks many of the things that
made american what it is: everything is controlled by a unelected <i>president</i>
@@ -325,12 +322,12 @@ table {
above the throne to fool people. They plant fake signs to throw you off
course, to stop you from following the path. Dont trust the signs!
</p>
-</td></tr>
- </table>
-
- <table border="1" width="60%">
- <tr><td><h2 id="fuck_aba_therapy">Fuck aba therapy</h2>--- Fri, 11 Apr 2025 10:22:54 GMT</td></tr>
- <tr><td>
+ </td></tr>
+</table>
+
+<table border="1" width="60%">
+ <tr><td><h2 id="fuck_aba_therapy">Fuck aba therapy</h2>--- Fri, 11 Apr 2025 10:22:54 GMT</td></tr>
+ <tr><td>
<p>
Lets get all the soft words out of the way: aba therapy is the use of psychological and sometimes even
physical torture to train kids with autism and other conditions to act more like normal people. It
@@ -380,12 +377,12 @@ table {
Pets and animals
</li>
</ul>
-</td></tr>
- </table>
-
- <table border="1" width="60%">
- <tr><td><h2 id="dogs_against_doge">Dogs against doge</h2>--- Sat, 5 Apr 2025 23:17:25 GMT</td></tr>
- <tr><td>
+ </td></tr>
+</table>
+
+<table border="1" width="60%">
+ <tr><td><h2 id="dogs_against_doge">Dogs against doge</h2>--- Sat, 5 Apr 2025 23:17:25 GMT</td></tr>
+ <tr><td>
<p>
On this website I have said before that as a nonhuman (I am a nonhuman believe it or not) my
power to engage in revolution is lower than all you humans and my words and actions are less
@@ -400,12 +397,12 @@ table {
<br/><br/>
The revolution will not be <s>televised</s> on social media!
</p>
-</td></tr>
- </table>
-
- <table border="1" width="60%">
- <tr><td><h2 id="wikipedia">On the issue of wikipedia</h2>--- Mon, 31 Mar 2025 10:55:00 GMT</td></tr>
- <tr><td>
+ </td></tr>
+</table>
+
+<table border="1" width="60%">
+ <tr><td><h2 id="wikipedia">On the issue of wikipedia</h2>--- Mon, 31 Mar 2025 10:55:00 GMT</td></tr>
+ <tr><td>
<h3>Why do I write this?</h3>
<p>
Wikipedia is one of those things a lot of people like to shit on without really
@@ -507,12 +504,12 @@ table {
articles... only ever serve to give you disconnected data points:
aka tell <b>what</b> to believe not <b>how</b> to believe.
</p>
-</td></tr>
- </table>
-
- <table border="1" width="60%">
- <tr><td><h2 id="dreamlog1">Dream log 1</h2>--- Sun, 30 Mar 2025 01:51:00 GMT</td></tr>
- <tr><td>
+ </td></tr>
+</table>
+
+<table border="1" width="60%">
+ <tr><td><h2 id="dreamlog1">Dream log 1</h2>--- Sun, 30 Mar 2025 01:51:00 GMT</td></tr>
+ <tr><td>
<p>
Last night I had the type of dream that inspires new stories. In my dream the favorite author:
Kurt Vonnegut, was a unix and emacs user. And he wrote a book about someone in some government
@@ -525,12 +522,12 @@ table {
not only survive but live well as the last person. They even became a unix power user through
the guides left behind.
</p>
-</td></tr>
- </table>
-
- <table border="1" width="60%">
- <tr><td><h2 id="overthinking">Overthinking</h2>--- Sat, 29 Mar 2025 11:42:00 GMT</td></tr>
- <tr><td>
+ </td></tr>
+</table>
+
+<table border="1" width="60%">
+ <tr><td><h2 id="overthinking">Overthinking</h2>--- Sat, 29 Mar 2025 11:42:00 GMT</td></tr>
+ <tr><td>
<p>
Whenver I decide to add something to this website I always overthink on how
to add the thing. In general I just overthink how I will do everything. It
@@ -547,10 +544,9 @@ table {
<br/><br/>
Next time you overthink do what I do: eat junk food.
</p>
-</td></tr>
- </table>
-
+ </td></tr>
+</table>
+
</center>
</body>
</html>
-
diff --git a/blog/template.html b/blog/template.html
index de3af96..d4eeffb 100644
--- a/blog/template.html
+++ b/blog/template.html
@@ -7,22 +7,19 @@
<style>
- /* the weird formating is because its going to be used in a python format
- string.
- */
-body {{
+body {
color: black;
background-image: url('../images/blog_background.png');
-}}
+}
-table {{
+table {
color: black;
background-color: #bebebe;
margin-top: 10px;
margin-bottom: 10px;
margin-left: 10px;
margin-right: 10px;
-}}
+}
</style>
@@ -50,13 +47,12 @@ table {{
<tr>
<td>
- {article_list}
+ ~a
</td>
</tr>
</table>
- <!-- Python will insert the articles from rss here -->
- {articles}
+ ~a
</center>
</body>
</html>