about summary refs log tree commit diff homepage
path: root/utils.jl
diff options
context:
space:
mode:
Diffstat (limited to 'utils.jl')
-rw-r--r--utils.jl24
1 files changed, 17 insertions, 7 deletions
diff --git a/utils.jl b/utils.jl
index 5a6e1c4..81c56fa 100644
--- a/utils.jl
+++ b/utils.jl
@@ -11,19 +11,32 @@ function hfun_abslink(args)
 end
 
 dir_url() = strip(dirname(locvar(:fd_url)), '/')
-message_id() = @sprintf("<%s@cnx>", dir_url())
+message_id() = "<$(dir_url())@cnx>"
 hfun_comments() = @sprintf("https://lists.sr.ht/~cnx/site?search=%s:%s",
                            "In-Reply-To", message_id())
 
+function render_comments(template)
+  prefix = joinpath(path(:libs), "formbox")
+  format = joinpath(prefix, "format")
+  mbox = joinpath(prefix, "mbox")
+  template_path = joinpath(prefix, template)
+  readchomp(`python3 $format $mbox $(message_id()) $template_path`)
+end
+
+hfun_comments_rendered() = render_comments("comment.html")
+
 function hfun_comment_rss()
   rpath = joinpath(dir_url(), "comments.xml")
   open(joinpath(path(:site), rpath), "w") do feed
     write(feed, convert_html(readchomp(joinpath(path(:rss), "comments.xml"))))
-    #write(feed, read(`python3 formbox.py mbox $(message_id()) $item_template`, String))
   end
   joinpath(globvar(:website_url), rpath)
 end
 
+hfun_comment_rss_feed_url() = joinpath(dirname(locvar(:fd_full_url)),
+                                       "comments.xml")
+hfun_comment_rss_items() = render_comments("comment.xml")
+
 function hfun_fediring(args)
   adj = readlines(joinpath(path(:libs), "fediring"))[parse(Int, args[1])]
   "<a href=https://$adj>$(args[2])</a>"
@@ -33,11 +46,8 @@ hfun_github(args) = "<a href=https://github.com/$(args[1])>@$(args[1])</a>"
 hfun_job_url() = get(ENV, "JOB_URL", "https://builds.sr.ht/~cnx/site")
 
 function hfun_mailto_comment()
-  @sprintf("<a href='mailto:%s?%s=%s&%s=Re: %s' title='Reply via email'>%s</a>",
-           "~cnx/site@lists.sr.ht",
-           "In-Reply-To", message_id(),
-           "Subject", locvar(:title),
-           globvar(:author))
+  @sprintf("mailto:%s?%s=%s&%s=Re: %s", "~cnx/site@lists.sr.ht",
+           "In-Reply-To", message_id(), "Subject", locvar(:title))
 end
 
 hfun_openring() = readchomp(joinpath(path(:libs), "openring", "out.html"))