From 8f216f569b0de06c2899d69a0f53be8c5a3b268a Mon Sep 17 00:00:00 2001 From: makeworld Date: Mon, 1 Mar 2021 15:35:47 -0500 Subject: [PATCH] renderer -> render --- display/about.go | 4 ++-- display/bookmarks.go | 4 ++-- display/display.go | 6 +++--- display/file.go | 8 ++++---- display/handlers.go | 10 +++++----- display/private.go | 10 +++++----- display/subscriptions.go | 6 +++--- {renderer => render}/page.go | 2 +- renderer/renderer.go => render/render.go | 4 ++-- 9 files changed, 27 insertions(+), 27 deletions(-) rename {renderer => render}/page.go (99%) rename renderer/renderer.go => render/render.go (99%) diff --git a/display/about.go b/display/about.go index bdd3005..88dc991 100644 --- a/display/about.go +++ b/display/about.go @@ -3,7 +3,7 @@ package display import ( "fmt" - "github.com/makeworld-the-better-one/amfora/renderer" + "github.com/makeworld-the-better-one/amfora/render" "github.com/makeworld-the-better-one/amfora/structs" ) @@ -34,7 +34,7 @@ func aboutInit(version, commit, builtBy string) { } func createAboutPage(url string, content string) structs.Page { - renderContent, links := renderer.RenderGemini(content, textWidth(), false) + renderContent, links := render.RenderGemini(content, textWidth(), false) return structs.Page{ Raw: content, Content: renderContent, diff --git a/display/bookmarks.go b/display/bookmarks.go index 116bbe3..c1f9366 100644 --- a/display/bookmarks.go +++ b/display/bookmarks.go @@ -6,7 +6,7 @@ import ( "github.com/gdamore/tcell/v2" "github.com/makeworld-the-better-one/amfora/bookmarks" "github.com/makeworld-the-better-one/amfora/config" - "github.com/makeworld-the-better-one/amfora/renderer" + "github.com/makeworld-the-better-one/amfora/render" "github.com/makeworld-the-better-one/amfora/structs" "github.com/spf13/viper" "gitlab.com/tslocum/cview" @@ -132,7 +132,7 @@ func Bookmarks(t *tab) { bkmkPageRaw += fmt.Sprintf("=> %s %s\r\n", keys[i], m[keys[i]]) } // Render and display - content, links := renderer.RenderGemini(bkmkPageRaw, textWidth(), false) + content, links := render.RenderGemini(bkmkPageRaw, textWidth(), false) page := structs.Page{ Raw: bkmkPageRaw, Content: content, diff --git a/display/display.go b/display/display.go index 268b5b4..59256a2 100644 --- a/display/display.go +++ b/display/display.go @@ -11,7 +11,7 @@ import ( "github.com/gdamore/tcell/v2" "github.com/makeworld-the-better-one/amfora/cache" "github.com/makeworld-the-better-one/amfora/config" - "github.com/makeworld-the-better-one/amfora/renderer" + "github.com/makeworld-the-better-one/amfora/render" "github.com/makeworld-the-better-one/amfora/structs" "github.com/makeworld-the-better-one/go-gemini" "github.com/spf13/viper" @@ -249,7 +249,7 @@ func Init(version, commit, builtBy string) { // Render the default new tab content ONCE and store it for later // This code is repeated in Reload() newTabContent := getNewTabContent() - renderedNewTabContent, newTabLinks := renderer.RenderGemini(newTabContent, textWidth(), false) + renderedNewTabContent, newTabLinks := render.RenderGemini(newTabContent, textWidth(), false) newTabPage = structs.Page{ Raw: newTabContent, Content: renderedNewTabContent, @@ -531,7 +531,7 @@ func Reload() { // Re-render new tab, similar to Init() newTabContent := getNewTabContent() tmpTermW := termW - renderedNewTabContent, newTabLinks := renderer.RenderGemini(newTabContent, textWidth(), false) + renderedNewTabContent, newTabLinks := render.RenderGemini(newTabContent, textWidth(), false) newTabPage = structs.Page{ Raw: newTabContent, Content: renderedNewTabContent, diff --git a/display/file.go b/display/file.go index df9cb59..fdf73f7 100644 --- a/display/file.go +++ b/display/file.go @@ -9,7 +9,7 @@ import ( "path/filepath" "strings" - "github.com/makeworld-the-better-one/amfora/renderer" + "github.com/makeworld-the-better-one/amfora/render" "github.com/makeworld-the-better-one/amfora/structs" "github.com/spf13/viper" ) @@ -59,7 +59,7 @@ func handleFile(u string) (*structs.Page, bool) { } if mimetype == "text/gemini" { - rendered, links := renderer.RenderGemini(string(content), textWidth(), false) + rendered, links := render.RenderGemini(string(content), textWidth(), false) page = &structs.Page{ Mediatype: structs.TextGemini, URL: u, @@ -73,7 +73,7 @@ func handleFile(u string) (*structs.Page, bool) { Mediatype: structs.TextPlain, URL: u, Raw: string(content), - Content: renderer.RenderPlainText(string(content)), + Content: render.RenderPlainText(string(content)), Links: []string{}, TermWidth: termW, } @@ -107,7 +107,7 @@ func createDirectoryListing(u string) (*structs.Page, bool) { content += fmt.Sprintf("=> %s%s %s%s\n", f.Name(), separator, f.Name(), separator) } - rendered, links := renderer.RenderGemini(content, textWidth(), false) + rendered, links := render.RenderGemini(content, textWidth(), false) page = &structs.Page{ Mediatype: structs.TextGemini, URL: u, diff --git a/display/handlers.go b/display/handlers.go index 8f63370..1e68bbd 100644 --- a/display/handlers.go +++ b/display/handlers.go @@ -12,7 +12,7 @@ import ( "github.com/makeworld-the-better-one/amfora/cache" "github.com/makeworld-the-better-one/amfora/client" "github.com/makeworld-the-better-one/amfora/config" - "github.com/makeworld-the-better-one/amfora/renderer" + "github.com/makeworld-the-better-one/amfora/render" "github.com/makeworld-the-better-one/amfora/rr" "github.com/makeworld-the-better-one/amfora/structs" "github.com/makeworld-the-better-one/amfora/subscriptions" @@ -309,14 +309,14 @@ func handleURL(t *tab, u string, numRedirects int) (string, bool) { // Fetch happened successfully, use RestartReader to buffer read data res.Body = rr.NewRestartReader(res.Body) - if renderer.CanDisplay(res) { - page, err := renderer.MakePage(u, res, textWidth(), usingProxy) + if render.CanDisplay(res) { + page, err := render.MakePage(u, res, textWidth(), usingProxy) // Rendering may have taken a while, make sure tab is still valid if !isValidTab(t) { return ret("", false) } - if errors.Is(err, renderer.ErrTooLarge) { + if errors.Is(err, render.ErrTooLarge) { // Downloading now // Disable read timeout and go back to start res.SetReadTimeout(0) //nolint: errcheck @@ -324,7 +324,7 @@ func handleURL(t *tab, u string, numRedirects int) (string, bool) { go dlChoice("That page is too large. What would you like to do?", u, res) return ret("", false) } - if errors.Is(err, renderer.ErrTimedOut) { + if errors.Is(err, render.ErrTimedOut) { // Downloading now // Disable read timeout and go back to start res.SetReadTimeout(0) //nolint: errcheck diff --git a/display/private.go b/display/private.go index 90cd8bd..951d3e6 100644 --- a/display/private.go +++ b/display/private.go @@ -5,7 +5,7 @@ import ( "strconv" "strings" - "github.com/makeworld-the-better-one/amfora/renderer" + "github.com/makeworld-the-better-one/amfora/render" "github.com/makeworld-the-better-one/amfora/structs" ) @@ -52,7 +52,7 @@ func reformatPage(p *structs.Page) { return } - // TODO: Setup a renderer.RenderFromMediatype func so this isn't needed + // TODO: Setup a render.RenderFromMediatype func so this isn't needed var rendered string switch p.Mediatype { @@ -64,11 +64,11 @@ func reformatPage(p *structs.Page) { strings.HasPrefix(p.URL, "file") { proxied = false } - rendered, _ = renderer.RenderGemini(p.Raw, textWidth(), proxied) + rendered, _ = render.RenderGemini(p.Raw, textWidth(), proxied) case structs.TextPlain: - rendered = renderer.RenderPlainText(p.Raw) + rendered = render.RenderPlainText(p.Raw) case structs.TextAnsi: - rendered = renderer.RenderANSI(p.Raw) + rendered = render.RenderANSI(p.Raw) default: // Rendering this type is not implemented return diff --git a/display/subscriptions.go b/display/subscriptions.go index b582dd9..f841611 100644 --- a/display/subscriptions.go +++ b/display/subscriptions.go @@ -12,7 +12,7 @@ import ( "github.com/gdamore/tcell/v2" "github.com/makeworld-the-better-one/amfora/cache" "github.com/makeworld-the-better-one/amfora/config" - "github.com/makeworld-the-better-one/amfora/renderer" + "github.com/makeworld-the-better-one/amfora/render" "github.com/makeworld-the-better-one/amfora/structs" "github.com/makeworld-the-better-one/amfora/subscriptions" "github.com/makeworld-the-better-one/go-gemini" @@ -149,7 +149,7 @@ func Subscriptions(t *tab, u string) string { } } - content, links := renderer.RenderGemini(rawPage, textWidth(), false) + content, links := render.RenderGemini(rawPage, textWidth(), false) page := structs.Page{ Raw: rawPage, Content: content, @@ -191,7 +191,7 @@ func ManageSubscriptions(t *tab, u string) { ) } - content, links := renderer.RenderGemini(rawPage, textWidth(), false) + content, links := render.RenderGemini(rawPage, textWidth(), false) page := structs.Page{ Raw: rawPage, Content: content, diff --git a/renderer/page.go b/render/page.go similarity index 99% rename from renderer/page.go rename to render/page.go index 940a322..750eb36 100644 --- a/renderer/page.go +++ b/render/page.go @@ -1,4 +1,4 @@ -package renderer +package render import ( "bytes" diff --git a/renderer/renderer.go b/render/render.go similarity index 99% rename from renderer/renderer.go rename to render/render.go index 0376fe8..d21bcc2 100644 --- a/renderer/renderer.go +++ b/render/render.go @@ -1,8 +1,8 @@ -// Package renderer provides functions to convert various data into a cview primitive. +// Package render provides functions to convert various data into a cview primitive. // Example objects include a Gemini response, and an error. // // Rendered lines always end with \r\n, in an effort to be Window compatible. -package renderer +package render import ( "fmt"