Skip to content
This repository was archived by the owner on Nov 2, 2025. It is now read-only.

Commit 8ccc286

Browse files
committed
📦 Updates
1 parent e046b85 commit 8ccc286

File tree

6 files changed

+25
-15
lines changed

6 files changed

+25
-15
lines changed
Binary file not shown.

src/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ class Config(object):
88
CACHE_MAX_AGE = 20 # seconds
99
# Icon
1010
FLASK_ICON = "icon.png"
11+
GOOGLE_ICON = "google.png"
1112
# Algolia credentials
1213
ALGOLIA_APP_ID = "WODHKE4WZG"
1314
ALGOLIA_SEARCH_ONLY_API_KEY = "7456cdd91ba8d4f87846549697397759"

src/docs.py

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,11 @@
66
import functools
77
import re
88
import sys
9-
from HTMLParser import HTMLParser
9+
from urllib import quote_plus
1010

1111
from algoliasearch.search_client import SearchClient
1212
from config import Config
13-
from workflow import Workflow, ICON_WARNING, ICON_INFO
14-
15-
# h.unescape() turns HTML escapes back into real characters
16-
h = HTMLParser()
13+
from workflow import Workflow, ICON_INFO
1714

1815
# Algolia client
1916
client = SearchClient.create(Config.ALGOLIA_APP_ID, Config.ALGOLIA_SEARCH_ONLY_API_KEY)
@@ -38,7 +35,7 @@ def handle_result(api_dict):
3835
result = {}
3936

4037
for key in {"id", "title", "permalink", "default", "content"}:
41-
result[key] = h.unescape(api_dict[key])
38+
result[key] = api_dict[key]
4239

4340
return result
4441

@@ -77,15 +74,27 @@ def main(wf):
7774

7875
key = cache_key(query)
7976

80-
results = wf.cached_data(
81-
key, functools.partial(search, query), max_age=Config.CACHE_MAX_AGE
82-
)
77+
results = [
78+
handle_result(result)
79+
for result in wf.cached_data(
80+
key, functools.partial(search, query), max_age=Config.CACHE_MAX_AGE
81+
)
82+
]
8383

8484
log.debug("{} results for {!r}".format(len(results), query))
8585
# Show results
8686
if not results:
87+
url = "https://www.google.com/search?q={}".format(
88+
quote_plus("Flask {}".format(query))
89+
)
8790
wf.add_item(
88-
"No matching answers found", "Try a different query", icon=ICON_WARNING
91+
"No matching answers found",
92+
"Try a and search Google?",
93+
valid=True,
94+
arg=url,
95+
copytext=url,
96+
quicklookurl=url,
97+
icon=Config.GOOGLE_ICON,
8998
)
9099

91100
for result in results:

src/google.png

17.7 KB
Loading

src/requirements.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
Alfred-Workflow==1.37.1
2-
algoliasearch==2.0.2
3-
certifi==2019.3.9
1+
Alfred-Workflow==1.37.2
2+
algoliasearch==2.0.4
3+
certifi==2019.6.16
44
chardet==3.0.4
55
idna==2.8
66
requests==2.22.0
7-
typing==3.6.6
7+
typing==3.7.4
88
urllib3==1.25.3

src/version

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

0 commit comments

Comments
 (0)