skipper/bookmarks/bookmarks.go

38 lines
780 B
Go
Raw Normal View History

2022-11-26 09:44:07 -07:00
package bookmarks
import "net/url"
type Bookmark struct {
Title string
Location *url.URL
}
var HomePage = New("Home", "about:home")
var SearchEngine = New("Search", "gemini://geminispace.info:1965/search/")
var bookmarks = []Bookmark {
New("Project Gemini", "gemini://gemini.circumlunar.space:1965/"),
New("Search", "gemini://geminispace.info:1965/search/"),
}
func Gemtext () (page string) {
page += "# Bookmarks\n"
for _, bookmark := range bookmarks {
page +=
"=> " + bookmark.Location.String() +
" " + bookmark.Title + "\n"
}
return
}
func New (title, location string) (bookmark Bookmark) {
bookmark.Title = title
bookmark.Location, _ = url.Parse(location)
return
}
func Add (bookmark Bookmark) {
bookmarks = append(bookmarks, bookmark)
}