using Printf: @sprintf
using Franklin: convert_html, path
function hfun_author_date()
readchomp(`git log -1 --date=short --format=%ad $(locvar(:fd_rpath))`)
end
function hfun_abslink(args)
rpath = args[1]
@sprintf("%s", 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")
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
function hfun_fediring(args)
adj = readlines(joinpath(path(:libs), "fediring"))[parse(Int, args[1])]
"$(args[2])"
end
hfun_github(args) = "@$(args[1])"
hfun_job_url() = get(ENV, "JOB_URL", "https://builds.sr.ht/~cnx/site")
function hfun_mailto_comment()
@sprintf("%s",
"~cnx/site@lists.sr.ht",
"In-Reply-To", message_id(),
"Subject", locvar(:title),
globvar(:author))
end
hfun_openring() = readchomp(joinpath(path(:libs), "openring", "out.html"))
function hfun_pep(args)
postfix = length(args) < 2 ? "" : '#' * args[2]
@sprintf("PEP %s%s",
Meta.parse(args[1]), postfix, args[1], postfix)
end
function hfun_pip(args)
content = length(args) < 2 ? "GH-" * args[1] : args[2]
"$content"
end