summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoresquizo <esquizo+noreply@esquizo.net>2026-03-13 13:38:43 -0300
committeresquizo <esquizo+noreply@esquizo.net>2026-03-13 13:38:43 -0300
commit48aef69ee70916d726d15e6c141715c767d915d8 (patch)
tree073a12563ad6c175dfcf2e67973304c5a4218881
parent8bff241df92c4d17e6b83242ca329cb680355f88 (diff)
adicionado rss
-rw-r--r--Makefile17
-rw-r--r--blog/index.md6
-rw-r--r--blog/posts.csv2
-rwxr-xr-xcsv2index.sh24
-rwxr-xr-xcsv2rss.sh33
5 files changed, 73 insertions, 9 deletions
diff --git a/Makefile b/Makefile
index 70924f3..270230b 100644
--- a/Makefile
+++ b/Makefile
@@ -3,13 +3,24 @@ PAGES=index.html\
blog/first.html\
blog/anonimato-estatistica.html
-all: $(PAGES)
+RSS = blog/index.rss
+
+URL ?= http://localhost:8000
+
+all: $(PAGES) blog/index.rss
clean:
- rm -f $(PAGES) dist.tar.gz
+ rm -f $(PAGES) $(RSS) dist.tar.gz
dist: all
- tar -cv static $(PAGES) | gzip > dist.tar.gz
+ tar -cv static $(RSS) $(PAGES) | gzip > dist.tar.gz
+
+blog/index.rss: blog/posts.csv
+ ./csv2rss.sh 'Blogs do Esquizo' '$(URL)/blog' 'Transliteração das vozes da minha cabeça' \
+ < blog/posts.csv > blog/index.rss
+
+blog/index.html: blog/posts.csv templates/base.m4
+ m4 -DPAGECONTENT="$$(./csv2index.sh /blog < $<)" templates/base.m4 > $@
%.html: %.md templates/base.m4
m4 -DPAGECONTENT="$$(markdown $<)" templates/base.m4 > $@
diff --git a/blog/index.md b/blog/index.md
deleted file mode 100644
index ab98f7a..0000000
--- a/blog/index.md
+++ /dev/null
@@ -1,6 +0,0 @@
-Lista de blogs
-
-- [Anonimato é só estatistica](anonimato-estatistica.html) (sex 13 mar 2026 10:58:31 -03)
-- [First!](first.html) (sex 13 mar 2026 00:36:42 -03)
-- [Voltar](/)
-
diff --git a/blog/posts.csv b/blog/posts.csv
new file mode 100644
index 0000000..32b89e4
--- /dev/null
+++ b/blog/posts.csv
@@ -0,0 +1,2 @@
+Anonimato é só estatistica|anonimato-estatistica.html|sex 13 mar 2026 10:58:31 -03
+First!|first.html|sex 13 mar 2026 00:36:42 -03
diff --git a/csv2index.sh b/csv2index.sh
new file mode 100755
index 0000000..5a833bd
--- /dev/null
+++ b/csv2index.sh
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+LINK="$1"
+
+SCRIPT="$(cat << EOF
+{
+ title = \$1
+ url = "$LINK/" \$2
+ date = \$3
+ print "<li>"
+ print "<a href=\"" url "\">" title "</a> (" date ")"
+ print "</li>"
+}
+EOF
+)"
+
+echo "<a href='$LINK/index.rss'>RSS</a>"
+echo "<a href='/'>Voltar</a>"
+
+echo '<ul>'
+
+awk -F'|' "$SCRIPT"
+
+echo '</ul>'
diff --git a/csv2rss.sh b/csv2rss.sh
new file mode 100755
index 0000000..0469849
--- /dev/null
+++ b/csv2rss.sh
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+TITLE="$1"
+LINK="$2"
+DESCRIPTION="$3"
+
+SCRIPT="$(cat << EOF
+{
+ title = \$1
+ url = "$LINK/" \$2
+ date = \$3
+
+ print " <item>"
+ print " <title>" title "</title>"
+ print " <link>" url "</link>"
+ print " <pubDate>" date "</pubDate>"
+ print " <guid>" url "</guid>"
+ print " </item>"
+}
+EOF
+)"
+
+echo '<?xml version="1.0" encoding="UTF-8" ?>'
+echo '<rss version="2.0">'
+echo '<channel>'
+echo " <title>$TITLE</title>"
+echo " <link>$LINK</link>"
+echo " <description>$DESCRIPTION</description>"
+
+awk -F'|' "$SCRIPT"
+
+echo '</channel>'
+echo '</rss>'