Skip to content

Commit 4e2389e

Browse files
committed
Merge pull request #5 from Jmuccigr/master
Use with any application.
2 parents a00c893 + 611185e commit 4e2389e

File tree

4 files changed

+88
-37
lines changed

4 files changed

+88
-37
lines changed

README.md

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,27 @@
11
# zotpick-applescript
22

3-
Leverage [Better-BibTeX's citation picker](https://zotplus.github.io/better-bibtex/cayw.html) in Scrivener
3+
Leverage [Better-BibTeX's citation picker](https://zotplus.github.io/better-bibtex/cayw.html) in your word-processing app.
44

55
These three scripts allow you to use [Better BibTeX's citation picker](https://zotplus.github.io/better-bibtex/cayw.html)
6-
with Scrivener. The three applets (available compiled in the Releases section) correspond
7-
to the three available citation ouputs: pandoc formatted citations, MultiMarkdown
8-
formatted citations, and Scannable Cites
6+
with any word-processing app. The three applets (available compiled in the Releases section) correspond to the three available citation ouputs: pandoc-formatted citations, MultiMarkdown-formatted citations, and Scannable Cites
97
(for [RTF/ODF Scan for Zotero](http://zotero-odf-scan.github.io/zotero-odf-scan/)).
108

11-
To use, set one of the applets as your refernce manager in Scrivener, call up with ⌘-Y
12-
and search for a citation in the box. Suffixes, prefixes, page numbers and author
13-
suppression can be set by clicking the selected citation in the search box and filling
14-
out the options. These do not work in MultiMarkdown output.
9+
## Basic usage
1510

16-
These applets work well in conjunction with this workflow for using [Scrivner, Pandoc, Zotero and Marked 2 for academic writing](http://davepwsmith.github.io/academic-scrivener-howto/).
11+
When you run one of the scripts, Zotero (which must already be open and have Better BibTeX installed) will appear and open a search box where you can search for the desired citation. Suffixes, prefixes, page numbers and author suppression can be set by clicking the selected citation in the search box and filling out the options, but these do *not* work in MultiMarkdown output. The resultant citation text will then be entered into the app you were working in when you ran the script. Since the script is basically typing the citation into your application, it should work with any word processor (and any others that accept text input as well).
1712

18-
**N.B** **These applets will type over whatever text you have selected when you call them. You have been warned.**
13+
Please report any errors as issues on the [GitHub page](https://github.com/davepwsmith/zotpick-applescript).
14+
15+
---
16+
17+
## With Scrivener
18+
Set one of the applets as your reference manager in Scrivener, call up with ⌘-Y.
19+
20+
These applets work well in conjunction with [this workflow](http://davepwsmith.github.io/academic-scrivener-howto/) for using Scrivener, Pandoc, Zotero and Marked 2 for academic writing.
21+
22+
## With other Apps
23+
24+
One or both of these approaches will work:
25+
26+
- To use these scripts with any application is to put them in your ~/Library/Scripts folder. Or to use them with one specific app, put them inside a folder with that app's name inside the Scripts folder.
27+
- If you use an app-launching utility that lets you assign key combos to apps, use that to launch these scripts.

zotpick-mmd.applescript

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,38 @@
1+
tell application "System Events"
2+
try
3+
set appName to (the name of every process whose frontmost is true) as string
4+
on error errMsg
5+
display alert "Problem" message "Could not get the name of the frontmost application."
6+
error number -128
7+
end try
8+
end tell
19
set zotRunning to do shell script "/usr/bin/curl 'http://localhost:23119/better-bibtex/cayw?probe=probe' 2>/dev/null; exit 0"
210
if zotRunning is "" then
3-
display alert "This script will not work unless Zotero is running. Please launch Zotero and try again"
4-
tell application "Scrivener"
11+
display alert "Zotero not running" message "This script will not work unless Zotero is running. Please launch Zotero and try again"
12+
tell application appName
513
activate
614
end tell
715
error number -128
816
else if zotRunning is "No endpoint found" then
9-
display alert "This script will not work unless Better BibTeX is installed. Please make sure that Better BibTeX is installed in the running instance of Zotero"
10-
tell application "Scrivener"
17+
display alert "Better BibTeX not installed" message "This script will not work unless Better BibTeX is installed. Please make sure that Better BibTeX is installed in the running instance of Zotero"
18+
tell application appName
1119
activate
1220
end tell
1321
error number -128
1422
else if zotRunning is "ready" then
1523
set theReference to do shell script "/usr/bin/curl 'http://localhost:23119/better-bibtex/cayw?format=mmd' 2>/dev/null; exit 0"
16-
tell application "Scrivener"
17-
activate
18-
repeat until application "Scrivener" is frontmost
24+
try
25+
repeat until application appName is frontmost
26+
tell application appName to activate
1927
end repeat
20-
tell application "System Events"
28+
on error errMsg
29+
display alert errMsg
30+
end try
31+
tell application "System Events"
32+
try
2133
keystroke theReference
22-
end tell
34+
on error errMsg
35+
display alert errMsg
36+
end try
2337
end tell
2438
end if

zotpick-pandoc.applescript

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,38 @@
1+
tell application "System Events"
2+
try
3+
set appName to (the name of every process whose frontmost is true) as string
4+
on error errMsg
5+
display alert "Problem" message "Could not get the name of the frontmost application."
6+
error number -128
7+
end try
8+
end tell
19
set zotRunning to do shell script "/usr/bin/curl 'http://localhost:23119/better-bibtex/cayw?probe=probe' 2>/dev/null; exit 0"
210
if zotRunning is "" then
3-
display alert "This script will not work unless Zotero is running. Please launch Zotero and try again"
4-
tell application "Scrivener"
11+
display alert "Zotero not running" message "This script will not work unless Zotero is running. Please launch Zotero and try again"
12+
tell application appName
513
activate
614
end tell
715
error number -128
816
else if zotRunning is "No endpoint found" then
9-
display alert "This script will not work unless Better BibTeX is installed. Please make sure that Better BibTeX is installed in the running instance of Zotero"
10-
tell application "Scrivener"
17+
display alert "Better BibTeX not installed" message "This script will not work unless Better BibTeX is installed. Please make sure that Better BibTeX is installed in the running instance of Zotero"
18+
tell application appName
1119
activate
1220
end tell
1321
error number -128
1422
else if zotRunning is "ready" then
1523
set theReference to do shell script "/usr/bin/curl 'http://localhost:23119/better-bibtex/cayw?format=pandoc' 2>/dev/null; exit 0"
16-
tell application "Scrivener"
17-
activate
18-
repeat until application "Scrivener" is frontmost
24+
try
25+
repeat until application appName is frontmost
26+
tell application appName to activate
1927
end repeat
20-
tell application "System Events"
28+
on error errMsg
29+
display alert errMsg
30+
end try
31+
tell application "System Events"
32+
try
2133
keystroke theReference
22-
end tell
34+
on error errMsg
35+
display alert errMsg
36+
end try
2337
end tell
2438
end if

zotpick-scannable-cite.applescript

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,38 @@
1+
tell application "System Events"
2+
try
3+
set appName to (the name of every process whose frontmost is true) as string
4+
on error errMsg
5+
display alert "Problem" message "Could not get the name of the frontmost application."
6+
error number -128
7+
end try
8+
end tell
19
set zotRunning to do shell script "/usr/bin/curl 'http://localhost:23119/better-bibtex/cayw?probe=probe' 2>/dev/null; exit 0"
210
if zotRunning is "" then
3-
display alert "This script will not work unless Zotero is running. Please launch Zotero and try again"
4-
tell application "Scrivener"
11+
display alert "Zotero not running" message "This script will not work unless Zotero is running. Please launch Zotero and try again"
12+
tell application appName
513
activate
614
end tell
715
error number -128
816
else if zotRunning is "No endpoint found" then
9-
display alert "This script will not work unless Better BibTeX is installed. Please make sure that Better BibTeX is installed in the running instance of Zotero"
10-
tell application "Scrivener"
17+
display alert "Better BibTeX not installed" message "This script will not work unless Better BibTeX is installed. Please make sure that Better BibTeX is installed in the running instance of Zotero"
18+
tell application appName
1119
activate
1220
end tell
1321
error number -128
1422
else if zotRunning is "ready" then
1523
set theReference to do shell script "/usr/bin/curl 'http://localhost:23119/better-bibtex/cayw?format=scannable-cite' 2>/dev/null; exit 0"
16-
tell application "Scrivener"
17-
activate
18-
repeat until application "Scrivener" is frontmost
24+
try
25+
repeat until application appName is frontmost
26+
tell application appName to activate
1927
end repeat
20-
tell application "System Events"
28+
on error errMsg
29+
display alert errMsg
30+
end try
31+
tell application "System Events"
32+
try
2133
keystroke theReference
22-
end tell
34+
on error errMsg
35+
display alert errMsg
36+
end try
2337
end tell
2438
end if

0 commit comments

Comments
 (0)