Merge branch 'default-scheme' of sloum/bombadillo into develop

This commit is contained in:
Sloom Sloum Sluom IV 2019-12-08 01:23:29 -05:00 committed by Gitea
commit 786784bf4f
4 changed files with 11 additions and 4 deletions

View File

@ -210,6 +210,10 @@ configlocation
The path to the directory that the \fI.bombadillo.ini\fP configuration file is stored in. This is a \fBread only\fP setting and cannot be changed with the \fIset\fP command, but it can be read with the \fIcheck\fP command.
.TP
.B
defaultscheme
The scheme that should be used when no scheme is present in a given URL. \fIgopher\fP, \fIgemini\fP, \fIhttp\fP, and \fIhttps\fP are valid values.
.TP
.B
homeurl
The url that \fBbombadillo\fP navigates to when the program loads or when the \fIhome\fP or \fIh\fP LINE COMMAND is issued. This should be a valid url. If a scheme/protocol is not included, gopher will be assumed.
.TP

View File

@ -50,6 +50,7 @@ var defaultOptions = map[string]string{
"searchengine": "gopher://gopher.floodgap.com:70/7/v2/vs",
"telnetcommand": "telnet",
"configlocation": xdgConfigPath(),
"defaultscheme": "gopher", // "gopher", "gemini", "http", "https"
"theme": "normal", // "normal", "inverted"
"tlscertificate": "",
"tlskey": "",

View File

@ -66,8 +66,9 @@ func saveConfig() error {
func validateOpt(opt, val string) bool {
var validOpts = map[string][]string{
"webmode": []string{"none", "gui", "lynx", "w3m", "elinks"},
"theme": []string{"normal", "inverse"},
"webmode": []string{"none", "gui", "lynx", "w3m", "elinks"},
"theme": []string{"normal", "inverse"},
"defaultscheme": []string{"gopher", "gemini", "http", "https"},
}
opt = strings.ToLower(opt)
@ -86,7 +87,7 @@ func validateOpt(opt, val string) bool {
func lowerCaseOpt(opt, val string) string {
switch opt {
case "webmode", "theme":
case "webmode", "theme", "defaultscheme":
return strings.ToLower(val)
default:
return val

3
url.go
View File

@ -44,6 +44,7 @@ func MakeUrl(u string) (Url, error) {
if len(u) < 1 {
return Url{}, fmt.Errorf("Invalid url, unable to parse")
}
if strings.HasPrefix(u, "finger://") {
return parseFinger(u)
}
@ -103,7 +104,7 @@ func MakeUrl(u string) (Url, error) {
out.Scheme = strings.ToLower(out.Scheme)
if out.Scheme == "" {
out.Scheme = "gopher"
out.Scheme = bombadillo.Options["defaultscheme"]
}
if out.Scheme == "gopher" && out.Port == "" {