Skip to content

Commit

Permalink
version 1.99.4, RTF and plain text clipboard
Browse files Browse the repository at this point in the history
  • Loading branch information
giovannicoppola committed Jun 14, 2022
1 parent cc9155d commit 366ea6d
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 26 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,4 @@ Session.vim
tags

# End of https://www.gitignore.io/api/python,sublimetext,vim
src/lib/.DS_Store
Binary file added releases/ZotHero1-99-4.alfredworkflow
Binary file not shown.
76 changes: 68 additions & 8 deletions src/info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,8 @@
<false/>
</dict>
</array>
<key>9A202C58-854E-4E02-A640-BF13A9E1B823</key>
<array/>
<key>9A384EEE-AA82-4FC5-8B13-1F7319613854</key>
<array>
<dict>
Expand All @@ -450,7 +452,18 @@
</dict>
</array>
<key>A950947F-8EA7-4749-AF55-2C7F9D6E695E</key>
<array/>
<array>
<dict>
<key>destinationuid</key>
<string>9A202C58-854E-4E02-A640-BF13A9E1B823</string>
<key>modifiers</key>
<integer>0</integer>
<key>modifiersubtext</key>
<string></string>
<key>vitoclose</key>
<false/>
</dict>
</array>
<key>AEE6452E-9186-4609-8AD4-D74F469F1A79</key>
<array>
<dict>
Expand Down Expand Up @@ -1401,6 +1414,46 @@ python3 zh.py citations "$id" "$1"
<key>version</key>
<integer>3</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>concurrently</key>
<false/>
<key>escaping</key>
<integer>68</integer>
<key>script</key>
<string>function copyLink(uti_html, uti_plain, uti_rtf) {
let pboard = $.NSPasteboard.generalPasteboard;
pboard.clearContents;
pboard.setStringForType(uti_rtf, 'public.rtf');
pboard.setStringForType(uti_html, 'public.html');
pboard.setStringForType(uti_plain, 'public.utf8-plain-text');
}
function run(argv) {
ObjC.import('AppKit');
ObjC.import('stdlib');
var UTI_HTML = $.getenv('UTI_HTML');
var UTI_PLAIN = $.getenv('UTI_PLAIN');
var UTI_RTF = $.getenv('UTI_RTF');
return copyLink(UTI_HTML, UTI_PLAIN, UTI_RTF)
}</string>
<key>scriptargtype</key>
<integer>1</integer>
<key>scriptfile</key>
<string></string>
<key>type</key>
<integer>7</integer>
</dict>
<key>type</key>
<string>alfred.workflow.action.script</string>
<key>uid</key>
<string>9A202C58-854E-4E02-A640-BF13A9E1B823</string>
<key>version</key>
<integer>2</integer>
</dict>
<dict>
<key>config</key>
<dict>
Expand Down Expand Up @@ -2312,7 +2365,7 @@ Edit the `ZOTERO_DIR` variable to point to Zotero 5's data directory if you aren
<key>colorindex</key>
<integer>4</integer>
<key>xpos</key>
<integer>1330</integer>
<integer>1335</integer>
<key>ypos</key>
<integer>735</integer>
</dict>
Expand Down Expand Up @@ -2466,6 +2519,15 @@ Edit the `ZOTERO_DIR` variable to point to Zotero 5's data directory if you aren
<key>ypos</key>
<integer>210</integer>
</dict>
<key>9A202C58-854E-4E02-A640-BF13A9E1B823</key>
<dict>
<key>note</key>
<string>Copy citation to pasteboard</string>
<key>xpos</key>
<integer>1630</integer>
<key>ypos</key>
<integer>705</integer>
</dict>
<key>9A384EEE-AA82-4FC5-8B13-1F7319613854</key>
<dict>
<key>note</key>
Expand All @@ -2480,7 +2542,7 @@ Edit the `ZOTERO_DIR` variable to point to Zotero 5's data directory if you aren
<key>colorindex</key>
<integer>4</integer>
<key>note</key>
<string>Copy citation to pasteboard</string>
<string>Generate citation</string>
<key>xpos</key>
<integer>1450</integer>
<key>ypos</key>
Expand Down Expand Up @@ -2662,7 +2724,7 @@ Edit the `ZOTERO_DIR` variable to point to Zotero 5's data directory if you aren
<key>ATTACHMENTS_DIR</key>
<string></string>
<key>CITE_STYLE</key>
<string>http://www.zotero.org/styles/modern-humanities-research-association</string>
<string>http://www.zotero.org/styles/chicago-author-date</string>
<key>COPY_CITEKEY_MOD</key>
<string></string>
<key>LOCALE</key>
Expand All @@ -2672,14 +2734,12 @@ Edit the `ZOTERO_DIR` variable to point to Zotero 5's data directory if you aren
</dict>
<key>variablesdontexport</key>
<array>
<string>LOCALE</string>
<string>ATTACHMENTS_DIR</string>
<string>ZOTERO_DIR</string>
<string>COPY_CITEKEY_MOD</string>
<string>CITE_STYLE</string>
<string>ZOTERO_DIR</string>
</array>
<key>version</key>
<string>1.99.3</string>
<string>1.99.4</string>
<key>webaddress</key>
<string>https://github.com/deanishe/zothero</string>
</dict>
Expand Down
Binary file modified src/lib/.DS_Store
Binary file not shown.
14 changes: 7 additions & 7 deletions src/lib/pasteboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ def set(contents):
log.debug ("uti: {}, contents: {}".format (uti, contents[uti]))


