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