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
Last revisionBoth sides next revision
dev:how_to_write_a_zotero_translator_plusplus [2010/07/28 09:55] – split ch4 <html> into sections tomrochewikidev:how_to_write_a_zotero_translator_plusplus [2017/11/12 19:53] – external edit 127.0.0.1
Line 1: Line 1:
 +<html><p id="zotero-5-update-warning" style="color: red; font-weight: bold">We’re
 +in the process of updating the documentation for
 +<a href="https://www.zotero.org/blog/zotero-5-0">Zotero 5.0</a>. Some documentation
 +may be outdated in the meantime. Thanks for your understanding.</p></html>
 +
 +
 +**Note: This guide's advice on translator code [[https://github.com/zotero/translators/pull/1282#issuecomment-287574730|may be outdated]].** Instead, model your code on [[https://github.com/zotero/translators/pulls|recently updated translators]], [[https://github.com/zuphilip/translators/wiki/Common-code-blocks-for-translators|common code templates]], [[https://www.zotero.org/support/dev/translators/coding|the translator coding documentation]], and search for answers in the [[https://forums.zotero.org/discussions|Zotero Forums]] and [[https://github.com/zotero/translators/issues|on GitHub]].
 +
 ===== Chapter 0: Introduction ===== ===== Chapter 0: Introduction =====
  
Line 203: Line 211:
 Be sure you have the most up to date version of Zotero. You can find this information on the [[http://www.zotero.org/|Zotero website]]. Be sure you have the most up to date version of Zotero. You can find this information on the [[http://www.zotero.org/|Zotero website]].
  
-==== Scaffold 2.0 ====+==== Scaffold ====
  
-install Scaffold from [[http://bitbucket.org/rmzelle/scaffold/downloads|here]] (temporarily)+Install [[https://www.zotero.org/support/dev/translators/scaffold Scaffold]]. Note that it has been updated more recently than most of this wiki, and some features may have changed.
  
 The makers of Zotero created Scaffold specifically for writing translators. It's a sort of a "sandbox," which means you can muck around with the code without worrying about really messing anything up, and it automates some tasks. In this guide, all code will be written, tested, and retested in Scaffold. The makers of Zotero created Scaffold specifically for writing translators. It's a sort of a "sandbox," which means you can muck around with the code without worrying about really messing anything up, and it automates some tasks. In this guide, all code will be written, tested, and retested in Scaffold.
Line 581: Line 589:
 ===== Chapter 5: XPath directions ===== ===== Chapter 5: XPath directions =====
  
-[[http:/XPath directions/niche-canada.org/member-projects/zotero-guide/chapter5.html|HWZT chapter 5 (XPath directions)]]:+[[http://niche-canada.org/member-projects/zotero-guide/chapter5.html|HWZT chapter 5 (XPath directions)]]:
  
 The {DOM Inspector + XPather} workflow differs from that of Solvent. After opening the [[http://niche-canada.org/member-projects/zotero-guide/sample1.html|first sample page]], The {DOM Inspector + XPather} workflow differs from that of Solvent. After opening the [[http://niche-canada.org/member-projects/zotero-guide/sample1.html|first sample page]],
-  - Open DOM Inspector (aka //DI//) with C-S-i or from the Firefox main menu with Tools>DOM Inspector. XPather functionality is available from UI within the DI window.+  - Open DOM Inspector (aka //DI//) with CTRL+SHIFT+C or from the Firefox main menu with Tools>DOM Inspector. XPather functionality is available from UI within the DI window.
   - Hit button=Inspect at the upper right of the DI window. This will open pane=Browser in the DI window displaying the contents of the first sample page.   - Hit button=Inspect at the upper right of the DI window. This will open pane=Browser in the DI window displaying the contents of the first sample page.
   - To test the XPath string denoting the heading (text="Method and Meaning in Canadian Environmental History") of the first sample page,   - To test the XPath string denoting the heading (text="Method and Meaning in Canadian Environmental History") of the first sample page,
Line 639: Line 647:
   - The URI of the sample page has changed since HWZT, so you will need to enter Target=<code>http://niche-canada.org/member-projects/zotero-guide/</code>   - The URI of the sample page has changed since HWZT, so you will need to enter Target=<code>http://niche-canada.org/member-projects/zotero-guide/</code>
   - Hit button="Test Regex". You should get a result, in the "Test Frame" on the right of the tab, similar to that described in HWZT.   - Hit button="Test Regex". You should get a result, in the "Test Frame" on the right of the tab, similar to that described in HWZT.
-  - Instead of <code>Click on the "Detect Code" tab</code>, click on tab=Code.  +  - Instead of <code>Click on the "Detect Code" tab</code>, click on tab=Code. This is the tab where code should be entered
-  - In that tab enter <code>function detectWeb(doc, url) {+  - To excute code and debug, HWZT has you click an "Execute" button with a thunderbolt icon.  In newer versions of Scaffold, the single execute button as been replaced by one "Run doWeb" button (thunderbolt icon) and one "Run detectWeb" button (eye icon).  Starting in HWZT exampe 11.6, you'll be writing detectWeb functions, so you'll need to click the "Run detectWeb" button to run your detectWeb function.  For example, at example 11.6, when you click "Run detectWeb", you should get results like <code>12:00:00 Title:</code> 
 + 
 + 
 +As noted at HWZT, example 11.4, certain code needs to be included inside the top of every Function in which you have an XPath (container).  So, putting everything together, the code for example 11.6 should look like this: <code>function detectWeb(doc, url) {
   var namespace = doc.documentElement.namespaceURI;   var namespace = doc.documentElement.namespaceURI;
   var nsResolver = namespace ? function(prefix) {   var nsResolver = namespace ? function(prefix) {
Line 650: Line 661:
   Zotero.debug(myXPathObject);   Zotero.debug(myXPathObject);
 }</code>  }</code> 
-  - Click on icon="Run detectWeb" (the eye): you should get results like <code>12:00:00 Title:</code> 
  
-The code for the second complete Scaffold example (from "Example 11.10") is similarly+The code for the second complete Scaffold example (from "Example 11.9") is similarly
 <code>function detectWeb(doc, url) { <code>function detectWeb(doc, url) {
   var namespace = doc.documentElement.namespaceURI;   var namespace = doc.documentElement.namespaceURI;
dev/how_to_write_a_zotero_translator_plusplus.txt · Last modified: 2017/11/19 19:24 by adamsmith