pboard = NSPasteboard.generalPasteboard()
pboard.clearContents()
for uti in contents:
#log.debug ("uti: %s" % uti)
data = nsdata(contents[uti])
#pboard.setData_forType_(data, uti.encode('utf-8'))
pboard.setData_forType_(data, str(uti))
# pboard = NSPasteboard.generalPasteboard()
# pboard.clearContents()
# for uti in contents:
# #log.debug ("uti: %s" % uti)
# data = nsdata(contents[uti])
# #pboard.setData_forType_(data, uti.encode('utf-8'))
# pboard.setData_forType_(data, str(uti))


def paste():
Expand Down
40 changes: 29 additions & 11 deletions src/zh.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
import os
from operator import attrgetter
import sys
import json


sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'lib'))

Expand Down Expand Up @@ -360,18 +362,34 @@ def do_copy(style_key, entry_id, bib_style=False, paste=False):
data = app.styles.cite(e, s, bib_style, LOCALE)

## Copying to clipboard
import subprocess
p = subprocess.Popen(['pbcopy'], stdin=subprocess.PIPE)
p.stdin.write(data['rtf'].encode())
p.stdin.close()
# import subprocess
# p = subprocess.Popen(['pbcopy'], stdin=subprocess.PIPE)
# p.stdin.write(data['rtf'].encode())
# p.stdin.close()

pbdata = {
#pb.UTI_HTML: data['html'],
#pb.UTI_PLAIN: data['text'],
#log.debug ("RTF DATA %s" % str(data['rtf']))
#pb.UTI_TEXT: data['rtf'],
}
#pb.set(pbdata)
# pbdata = {
# pb.UTI_HTML: data['html'],
# pb.UTI_PLAIN: data['text'],
# #log.debug ("RTF DATA %s" % str(data['rtf']))
# pb.UTI_TEXT: data['rtf'],
# }
# pb.set(pbdata)




myVars = {}
myVars ["alfredworkflow"] = {"variables":
{"UTI_HTML": data['html'],
"UTI_PLAIN": data['text'],
"UTI_RTF": data['rtf']}
}


print (json.dumps(myVars))




if paste:
from workflow.util import run_trigger
Expand Down

0 comments on commit 366ea6d

Please sign in to comment.