aboutsummaryrefslogtreecommitdiff
path: root/info.filter.dpi
diff options
context:
space:
mode:
Diffstat (limited to 'info.filter.dpi')
-rwxr-xr-xinfo.filter.dpi39
1 files changed, 39 insertions, 0 deletions
diff --git a/info.filter.dpi b/info.filter.dpi
new file mode 100755
index 0000000..e0b7e47
--- /dev/null
+++ b/info.filter.dpi
@@ -0,0 +1,39 @@
+#!/bin/bash
+# Copyright (c) 2024-2025 Rodrigo Arias Mallo
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+IFS= read -d '>' auth # Ignore auth
+IFS= read -d '>' cmd
+
+case "$cmd" in
+ "<cmd='open_url' url='"*);;
+ *) echo $cmd; exit;;
+esac
+
+url=${cmd#"<cmd='open_url' url='"}
+url=${url%"' '"}
+
+serve_404() {
+ printf "<cmd='start_send_page' url='' '>\n"
+ printf "Content-type: text/plain\r\n\r\n"
+ echo "Not found"
+ exit 0
+}
+
+serve_manpage() {
+ url="$1"
+ ref="${url#"info:"}"
+ # If page not found, return 404
+ #if [ -z "$ref" ]; then
+ # serve_404
+ # exit 0
+ #fi
+ printf "<cmd='start_send_page' url='' '>\n"
+ printf "Content-type: text/html\r\n\r\n"
+ perl ~/.dillo/dpi/info/info2html "$ref"
+}
+
+case "$url" in
+ info:*) serve_manpage "$url";;
+ *) serve_404;;
+esac