-
Notifications
You must be signed in to change notification settings - Fork 38
/
defaults.go
40 lines (36 loc) · 1.19 KB
/
defaults.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package main
import (
"net/http/httptest"
)
// DefaultBookmarks ...
var DefaultBookmarks map[string]string
func init() {
DefaultBookmarks = map[string]string{
"g": "https://www.google.com/search?q=%s&btnK",
"gl": "https://www.google.com/search?q=%s&btnI",
"gh": "https://github.com/search?q=%s&ref=opensearch",
"go": "https://golang.org/search?q=%s",
"wp": "http://en.wikipedia.org/?search=%s",
"py": "https://docs.python.org/2/search.html?q=%s",
"py3": "https://docs.python.org/3/search.html?q=%s",
"yt": "http://www.youtube.com/results?search_type=search_videos&search_sort=relevance&search_query=%s&search=Search",
"gim": "https://www.google.com/search?q=%s&um=1&ie=UTF-8&hl=en&tbm=isch",
"gdef": "http://www.google.com/search?q=define%3A+%s&hl=en&lr=&oi=definel&defl=all",
"imdb": "http://www.imdb.com/find?q=%s",
"gm": "http://maps.google.com/maps?q=%s",
}
}
// EnsureDefaultBookmarks ...
func EnsureDefaultBookmarks() error {
for k, v := range DefaultBookmarks {
if _, ok := LookupBookmark(k); !ok {
w := httptest.NewRecorder()
args := []string{k, v}
add := Add{}
if err := add.Exec(w, args); err != nil {
return err
}
}
}
return nil
}