diff --git a/.gitignore b/.gitignore
index b943e2c..352e4e4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
__pycache__
*.pyc
.pytest_cache
+adsabs.alfredworkflow
diff --git a/info.plist b/info.plist
index fb678f0..4662110 100644
--- a/info.plist
+++ b/info.plist
@@ -113,25 +113,6 @@
version
1
-
- config
-
- browser
-
- spaces
-
- url
- {query}
- utf8
-
-
- type
- alfred.workflow.action.openurl
- uid
- 407E7C1B-5537-436F-8D97-71204E3433D3
- version
- 1
-
config
@@ -181,6 +162,25 @@
version
3
+
+ config
+
+ browser
+
+ spaces
+
+ url
+ {query}
+ utf8
+
+
+ type
+ alfred.workflow.action.openurl
+ uid
+ 407E7C1B-5537-436F-8D97-71204E3433D3
+ version
+ 1
+
readme
Search for papers using SAO/NASA Astrophysics Data System
@@ -203,7 +203,7 @@
88F638D8-273F-4E10-979E-6CFBCBC1AD83
xpos
- 50
+ 40
ypos
60
@@ -228,7 +228,7 @@
ADS_DEV_KEY
version
- 0.1.1
+ 0.1.2
webaddress
https://github.com/dfm/adsabs.alfredworkflow
diff --git a/release.py b/release.py
new file mode 100644
index 0000000..856c8f7
--- /dev/null
+++ b/release.py
@@ -0,0 +1,54 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+import os
+import zipfile
+import plistlib
+
+VERSION = "0.1.2"
+OUTFILE = "adsabs.alfredworkflow"
+
+# Remove the previous build
+if os.path.exists(OUTFILE):
+ os.remove(OUTFILE)
+
+# Load the plist
+with open("info.plist", "rb") as f:
+ plist = plistlib.load(f)
+
+# Remove Alfred 3 incompatible arguments
+objects = plist.get("objects", [])
+for obj in objects:
+ if "config" not in obj:
+ continue
+ config = obj["config"]
+ config.pop("argumenttreatemptyqueryasnil", None)
+ obj["config"] = config
+
+ if "version" in obj and obj.get("version") > 2:
+ obj["version"] = 2
+
+# Clear variables
+plist["variables"]["ADS_PYTHON"] = "python"
+plist["variables"]["ADS_DEV_KEY"] = ""
+
+# Update the version number
+plist["version"] = VERSION
+
+# Create the zip file
+with zipfile.ZipFile(OUTFILE, "w") as zf:
+
+ # Save the plist
+ print("writing info.plist")
+ zf.writestr("info.plist", plistlib.dumps(plist))
+
+ # Copy the other files
+ for fn in os.listdir("."):
+ if fn in ["info.plist", "__pycache__", "build", "release.py", OUTFILE]:
+ continue
+ if fn.startswith("."):
+ continue
+ if fn.endswith(".pyc"):
+ continue
+ print("writing {0}".format(fn))
+ zf.write(fn)
diff --git a/run_search.py b/run_search.py
index 78879b2..75212e1 100644
--- a/run_search.py
+++ b/run_search.py
@@ -43,7 +43,7 @@ def set_ratelimit(ratelimit):
return_error("Install the 'ads' Python library to enable search",
"https://github.com/andycasey/ads",
sub=("Or set you prefered python interpreter in the "
- "~/.ads/python file"))
+ "ADS_PYTHON variable for this workflow"))
# Make sure that the ~/.ads directory exists
if not os.path.exists(os.path.expanduser("~/.ads")):
@@ -62,6 +62,10 @@ def set_ratelimit(ratelimit):
# Parse the query
query = " ".join(sys.argv[1:]).strip()
+ if len(query) < 3:
+ sys.stdout.write(json.dumps(dict(items=[])))
+ sys.exit(0)
+
try:
query_string = parse_query_string(query)
except Exception: