Skip to content

Commit 7a43bd5

Browse files
committed
🔥 Remove some debug code. Fix a typo and drop support for Alfred 2.
1 parent 8ccc286 commit 7a43bd5

File tree

4 files changed

+24
-12
lines changed

4 files changed

+24
-12
lines changed
Binary file not shown.

src/docs.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66
import functools
77
import re
88
import sys
9+
from textwrap import wrap
910
from urllib import quote_plus
1011

1112
from algoliasearch.search_client import SearchClient
1213
from config import Config
13-
from workflow import Workflow, ICON_INFO
14+
from workflow import Workflow3, ICON_INFO
1415

1516
# Algolia client
1617
client = SearchClient.create(Config.ALGOLIA_APP_ID, Config.ALGOLIA_SEARCH_ONLY_API_KEY)
@@ -26,7 +27,7 @@ def cache_key(query):
2627
key = key.lower()
2728
key = re.sub(r"[^a-z0-9-_;.]", "-", key)
2829
key = re.sub(r"-+", "-", key)
29-
log.debug("Cache key : {!r} -> {!r}".format(query, key))
30+
# log.debug("Cache key : {!r} -> {!r}".format(query, key))
3031
return key
3132

3233

@@ -60,8 +61,6 @@ def main(wf):
6061

6162
query = wf.args[0].strip()
6263

63-
log.debug("query : {!r}".format(query))
64-
6564
if not query:
6665
wf.add_item("Search the Flask docs...")
6766
wf.send_feedback()
@@ -72,6 +71,8 @@ def main(wf):
7271

7372
query = " ".join(words)
7473

74+
log.debug("query : {!r}".format(query))
75+
7576
key = cache_key(query)
7677

7778
results = [
@@ -81,15 +82,16 @@ def main(wf):
8182
)
8283
]
8384

84-
log.debug("{} results for {!r}".format(len(results), query))
85+
# log.debug("{} results for {!r}".format(len(results), query))
86+
8587
# Show results
8688
if not results:
8789
url = "https://www.google.com/search?q={}".format(
8890
quote_plus("Flask {}".format(query))
8991
)
9092
wf.add_item(
9193
"No matching answers found",
92-
"Try a and search Google?",
94+
"Shall I try and search Google?",
9395
valid=True,
9496
arg=url,
9597
copytext=url,
@@ -98,10 +100,14 @@ def main(wf):
98100
)
99101

100102
for result in results:
103+
subtitle = wrap(result["content"], width=75)[0]
104+
if len(result["content"]) > 75:
105+
subtitle += " ..."
106+
101107
wf.add_item(
102108
uid=result["id"],
103109
title=result["id"],
104-
subtitle=result["content"],
110+
subtitle=subtitle,
105111
arg=result["permalink"],
106112
valid=True,
107113
largetext=result["title"],
@@ -115,7 +121,7 @@ def main(wf):
115121

116122

117123
if __name__ == "__main__":
118-
wf = Workflow(
124+
wf = Workflow3(
119125
update_settings={"github_slug": "techouse/alfred-flask-docs", "frequency": 7}
120126
)
121127
log = wf.logger

src/info.plist

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
<false/>
4040
<key>alfredfiltersresultsmatchmode</key>
4141
<integer>0</integer>
42+
<key>argumenttreatemptyqueryasnil</key>
43+
<false/>
4244
<key>argumenttrimmode</key>
4345
<integer>0</integer>
4446
<key>argumenttype</key>
@@ -77,7 +79,7 @@
7779
<key>uid</key>
7880
<string>9CD5E9DE-7116-4632-91A8-1CA381F10126</string>
7981
<key>version</key>
80-
<integer>2</integer>
82+
<integer>3</integer>
8183
</dict>
8284
<dict>
8385
<key>config</key>
@@ -100,7 +102,7 @@
100102
</dict>
101103
</array>
102104
<key>readme</key>
103-
<string></string>
105+
<string>Search the Flask documentation using Alfred</string>
104106
<key>uidata</key>
105107
<dict>
106108
<key>0A7A05D1-2AA4-458A-85FF-9F1C225796EE</key>
@@ -118,7 +120,11 @@
118120
<integer>170</integer>
119121
</dict>
120122
</dict>
123+
<key>variablesdontexport</key>
124+
<array/>
125+
<key>version</key>
126+
<string>1.0.5</string>
121127
<key>webaddress</key>
122-
<string></string>
128+
<string>https://github.com/techouse</string>
123129
</dict>
124130
</plist>

src/version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0.4
1+
1.0.5

0 commit comments

Comments
 (0)