Skip to content

Commit

Permalink
allow non-ascii characters
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbro committed Jun 24, 2017
1 parent 97959a6 commit a9c9a2f
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 39 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ To install, download a [released alfred-bear workflow](https://github.com/chrisb
## Versions

**0.2.0**
* Now allows non-ASCII characters.
* Searching by tag now displays not only tags that match the search query, but notes that match those tags as well.
* Searching by tag now works with *or* without the '#' symbol in front of the tag.

Expand Down
8 changes: 4 additions & 4 deletions create.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ def create_query_output(title, tags):

query_string = ''
if title:
query_string += 'title=' + quote(title)
query_string += '&text=' + quote(title)
query_string += 'title=' + quote(title.encode('utf-8'))
query_string += '&text=' + quote(title.encode('utf-8'))

if tags:
tags_string = ''
for tag in tags:
tags_string += quote(tag) + ','
tags_string += quote(tag.encode('utf-8')) + ','
query_string = strip_tags_from_string(tags, query_string)
tags_string = tags_string[:-1]
query_string += '&tags=' + tags_string
Expand All @@ -79,7 +79,7 @@ def strip_tags_from_string(tags, query):
Yanks out all the hashtags from a string.
"""
for tag in tags:
query = query.replace(quote('#' + tag), '')
query = query.replace(quote('#' + tag.encode('utf-8')), '')
query = query.replace('#' + tag, '')
return query

Expand Down
68 changes: 34 additions & 34 deletions info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -120,37 +120,6 @@
<key>version</key>
<integer>2</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>concurrently</key>
<false/>
<key>escaping</key>
<integer>102</integer>
<key>script</key>
<string>orig_query={query}
echo $orig_query
if [[ $orig_query == ":t:"* ]]; then
new_query=${orig_query:3}
open "bear://x-callback-url/open-tag?name=$new_query"
else
new_query=${orig_query:3}
open "bear://x-callback-url/open-note?id=$new_query"
fi</string>
<key>scriptargtype</key>
<integer>0</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>34803D0C-B70E-4032-96FA-E0A5E179236A</string>
<key>version</key>
<integer>2</integer>
</dict>
<dict>
<key>config</key>
<dict>
Expand Down Expand Up @@ -204,7 +173,15 @@ fi</string>
<key>escaping</key>
<integer>102</integer>
<key>script</key>
<string>open "bear://x-callback-url/create?{query}"</string>
<string>orig_query={query}
echo $orig_query
if [[ $orig_query == ":t:"* ]]; then
new_query=${orig_query:3}
open "bear://x-callback-url/open-tag?name=$new_query"
else
new_query=${orig_query:3}
open "bear://x-callback-url/open-note?id=$new_query"
fi</string>
<key>scriptargtype</key>
<integer>0</integer>
<key>scriptfile</key>
Expand All @@ -215,7 +192,7 @@ fi</string>
<key>type</key>
<string>alfred.workflow.action.script</string>
<key>uid</key>
<string>B7C7DDC1-B797-4FF0-8AA0-0362C306C19A</string>
<string>34803D0C-B70E-4032-96FA-E0A5E179236A</string>
<key>version</key>
<integer>2</integer>
</dict>
Expand Down Expand Up @@ -264,6 +241,29 @@ fi</string>
<key>version</key>
<integer>2</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>concurrently</key>
<false/>
<key>escaping</key>
<integer>102</integer>
<key>script</key>
<string>open "bear://x-callback-url/create?{query}"</string>
<key>scriptargtype</key>
<integer>0</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>B7C7DDC1-B797-4FF0-8AA0-0362C306C19A</string>
<key>version</key>
<integer>2</integer>
</dict>
</array>
<key>readme</key>
<string># Bear Alfred Workflow
Expand Down Expand Up @@ -327,7 +327,7 @@ To install, download a released alfred-bear.alfredworkflow and double-click to o
</dict>
</dict>
<key>version</key>
<string>0.1.0</string>
<string>0.2.0</string>
<key>webaddress</key>
<string>https://github.com/chrisbro/alfred-bear</string>
</dict>
Expand Down
1 change: 1 addition & 0 deletions search.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def execute_search_query(args):
query = None
if args.query:
query = args.query[0]
query = query.encode('utf-8')

if SINGLE_QUOTE in query:
query = query.replace(SINGLE_QUOTE, ESC_SINGLE_QUOTE)
Expand Down
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.0
0.2.0

0 comments on commit a9c9a2f

Please sign in to comment.