Adds an option to set a default scheme
This commit is contained in:
parent
3a226f3769
commit
d5ff5694d4
|
@ -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.
|
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
|
.TP
|
||||||
.B
|
.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
|
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.
|
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
|
.TP
|
||||||
|
|
|
@ -50,6 +50,7 @@ var defaultOptions = map[string]string{
|
||||||
"searchengine": "gopher://gopher.floodgap.com:70/7/v2/vs",
|
"searchengine": "gopher://gopher.floodgap.com:70/7/v2/vs",
|
||||||
"telnetcommand": "telnet",
|
"telnetcommand": "telnet",
|
||||||
"configlocation": xdgConfigPath(),
|
"configlocation": xdgConfigPath(),
|
||||||
|
"defaultscheme": "gopher", // "gopher", "gemini", "http", "https"
|
||||||
"theme": "normal", // "normal", "inverted"
|
"theme": "normal", // "normal", "inverted"
|
||||||
"tlscertificate": "",
|
"tlscertificate": "",
|
||||||
"tlskey": "",
|
"tlskey": "",
|
||||||
|
|
7
main.go
7
main.go
|
@ -66,8 +66,9 @@ func saveConfig() error {
|
||||||
|
|
||||||
func validateOpt(opt, val string) bool {
|
func validateOpt(opt, val string) bool {
|
||||||
var validOpts = map[string][]string{
|
var validOpts = map[string][]string{
|
||||||
"webmode": []string{"none", "gui", "lynx", "w3m", "elinks"},
|
"webmode": []string{"none", "gui", "lynx", "w3m", "elinks"},
|
||||||
"theme": []string{"normal", "inverse"},
|
"theme": []string{"normal", "inverse"},
|
||||||
|
"defaultscheme": []string{"gopher", "gemini", "http", "https"},
|
||||||
}
|
}
|
||||||
|
|
||||||
opt = strings.ToLower(opt)
|
opt = strings.ToLower(opt)
|
||||||
|
@ -86,7 +87,7 @@ func validateOpt(opt, val string) bool {
|
||||||
|
|
||||||
func lowerCaseOpt(opt, val string) string {
|
func lowerCaseOpt(opt, val string) string {
|
||||||
switch opt {
|
switch opt {
|
||||||
case "webmode", "theme":
|
case "webmode", "theme", "defaultscheme":
|
||||||
return strings.ToLower(val)
|
return strings.ToLower(val)
|
||||||
default:
|
default:
|
||||||
return val
|
return val
|
||||||
|
|
3
url.go
3
url.go
|
@ -44,6 +44,7 @@ func MakeUrl(u string) (Url, error) {
|
||||||
if len(u) < 1 {
|
if len(u) < 1 {
|
||||||
return Url{}, fmt.Errorf("Invalid url, unable to parse")
|
return Url{}, fmt.Errorf("Invalid url, unable to parse")
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.HasPrefix(u, "finger://") {
|
if strings.HasPrefix(u, "finger://") {
|
||||||
return parseFinger(u)
|
return parseFinger(u)
|
||||||
}
|
}
|
||||||
|
@ -103,7 +104,7 @@ func MakeUrl(u string) (Url, error) {
|
||||||
out.Scheme = strings.ToLower(out.Scheme)
|
out.Scheme = strings.ToLower(out.Scheme)
|
||||||
|
|
||||||
if out.Scheme == "" {
|
if out.Scheme == "" {
|
||||||
out.Scheme = "gopher"
|
out.Scheme = bombadillo.Options["defaultscheme"]
|
||||||
}
|
}
|
||||||
|
|
||||||
if out.Scheme == "gopher" && out.Port == "" {
|
if out.Scheme == "gopher" && out.Port == "" {
|
||||||
|
|
Loading…
Reference in New Issue