WikiCite

From Computational Cognitive Neuroscience Wiki
Jump to: navigation, search

Overview

WikiCite is a Mediawiki extension to allow to create scientific references and bibliographys on a wiki and link it to the bibliographic information in a Zotero database. It allows to easily create (and link) wiki pages to write notes and comment on individual papers, create inline references in a variety of scientific citation styles and generate a bibliography for the papers cited on a page.

Using WikiCite

Paper pages

These are the pages about a specific paper. The extension provides a template to include an info box with the bibliographic data of the paper and a link to the entry in Zotero. Paper pages should be created if you want to take notes about a paper. In order to do this you go to the corresponding wiki page, e.g. HornerBurgess13. The title of the page is the bibtex key of the paper. What this key is exactly, depends on if there is a bibtex key in the Zotero database for the paper, or how the linking database was configured. By default WikiCite is configured to use the citation key style of [authors3][shortyear]. If no one else has created the page so far, this page will not yet exist. You will have to create it and then add the { { cite_page } } template to the page. This will then render out the paper info box assuming there already is an entry for this paper in Zotero. After adding this template, you can use the page as normal to create comments.

Referencing other papers from a notes page

When writing notes, one can cite papers . This is done using the { { cite | HornerBurgess13 } } template. If the citation points to a paper for which there is a page on the wiki with notes, this link will point to this wiki entry, otherwise, it will point directly to the Zotero page of the paper. It is also possible to cite papers inline. E.g. Horner & Burgess (2013) claim a certain thing. This is done using the { { citet | HornerBurgess13 } } template. Furthermore, it is possible to cite papers in different formats. E.g. one can cite the paper in APA style (Horner & Burgess, 2013) or in Cell style (Horner and Burgess, 2013) or any of the other citation style defined in zotero [1]. The different styles are defined as the second parameter to the template { { cite | HornerBurgess13 | ieee } }. It is possible to create custom made citation styles. The citation style definitions are written in citation style language | (CSL) . One can also cite multiple papers (Horner & Burgess, 2013; Horner, Bisby, Bush, Lin, & Burgess, 2015; Huys & Dayan, 2009) by specifying a comma separated list of bibkeys: { { cite|HornerBurgess13,HornerBisbyBushEtAl15,HuysDayan09|apa } }

Adding bibliography information to a page

It is also possible to create bibliographies on pages with the full bibliographic information about the papers. This is done with the { { cite_ref | HornerBurgess13 } } template. Again, it is possible to specify the style to use in the bibliography as the second argument to the template { { cite_ref | HornerBurgess13 | apa } }. The style definitions are again written in | CSL


  • Horner, A. J., & Burgess, N. (2013). The associative structure of memory for multi-element events. Journal Of Experimental Psychology. General, 142(4), 1370-1383. http://doi.org/10.1037/a0033626
  • Horner, A. J., Bisby, J. A., Bush, D., Lin, W. -J., & Burgess, N. (2015). Evidence for holistic episodic recollection via hippocampal pattern completion. Nature Communications, 6, 7462. http://doi.org/10.1038/ncomms8462

