mirror of
https://github.com/makew0rld/amfora.git
synced 2024-12-04 14:46:29 -05:00
🐛 Fixes #81
This commit is contained in:
parent
eb10c26599
commit
b7efbdaeea
@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- XDG user dir file is parsed instead of looking for XDG env vars (#97, #100)
|
||||
- Support paths with spaces in HTTP browser config setting (#77)
|
||||
- Clicking "Change" on an existing bookmark without changing the text no longer removes it (#91)
|
||||
- Display HTTP Error if "Open In Portal" fails (#81)
|
||||
|
||||
|
||||
## [v1.5.0] - 2020-09-01
|
||||
|
@ -117,10 +117,12 @@ func dlChoice(text, u string, resp *gemini.Response) {
|
||||
portalURL = parsed.String() + "%3F" + query
|
||||
}
|
||||
portalURL = strings.TrimPrefix(portalURL, "gemini://") + "?raw=1"
|
||||
handleHTTP("https://portal.mozz.us/gemini/"+portalURL, false)
|
||||
tabPages.SwitchToPage(strconv.Itoa(curTab))
|
||||
App.SetFocus(tabs[curTab].view)
|
||||
App.Draw()
|
||||
ok := handleHTTP("https://portal.mozz.us/gemini/"+portalURL, false)
|
||||
if ok {
|
||||
tabPages.SwitchToPage(strconv.Itoa(curTab))
|
||||
App.SetFocus(tabs[curTab].view)
|
||||
App.Draw()
|
||||
}
|
||||
return
|
||||
}
|
||||
tabPages.SwitchToPage(strconv.Itoa(curTab))
|
||||
|
@ -145,35 +145,42 @@ func setPage(t *tab, p *structs.Page) {
|
||||
|
||||
// handleHTTP is used by handleURL.
|
||||
// It opens HTTP links and displays Info and Error modals.
|
||||
func handleHTTP(u string, showInfo bool) {
|
||||
// Returns false if there was an error.
|
||||
func handleHTTP(u string, showInfo bool) bool {
|
||||
if len(config.HTTPCommand) == 1 {
|
||||
// Possibly a non-command
|
||||
|
||||
switch strings.TrimSpace(config.HTTPCommand[0]) {
|
||||
case "", "off":
|
||||
Error("HTTP Error", "Opening HTTP URLs is turned off.")
|
||||
return false
|
||||
case "default":
|
||||
s, err := webbrowser.Open(u)
|
||||
if err != nil {
|
||||
Error("Webbrowser Error", err.Error())
|
||||
} else if showInfo {
|
||||
return false
|
||||
}
|
||||
if showInfo {
|
||||
Info(s)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Custom command
|
||||
var err error = nil
|
||||
if len(config.HTTPCommand) > 1 {
|
||||
err = exec.Command(config.HTTPCommand[0], append(config.HTTPCommand[1:], u)...).Start()
|
||||
} else {
|
||||
err = exec.Command(config.HTTPCommand[0], u).Start()
|
||||
}
|
||||
if err != nil {
|
||||
Error("HTTP Error", "Error executing custom browser command: "+err.Error())
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
// Custom command
|
||||
var err error = nil
|
||||
if len(config.HTTPCommand) > 1 {
|
||||
err = exec.Command(config.HTTPCommand[0], append(config.HTTPCommand[1:], u)...).Start()
|
||||
} else {
|
||||
err = exec.Command(config.HTTPCommand[0], u).Start()
|
||||
}
|
||||
if err != nil {
|
||||
Error("HTTP Error", "Error executing custom browser command: "+err.Error())
|
||||
return false
|
||||
}
|
||||
|
||||
App.Draw()
|
||||
return true
|
||||
}
|
||||
|
||||
// handleOther is used by handleURL.
|
||||
|
Loading…
Reference in New Issue
Block a user