summaryrefslogtreecommitdiff
path: root/posts
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2015-03-29 05:14:18 +0200
committerGregor Kleen <gkleen@yggdrasil.li>2015-03-29 05:14:18 +0200
commit70a7dc39876f2825962a96d85a6d4f3363435e43 (patch)
tree2f2e5d87087465e5ce15d0481350ac808f0aa353 /posts
parent1ff7bce325af3bc095df241721cbea79d08aa8b9 (diff)
downloaddirty-haskell.org-70a7dc39876f2825962a96d85a6d4f3363435e43.tar
dirty-haskell.org-70a7dc39876f2825962a96d85a6d4f3363435e43.tar.gz
dirty-haskell.org-70a7dc39876f2825962a96d85a6d4f3363435e43.tar.bz2
dirty-haskell.org-70a7dc39876f2825962a96d85a6d4f3363435e43.tar.xz
dirty-haskell.org-70a7dc39876f2825962a96d85a6d4f3363435e43.zip
Documentation of rss patch
Diffstat (limited to 'posts')
-rw-r--r--posts/blog-rss.md25
1 files changed, 25 insertions, 0 deletions
diff --git a/posts/blog-rss.md b/posts/blog-rss.md
new file mode 100644
index 0000000..559a6c6
--- /dev/null
+++ b/posts/blog-rss.md
@@ -0,0 +1,25 @@
1% dirty-haskell.org´s rss feeds
2
3I extended the software suite inherited from [math.kleen.org](http://math.kleen.org) to include support for rss feeds.
4The heart of the issue is a ~80 line haskell script I chose to call, in a bout of creativity, "generate-rss.hs".
5The script uses the [feed](http://hackage.haskell.org/package/feed-0.3.9.2) package.
6
7generate-rss.hs gets passed a title and a list of paths below ./lists to incorporate as items.
8It generates an empty feed structure, adds title and a (hardcoded) base url for RSS metadata, and iterates over the given paths — generating for each path an item to be included in the finished feed.
9This procedure makes use of a state monad (StateT (Feed, Maybe ClockTime) IO ()) to sequentially add items to the feed and keep track of the modification/change time of the newest path examined.
10Each item carries a title, an url, a date, and contents as follows:
11
12- The date used is the modification/change time of the path supplied as a command line argument at the beginning of the program (usually a symbolic link in ./lists) — as such it is the time the post was linked into the particular list we´re generating a RSS feed for (this was not a deliberate design choice but a side effect of the canonical implementation — it was later decided that this behaviour was in fact the one expected all along).
13- The url is generated by following, recursively, the trail of symbolic links starting in ./lists, assuming the final target is indeed in ./posts, and forming the filename of that target into a (hopefully) functional url in a hardcoded fashion.
14- The title is extracted from the markdown file using a function shamelessly copied from extract-title.hs (The author wrote that one too, after all).
15- The contents are read into Pandoc and rendered into [AsciiDoc](http://en.wikipedia.org/wiki/AsciiDoc) format (it seemed convenient at the time).
16
17Along the way two helper functions were introduced — if an implementation of those already exists in Prelude or somewhere else common please mail in a comment:
18
19 (<->) :: [(a -> b)] -> a -> [b]
20 [] <-> _ = []
21 (f:fs) <-> x = (f x:fs <-> x)
22
23 (<-->) :: [(a -> a)] -> a -> a
24 [] <--> x = x
25 (f:fs) <--> x = fs <--> (f x)