Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
dev:scaffold [2011/04/05 16:20] ajlyondev:scaffold [2018/05/07 13:09] (current) bwiernik
Line 1: Line 1:
-====== Scaffold - an IDE for Zotero translators ====== +See [[dev/translators/Scaffold]].
- +
-Translators in Zotero 2.x are stored as individual JavaScript files in the "translators" subdirectory of the [[:zotero_data|Zotero data directory]]. While translators can be edited with any tool, Scaffold is a Firefox add-on dedicated to writing Zotero translators, offering advantages such as real-time testing and debugging. +
- +
-===== Installation ===== +
- +
-Separate versions of Scaffold exist for Zotero 2.0 and 2.1: +
- +
-[[http://bitbucket.org/rmzelle/scaffold/downloads/scaffold2.1-20110227.xpi|Install Scaffold 2.1]]  +
-(compatible with Zotero 2.1.x, released February 27, 2011) +
- +
-[[http://bitbucket.org/rmzelle/scaffold/downloads/scaffold2.0-20100606.xpi|Install Scaffold 2.0]] (compatible with Zotero 2.0.x, released  June 6, 2010) +
- +
-===== Interface ===== +
- +
-After installation, the "Tools" menu in Firefox should contain a "Scaffold" item. Selecting this item opens the main Scaffold window: +
- +
-{{:dev:scaffold2.0-metadata.png?640&nocache&nolink|}} +
- +
-==== Top buttons ==== +
- +
-{{:dev:load.png?nocache&nolink|}} **Load** \\  +
-Opens the "Load Translator" window. Select one of the currently installed translators, and load the translator metadata and code into Scaffold. +
- +
-{{:dev:save.png?nocache&nolink|}} **Save** \\ +
-Saves the translator you are currently working on. Provide a unique label and translator ID for your translator if you don't want to overwrite an existing translator. New translator IDs can be automatically generated via the "Generate" button. +
- +
-{{:dev:detectweb.png?nocache&nolink|}} **Run detectWeb** \\  +
-Saves and runs the ''detectWeb'' function of the translator code on the site loaded in the most recently selected tab. +
- +
-{{:dev:doweb.png?nocache&nolink|}} **Run doWeb** \\  +
-Saves and runs the ''doWeb'' function of the translator code on the site loaded in the most recently selected tab. +
- +
-==== Tabs ==== +
- +
-**Metadata** \\ Shows the translator metadata. Translator IDs can be generated via the "Generate" button. The target regular expression can be tested with the "Test Regex" button. +
- +
-**Code** \\ The text box in this tab contains the translator's JavaScript code: +
- +
-{{:dev:scaffold2.0-code.png?640&nocache&nolink|}} +
- +
-==== Debug Output ==== +
- +
-The main strength of Scaffold is its ability to provide you with immediate feedback, which can dramatically speed up translator development. After a code change, a single click suffices to run the modified translator and generate debug output. The following types of debug output can be generated: +
- +
-=== Metadata === +
-When the "Test Regex" button in the "Metadata" tab is clicked, the regular expression in the target field is applied to the site loaded in the most recently selected Firefox tab. The debug window at the right of the Scaffold window will show whether the regular expression matches (''true'' for a match, ''false'' for no match), e.g.: +
- +
-<code> +
-09:54:11 ===>true<===(boolean) +
-</code> +
- +
-=== detectWeb and doWeb === +
- +
-When the "Run detectWeb" button is clicked, the ''detectWeb'' function of the translator will be executed. Similarly, clicking the "Run doWeb" button executes the translator's ''doWeb'' function. +
- +
-Debug output for the ''detectWeb'' function shows what type of item is found on the loaded webpage, e.g.: +
- +
-<code> +
-19:19:43 detectWeb returned type "book" +
-</code> +
- +
-Debug output for the ''doWeb'' function shows all the item data that would be saved if the translator would be run by Zotero (when testing translators with Scaffold, no items are actually saved to your Zotero library), e.g.: +
- +
-<code> +
-19:24:21 Returned item: +
-             'itemType' => "book" +
-             'creators' ... +
-                 '0' ... +
-                     'firstName' => "Herman" +
-                     'lastName' => "Melville" +
-                     'creatorType' => "author" +
-             'notes' ... +
-             'tags' ... +
-             'seeAlso' ... +
-             'attachments' ... +
-                 '0' ... +
-                     'title' => "Google Books Link" +
-                     'snapshot' => "false" +
-                     'mimeType' => "text/html" +
-                     'url' => "http://books.google.com/books?id=cYKYYypj8UAC" +
-                     'document' => "[object]" +
-             'date' => "1851" +
-             'pages' => "504" +
-             'ISBN' => "1603033742, 9781603033749" +
-             'publisher' => "Plain Label Books" +
-             'title' => "Moby Dick" +
-             'repository' => "Google Books" +
-             'complete' => function(...){...}  +
-          +
-19:24:21 Translation successful +
-</code> +
- +
-If running ''detectWeb'' or ''doWeb'' results in an error, the debug window will show an error message. For debugging, additional debug output can be added to the code by adding ''Zotero.debug(string);'' statements.+
dev/scaffold.1302034804.txt.gz · Last modified: 2011/04/05 16:20 by ajlyon