1
0
mirror of https://github.com/makew0rld/amfora.git synced 2024-06-15 19:15:24 +00:00

about:version page

Fixes #126
This commit is contained in:
makeworld 2020-12-20 16:39:33 -05:00
parent b6ad49dfb0
commit 8ec9bb780c
4 changed files with 23 additions and 2 deletions

View File

@ -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

View File

@ -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()

View File

@ -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()
})

View File

@ -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?") {