Skip to content

Commit

Permalink
fuzzy search working
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitavoloboev committed Aug 12, 2017
1 parent 86b5719 commit 95d1308
Show file tree
Hide file tree
Showing 5 changed files with 278 additions and 30 deletions.
8 changes: 7 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ var (
// script options (populated by kingpin application)
searchURL *url.URL
maxResults int
query string

// workflow
wf *aw.Workflow
Expand All @@ -38,6 +39,10 @@ func init() {

filterWebsitesCmd = app.Command("websites", "filters websites").Alias("fl")

for _, cmd := range []*kingpin.CmdClause{filterWebsitesCmd} {
cmd.Flag("query", "search query").Short('q').StringVar(&query)
}

// list action commands
app.DefaultEnvars()
}
Expand All @@ -50,10 +55,11 @@ func filterWebsites(links map[string]string) {
var re = regexp.MustCompile(`.: `)

for key, value := range links {
wf.NewItem(key).Valid(true).Var("URL", value).Var("ARG", re.ReplaceAllString(key, ``)).SortKey(key)
wf.NewItem(key).Valid(true).Var("URL", value).Var("ARG", re.ReplaceAllString(key, ``))
log.Println(key)
log.Println(value)
}
wf.Filter(query)
wf.SendFeedback()
}

Expand Down
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Each search has a prefix to signify the theme or scope of the search. For exampl
| g: | search GitHub |
| s: | search stack exchange sites |
| f: | search forums |
| t: | search Google Translate |
| w: | search ordinary websites (none of the above) |


Expand Down
Binary file modified workflow/alfred-web-searches
Binary file not shown.
127 changes: 102 additions & 25 deletions workflow/info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,19 @@
<string>mine</string>
<key>connections</key>
<dict>
<key>0B629748-2068-4345-BA43-5772F37C3013</key>
<array>
<dict>
<key>destinationuid</key>
<string>64553C43-17D7-47DB-9683-2EF6A128F514</string>
<key>modifiers</key>
<integer>0</integer>
<key>modifiersubtext</key>
<string></string>
<key>vitoclose</key>
<false/>
</dict>
</array>
<key>12976163-3ECA-4242-AA2F-049100EE88ED</key>
<array>
<dict>
Expand Down Expand Up @@ -46,6 +59,16 @@
<key>vitoclose</key>
<false/>
</dict>
<dict>
<key>destinationuid</key>
<string>0B629748-2068-4345-BA43-5772F37C3013</string>
<key>modifiers</key>
<integer>262144</integer>
<key>modifiersubtext</key>
<string></string>
<key>vitoclose</key>
<false/>
</dict>
</array>
<key>C94BCEFA-1DEE-4E57-AADB-25226571390C</key>
<array>
Expand Down Expand Up @@ -97,6 +120,25 @@
<key>version</key>
<integer>1</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>argumenttype</key>
<integer>0</integer>
<key>subtext</key>
<string></string>
<key>text</key>
<string>search {var:ARG} for {query}</string>
<key>withspace</key>
<true/>
</dict>
<key>type</key>
<string>alfred.workflow.input.keyword</string>
<key>uid</key>
<string>9B873AF1-35BA-49E8-B24D-12F7FABB9DDF</string>
<key>version</key>
<integer>1</integer>
</dict>
<dict>
<key>config</key>
<dict>
Expand All @@ -105,9 +147,7 @@
<key>escaping</key>
<integer>102</integer>
<key>script</key>
<string>query=$1
echo -n ${URL/tester/$query}</string>
<string>echo -n ${URL/tester/$1}</string>
<key>scriptargtype</key>
<integer>1</integer>
<key>scriptfile</key>
Expand Down Expand Up @@ -141,25 +181,6 @@ echo -n ${URL/tester/$query}</string>
<key>version</key>
<integer>1</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>argumenttype</key>
<integer>0</integer>
<key>subtext</key>
<string></string>
<key>text</key>
<string>search {var:ARG} for {query}</string>
<key>withspace</key>
<true/>
</dict>
<key>type</key>
<string>alfred.workflow.input.keyword</string>
<key>uid</key>
<string>9B873AF1-35BA-49E8-B24D-12F7FABB9DDF</string>
<key>version</key>
<integer>1</integer>
</dict>
<dict>
<key>config</key>
<dict>
Expand All @@ -182,7 +203,7 @@ echo -n ${URL/tester/$query}</string>
<key>runningsubtext</key>
<string></string>
<key>script</key>
<string>./alfred-web-searches websites</string>
<string>./alfred-web-searches websites -q "$1"</string>
<key>scriptargtype</key>
<integer>1</integer>
<key>scriptfile</key>
Expand Down Expand Up @@ -234,11 +255,60 @@ echo -n ${URL/tester/$query}</string>
<key>version</key>
<integer>2</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>browser</key>
<string>com.google.Chrome</string>
<key>spaces</key>
<string></string>
<key>url</key>
<string>{query}</string>
<key>utf8</key>
<true/>
</dict>
<key>type</key>
<string>alfred.workflow.action.openurl</string>
<key>uid</key>
<string>64553C43-17D7-47DB-9683-2EF6A128F514</string>
<key>version</key>
<integer>1</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>concurrently</key>
<false/>
<key>escaping</key>
<integer>102</integer>
<key>script</key>
<string>echo -n ${URL/tester/$1}</string>
<key>scriptargtype</key>
<integer>1</integer>
<key>scriptfile</key>
<string></string>
<key>type</key>
<integer>0</integer>
</dict>
<key>type</key>
<string>alfred.workflow.action.script</string>
<key>uid</key>
<string>0B629748-2068-4345-BA43-5772F37C3013</string>
<key>version</key>
<integer>2</integer>
</dict>
</array>
<key>readme</key>
<string></string>
<key>uidata</key>
<dict>
<key>0B629748-2068-4345-BA43-5772F37C3013</key>
<dict>
<key>xpos</key>
<integer>610</integer>
<key>ypos</key>
<integer>180</integer>
</dict>
<key>12976163-3ECA-4242-AA2F-049100EE88ED</key>
<dict>
<key>xpos</key>
Expand All @@ -253,6 +323,13 @@ echo -n ${URL/tester/$query}</string>
<key>ypos</key>
<integer>40</integer>
</dict>
<key>64553C43-17D7-47DB-9683-2EF6A128F514</key>
<dict>
<key>xpos</key>
<integer>780</integer>
<key>ypos</key>
<integer>180</integer>
</dict>
<key>9B873AF1-35BA-49E8-B24D-12F7FABB9DDF</key>
<dict>
<key>xpos</key>
Expand All @@ -263,14 +340,14 @@ echo -n ${URL/tester/$query}</string>
<key>A16C9145-6939-48CC-8054-EF9FD220B697</key>
<dict>
<key>xpos</key>
<integer>740</integer>
<integer>800</integer>
<key>ypos</key>
<integer>40</integer>
</dict>
<key>C94BCEFA-1DEE-4E57-AADB-25226571390C</key>
<dict>
<key>xpos</key>
<integer>570</integer>
<integer>610</integer>
<key>ypos</key>
<integer>40</integer>
</dict>
Expand Down
Loading

0 comments on commit 95d1308

Please sign in to comment.