Commit 7113efe71ed4e1d5aebcb7501129ab30b1cfa2fd
Support input status type
cel committed on 2/26/2020, 2:22:44 PMParent: 02044cb4be75b9a46439f79179efc828aceb7d50
Files changed
gemini.filter.dpi | changed |
gemini.filter.dpi | |||
---|---|---|---|
@@ -49,8 +49,30 @@ | |||
49 | 49 … | printf "Content-type: text/plain\r\n\r\n" | |
50 | 50 … | echo Empty status response. $2 | |
51 | 51 … | } | |
52 | 52 … | ||
53 … | +serve_input() { | ||
54 … | + printf "<cmd='start_send_page' url='' '>\n" | ||
55 … | + prompt=$1 | ||
56 … | + # TODO: html-escape prompt | ||
57 … | + printf "Content-type: text/html\r\n\r\n" | ||
58 … | + cat <<-EOF | ||
59 … | + <!doctype html> | ||
60 … | + <html> | ||
61 … | + <head> | ||
62 … | + <title>Input</title> | ||
63 … | + </head> | ||
64 … | + <body> | ||
65 … | + <form action="" method="get"> | ||
66 … | + <h3>$prompt</h3> | ||
67 … | + <input name=_ style='width:100%'> | ||
68 … | + <input type=submit> | ||
69 … | + </form> | ||
70 … | + </body> | ||
71 … | + </html> | ||
72 … | + EOF | ||
73 … | +} | ||
74 … | + | ||
53 | 75 … | serve_success() { | |
54 | 76 … | printf "<cmd='start_send_page' url='' '>\n" | |
55 | 77 … | type=$1 | |
56 | 78 … | case "$type" in | |
@@ -123,8 +145,17 @@ | |||
123 | 145 … | url1=${url#gemini://} | |
124 | 146 … | hostname=${url1%%/*} | |
125 | 147 … | host=${hostname%%:*} | |
126 | 148 … | port=${hostname##*:} | |
149 … | + | ||
150 … | + # replace "?_=" with "?". | ||
151 … | + # dillo can only submit forms with name=value items, but Gemini | ||
152 … | + # uses the whole querystring as a single string | ||
153 … | + url1=${url%%?_=*} | ||
154 … | + if [ "$url1" != "$url" ]; then | ||
155 … | + url="${url1}?${url#*?_=}" | ||
156 … | + fi | ||
157 … | + | ||
127 | 158 … | if [ "$host" = "$port" ]; then port=1965; fi | |
128 | 159 … | send_status_msg "Sending request..." | |
129 | 160 … | printf "%s\r\n" "$url" | openssl s_client -verify_quiet -quiet "$host:$port" | { | |
130 | 161 … | read status meta |
Built with git-ssb-web