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.jl41
1 files changed, 17 insertions, 24 deletions
diff --git a/utils.jl b/utils.jl
index 4d43cdc..5a6e1c4 100644
--- a/utils.jl
+++ b/utils.jl
@@ -2,12 +2,12 @@ using Printf: @sprintf
 using Franklin: convert_html, path
 
 function hfun_author_date()
-  return readchomp(`git log -1 --date=short --format=%ad $(locvar(:fd_rpath))`)
+  readchomp(`git log -1 --date=short --format=%ad $(locvar(:fd_rpath))`)
 end
 
 function hfun_abslink(args)
   rpath = args[1]
-  return @sprintf("<a href=/%s>%s</a>", rpath, pagevar(rpath, :title))
+  @sprintf("<a href=/%s>%s</a>", rpath, pagevar(rpath, :title))
 end
 
 dir_url() = strip(dirname(locvar(:fd_url)), '/')
@@ -21,41 +21,34 @@ function hfun_comment_rss()
     write(feed, convert_html(readchomp(joinpath(path(:rss), "comments.xml"))))
     #write(feed, read(`python3 formbox.py mbox $(message_id()) $item_template`, String))
   end
-  return joinpath(globvar(:website_url), rpath)
+  joinpath(globvar(:website_url), rpath)
+end
+
+function hfun_fediring(args)
+  adj = readlines(joinpath(path(:libs), "fediring"))[parse(Int, args[1])]
+  "<a href=https://$adj>$(args[2])</a>"
 end
 
-hfun_fediring(args) = "https://fediring.net/$(args[1])?host=cnx.srht.site"
 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()
-  return @sprintf("mailto:%s?%s=%s&%s=Re: %s",
-                  "~cnx/site@lists.sr.ht",
-                  "In-Reply-To", message_id(),
-                  "Subject", locvar(:title))
+  @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))
 end
 
-ring_sources = ["https://blog.ganssle.io/feeds/all.atom.xml",
-                "https://codesections.com/rss.xml",
-                "https://danct12.github.io/feed.xml",
-                "https://drewdevault.com/feed.xml",
-                "https://huyngo.envs.net/index.xml",
-                "https://pgjones.dev/blog/rss20.xml",
-                "https://stallman.org/rss/rss.xml",
-                "https://unixsheikh.com/feed.rss"]
-# TODO: joinpath
-hfun_openring() = readchomp(pipeline("_templates/openring.html",
-                                     `openring -n4 -s$ring_sources`))
+hfun_openring() = readchomp(joinpath(path(:libs), "openring", "out.html"))
 
 function hfun_pep(args)
   postfix = length(args) < 2 ? "" : '#' * args[2]
-  return @sprintf(
-    "<a href=https://www.python.org/dev/peps/pep-%04d%s>PEP %s%s</a>",
-    Meta.parse(args[1]), postfix, args[1], postfix)
+  @sprintf("<a href=https://www.python.org/dev/peps/pep-%04d%s>PEP %s%s</a>",
+           Meta.parse(args[1]), postfix, args[1], postfix)
 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>",
-                  args[1], content)
+  "<a href=https://github.com/pypa/pip/pull/$(args[1])>$content</a>"
 end