X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=examples%2Fcgit-commit-filter.lua;h=167725348be4a94fc508a44c38b29a2ff7a171a4;hb=d883d4a93b23be134038e28f421eafca70c3d838;hp=e2a079cf8ec024836e50bc573248c40d8deb16a0;hpb=3d41aa23f35501ca92aab8aa42980fa73f7fa74f;p=public-inbox.git diff --git a/examples/cgit-commit-filter.lua b/examples/cgit-commit-filter.lua index e2a079cf..16772534 100644 --- a/examples/cgit-commit-filter.lua +++ b/examples/cgit-commit-filter.lua @@ -8,31 +8,39 @@ -- -- commit-filter=lua:/path/to/this/script.lua -- --- Example: http://bogomips.org/public-inbox.git/ +-- Example site: https://80x24.org/public-inbox.git/ local urls = {} -urls['public-inbox.git'] = 'http://public-inbox.org/meta/' +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