forked from deanishe/alfred-safari-assistant
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cloud.go
53 lines (40 loc) · 1.25 KB
/
cloud.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
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright (c) 2018 Dean Jackson <[email protected]>
// MIT Licence applies http://opensource.org/licenses/MIT
package main
import (
"fmt"
"log"
aw "github.com/deanishe/awgo"
"github.com/deanishe/go-safari/cloud"
)
func doFilterCloudTabs() error {
showUpdateStatus()
tabs, err := cloud.Tabs()
if err != nil {
return err
}
log.Printf("%d cloud tab(s)", len(tabs))
for _, t := range tabs {
URLerItem(&cloudTabURLer{t})
}
if query != "" {
res := wf.Filter(query)
log.Printf("%d cloud tab(s) for %q", len(res), query)
for i, r := range res {
log.Printf("#%02d %5.2f %q", i+1, r.Score, r.SortKey)
}
}
wf.WarnEmpty("No matching tabs found", "Try a different query?")
wf.SendFeedback()
return nil
}
type cloudTabURLer struct {
tab *cloud.Tab
}
func (u *cloudTabURLer) Title() string { return u.tab.Title }
func (u *cloudTabURLer) Subtitle() string { return fmt.Sprintf("%s // %s", u.tab.Device, u.tab.URL) }
func (u *cloudTabURLer) URL() string { return u.tab.URL }
func (u *cloudTabURLer) UID() string { return u.tab.URL }
func (u *cloudTabURLer) Copytext() string { return u.tab.URL }
func (u *cloudTabURLer) Largetype() string { return u.tab.URL }
func (u *cloudTabURLer) Icon() *aw.Icon { return IconCloud }