Skip to content

Commit b2fbf29

Browse files
author
Nikita Voloboev
committed
icons added
1 parent 1dbae7c commit b2fbf29

File tree

6 files changed

+21
-20
lines changed

6 files changed

+21
-20
lines changed

main.go

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"log"
66
"os"
77
"os/exec"
8+
"strings"
89

910
"git.deanishe.net/deanishe/awgo"
1011
"git.deanishe.net/deanishe/awgo/update"
@@ -28,17 +29,22 @@ Options:
2829
`
2930

3031
var (
32+
// icons
3133
iconAvailable = &aw.Icon{Value: "icons/update.png"}
32-
repo = "nikitavoloboev/alfred-ask-create-share"
33-
wf *aw.Workflow
34+
redditIcon = &aw.Icon{Value: "icons/reddit.png"}
35+
githubIcon = &aw.Icon{Value: "icons/github.png"}
36+
forumsIcon = &aw.Icon{Value: "icons/forums.png"}
37+
stackIcon = &aw.Icon{Value: "icons/stack.png"}
38+
39+
repo = "nikitavoloboev/alfred-ask-create-share"
40+
wf *aw.Workflow
3441
)
3542

3643
func init() {
3744
wf = aw.New(update.GitHub(repo))
3845
}
3946

4047
func run() {
41-
// log.Println(wf.Args())
4248

4349
// Pass wf.Args() to docopt because our update logic relies on
4450
// AwGo's magic actions.
@@ -86,18 +92,19 @@ func run() {
8692
links := parseCSV()
8793

8894
for key, value := range links {
89-
wf.NewItem(key).Valid(true).UID(key).Var("URL", value).Var("ARG", key)
95+
if strings.Contains(key, "r: ") {
96+
wf.NewItem(key).Valid(true).UID(key).Var("URL", value).Var("ARG", key).Icon(redditIcon)
97+
} else if strings.Contains(key, "s: ") {
98+
wf.NewItem(key).Valid(true).UID(key).Var("URL", value).Var("ARG", key).Icon(stackIcon)
99+
} else if strings.Contains(key, "g: ") {
100+
wf.NewItem(key).Valid(true).UID(key).Var("URL", value).Var("ARG", key).Icon(githubIcon)
101+
} else if strings.Contains(key, "f: ") {
102+
wf.NewItem(key).Valid(true).UID(key).Var("URL", value).Var("ARG", key).Icon(forumsIcon)
103+
} else {
104+
wf.NewItem(key).Valid(true).UID(key).Var("URL", value).Var("ARG", key)
105+
}
90106
}
91107

92-
// script filter results
93-
// for i := 1; i <= 20; i++ {
94-
// t := fmt.Sprintf("Item #%d", i)
95-
// wf.NewItem(t).
96-
// Icon(aw.IconFavourite).
97-
// Arg(t).
98-
// Valid(true)
99-
// }
100-
101108
if query != "" {
102109
wf.Filter(query)
103110
}
@@ -106,6 +113,7 @@ func run() {
106113
wf.SendFeedback()
107114
}
108115

116+
// parses CSV of links and arguments
109117
func parseCSV() map[string]string {
110118
var err error
111119

@@ -134,13 +142,6 @@ func parseCSV() map[string]string {
134142

135143
}
136144

137-
// fills Alfred with hash map values and shows keys
138-
func filterResults(links map[string]string) {
139-
140-
// wf.Filter(query)
141-
// wf.SendFeedback()
142-
}
143-
144145
func main() {
145146
wf.Run(run)
146147
}

workflow/alfred-ask-create-share

8.27 KB
Binary file not shown.

workflow/icons/forums.png

10.2 KB
Loading

workflow/icons/github.png

8.44 KB
Loading

workflow/icons/reddit.png

13.8 KB
Loading

workflow/icons/stack.png

19.9 KB
Loading

0 commit comments

Comments
 (0)