38 lines
780 B
Go
38 lines
780 B
Go
|
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)
|
||
|
}
|