aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile34
-rwxr-xr-xinfo.filter.dpi39
2 files changed, 73 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..159e26a
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,34 @@
+NAME = info
+BIN = $(NAME).filter.dpi
+EXTRA = info2html info2html.css info2html.conf
+DILLO_DIR = ~/.dillo
+DPI_DIR = $(DILLO_DIR)/dpi/$(NAME)
+DPIDRC = $(DILLO_DIR)/dpidrc
+
+all:
+ @echo "Use 'make install' to install"
+ @echo "Use 'make uninstall' to uninstall"
+
+$(DPIDRC):
+ cp /etc/dillo/dpidrc $@
+
+install-proto: $(DPIDRC)
+ grep -q '^proto.$(NAME)=$(NAME)' $< || echo 'proto.$(NAME)=$(NAME)/$(BIN)' >> $<
+
+link: $(BIN) install-proto
+ mkdir -p $(DPI_DIR)
+ ln -frs $(BIN) $(DPI_DIR)
+ ln -frs $(EXTRA) $(DPI_DIR)
+
+install: $(BIN) install-proto
+ mkdir -p $(DPI_DIR)
+ cp -f $(BIN) $(DPI_DIR)
+ cp -f $(EXTRA) $(DPI_DIR)
+
+uninstall: $(BIN)
+ rm -f $(DPI_DIR)/$(BIN)
+ cd $(DPI_DIR) && rm -f $(EXTRA)
+ rmdir $(DPI_DIR)
+
+.PHONY:
+ all link install install-proto uninstall
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