Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
dev:translators:coding [2018/09/27 19:59] – [detectWeb] adamsmith | dev:translators:coding [2018/12/26 06:49] – Add proxy: false attachment flag dstillman | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Writing Translator Code ====== | ====== Writing Translator Code ====== | ||
- | Below we will describe how the '' | + | Below we will describe how the '' |
+ | |||
+ | While translators can be written with any text editor, the Zotero add-on | ||
- | While translators can be written with any text editor, the Firefox add-on [[dev/ | ||
====== Web Translators ====== | ====== Web Translators ====== | ||
Line 29: | Line 31: | ||
=== Metadata === | === Metadata === | ||
- | The first step towards saving an item is to create an item object of the desired [[http://gsl-nagoya-u.net/ | + | The first step towards saving an item is to create an item object of the desired [[https://aurimasv.github.io/z2csl/typeMap.xml|item type]] (examples from "NCBI PubMed.js" |
<code javascript> | <code javascript> | ||
- | Metadata can then be stored in the properties of the object. Of the different fields available for the chosen item type (see the [[http://gsl-nagoya-u.net/ | + | Metadata can then be stored in the properties of the object. Of the different fields available for the chosen item type (see the [[https://aurimasv.github.io/z2csl/typeMap.xml|Field Index]]), only the title is required. E.g.: |
<code javascript> | <code javascript> | ||
Line 74: | Line 76: | ||
document: | document: | ||
+ | Zotero will automatically use proxied versions of attachment URLs returned from translators when the original page was proxied, which allows translators to construct and return attachment URLs without needing to know whether proxying is in use. However, some sites expect unproxied PDF URLs at all times, causing PDF downloads to potentially fail if requested via a proxy. If a PDF URL is extracted directly from the page, it's already a functioning link that's proxied or not as appropriate, | ||
+ | |||
+ | <code javascript> | ||
+ | item.attachments.push({ | ||
+ | url: | ||
+ | title: "EBSCO Full Text", | ||
+ | mimeType:" | ||
+ | proxy: false | ||
+ | }); | ||
+ | </ | ||
=== Notes === | === Notes === | ||
Line 185: | Line 197: | ||
Export translators use '' | Export translators use '' | ||
<code javascript> | <code javascript> | ||
- | var item; | + | function doExport() { |
- | while (item = Zotero.nextItem()) { | + | |
- | | + | while (item = Zotero.nextItem()) { |
+ | Zotero.write(item.title); | ||
+ | } | ||
} | } | ||
</ | </ |