summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2023-01-15 12:36:03 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2023-01-15 12:36:03 +0100
commitca3af179dfa822b00eca8caf62bef6c2ceefb649 (patch)
treef6ddd6983afead0edaa2c2867a22fe48fdd6e9c2
parentFail properly for failed filter type inferrence. (diff)
downloadcgit-ca3af179dfa822b00eca8caf62bef6c2ceefb649.tar.gz
cgit-ca3af179dfa822b00eca8caf62bef6c2ceefb649.tar.xz
Add some filters for possible use.
-rw-r--r--files/filters/auth-deny-all.lua46
-rw-r--r--files/filters/highlight.sh9
2 files changed, 55 insertions, 0 deletions
diff --git a/files/filters/auth-deny-all.lua b/files/filters/auth-deny-all.lua
new file mode 100644
index 0000000..1bf34ce
--- /dev/null
+++ b/files/filters/auth-deny-all.lua
@@ -0,0 +1,46 @@
+-- Filter which denies access to all repos
+--
+-- File managed by Puppet
+
+function authenticate_post()
+ return 0
+end
+
+function authenticate_cookie()
+ return 0
+end
+
+function body()
+ html("<h2>Access denied for everyone and everything</h2>")
+ return 0
+end
+
+actions["authenticate-post"] = authenticate_post
+actions["authenticate-cookie"] = authenticate_cookie
+actions["body"] = body
+
+function filter_open(...)
+ action = actions[select(1, ...)]
+ http = {}
+ http["cookie"] = select(2, ...)
+ http["method"] = select(3, ...)
+ http["query"] = select(4, ...)
+ http["referer"] = select(5, ...)
+ http["path"] = select(6, ...)
+ http["host"] = select(7, ...)
+ http["https"] = select(8, ...)
+
+ cgit = {}
+ cgit["repo"] = select(9, ...)
+ cgit["page"] = select(10, ...)
+ cgit["url"] = select(11, ...)
+ cgit["login"] = select(12, ...)
+end
+
+-- function filter_close()
+-- return action()
+-- end
+--
+-- function filter_write(str)
+-- post = parse_qs(str)
+-- end
diff --git a/files/filters/highlight.sh b/files/filters/highlight.sh
new file mode 100644
index 0000000..75a8ccd
--- /dev/null
+++ b/files/filters/highlight.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+filename="$1"
+extension="${filename##*.}"
+
+exec highlight --inline-css --force --fragment \
+ --enclose-pre --out-format=xhtml \
+ --syntax="$extension" \
+ "$filename"