all repos — flounder @ ce21fbbef51b224e3897cbcf2b4639a191c97e39

A small site builder for the Gemini protocol

fix path issues for proxy server
alex wennerberg alex@alexwennerberg.com
Thu, 07 Jan 2021 00:07:08 -0800
commit

ce21fbbef51b224e3897cbcf2b4639a191c97e39

parent

521dc799fb2e4b2080eb37f44115a2f2c6536a18

4 files changed, 8 insertions(+), 8 deletions(-)

jump to
M gmi2html.gogmi2html.go

@@ -9,7 +9,7 @@

"git.sr.ht/~adnano/go-gemini" ) -func textToHTML(text gemini.Text) string { +func textToHTML(reqUrl *url.URL, text gemini.Text) string { var b strings.Builder var pre bool var list bool

@@ -32,7 +32,8 @@ u, err := url.Parse(urlstring)

if err != nil { continue } - if u.Scheme == "gemini" { + u = reqUrl.ResolveReference(u) + if u.Scheme == "gemini" || u.Scheme == "" { if strings.HasSuffix(u.Host, c.Host) { u.Scheme = "" urlstring = html.EscapeString(u.String())
M http.gohttp.go

@@ -586,14 +586,14 @@ if !raw && !acceptsGemini && (isGemini(fullPath) || geminiContent != "") {

var htmlString string if geminiContent == "" { file, _ := os.Open(fullPath) - htmlString = textToHTML(gmi.ParseText(file)) + htmlString = textToHTML(nil, gmi.ParseText(file)) defer file.Close() } else { - htmlString = textToHTML(gmi.ParseText(strings.NewReader(geminiContent))) + htmlString = textToHTML(nil, gmi.ParseText(strings.NewReader(geminiContent))) } favicon := getFavicon(userName) hostname := strings.Split(r.Host, ":")[0] - URI := hostname + r.URL.String() + URI := "gemini://" + hostname + r.URL.String() data := struct { SiteBody template.HTML Favicon string
M proxy.goproxy.go

@@ -33,7 +33,6 @@ client := gemini.Client{

Timeout: 60 * time.Second, InsecureSkipTrust: true, } - fmt.Println(req) if h := (url.URL{Host: req.Host}); h.Port() == "" { req.Host += ":1965"

@@ -106,7 +105,7 @@ }

w.Header().Add("Content-Type", "text/html") - htmlString := textToHTML(gemini.ParseText(resp.Body)) + htmlString := textToHTML(req.URL, gemini.ParseText(resp.Body)) data := struct { SiteBody template.HTML Favicon string
M templates/user_page.htmltemplates/user_page.html

@@ -12,7 +12,7 @@ <main>

{{.SiteBody}} <br> <div class="footer"> - Proxied from the original at <a href="gemini://{{.URI}}">gemini://{{.URI}}</a> (<a href="https://admin.flounder.online/gemini.gmi">about Gemini</a>) <a href="./?raw=1">raw</a></div> + Proxied from the original at <a href="{{.URI}}">{{.URI}}</a> (<a href="https://admin.flounder.online/gemini.gmi">about Gemini</a>) <a href="./?raw=1">raw</a></div> </main> </body> </html>