This is an old revision of the document!


Setting up the standalone citeproc-node server

1. Get citeproc-node

svn co https://www.zotero.org/svn/citeproc-node/trunk citeproc-node
cd citeproc-node

2. Get CSL 1.0 citation styles

git clone https://github.com/citation-style-language/styles.git

3. Move CSL styles to where citeproc-node can find them

mv styles csl1.0

4. Get citeproc-js

hg clone https://bitbucket.org/fbennett/citeproc-js

5. Get sample data from citeproc-js

mv citeproc-js/demo/sampledata.html .

6. Remove citeproc-js directory

rm -rf citeproc-js

7. Get node-o3-xml processing library

git clone https://github.com/ajaxorg/node-o3-xml.git

If no prebuild of node-o3-xml is available for your platform (e.g. 32-bit Mac OS X), you can built it yourself:

git clone https://github.com/ajaxorg/o3.git
cd o3
./tools/node_modules_build
cp build/default/o3.node ../node-o3-xml/lib/o3-xml/

8. Get CSL locale files

git clone https://github.com/citation-style-language/locales.git

9. Move CSL locale files to where citeproc-node can find them

mv locales csl-locales

Your directory listing is now

benchServer.js       COPYING        loadcitesnode.js  testciteproc.js
citeprocmodule.js    csl1.0         node-o3-xml       zoteronode.js
citeprocnode.js      cslFetcher.js  sampledata.html
citeServerConf.json  csl-locales    stdNodeTest.js
citeServer.js        csl_nodejs.js  step.js

(csl1.0, node-o3-xml, and csl-locales are all directories)

10. Change configured path to xml library

open config file:  vi citeServerConf.json

change the line: “parserPath” : “../nodejs/node-o3-xml/lib/o3-xml”, to: “parserPath” : “./node-o3-xml/lib/o3-xml”,

11. Start the server (assuming node binary is in your path):

node citeServer.js

If all is well, you will see:

debug log file :./citeServerLog.log
precaching CSL engines
processStyleIdentifier
short name only
Server running at http://127.0.0.1:8085/
zcite.createEngine
cpSys created
en-US

and in 20 or 30 seconds also:

engine created
zcite.cacheSaveEngine
http://www.zotero.org/styles/chicago-author-date:en-US
saving engine
turn precache flag off
last Step

Now to test the server. Open another window and cd into your citeproc-node directory.

1. Edit the sampledata.html document to the expected JSON format to POST:

vi sampledata.html

get rid of the HTML markup at the top & bottom of the file

delete:

<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  <title>Sample data for CSL demo page</title>
</head>
<body>
<pre>

and delete (note the semicolon – I think that is a typo in the file, so make sure and delete it):

;
</pre>
</html>

2. Now you should have a valid JSON file, BUT the server expects to find an “items” object in the POST, so wrap this JSON but adding this as a first line:

{ "items" :

and, of course, this as a last line:

}

3. Save this file as “sampledata.json”

4. Try posting it to your server (which you should still have running):

curl --header "Content-type: application/json" --data @sampledata.json -X POST http://127.0.0.1:8085?responseformat=html\&style=mla

You should see this response appear on your screen:

<div class="csl-bib-body">
  <div class="csl-entry">Abbott, Derek A. et al. “Metabolic engineering of &amp;lt;i&amp;gt;Saccharomyces cerevisiae&amp;lt;/ i&amp;gt; for production of carboxylic acids: current status and challenges.” <i>FEMS Yeast Research</i> 9.8 (2009): 1123-1136.</div>
  <div class="csl-entry">“Beck v. Beck.” <i>ME</i> 1999: 110.</div>
  <div class="csl-entry">---. <i>A.2d</i> 1999: 981.</div>
  <div class="csl-entry">Bennett, Frank G., Jr. “Getting Property Right: ‘Informal’ Mortgages in the Japanese Courts.” <i>Pacific Rim Law &amp; Policy Journal</i> 18 (2009): 463-509.</div>
  <div class="csl-entry">“British Columbia Elec. Ry. v. Loach.” <i>App. Cas.</i> 1915: 719.</div>
  <div class="csl-entry">“Clayton Act.” <i>ch.</i> 1914.</div>
  <div class="csl-entry">---. <i>Stat.</i> 1914: 730.</div>
  <div class="csl-entry">“Donoghue v. Stevenson.” <i>App. Cas.</i> 1932: 562.</div>
  <div class="csl-entry">DʼArcus, Bruce. <i>Boundaries of Dissent: Protest and State Power in the Media Age</i>. Routledge, 2005.</div>
  <div class="csl-entry">“FTC Credit Practices Rule.” <i>C.F.R.</i> 1999.</div>
  <div class="csl-entry">Malone, Nolan J., U.S. Bureau of the Census. <i>Evaluating Components of International Migration: Consistency of 2000 Nativity Data</i>. Routledge, 2001.</div>
  <div class="csl-entry">“People v. Taylor.” <i>N.Y.2d</i> 1989: 683.</div>
  <div class="csl-entry">---. <i>N.E.2d</i> 1989: 386.</div>
  <div class="csl-entry">---. <i>N.Y.S.2d</i> 1989: 357.</div>
  <div class="csl-entry">Razlogova, Elena. “Radio and Astonishment: The Emergence of Radio Sound, 1920-1926.” May 2002.</div>
  <div class="csl-entry">---. “True Crime Radio and Listener Disenchantment with Network Broadcasting, 1935-1946.” <i>American Quarterly</i> 58 (2006): 137-158.</div>
  <div class="csl-entry">Razlogova, Elena, and Lisa Lynch. “The Guantanamobile Project.” <i>Vectors</i> 1 (2005).</div>
  <div class="csl-entry">Zelle, Rintze M. et al. “Key Process Conditions for Production of C&amp;lt;sub&amp;gt;4&amp;lt;/sub&amp;gt; Dicarboxylic Acids in Bioreactor Batch Cultures of an Engineered &amp;lt;i&amp;gt;Saccharomyces cerevisiae&amp;lt;/i&amp;gt; Strain.” <i>Applied and Environmental Microbiology</i> 76.3 (2010): 744-750.</div>
  <div class="csl-entry">梶田将司 et al. “高等教育機関における次世代教育学習支援プラットフォームの構築に向けて.” <i>日本教育工学会論文誌</i> Dec. 2007: 297-305.</div>
  <div class="csl-entry">“民法.”</div>
</div>
dev/citeproc-node.1302879236.txt.gz · Last modified: 2011/04/15 10:53 by rmzelle