Homepage and search engine can now be set in a configuration file
This commit is contained in:
parent
c9cbc2acb1
commit
57b6bd2f8d
@ -1,5 +1,6 @@
|
||||
package main
|
||||
|
||||
import "net/url"
|
||||
import "git.tebibyte.media/sashakoshka/stone"
|
||||
import "git.tebibyte.media/sashakoshka/skipper/bookmarks"
|
||||
|
||||
@ -55,7 +56,11 @@ var bindings = map[bindingKey] func () {
|
||||
|
||||
bindingKey {
|
||||
button: stone.Button('h'),
|
||||
}: func () { fetch(bookmarks.HomePage.Location) },
|
||||
}: func () {
|
||||
location, _ := url.Parse (
|
||||
browserConfig.Parameters["homePage"].(string))
|
||||
go fetch(location)
|
||||
},
|
||||
|
||||
bindingKey {
|
||||
button: stone.Button('0'),
|
||||
|
@ -16,9 +16,6 @@ type Bookmark struct {
|
||||
Location *url.URL
|
||||
}
|
||||
|
||||
var HomePage = New("Home", "about:home")
|
||||
var SearchEngine = New("Search", "gemini://geminispace.info:1965/search/")
|
||||
|
||||
var bookmarks []Bookmark
|
||||
|
||||
func Gemtext () (page string) {
|
||||
|
24
main.go
24
main.go
@ -5,7 +5,6 @@ package main
|
||||
|
||||
import "git.tebibyte.media/sashakoshka/skipper/dom"
|
||||
import "git.tebibyte.media/sashakoshka/skipper/input"
|
||||
import "git.tebibyte.media/sashakoshka/skipper/bookmarks"
|
||||
|
||||
import "os"
|
||||
import "fmt"
|
||||
@ -19,6 +18,7 @@ import _ "embed"
|
||||
import _ "image/png"
|
||||
import "git.sr.ht/~yotam/go-gemini"
|
||||
import "git.tebibyte.media/sashakoshka/stone"
|
||||
import "git.tebibyte.media/sashakoshka/stone/config"
|
||||
import _ "git.tebibyte.media/sashakoshka/stone/backends/x"
|
||||
|
||||
//go:embed icon/icon64.png
|
||||
@ -27,6 +27,18 @@ var iconBytes []byte
|
||||
var application = &stone.Application { }
|
||||
var client = gemini.Client { InsecureSkipVerify: true }
|
||||
|
||||
var browserConfig = config.Config {
|
||||
LegalParameters: map[string] config.Type {
|
||||
"homePage": config.TypeString,
|
||||
"searchEngine": config.TypeString,
|
||||
},
|
||||
|
||||
Parameters: map[string] any {
|
||||
"homePage": "about:home",
|
||||
"searchEngine": "gemini://geminispace.info:1965/search/",
|
||||
},
|
||||
}
|
||||
|
||||
var page struct {
|
||||
history History
|
||||
|
||||
@ -91,7 +103,8 @@ func main () {
|
||||
}
|
||||
|
||||
func onStart () {
|
||||
go fetch(bookmarks.HomePage.Location)
|
||||
location, _ := url.Parse(browserConfig.Parameters["homePage"].(string))
|
||||
go fetch(location)
|
||||
}
|
||||
|
||||
func onResize () {
|
||||
@ -190,7 +203,9 @@ func onUrlBarDone () {
|
||||
} else if strings.HasPrefix(inputText, "gemini://") {
|
||||
location, err := url.Parse(inputText)
|
||||
if err != nil {
|
||||
location := bookmarks.SearchEngine.Location.JoinPath("")
|
||||
location, _ := url.Parse (
|
||||
browserConfig.Parameters["searchEngine"].
|
||||
(string))
|
||||
location.RawQuery = inputText
|
||||
go fetch(location)
|
||||
return
|
||||
@ -198,7 +213,8 @@ func onUrlBarDone () {
|
||||
go fetch(location)
|
||||
|
||||
} else {
|
||||
location := bookmarks.SearchEngine.Location.JoinPath("")
|
||||
location, _ := url.Parse (
|
||||
browserConfig.Parameters["searchEngine"].(string))
|
||||
location.RawQuery = inputText
|
||||
go fetch(location)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user