From: Christian Moe <mail@christianmoe.com>
To: Matt Price <moptop99@gmail.com>
Cc: Erik Hetzner <egh@e6h.org>, Org Mode <emacs-orgmode@gnu.org>,
Jambunathan K <kjambunathan@gmail.com>
Subject: Re: zotero plain, org-odt, and citations in general
Date: Sun, 13 Nov 2011 23:47:12 +0100 [thread overview]
Message-ID: <4EC048F0.9050006@christianmoe.com> (raw)
In-Reply-To: <CAN_Dec_20jLWE5YV-3t++WXe2_+ywdMqYib-P0EykCR8cnDn_w@mail.gmail.com>
* Towards a solution for Zotero -> Org -> ODT
I think I have a way to get Zotero references from Org links into ODT
as working reference marks. Interested parties, please
test if this works for you at all.
1. Create Zotero links such as e.g.:
: [[zotero:0_RADJMJ8Q][{Bolin, 1958}]]
Below, I include code for a simple Zotero export translator
(OrgMode.js) that will create such links at a keystroke/mouse drag,
since some of us are currently experiencing difficulties with
zotero-plain.
2. Define a custom link export function to fake a Zotero field code
for ODT. Code below.
3. Export to ODT and do the things you normally do with Zotero, like
generating a bibliography. (Note that Zotero won't let you insert a
bibliography until you've inserted at least one Zotero reference
from within LibreOffice. You can always delete it afterwards.)
If this works for you, the code (which is a quickly thrown-together
mess) can probably be improved on.
Yours,
Christian Moe
** OrgMode.js translator
Installation:
1. Tangle or copy the below to a file called "OrgMode.js".
2. Place it in the Zotero translators folder (on Mac, that's
~/Library/Application
Support/Firefox/Profiles/[PROFILENAME]/zotero/translators/
3. Restart Firefox.
4. Open Zotero > Actions (the cogwheel icon) > Preferences. From the
drop-down menu, select "Org-mode" as the Quick Copy default format.
Use: you can
- drag and drop references from the Zotero panel to the Emacs buffer,
or
- "Quick Copy" to clipboard with Shift-Cmd-C (Mac) and yank in the
Emacs buffer
#+name: OrgMode.js
#+begin_src javascript
{
"translatorID": "b0006c6f-b743-4508-beaf-490bbd68a403",
"label": "Org-mode",
"creator": "Christian Moe",
"target": "org",
"minVersion": "2.1.9",
"maxVersion": "",
"priority": 200,
"displayOptions": {
"exportCharset": "UTF-8",
"exportNotes": true,
"exportFileData": false
},
"inRepository": false,
"translatorType": 2,
"browserSupport": "gcs",
"lastUpdated": "2011-11-12 17:05:00"
}
// Loosely based on Scott Campbell's ZotSelect.js
// posted at
http://forums.zotero.org/discussion/8306/testing-zoteroselect/
function doExport() {
// Zotero.write("zotero://select//");
// Zotero.write("\n");
var item;
var notfirst = false;
while(item = Zotero.nextItem()) {
// Separate multiple links
if (notfirst) {
Zotero.write("; ")
}
// Org link path
Zotero.write("[[zotero:");
var library_id = item.LibraryID ? item.LibraryID : 0;
Zotero.write(library_id+"_"+item.key);
// Org link descr
Zotero.write("][{");
// create a unique citation key
//var descr = buildCiteKey(item, citekeys);
// write citation key
//Zotero.write("/"+citekey);
// Authorname
if(item.creators && item.creators[0] && item.creators[0].lastName) {
Zotero.write(item.creators[0].lastName);
} else {
Zotero.write("n.a.")
}
// Separator
Zotero.write(", ")
// Year
var numberRe = /^[0-9]+/;
if(item.date) {
var date = Zotero.Utilities.strToDate(item.date);
if(date.year && numberRe.test(date.year)) {
Zotero.write(date.year);
}
} else {
Zotero.write("n.d.");
}
// Close Org link
Zotero.write("}]]")
notfirst = true;
}
}
#+end_src
** Zotero link type
Evaluate the following (or place it in your .emacs for repeated use).
Note that clicking the links does not work on Mac and probably won't
work on Linux/Windows, either (but please let me know if it does!).
Consider org-zotero-open a placeholder for now.
#+begin_src elisp
(org-add-link-type "zotero"
'org-zotero-open
'org-zotero-export)
(defun org-zotero-open (path)
(browse-url (format "zotero://select//%s" path)))
(defun org-zotero-export (path desc format)
(cond
((eq format 'odt)
(let
((refmark "<text:reference-mark-start
text:name=\"%s\"/>%s<text:reference-mark-end text:name=\"%s\"/>")
(zitem "ZOTERO_ITEM
{"citationID":"%s","citationItems":[{"uri":["http://zotero.org/users/local/%s/items/%s"]}]}
%s")
(citation-id (substring (org-id-new) -10)) ; Is this a
good way to make a unique ID?
(library-id (car (split-string path "_")))
(item-key (car (cdr (split-string path "_"))))
(rnd (concat "RND" (substring (org-id-new) -10))))
(setq zitem
(format zitem
citation-id
library-id
item-key
rnd))
(setq desc (format "(%s)" desc))
(format refmark zitem desc zitem)))
(t desc)))
#+end_src
next prev parent reply other threads:[~2011-11-13 22:43 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-09 2:06 zotero plain, org-odt, and citations in general Matt Price
2011-11-09 5:26 ` Jambunathan K
2011-11-10 15:17 ` Jambunathan K
2011-11-10 15:50 ` Thomas S. Dye
2011-11-10 17:48 ` Erik Hetzner
2011-11-11 15:51 ` Matt Price
2011-11-11 16:12 ` Erik Hetzner
2011-11-11 18:45 ` Matt Price
2011-11-12 0:07 ` Erik Hetzner
2011-11-12 23:45 ` Christian Moe
2011-11-12 23:46 ` Christian Moe
2011-11-11 20:34 ` zotero-cite (A Proposal) Jambunathan K
2011-11-14 15:38 ` Matt Price
2011-11-16 5:25 ` Erik Hetzner
2011-11-11 21:13 ` zotero plain, org-odt, and citations in general Jambunathan K
2011-11-12 7:21 ` Christian Moe
2011-11-12 14:20 ` Matt Price
2011-11-16 5:30 ` Erik Hetzner
2011-11-09 7:03 ` Erik Hetzner
2011-11-09 7:25 ` Jambunathan K
2011-11-09 14:13 ` Ken Williams
2011-11-09 19:39 ` Christian Moe
2011-11-10 4:53 ` Erik Hetzner
2011-11-10 9:01 ` Christian Moe
2011-11-11 15:37 ` Matt Price
2011-11-11 17:51 ` Erik Hetzner
2011-11-11 18:34 ` Matt Price
2011-11-09 15:28 ` Matt Price
2011-11-10 4:40 ` Erik Hetzner
2011-11-13 22:47 ` Christian Moe [this message]
2011-11-14 15:38 ` Matt Price
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4EC048F0.9050006@christianmoe.com \
--to=mail@christianmoe.com \
--cc=egh@e6h.org \
--cc=emacs-orgmode@gnu.org \
--cc=kjambunathan@gmail.com \
--cc=moptop99@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.