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
Next revisionBoth sides next revision
dev:translators:scaffold [2019/08/05 05:46] dstillmandev:translators:scaffold [2022/04/15 15:32] – Update for overhauled Scaffold abejellinek
Line 1: Line 1:
-<html><p id="zotero-5-update-warning" style="color: red; font-weight: bold">We’re 
-in the process of updating this page after recent changes to Scaffold. Some parts may be outdated in the meantime. Thanks for your understanding.</p></html> 
- 
- 
 ====== Scaffold - an IDE for Zotero translators ====== ====== Scaffold - an IDE for Zotero translators ======
  
Line 19: Line 15:
 After selecting your translator directory, the main Scaffold window will open: After selecting your translator directory, the main Scaffold window will open:
  
-{{:dev:translators:scaffold.png?640&nocache&nolink|}}+{{:dev:translators:scaffold_new_small.png?750&nocache&nolink|}}
  
 ==== Top buttons ==== ==== Top buttons ====
Line 29: Line 25:
 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. 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** \\  +{{:dev:translators:savetozotero.png?16&nocache&nolink|}} **Save to Zotero** \\ 
-Saves and runs the ''detectWeb'' function of the translator code on the site loaded in the browser tab.+Saves the translator you are currently working on and writes it to the "translators" subdirectory of the Zotero data directory, making it available to the client and Zotero Connector. (To use it in the Connector, open the Connector preferences to the Advanced tab and click Reset Translators.)
  
-{{:dev:doweb.png?nocache&nolink|}} **Run doWeb** \\  +{{:dev:translators:detectweb.png?16&nocache&nolink|}} **Run detect*** \\  
-Saves and runs the ''doWeb'' function of the translator code on the site loaded in the browser tab.+Saves and runs the appropriate ''detect'' function
 +  * If it's a web translator and a page is loaded in the Browser tab: ''detectWeb'' 
 +  * If it's an import translator and data has been entered in the Test Data tab: ''detectImport'' 
 +  * If it's a search translator and a JSON search object has been entered in the Test Data tab: ''detectSearch''
  
-{{:dev:translators:detectimport.png?nocache&nolink|}} **Run detectImport** \\  +{{:dev:translators:doweb.png?16&nocache&nolink|}} **Run do*** \\  
-Saves and runs the ''detectImport'' function of the translator code on the content entered in the Import tab. +Saves and runs the appropriate ''do'' function of the translator code. Runs the corresponding ''do'' functions for the above situations, plus: 
- +  If it's an export translator and an item is selected in the main Zotero window: ''doExport''
-{{:dev:translators:doimport.png?nocache&nolink|}} **Run doImport** \\  +
-Saves and runs the ''doImport'' function of the translator code on the content entered in the Import tab.+
  
  
Line 46: Line 43:
 **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. **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. The editor supports syntax highlighting, folding of code parts, and search and replace+**Code** \\ The text box in this tab contains the translator's JavaScript code. The editor supports syntax highlighting, folding of code parts, search and replace, basic type inference, code suggestions, Zotero-specific hints when hovering over an item type or translator UUID string, and more.
- +
-**Import** \\ For import translator you can copy here test data to import.+
  
-**Tests**\\ This tab contains the data for all test cases saved with the translator, which is currently open.+**Tests**\\ This tab contains the list of tests saved in the translator, as well as the raw JSON and expected output for each one. You can run or update tests from here. Create tests from the corresponding tab for the type of test you want to create (Browser or Test Data).
  
-**Testing**\\ This is a list of all test cases for the current translator, which you can run, check or update.+**Test Data** \\ Input data for import and search translators.
  
-**Browser**\\ You can open specified URLs in the browser tab and then test the detection and data extraction for that website.+**Browser**\\ View sites and test detection and data extraction.
  
 ==== Debug Output ==== ==== Debug Output ====
Line 110: Line 105:
 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. 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.
  
-===== Import Translators ===== +===== Import, Export, and Search Translators ===== 
-Starting with version 2.1.2, Scaffold can be used to test import translators. To do so, enter the test import data in the "Import" tab and use the "Run detectImport" and "Run doImport" buttons to test the translator against the data. The output will be displayed in the right-hand pane as with web translators.+Starting with version 6.0, Scaffold can be used to test import, export, and search translators. To test an import or search translator, enter the test data in the "Test Data" tab and use the "Run detect*" and "Run *" buttons to test the translator against the data. The output will be displayed in the right-hand pane as with web translators. For export translators, select an item in the main Zotero window to use it for testing.
  
 In the translator load window, import translators are arranged in alphabetical order at the bottom of the list. In the translator load window, import translators are arranged in alphabetical order at the bottom of the list.
Line 117: Line 112:
  
 ===== Scaffold Troubleshooting ===== ===== Scaffold Troubleshooting =====
-  * **Why does my translator work in Scaffold but not when I click on the address bar icon in my browser?** +  * **Why does my translator work in Scaffold but not when I click on the toolbar icon in my browser?** 
-Scaffold runs the functions ''detectWeb'' and ''doWeb'' against the active document in the top Firefox window. Outside of Scaffold, clicking the address bar icon runs the first web translator with a matching ''target'' regular expression that returns a non-false value from the function ''detectWeb'', when run on that document and URL.+Scaffold runs the functions ''detectWeb'' and ''doWeb'' against the active document in the top browser window. Outside of Scaffold, clicking the toolbar icon runs the first web translator with a matching ''target'' regular expression that returns a non-false value from the function ''detectWeb'', when run on that document and URL.
  
-This can differ from the active document in Firefox when the ''target'' expression or ''detectWeb'' conditions are too lax, which can allow embedded documents, such as IFRAMES used for advertising or sharing panes, to be detected as content pages. To see if this is what is happening, look at the debug output for a save attempt from Firefox proper and check the URL that is being processed.+This can differ from the active document in Firefox when the ''target'' expression or ''detectWeb'' conditions are too lax, which can allow embedded documents, such as ''iframe''used for advertising or sharing panes, to be detected as content pages. To see if this is what is happening, look at the debug output for a save attempt from Firefox proper and check the URL that is being processed.
  
   * **Why won't my attachments save?**   * **Why won't my attachments save?**
Line 132: Line 127:
 ====== Further Reading ====== ====== Further Reading ======
  
-More detailed instructions are available at [[https://www.mediawiki.org/wiki/Citoid/Creating_Zotero_translators#For_translation-server_side_development |MediaWiki]]. See [[https://www.mediawiki.org/wiki/Citoid/Creating_Zotero_translators#For_development_through_IDE|For development through IDE]] +More detailed instructions are available at [[https://www.mediawiki.org/wiki/Citoid/Creating_Zotero_translators|MediaWiki]]. These instructions may be slightly out of date.
- and [[https://www.mediawiki.org/wiki/Citoid/Creating_Zotero_translators#Run_on_Scaffold|Run on Scaffold]].+
dev/translators/scaffold.txt · Last modified: 2024/04/26 06:57 by dstillman