user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [PATCH] add cgit commit-filter example
@ 2015-09-15 22:03  7% Eric Wong
  0 siblings, 0 replies; 1+ results
From: Eric Wong @ 2015-09-15 22:03 UTC (permalink / raw)
  To: meta

public-inbox has search functionality, so take advantage of
good commit messages with proper titles to lookup discussion.
---
 examples/cgit-commit-filter.lua | 44 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)
 create mode 100644 examples/cgit-commit-filter.lua

diff --git a/examples/cgit-commit-filter.lua b/examples/cgit-commit-filter.lua
new file mode 100644
index 0000000..4b90125
--- /dev/null
+++ b/examples/cgit-commit-filter.lua
@@ -0,0 +1,44 @@
+-- Copyright (C) 2015 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.
+--
+-- This requires cgit linked with Lua
+-- Usage (in your cgitrc(5) config file):
+--
+--   commit-filter=lua:/path/to/this/script.lua
+--
+-- Example: http://bogomips.org/public-inbox.git/
+
+local urls = {}
+urls['public-inbox.git'] = 'http://public-inbox.org/meta/'
+-- additional URLs here...
+
+function filter_open(...)
+	lineno = 0
+	buffer = ""
+	subject = ""
+end
+
+function filter_close()
+	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('<a href="' .. u .. '?x=t&q=')
+			html_url_arg('"' .. buffer .. '"')
+			html('"><tt>')
+			html_txt(buffer)
+			html('</tt></a>')
+		end
+	else
+		html(buffer)
+	end
+	return 0
+end
+
+function filter_write(str)
+	lineno = lineno + 1
+	buffer = buffer .. str
+end
-- 
EW


^ permalink raw reply related	[relevance 7%]

Results 1-1 of 1 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2015-09-15 22:03  7% [PATCH] add cgit commit-filter example Eric Wong

Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).