mirror of
https://github.com/makew0rld/amfora.git
synced 2024-12-04 14:46:29 -05:00
✨ Give Error modals titles
This commit is contained in:
parent
85a89846bb
commit
92738f54b3
13
NOTES.md
13
NOTES.md
@ -8,14 +8,5 @@
|
||||
- Filed [issue 23](https://gitlab.com/tslocum/cview/-/issues/23)
|
||||
- Text background not reset on ANSI pages
|
||||
- Filed [issue 25](https://gitlab.com/tslocum/cview/-/issues/25)
|
||||
- Inputfield isn't repeatedly in focus
|
||||
- Tried multiple focus options with App and Form funcs, but nothing worked
|
||||
- Modal title does not display
|
||||
- See [my comment](https://gitlab.com/tslocum/cview/-/issues/24#note_364617155)
|
||||
|
||||
## Small todos
|
||||
- Look at Github issues
|
||||
- Look at other todos in code
|
||||
- Add "Why the name amfora" thing to README
|
||||
- Pass `gemini://egsam.pitr.ca/` test
|
||||
- Timeout for server not closing connection?
|
||||
- Modal styling messed up when wrapped - example occurence is the error modal for a long unsupported scheme URL
|
||||
- Filed [issue 26](https://gitlab.com/tslocum/cview/-/issues/26)
|
||||
|
@ -2,8 +2,6 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/makeworld-the-better-one/go-gemini"
|
||||
)
|
||||
|
||||
@ -12,7 +10,7 @@ import (
|
||||
func Fetch(url string) (*gemini.Response, error) {
|
||||
resp, err := gemini.Fetch(url)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("URL could not be fetched: %v", err)
|
||||
return nil, err
|
||||
}
|
||||
ok := handleTofu(resp.Cert)
|
||||
if !ok {
|
||||
|
@ -54,8 +54,8 @@ func modalInit() {
|
||||
|
||||
errorModal.SetBorder(true)
|
||||
errorModal.SetBorderColor(tcell.ColorWhite)
|
||||
errorModal.SetTitleColor(tcell.ColorWhite)
|
||||
errorModal.SetTitleAlign(cview.AlignCenter)
|
||||
errorModal.GetFrame().SetTitleColor(tcell.ColorWhite)
|
||||
errorModal.GetFrame().SetTitleAlign(cview.AlignCenter)
|
||||
errorModal.SetDoneFunc(func(buttonIndex int, buttonLabel string) {
|
||||
tabPages.SwitchToPage(strconv.Itoa(curTab))
|
||||
})
|
||||
@ -96,8 +96,7 @@ func Error(title, text string) {
|
||||
// Add spaces to title for aesthetic reasons
|
||||
title = " " + strings.TrimSpace(title) + " "
|
||||
|
||||
errorModal.GetFrame().Clear()
|
||||
errorModal.GetFrame().AddText(title, true, cview.AlignCenter, tcell.ColorWhite)
|
||||
errorModal.GetFrame().SetTitle(title)
|
||||
errorModal.SetText(text)
|
||||
tabPages.ShowPage("error")
|
||||
tabPages.SendToFront("error")
|
||||
|
@ -60,7 +60,7 @@ func followLink(prev, next string) {
|
||||
prevParsed, _ := url.Parse(prev)
|
||||
nextParsed, err := url.Parse(next)
|
||||
if err != nil {
|
||||
Error("Error", "Link URL could not be parsed")
|
||||
Error("URL Error", "Link URL could not be parsed")
|
||||
return
|
||||
}
|
||||
nextURL := prevParsed.ResolveReference(nextParsed).String()
|
||||
@ -116,11 +116,11 @@ func handleURL(u string) (string, bool) {
|
||||
if strings.HasPrefix(u, "http") {
|
||||
switch strings.TrimSpace(viper.GetString("a-general.http")) {
|
||||
case "", "off":
|
||||
Error("Error", "Opening HTTP URLs is turned off.")
|
||||
Info("Opening HTTP URLs is turned off.")
|
||||
case "default":
|
||||
s, err := webbrowser.Open(u)
|
||||
if err != nil {
|
||||
Error("Error", err.Error())
|
||||
Error("Webbrowser Error", err.Error())
|
||||
} else {
|
||||
Info(s)
|
||||
}
|
||||
@ -129,15 +129,14 @@ func handleURL(u string) (string, bool) {
|
||||
fields := strings.Fields(viper.GetString("a-general.http"))
|
||||
err := exec.Command(fields[0], append(fields[1:], u)...).Start()
|
||||
if err != nil {
|
||||
Error("Error", err.Error())
|
||||
Error("HTTP Error", "Error executing custom browser command: "+err.Error())
|
||||
}
|
||||
}
|
||||
bottomBar.SetText(tabMap[curTab].Url)
|
||||
return "", false
|
||||
}
|
||||
if !strings.HasPrefix(u, "gemini") {
|
||||
// TODO: Replace it with with displaying the URL, once modal titles work
|
||||
Error("Error", "Unsupported protocol, only [::b]gemini[::-] and [::b]http[::-] are supported.")
|
||||
Error("Protocol Error", "Only [::b]gemini[::-] and [::b]http[::-] are supported. URL was "+u)
|
||||
bottomBar.SetText(tabMap[curTab].Url)
|
||||
return "", false
|
||||
}
|
||||
@ -155,7 +154,7 @@ func handleURL(u string) (string, bool) {
|
||||
|
||||
res, err := client.Fetch(u)
|
||||
if err != nil {
|
||||
Error("Error", err.Error())
|
||||
Error("URL Fetch Error", err.Error())
|
||||
// Set the bar back to original URL
|
||||
bottomBar.SetText(tabMap[curTab].Url)
|
||||
return "", false
|
||||
@ -163,7 +162,7 @@ func handleURL(u string) (string, bool) {
|
||||
if renderer.CanDisplay(res) {
|
||||
page, err := renderer.MakePage(u, res)
|
||||
if err != nil {
|
||||
Error("Error", "Issuing creating page: "+err.Error())
|
||||
Error("Page Error", "Issuing creating page: "+err.Error())
|
||||
// Set the bar back to original URL
|
||||
bottomBar.SetText(tabMap[curTab].Url)
|
||||
return "", false
|
||||
@ -227,7 +226,7 @@ func handleURL(u string) (string, bool) {
|
||||
|
||||
s, err := webbrowser.Open("https://portal.mozz.us/gemini/" + portalURL)
|
||||
if err != nil {
|
||||
Error("Error", err.Error())
|
||||
Error("Webbrowser Error", err.Error())
|
||||
} else {
|
||||
Info(s)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user