]> Sergey Matveev's repositories - public-inbox.git/blobdiff - examples/cgit-commit-filter.lua
treewide: run update-copyrights from gnulib for 2019
[public-inbox.git] / examples / cgit-commit-filter.lua
index 7799befa2b822e3baa7e91e1e4204717c3cb0b24..73af994828aebcb373a7bdd67cebbe592c1d4017 100644 (file)
@@ -1,4 +1,4 @@
--- Copyright (C) 2015-2018 all contributors <meta@public-inbox.org>
+-- Copyright (C) 2015-2020 all contributors <meta@public-inbox.org>
 -- License: GPLv2 or later <https://www.gnu.org/licenses/gpl-2.0.txt>
 -- This commit filter maps a subject line to a search URL of a public-inbox
 -- disclaimer: written by someone who does not know Lua.
 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
@@ -33,6 +38,9 @@ function filter_close()
                        html('</tt></a>')
                end
        else
+               -- pass the body-through as-is
+               -- TODO: optionally use WwwHighlight for linkification like
+               -- cgit-wwwhighlight-filter.lua
                html(buffer)
        end
        return 0