aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFeuerfuchs <git@feuerfuchs.dev>2019-11-17 11:28:53 +0100
committerFeuerfuchs <git@feuerfuchs.dev>2019-11-17 11:28:53 +0100
commit4fdfe9af0f5f4c0680a8d4148a276cc300d6c041 (patch)
tree789088da9bb707eb4cb75fe06abaa85330a07e26
parentFox location of default startpage file (diff)
downloadgopherproxy-4fdfe9af0f5f4c0680a8d4148a276cc300d6c041.tar.gz
gopherproxy-4fdfe9af0f5f4c0680a8d4148a276cc300d6c041.tar.bz2
gopherproxy-4fdfe9af0f5f4c0680a8d4148a276cc300d6c041.zip
Created proper startpage, support gemini:// links in Gopher mode
-rw-r--r--assets/startpage.txt32
-rw-r--r--gopherproxy.go18
2 files changed, 45 insertions, 5 deletions
diff --git a/assets/startpage.txt b/assets/startpage.txt
index b411de6..a48212e 100644
--- a/assets/startpage.txt
+++ b/assets/startpage.txt
@@ -1 +1,31 @@
1>>>> Gopher/Gemini proxy <<<< 1 P R O X Y
2 - - - - - - for - - - - - -
3 GOPHER + GEMINI
4
5
6GETTING STARTED --
7
8Just click on startpage:// in the top left corner and enter
9a gopher:// or gemini:// URL you'd like to visit.
10
11Here's a good starting point: gopher://gopher.floodgap.com/
12
13
14WHAT'S GOPHER? --
15
16Gopher is an internet protocol that was developed in 1991.
17It's a very simple protocol that, unlike the World Wide
18Web, is very text-focused and doesn't support technologies
19like CSS, JavaScript or even cookies.
20
21-> Read more: gopher://gopher.floodgap.com/0/gopher/welcome
22
23
24WHAT ABOUT GEMINI? --
25
26Gemini is a new internet protocol that is still in the
27process of being developed. Its purpose is to be an
28alternative to both Gopher and the WWW by being more
29powerful than Gopher, but lighter than the WWW.
30
31-> Read more: gemini://gemini.circumlunar.space
diff --git a/gopherproxy.go b/gopherproxy.go
index a91e057..8c0bb89 100644
--- a/gopherproxy.go
+++ b/gopherproxy.go
@@ -96,10 +96,20 @@ func renderGopherDirectory(w http.ResponseWriter, tpl *template.Template, assetL
96 continue 96 continue
97 } 97 }
98 98
99 if strings.HasPrefix(x.Selector, "URL:") { 99 if strings.HasPrefix(x.Selector, "URL:") || strings.HasPrefix(x.Selector, "/URL:") {
100 tr.Link = template.URL(x.Selector[4:]) 100 link := strings.TrimPrefix(strings.TrimPrefix(x.Selector, "/"), "URL:")
101 } else if strings.HasPrefix(x.Selector, "/URL:") { 101 if strings.HasPrefix(link, "gemini://") {
102 tr.Link = template.URL(x.Selector[5:]) 102 link = fmt.Sprintf(
103 "/gemini/%s",
104 strings.TrimPrefix(link, "gemini://"),
105 )
106 } else if strings.HasPrefix(link, "gopher://") {
107 link = fmt.Sprintf(
108 "/gopher/%s",
109 strings.TrimPrefix(link, "gopher://"),
110 )
111 }
112 tr.Link = template.URL(link)
103 } else { 113 } else {
104 var hostport string 114 var hostport string
105 if x.Port == 70 { 115 if x.Port == 70 {