diff --git a/.gitignore b/.gitignore index e21db65..4c27bdd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ .DS_Store *.pyc __pycache__ +prefs.plist # Created by https://www.gitignore.io/api/python,sublimetext,vim diff --git a/releases/ZotHero2.0.1.alfredworkflow b/releases/ZotHero2.0.1.alfredworkflow new file mode 100644 index 0000000..39c5014 Binary files /dev/null and b/releases/ZotHero2.0.1.alfredworkflow differ diff --git a/src/info.plist b/src/info.plist index ae9b397..ed79af7 100644 --- a/src/info.plist +++ b/src/info.plist @@ -254,16 +254,6 @@ vitoclose - - destinationuid - C75ABE16-D510-4099-BE4B-7BB579DA8435 - modifiers - 0 - modifiersubtext - - vitoclose - - 5CFF0FD7-987C-4910-AD1E-0C40BF66585A @@ -1147,103 +1137,6 @@ python3 zh.py attachments $id "$1" version 1 - - config - - concurrently - - escaping - 0 - script - # THESE VARIABLES MUST BE SET. SEE THE ONEUPDATER README FOR AN EXPLANATION OF EACH. -readonly remote_info_plist='https://raw.githubusercontent.com/giovannicoppola/zothero/master/src/info.plist' -readonly workflow_url='https://github.com/giovannicoppola/zothero' -readonly download_type='github_release' -readonly frequency_check='1' - -# FROM HERE ON, CODE SHOULD BE LEFT UNTOUCHED! -function abort { - echo "${1}" >&2 - exit 1 -} - -function url_exists { - curl --silent --location --output /dev/null --fail --range 0-0 "${1}" -} - -function notification { - local -r notificator="$(find . -type f -name 'notificator')" - - if [[ -f "${notificator}" && "$(/usr/bin/file --brief --mime-type "${notificator}")" == 'text/x-shellscript' ]]; then - "${notificator}" --message "${1}" --title "${alfred_workflow_name}" --subtitle 'A new version is available' - return - fi - - osascript -e "display notification \"${1}\" with title \"${alfred_workflow_name}\" subtitle \"A new version is available\"" -} - -# Local sanity checks -readonly local_info_plist='info.plist' -readonly local_version="$(/usr/libexec/PlistBuddy -c 'print version' "${local_info_plist}")" - -[[ -n "${local_version}" ]] || abort 'You need to set a workflow version in the configuration sheet.' -[[ "${download_type}" =~ ^(direct|page|github_release)$ ]] || abort "'download_type' (${download_type}) needs to be one of 'direct', 'page', or 'github_release'." -[[ "${frequency_check}" =~ ^[0-9]+$ ]] || abort "'frequency_check' (${frequency_check}) needs to be a number." - -# Check for updates -if [[ $(find "${local_info_plist}" -mtime +"${frequency_check}"d) ]]; then - # Remote sanity check - if ! url_exists "${remote_info_plist}"; then - abort "'remote_info_plist' (${remote_info_plist}) appears to not be reachable." - fi - - readonly tmp_file="$(mktemp)" - curl --silent --location --output "${tmp_file}" "${remote_info_plist}" - readonly remote_version="$(/usr/libexec/PlistBuddy -c 'print version' "${tmp_file}")" - rm "${tmp_file}" - - if [[ "${local_version}" == "${remote_version}" ]]; then - touch "${local_info_plist}" # Reset timer by touching local file - exit 0 - fi - - if [[ "${download_type}" == 'page' ]]; then - notification 'Opening download page…' - open "${workflow_url}" - exit 0 - fi - - readonly download_url="$( - if [[ "${download_type}" == 'github_release' ]]; then - osascript -l JavaScript -e 'function run(argv) { return JSON.parse(argv[0])["assets"].find(asset => asset["browser_download_url"].endsWith(".alfredworkflow"))["browser_download_url"] }' "$(curl --silent "https://api.github.com/repos/${workflow_url}/releases/latest")" - else - echo "${workflow_url}" - fi - )" - - if url_exists "${download_url}"; then - notification 'Downloading and installing…' - readonly download_name="$(basename "${download_url}")" - curl --silent --location --output "${HOME}/Downloads/${download_name}" "${download_url}" - open "${HOME}/Downloads/${download_name}" - else - abort "'workflow_url' (${download_url}) appears to not be reachable." - fi -fi - scriptargtype - 1 - scriptfile - - type - 0 - - type - alfred.workflow.action.script - uid - C75ABE16-D510-4099-BE4B-7BB579DA8435 - version - 2 - config @@ -2174,11 +2067,51 @@ python3 zh.py notify $flags readme - ZotHero -======= + # ZotHero Search your Zotero database and copy citations. -`zotconf` to view and edit workflow configuration. +`zotconf` to view and edit workflow configuration. +More details [here](https://github.com/giovannicoppola/zothero) + +## Features +-------- + +- Perform full-text search across your Zotero database, including only searching specific fields +- Copy citations using any [CSL][csl] style you have installed in Zotero +- Copy citations either in citation/note style or bibliography style +- Copy citations in any [locale supported by CSL](#locales) +- Copy Better BibTeX citekeys +- Citations are copied in multiple formats, so the right data are automatically pasted into the application you're using +- Trigger search while you type using the Snippet Trigger (you must assign the snippet keyword yourself in Alfred Preferences) + + +## Usage +----- + +These are the workflow's default keywords in Alfred: + +- `zot <query>` — Search your Zotero database (common fields). + - `↩` — Open the entry in Zotero. (`fn+↩` is an alternate) + - `⌘↩` — Copy citation to the pasteboard (see [Configuration](#configuration)). + - `⌥↩` — Copy bibliography-style citation to the pasteboard (see [Configuration](#configuration)). + - `⇧↩` — View entry attachments (if present). + - `↩` — Open an attachment in the default application. + - `^↩` — View all citation styles. + - `↩` or `⌘↩` — Copy citation in selected style. + - `⌥↩` — Copy bibliography-style citation in selected style. + - `^↩` — Set style as default. + - This search can also be triggered by typing a snippet (which you must first assign yourself in Alfred Preferences) + - When the Better-Bibtex plugin for Zotero is installed and `COPY_CITEKEY_MOD` is set to any of `-`(no modifier), `alt`, `ctrl`, `cmd`, `fn`, `shift`, the "Copy citekey" functionality can be enabled to override above operations + +- `zot:[<query>]` — Search a specific field. + - `↩` — Select a field to search against. +- `zotconf [<query>]` — View and edit workflow configuration. + - `Default Style: …` — Choose a citation style for the `⌘↩` and `⌥↩` hotkeys (on search results). + - `Locale: …` — Choose a locale for the formatting of citations. If unset, the default for the style is used, or if none is set, US English. + - `Reload Zotero Cache` — Clear the workflow's cache of Zotero data. Useful if the workflow gets out of sync with Zotero. + - `Open Log File` — Open the workflows log file in the default app (usually Console.app). Useful for checking on indexing problems (the indexer output isn't visible in Alfred's debugger). + - `View Documentation` — Open this README in your browser. + - `Report an Issue` — Open the GitHub issue tracker in your browser. uidata 01395D7D-4E59-4FB9-8369-9578C42822C6 @@ -2625,17 +2558,6 @@ Search your Zotero database and copy citations. ypos 875 - C75ABE16-D510-4099-BE4B-7BB579DA8435 - - colorindex - 12 - note - OneUpdater - xpos - 355 - ypos - 475 - C93018EF-4629-4261-B997-453D8F2D6856 colorindex @@ -2868,7 +2790,7 @@ Search your Zotero database and copy citations. variablesdontexport version - 2.0 + 2.0.1 webaddress https://github.com/giovannicoppola/zothero/ diff --git a/src/zh.py b/src/zh.py index cf10465..7afc75e 100755 --- a/src/zh.py +++ b/src/zh.py @@ -65,15 +65,10 @@ # Set if workflow was run via Snippet Trigger AUTOPASTE = os.getenv('autopaste') -# GitHub repo to check for updates -UPDATE_SETTINGS = { - 'github_slug': 'deanishe/zothero', - 'prereleases': '-beta' in (os.getenv('alfred_workflow_version') or ''), -} # URLs for help & docs URL_ISSUES = 'https://github.com/giovannicoppola/zothero/issues' -URL_DOCS = 'https://github.com/deanishe/zothero/blob/master/README.md' +URL_DOCS = 'https://github.com/giovannicoppola/zothero/blob/master/README.md' # Workflow icons ICON_CITATION = 'icons/citation.png' @@ -411,23 +406,6 @@ def do_config(query): log.debug(u'Default style: %s', style.name) items = [] # (item params, variables) tuples - if wf.update_available: - items.append((dict( - title='An Update is Available', - subtitle=u'↩ or ⇥ to install', - autocomplete='workflow:update', - valid=False, - icon=ICON_UPDATE_AVAILABLE, - ), {})) - - else: - items.append((dict( - title='Workflow is Up To Date', - subtitle=u'↩ or ⇥ to force update check', - autocomplete='workflow:update', - valid=False, - icon=ICON_UPDATE_OK, - ), {})) # Style icon = ICON_OFF @@ -765,7 +743,6 @@ def main(wf): if __name__ == '__main__': wf = Workflow3( - update_settings=UPDATE_SETTINGS, help_url=URL_ISSUES, ) log = wf.logger