about summary refs log tree commit diff homepage
diff options
context:
space:
mode:
authorNguyễn Gia Phong <mcsinyx@disroot.org>2021-12-20 17:46:31 +0700
committerNguyễn Gia Phong <mcsinyx@disroot.org>2021-12-20 17:46:31 +0700
commit09f668df44432da378da7b251ea4bd4a011d62c6 (patch)
tree75da35ce7f750cefa17c8323f3bc6fde1cf68326
parentafcf9702d8ea4014349561025865e85326657d84 (diff)
downloadsite-09f668df44432da378da7b251ea4bd4a011d62c6.tar.gz
Join Fediring
-rw-r--r--_layout/page_foot.html6
-rw-r--r--_rss/item.xml47
-rw-r--r--config.md5
-rw-r--r--index.md17
-rw-r--r--utils.jl39
5 files changed, 58 insertions, 56 deletions
diff --git a/_layout/page_foot.html b/_layout/page_foot.html
index 6a9431a..c7b7bca 100644
--- a/_layout/page_foot.html
+++ b/_layout/page_foot.html
@@ -1,6 +1,8 @@
+{{isnotpage /tag/*}}{{isnotempty rss}}<div class=comments>
+  <a href='{{mailto_comment}}'>Reply via email</a>
+</div>{{end}}{{end}}
 <div class=page-foot>
-  &copy; 2019&ndash;2021 {{author}};
-  See <a href=/COPYING>license terms</a><br>
+  {{copyright}}; See <a href=/COPYING>license terms</a><br>
   {{isnotpage /tag/*}}Last modified: {{author_date}};  View
   <a href=https://git.sr.ht/~cnx/site/tree/main/item/{{fd_rpath}}>page
   source</a><br>{{end}}
diff --git a/_rss/item.xml b/_rss/item.xml
index 412148a..76f892a 100644
--- a/_rss/item.xml
+++ b/_rss/item.xml
@@ -1,45 +1,14 @@
-<!--
-This is based on Yandex's https://yandex.com/support/zen/website/rss-modify.html
-
-The scope of this segment is the LOCAL scope (page variables). For instance 'rss_title'.
-
-Notes:
-* the local var rss_description (or rss) *must* be given otherwise the item
-is not generated.
-* rss_title if not given is inferred from page title
-* rss_pubdate if not given is inferred from the date of last modification
-* the full content is not added by default but can be if the variable rss_full_content
-is set to true (either globally or locally).
-* RFC822 or RFC1123 is a date format required by RSS.
-* there is debate about supporting one or several enclosures
-(see https://www.rssboard.org/rss-profile#element-channel-item-enclosure).
-We use the conservative 'only one' approach by default but you could tweak this by
-defining your own `rss_enclosures` variable with a list of string and use that.
--->
 <item>
-  <title><![CDATA[{{fd2rss rss_title}}]]></title>
+  <title>{{fd2rss rss_title}}</title>
   <link>{{fd_full_url}}</link>
   <guid>{{fd_full_url}}</guid>
-  <description><![CDATA[{{fd2rss rss_description}}]]></description>
-
-  <!-- note that fd_page_html is already HTML, so we don't use fd2rss here -->
-  {{if rss_full_content}}
+  <description>{{fd2rss rss_description}}</description>
+  {{for tag in tags}}<category>{{tag}}</category>{{end}}
+  <pubDate>{{RFC822 rss_pubdate}}</pubDate>
   <content:encoded>
-    <![CDATA[{{fix_relative_links fd_page_html}}]]>
+    <![CDATA[{{fix_relative_links fd_page_html}}
+    <a href="{{mailto_comment}}">Reply</a>]]>
   </content:encoded>
-  {{end}}
-
-  <!-- RFC1123 enforces a RSS-compliant date formatting -->
-  <pubDate>{{RFC822 rss_pubdate}}</pubDate>
-
-  {{isnotempty rss_author}}<author>{{rss_author}}</author>{{end}}
-  {{isnotempty author}}
-  <atom:author>
-    <atom:name>{{author}}</atom:name>
-  </atom:author>
-  {{end}}
-
-  {{isnotempty rss_category}}<category>{{rss_category}}</category>{{end}}
-  {{isnotempty rss_comments}}<comments>{{rss_comments}}</comments>{{end}}
-  {{isnotempty rss_enclosure}}<enclosure>{{rss_enclosure}}</enclosure>{{end}}
+  <comments><![CDATA[{{comments}}]]></comments>
+  <wfw:commentRss>{{comment_rss}}</wfw:commentRss>
 </item>
diff --git a/config.md b/config.md
index 0e556b2..fbd8a06 100644
--- a/config.md
+++ b/config.md
@@ -2,13 +2,14 @@
 author = "Nguyễn Gia Phong"
 website_title = "Web logs by McSinyx"
 website_description = "Random write-ups packed with pop culture references"
+copyright = "🄯 2019–2021 " * author
 website_url = "https://cnx.srht.site"
+website_url = "http://localhost:8000"
 date_format = "yyyy-mm-dd"
 mintoclevel = 2
 generate_rss = true
-rss_full_content = true
 ignore = ["Manifest.toml", "Project.toml", ".build.jl", ".build.yml",
-          "node_modules/", "package-lock.json"]
+          "mbox", "node_modules/", "package-lock.json"]
 +++
 
 \newcommand{\R}{\mathbb R}
diff --git a/index.md b/index.md
index 1ac9659..914a483 100644
--- a/index.md
+++ b/index.md
@@ -1,7 +1,11 @@
 # About Me
 
 Hi!  [My name is] Nguyễn Gia Phong and I'm a Vietnamese [free software]
-enthusiast.  You can find me under my Internet alias McSinyx (or CnX for short)
+enthusiast.  I am generally interested in programming languages,
+concurrency, reproducibility and decentralization.  In meatspace
+I also like cooking, dogs[^culture] and urban music.
+
+You can find me under my Internet alias McSinyx (or CnX for short)
 in the [Fediverse][]:
 
 * Pleroma: [cnx@nixnet.social]
@@ -10,12 +14,11 @@ in the [Fediverse][]:
 * Email (and XMPP): [mcsinyx@disroot.org][^pgp]
 * Matrix: [@cnx:halogen.city]
 
-I am generally interested in programming languages, concurrency,
-reproducibility and decentralization.  In meatspace I also like
-cooking, dogs[^culture] and urban music.
+In addition, I am a member of the [250kb Club] and a [Fediverse webring].
+You might want to pay my [left] and [right] neighbors a visit!
 
-[^pgp]: PGP: [27148B2C06A2224B], also on [OpenPGP]
 [^culture]: Not necessarily mutually exclusive
+[^pgp]: PGP: [27148B2C06A2224B], also on [OpenPGP]
 
 [My name is]: https://www.youtube.com/watch?v=LDj8kkVwisY
 [free software]: https://www.gnu.org/philosophy/free-sw.html
@@ -25,5 +28,9 @@ cooking, dogs[^culture] and urban music.
 [sr.ht/~cnx]: https://sr.ht/~cnx
 [mcsinyx@disroot.org]: mailto:mcsinyx@disroot.org
 [@cnx:halogen.city]: matrix:u/cnx:halogen.city
+[250kb Club]: https://250kb.club
+[Fediverse webring]: https://fediring.net
+[left]: https://fediring.net/previous?host=cnx.srht.site
+[right]: https://fediring.net/next?host=cnx.srht.site
 [27148B2C06A2224B]: https://meta.sr.ht/~cnx.pgp
 [OpenPGP]: https://keys.openpgp.org/search?q=27148B2C06A2224B
diff --git a/utils.jl b/utils.jl
index 86b16c5..3e58dde 100644
--- a/utils.jl
+++ b/utils.jl
@@ -1,14 +1,42 @@
-using Printf
+using Printf: @sprintf
+using Franklin: convert_html, path
 
 function hfun_author_date()
   return readchomp(`git log -1 --date=short --format=%ad $(locvar(:fd_rpath))`)
 end
 
 function hfun_abslink(args)
-  path = args[1]
-  return @sprintf("<a href=/%s>%s</a>", path, pagevar(path, "title"))
+  rpath = args[1]
+  return @sprintf("<a href=/%s>%s</a>", rpath, pagevar(rpath, :title))
 end
 
+dir_url() = strip(dirname(locvar(:fd_url)), '/')
+message_id() = @sprintf("<%s@cnx>", dir_url())
+hfun_comments() = @sprintf("https://lists.sr.ht/~cnx/site?search=%s:%s",
+                           "In-Reply-To", message_id())
+
+function hfun_comment_rss()
+  rpath = joinpath(dir_url(), "comments.xml")
+  head_template = joinpath(path(:rss), "comment-head.xml")
+  item_template = joinpath(path(:rss), "comment-item.xml")
+  open(joinpath(path(:site), rpath), "w") do feed
+    write(feed, convert_html(read(head_template, String)))
+    write(feed, read(`python3 formbox.py mbox $(message_id()) $(item_template)`, String))
+    write(feed, "</channel></rss>")
+  end
+  return joinpath(globvar(:website_url), rpath)
+end
+
+function hfun_mailto_comment()
+  return @sprintf("mailto:%s?%s=%s&%s=Re: %s",
+                  "~cnx/site@lists.sr.ht",
+                  "In-Reply-To", message_id(),
+                  "Subject", locvar(:title))
+end
+
+hfun_github(args) = @sprintf("<a href=https://github.com/%s>@%s</a>",
+                             args[1], args[1])
+
 function hfun_pep(args)
   postfix = length(args) < 2 ? "" : '#' * args[2]
   return @sprintf(
@@ -16,11 +44,6 @@ function hfun_pep(args)
     Meta.parse(args[1]), postfix, args[1], postfix)
 end
 
-function hfun_github(args)
-  return @sprintf("<a href=https://github.com/%s>@%s</a>",
-                  args[1], args[1])
-end
-
 function hfun_pip(args)
   content = length(args) < 2 ? "GH-" * args[1] : args[2]
   return @sprintf("<a href=https://github.com/pypa/pip/pull/%s>%s</a>",