mirror of
https://github.com/makeworld-the-better-one/amfora.git
synced 2024-11-22 15:46:51 +03:00
🐛 Fixes #77
This commit is contained in:
parent
424ce099dd
commit
b3482d3a09
@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
### Fixed
|
||||
- XDG user dir file is parsed instead of looking for XDG env vars (#97, #100)
|
||||
- Support paths in HTTP(S) browser config setting (#77)
|
||||
|
||||
|
||||
## [v1.5.0] - 2020-09-01
|
||||
|
@ -38,6 +38,9 @@ var bkmkPath string
|
||||
|
||||
var DownloadsDir string
|
||||
|
||||
// Command for opening HTTP(S) URLs in the browser, from "a-general.http" in config.
|
||||
var HttpCommand []string
|
||||
|
||||
//nolint:golint,goerr113
|
||||
func Init() error {
|
||||
|
||||
@ -237,5 +240,14 @@ func Init() error {
|
||||
cview.Styles.PrimitiveBackgroundColor = GetColor("bg")
|
||||
} // Otherwise it's black by default
|
||||
|
||||
// Parse HTTP command
|
||||
HttpCommand = viper.GetStringSlice("a-general.http")
|
||||
if len(HttpCommand) == 0 {
|
||||
// Not a string array, interpret as a string instead
|
||||
// Split on spaces to maintain compatibility with old versions
|
||||
// The new better way to is to just define a string array in config
|
||||
HttpCommand = strings.Fields(viper.GetString("a-general.http"))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -21,10 +21,20 @@ home = "gemini://gemini.circumlunar.space"
|
||||
# If set to false, a prompt will be shown before following redirects.
|
||||
auto_redirect = false
|
||||
|
||||
# What command to run to open a HTTP(S) URL. Set to "default" to try to guess the browser,
|
||||
# or set to "off" to not open HTTP(S) URLs.
|
||||
# What command to run to open a HTTP(S) URL.
|
||||
# Set to "default" to try to guess the browser, or set to "off" to not open HTTP(S) URLs.
|
||||
# If a command is set, than the URL will be added (in quotes) to the end of the command.
|
||||
# A space will be prepended if necessary.
|
||||
# A space will be prepended to the URL.
|
||||
#
|
||||
# The best to define a command is using a string array.
|
||||
# Examples:
|
||||
# http = ["firefox"]
|
||||
# http = ["custom-browser", "--flag", "--option=2"]
|
||||
# http = ["/path/with spaces/in it/firefox"]
|
||||
#
|
||||
# Using just a string will also work, but it is deprecated,
|
||||
# and will degrade if you use paths with spaces.
|
||||
|
||||
http = "default"
|
||||
|
||||
# Any URL that will accept a query string can be put here
|
||||
|
@ -18,10 +18,20 @@ home = "gemini://gemini.circumlunar.space"
|
||||
# If set to false, a prompt will be shown before following redirects.
|
||||
auto_redirect = false
|
||||
|
||||
# What command to run to open a HTTP(S) URL. Set to "default" to try to guess the browser,
|
||||
# or set to "off" to not open HTTP(S) URLs.
|
||||
# What command to run to open a HTTP(S) URL.
|
||||
# Set to "default" to try to guess the browser, or set to "off" to not open HTTP(S) URLs.
|
||||
# If a command is set, than the URL will be added (in quotes) to the end of the command.
|
||||
# A space will be prepended if necessary.
|
||||
# A space will be prepended to the URL.
|
||||
#
|
||||
# The best to define a command is using a string array.
|
||||
# Examples:
|
||||
# http = ["firefox"]
|
||||
# http = ["custom-browser", "--flag", "--option=2"]
|
||||
# http = ["/path/with spaces/in it/firefox"]
|
||||
#
|
||||
# Using just a string will also work, but it is deprecated,
|
||||
# and will degrade if you use paths with spaces.
|
||||
|
||||
http = "default"
|
||||
|
||||
# Any URL that will accept a query string can be put here
|
||||
|
@ -146,24 +146,33 @@ 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) {
|
||||
switch strings.TrimSpace(viper.GetString("a-general.http")) {
|
||||
case "", "off":
|
||||
Error("HTTP Error", "Opening HTTP URLs is turned off.")
|
||||
case "default":
|
||||
s, err := webbrowser.Open(u)
|
||||
if err != nil {
|
||||
Error("Webbrowser Error", err.Error())
|
||||
} else if showInfo {
|
||||
Info(s)
|
||||
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.")
|
||||
case "default":
|
||||
s, err := webbrowser.Open(u)
|
||||
if err != nil {
|
||||
Error("Webbrowser Error", err.Error())
|
||||
} else 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()
|
||||
}
|
||||
default:
|
||||
// The config has a custom command to execute for HTTP URLs
|
||||
fields := strings.Fields(viper.GetString("a-general.http"))
|
||||
err := exec.Command(fields[0], append(fields[1:], u)...).Start()
|
||||
if err != nil {
|
||||
Error("HTTP Error", "Error executing custom browser command: "+err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
App.Draw()
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user