From 8ec9bb780c7998a0854a77cf2d25560b8e36b54c Mon Sep 17 00:00:00 2001 From: makeworld Date: Sun, 20 Dec 2020 16:39:33 -0500 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20about:version=20page?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #126 --- CHANGELOG.md | 1 + amfora.go | 2 +- display/display.go | 17 ++++++++++++++++- display/handlers.go | 5 +++++ 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 11ff8c3..908a6b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - URLs are NFC-normalized before any processing (#138) - Links to the wiki in the new tab - Cache times out after 30 minutes by default (#110) +- `about:version` page (#126) ### Changed - Updated [go-gemini](https://github.com/makeworld-the-better-one/go-gemini) to v0.11.0 diff --git a/amfora.go b/amfora.go index 62e2c6d..650c041 100644 --- a/amfora.go +++ b/amfora.go @@ -52,7 +52,7 @@ func main() { client.Init() - display.Init() + display.Init(version, commit, builtBy) display.NewTab() display.NewTab() // Open extra tab and close it to fully initialize the app and wrapping display.CloseTab() diff --git a/display/display.go b/display/display.go index a50bf65..21855dd 100644 --- a/display/display.go +++ b/display/display.go @@ -59,6 +59,7 @@ var layout = cview.NewFlex(). SetDirection(cview.FlexRow) var newTabPage structs.Page +var versionPage structs.Page var App = cview.NewApplication(). EnableMouse(false). @@ -77,7 +78,21 @@ var App = cview.NewApplication(). }(tabs[curTab]) }) -func Init() { +func Init(version, commit, builtBy string) { + versionContent := fmt.Sprintf( + "# Amfora Version Info\n\nAmfora: %s\nCommit: %s\nBuilt by: %s", + version, commit, builtBy, + ) + renderVersionContent, versionLinks := renderer.RenderGemini(versionContent, textWidth(), leftMargin(), false) + versionPage = structs.Page{ + Raw: versionContent, + Content: renderVersionContent, + Links: versionLinks, + URL: "about:version", + Width: -1, // Force reformatting on first display + Mediatype: structs.TextGemini, + } + tabRow.SetChangedFunc(func() { App.Draw() }) diff --git a/display/handlers.go b/display/handlers.go index 5f99eeb..21e3af3 100644 --- a/display/handlers.go +++ b/display/handlers.go @@ -187,6 +187,11 @@ func handleAbout(t *tab, u string) (string, bool) { setPage(t, &temp) t.applyBottomBar() return u, true + case "about:version": + temp := versionPage + setPage(t, &temp) + t.applyBottomBar() + return u, true } if u == "about:subscriptions" || (len(u) > 20 && u[:20] == "about:subscriptions?") {