It is also possible to automatically generate a bibliography from all of the { { cite } } entries on a given page. One can add the template { { citereferences } } into the page, which then expands into a "References" section with the bibliographic information of all of the papers on the page, like it is shown at the end of this page. This is based on the wikiCite-function { { #citebibliography: apa } }

Setting up WikiCite

You can download all of the necessary code, both for the mediawiki extension and the backend linking database management scripts from the [WikiCite git repository https://github.com/apmon/WikiPapers2]. The mediawiki extension queries a linking database, that matches bibtex keys (used in the wikis) to (cryptic) zotero keys.

It is possible to either setup your own linking database (with your own Zotero citation database), or use the linking database used by the ccnlab. We recommend the latter -- email mailto:wikicite@grey.colorado.edu to request access to the CCNLab group on Zotero: https://www.zotero.org/groups/ccnlab

Installing MediWiki extension

  • To install the MediaWiki extension, first copy the content (WikiCite) in the WikiCite mediawiki directory to the extensions directory of your mediawiki installation.
  • Add the line "include_once("$IP/extensions/WikiCite/WikiCite.php");" to your LocalSettings.php of the mediawiki installation where you want to use WikiCite

There are three mediwiki settings for this extension that control which linking and zotero database $wgWikiCiteLinkerURL = 'https://grey.colorado.edu/wikicite/'; $wgWikiCiteZoteroGroupID = 340666; $wgWikiCiteZoteroGroup = 'ccnlab';

Installing mediawiki templates

The mediawiki extension will create a number of parser functions e.g. Template:cite. For cleaner access, there are a number of templates that wrap these parser functions, which use the syntax described above. To install the set of templates, you need to import these templates into your wiki. using the [ [ Special:Import ] ] page. The file containing the templates is in the WikiCite repository's top level directory (cite_templates.xml)

Installing linking database

Again, don't do this unless you want to use your own Zotero group, instead of the ccnlab group:

This provides a webservice and a database to link Zotero item keys with bibtex keys used on the wiki. I.e. it allows to translate between the non-sematic keys in Zotero ( e.g. 6HSZQF6P ) to the bibtex (semantic) ( e.g CardinalCheung05 ) keys used in the mediawiki extension. The actual database contains of a single table id_links, that contains two columns (wiki_id, zotero_id) that gets populated with the data in Zotero. There is a python script, that uses the Zotero API to query all entries in your Zotero database and generates a bib key to add to the linking database. This bib key is either taken from the Zotero entry's "extra" field, or if the former is not available it will try and auto generate it from the author and date information. The python script can either be manually invoked (e.g. on initial population), or it will automatically get invoked when the webservice is queried for an entry that does not yet exist in the database.

The webservice provides two functions wikicite.php and wikicite_api.php. Each take either a "wiki_id" or a "zotero_id" argument. (e.g. https://grey.colorado.edu/wikicite/wikicite_api.php?zotero_id=6PFXRK8Z ). Wikicite.php will generate a page to automatically forward you to the other. I.e. if you pass it a wiki_id, it will forward you to the corresponding Zotero page. If you pass a zotero_id, it will forward you to the appropriate wiki page. The wikicite_api.php on the other hand will just return a single json object containing both wiki_id and zotero_id for the respective entry.

It is not necessary to create a separate linking database for each wiki you want to use the zotero bibliography data. This is only necessary if you don't want to use the shared Zotero repository, or use a different bib key schema.

Creating a mysql database to contain the linking database

  • Create a new database in mysql
  • Load the database schema (schema.sql) found in the repository.

Setting up https://your_domain/wikicite

  • copy the contents of sync_daemon from the github repository into your webserver directory and ensure the php can be run.
  • setup database_config.json, zotero_config.json and settings.php

Setting up your Zotero client to work with WikiCite

If you're going to use the CCNLab group library, email: mailto:wikicite@grey.colorado.edu to get added to this group: https://www.zotero.org/groups/ccnlab Anyone doing work in the CCN field is welcome to join our group!

MUST INSTALL BetterBibTex: in Firefox, go here: https://zotplus.github.io/better-bibtex/index.html click on the install package -- it just installs as a Firefox extension, automatically.

Go to the Settings menu (gear) in the Firefox zotero app / Preferences / BetterBibTex pane, enter the following settings:

  • Citation key format:
  •  [authors3][shortyear] 
  • Auto-pin citation keys: On item change
  • This will record the bibkey in the extra field in Zotero -- Randy has already generated all the keys for all the existing refs, so you only need to make sure it is generated for anything you change or add.
  • On conflict..: changed
  • show citekey instead of extra: -- I wasn't able to get this to work on mac firefox.. also the subsequent option of re-importing upon restart does cause it to be slow to startup the next time, and then automatically turns itself off -- apparently this is just a one-time thing.
  • under Advanced tab: check Retain LaTeX markup on BibTeX Import
  • go to overall zotero preferences, tab Export, under Default Output Format, select “Better BibTeX Quick Copy” -- this allows you to drag-and-drop from zotero into your latex editor and get the \cite{bibkey} right there! very nice!

MUST INSTALL ZotFile: in Firefox, go here: http://zotfile.com/ click on install..

  • this supports auto-renaming of PDF attachments, according to our standard bibkey, plus a number of other potentially useful features.
  • in zotero settings / ZotFile Preferences, Renaming Rules, set the following:
  • Format for all Item Types except Patents:
  •  {%b} 
  • this automatically grabs the bibtex: key from the entry!
  • Advanced Settings:
  • Automatically rename new attachments: Always rename

Duplicate Detection

Zotero doesn't detect dupes as they happen when adding new items -- this plugin helps with that: https://github.com/corajr/zotero-prevent-duplicates -- just gives you a "ok cancel" kind of option, but at least you know about the dupe. We may try to improve it. Here is the installable package file: ftp://grey.colorado.edu/pub/oreilly/misc/preventduplicates.xpi -- otherwise you need to download the archive to a zip file, uncompress that, and run the package.sh script, then click on the resulting .xpi file..

Very Handy: Two Quick Copy Export Formats

The following steps allow you to drag and drop an item from the firefox plugin to a tab in firefox and automatically go to either that item in the web-based version of zotero (giving you the all-important ItemKey link), or to that item in lab wiki! It uses the current url that the browser tab is set to, to decide which one to use, so you just need to start with the wiki and zotero web tabs open and these will work.

Overall strategy is to install two small files into your firefox zotero data directory, which provide the "export translators" (see https://www.zotero.org/support/dev/translators) that do the work. Then set the preferences to make their use dependent on which web site you're on.

First, find your firefox zotero data directory by doing to zotero prefs, Advanced / Files and Folders, and click on Show Data Directory button -- on a mac, this may be in something like: /Users/<user>/Library/Application Support/Firefox/Profiles/<special code>.default/zotero. Then copy the following two files into the translators subdirectory there:

zotitem-link.js:

{
"translatorID":"c33430e2-0f69-43d2-8025-7d8def0a112d",
"translatorType":2,
"label":"Zotero ItemLink",
"creator":"Randall O'Reilly",
"target":"html",
"minVersion":"2.0",
"maxVersion":"",
"priority":200,
"inRepository":false,
"displayOptions":{"exportCharset":"UTF-8"},
"lastUpdated":"2015-05-18 22:27:00"
}
 
function doExport() {
	var item;
	while(item = Zotero.nextItem()) {
		Zotero.write("https://www.zotero.org/groups/ccnlab/items/itemKey/");
		Zotero.write(item.key);
	}
}

wikicite-link.js

{
"translatorID":"b4378972-049b-4000-a393-ec8a4f4f4dd2",
"translatorType":2,
"label":"WikiCite Link",
"creator":"Randall O'Reilly",
"target":"html",
"minVersion":"2.0",
"maxVersion":"",
"priority":200,
"inRepository":false,
"displayOptions":{"exportCharset":"UTF-8"},
"lastUpdated":"2015-05-18 22:27:00"
}
 
function doExport() {
	var item;
	while(item = Zotero.nextItem()) {
		Zotero.write("https://grey.colorado.edu/wikicite/wikicite.php?zotero_id=");
		Zotero.write(item.key);
	}
}

(for future reference, I got my GUID for the translatorID from https://gu8id.us )

Then, restart firefox, and go to zotero preferences / export, click the + to add a new site-specific setting, enter grey.colorado.edu as the domain, and select WikiCite Link as the output format (if this is not an option, the above translator files were not installed properly). Then add another and enter zotero.org with Zotero ItemLink as the output format. You can leave the default output format to LaTeX Citation, for copying into your editor while writing etc.

Then, give it a try! this mostly replaces the bookmark listed below. bookmark might still be convenient to go from Zotero ItemLink to wiki page.

Exporting the .bib File

  • use the context menu on the CCNLab folder, select Export Library and select BetterBibTex as the export format
  • also going to the gear menu and selecting export should work, as long as CCNLab folder is selected.
  • the first export will likely take quite a long time, but subsequent ones should be much faster -- it uses caching to speed up exports.
  • You will have to export two different files: ccnlab.bib and ccnlab_abbrv.bib -- one with journal abbreviations and the other without -- some journals want it one way and others the other way, and there doesn't seem to be any automatic way of doing this within bibtex / latex. Generally don't select any of the other options for exporting (keep it small).
  • See LatexToDoc for info on converting the final rendered LaTeX pdf to a word file.


References

  • Horner, A. J., Bisby, J. A., Bush, D., Lin, W. -J., & Burgess, N. (2015). Evidence for holistic episodic recollection via hippocampal pattern completion. Nature Communications, 6, 7462. http://doi.org/10.1038/ncomms8462
  • Horner, A. J., & Burgess, N. (2013). The associative structure of memory for multi-element events. Journal Of Experimental Psychology. General, 142(4), 1370-1383. http://doi.org/10.1037/a0033626
  • Huys, Q. J. M., & Dayan, P. (2009). A Bayesian formulation of behavioral control. Cognition, 113(3), 314-328. http://doi.org/10.1016/j.cognition.2009.01.008