X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=examples%2Fcgit-commit-filter.lua;h=73af994828aebcb373a7bdd67cebbe592c1d4017;hb=ecb21bea58c0a0cb2a4abb399339d197f8076e56;hp=1616b5a0d711408886523c4836f89e76189009b2;hpb=2b5da4383d9c6defd2d473bf02eb8920bd589890;p=public-inbox.git diff --git a/examples/cgit-commit-filter.lua b/examples/cgit-commit-filter.lua index 1616b5a0..73af9948 100644 --- a/examples/cgit-commit-filter.lua +++ b/examples/cgit-commit-filter.lua @@ -1,4 +1,4 @@ --- Copyright (C) 2015-2018 all contributors +-- Copyright (C) 2015-2020 all contributors -- License: GPLv2 or later -- This commit filter maps a subject line to a search URL of a public-inbox -- disclaimer: written by someone who does not know Lua. @@ -13,26 +13,34 @@ local urls = {} urls['public-inbox.git'] = 'https://public-inbox.org/meta/' -- additional URLs here... +-- TODO we should be able to auto-generate this based on "coderepo" +-- directives in the public-inbox config file; but keep in mind +-- the mapping is M:N between inboxes and coderepos function filter_open(...) lineno = 0 buffer = "" - subject = "" end function filter_close() + -- cgit opens and closes this filter for the commit subject + -- and body separately, and we only generate the link based + -- on the commit subject: if lineno == 1 and string.find(buffer, "\n") == nil then u = urls[os.getenv('CGIT_REPO_URL')] if u == nil then html(buffer) else - html('') html_txt(buffer) html('') end else + -- pass the body-through as-is + -- TODO: optionally use WwwHighlight for linkification like + -- cgit-wwwhighlight-filter.lua html(buffer) end return 0