Zotero translator for Wikimedia blog

This page shows how to build a Zotero web translator for the Wikimedia blog. We will be testing it on translation-server.

Create translator file and add Metadata

Set-up the environment for development of translators through translation following the steps as explained here.

Create a new file in you text editor named Wikimedia Blog.js and save it in translation-server/modules/zotero/translators.

Add the metadata in the format as shown at the top of the file. Generate a hash code by running md5sum /exact-path/Wikimedia blog.jn the terminal and enter it as the translatorID.

Generate the system time using the command date "+%Y-%m-%d %H:%M:%S" in the terminal. Add your name under the creator and let other fields be as shown.

Add polyfill functions and detectWeb

Next, add the polyfill functions for text and attr Open this Wikimedia blog entry in a browser tab and let us find out a way to identify any url if it is a single entry or not. Press Ctrl+Shift+I and check the class attribute in the body tag of the page.It can be used as a way of identifying the page type. We can use the string "single-post" to check if a page is a single blog entry or not.

Open this Search page of the blog in a browser tab and see the body tab to find a way to identify search results. Here the class inside the body tag has substrings like "search", "search-results", etc. So for any url we receive, we can check the class attribute of body tag to know the ti\ype of document in which we want to classify it. Following is the detectWeb code using this logic. Add getSearchResults and doWeb function

For detectWeb to work, we need to write the getSearchResults. This method should be able to pick all results from a multiple items page and save it in key,value pairs with the corresponding url.