summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2017-05-18 15:46:22 +0200
committerLeah Neukirchen <leah@vuxu.org>2017-05-18 15:46:22 +0200
commita35c64dddf69a0d90223800764e6b9a5e8a6dc68 (patch)
tree745e7b22b342c73a550d3807d4ea939020045ffc
parent28e7d682b4a22ffca873b74bc4daa100a4d85933 (diff)
downloadtrivium-a35c64dddf69a0d90223800764e6b9a5e8a6dc68.tar.gz
trivium-a35c64dddf69a0d90223800764e6b9a5e8a6dc68.tar.xz
trivium-a35c64dddf69a0d90223800764e6b9a5e8a6dc68.zip
add JSON Feed
-rw-r--r--template/front.ht1
-rw-r--r--template/json.ht23
-rw-r--r--trivium.rb4
3 files changed, 28 insertions, 0 deletions
diff --git a/template/front.ht b/template/front.ht
index 876f28d..77d8eee 100644
--- a/template/front.ht
+++ b/template/front.ht
@@ -6,6 +6,7 @@
     <link rel="icon" href="trivium.ico">
     <link rel="stylesheet" href="style.css">
     <link rel="alternate" type="application/atom+xml" title="Atom" href="http://chneukirchen.org/trivium/index.atom">
+    <link rel="alternate" type="application/json" title="JSON Feed" href="http://chneukirchen.org/trivium/index.json" />
     <link rel="up" href="http://chneukirchen.org/">
   </head>
   <body>
diff --git a/template/json.ht b/template/json.ht
new file mode 100644
index 0000000..9ad93ca
--- /dev/null
+++ b/template/json.ht
@@ -0,0 +1,23 @@
+$ require 'json'
+$ f = {
+$   "version" => "https://jsonfeed.org/version/1",
+$   "title" => "Trivium",
+$   "home_page_url" => "http://chneukirchen.org/trivium/",
+$   "feed_url" => "http://chneukirchen.org/trivium/index.json",
+$   "favicon" => "http://chneukirchen.org/trivium/trivium.ico",
+$   "author" => {
+$      "name" => "Leah Neukirchen",
+$      "url" => "http://chneukirchen.org/",
+$   },
+$   "items" => self[:entries].map { |entry|
+$      {
+$        "id" => "tag:chneukirchen.org,2008:trivium-#{entry[:id]}",
+$        "url" => "http://chneukirchen.org/trivium/#{entry[:id]}",
+$        "title" => entry[:title],
+$        "date_published" => entry[:date].iso8601,
+$        "date_modified" => entry[:updated].iso8601,
+$        "content_html" => format(entry)
+$      }
+$   }
+$ }
+$:{JSON.pretty_generate f}
diff --git a/trivium.rb b/trivium.rb
index bbb43d1..3ef8020 100644
--- a/trivium.rb
+++ b/trivium.rb
@@ -168,5 +168,9 @@ dep "html/index.atom", "template/atom.ht", *d do |dst|
   File.write(dst, template("template/atom.ht",
                            :entries => feed, :time => Time.now))
 end
+dep "html/index.json", "template/json.ht", *d do |dst|
+  File.write(dst, template("template/json.ht",
+                           :entries => feed, :time => Time.now))
+end
 
 system "rsync -r data/ html"