Permalink
Browse files

- Allow specifying bind_port and bind_addr in config.json

- Allow specifying bind_port on command line
- Update translators repository when refresh is called
- Set logging level to 3
- Don't support MODS yet in config.json
  • Loading branch information...
1 parent 4e92831 commit d93ca79fdcdae9631e18382cf0207797f9438735 @simonster simonster committed Jul 8, 2011
Showing with 32 additions and 6 deletions.
  1. +1 −1 README
  2. +2 −1 config.json
  3. +4 −1 src/zotero.js
  4. +25 −3 zotero-node.js
View
@@ -6,4 +6,4 @@ Dependencies:
node.js (tested with v0.4.9)
jsdom (tested with v0.2.0)
rdf-raptor-parser (tested with v0.1.2)
-o3-xml (not yet tested at all, since we use rdf-raptor-parser for XML parsing)
+o3-xml (not used yet, but will be, once MODS is ported to DOMParser)
View
@@ -1,10 +1,11 @@
{
+ "bind_addr":"127.0.0.1",
+ "bind_port":1969,
"translators_dir":"./translators",
"formats":{
"bibliontology_rdf":"14763d25-8ba0-45df-8f52-b8d1108e7ac9",
"bibtex":"9cb70025-a888-4a29-a210-93ec52da40d4",
"bookmarks":"4e7119e0-02be-4848-86ef-79a64185aad8",
- "mods":"0e2235e7-babf-413c-9acf-f27cce5f059c",
"refer":"881f60f2-0802-411a-9228-ce5f47b64c7d",
"dc_rdf":"6e372642-ed9d-4934-b5d1-c11ac758ebb7",
"ris":"32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7",
View
@@ -62,6 +62,9 @@ var Zotero = new function() {
if (!level) {
level = 3;
}
+ if(level > Zotero.Prefs.get("debug.level")) {
+ return;
+ }
if (typeof message !== 'string') {
message = Zotero.Utilities.varDump(message);
@@ -105,7 +108,7 @@ Zotero.Prefs = new function() {
"debug.log":true,
"debug.store":false,
"debug.store.limit":750000,
- "debug.level":5,
+ "debug.level":3,
"debug.time":false,
"downloadAssociatedFiles":false,
"automaticSnapshots":false,
View
@@ -2,6 +2,7 @@ var z = require('./zotero_bundle');
var url = require('url');
var http = require('http');
var fs = require('fs');
+var child_process = require('child_process');
var config = JSON.parse(fs.readFileSync("./config.json", "utf-8"));
var Zotero = z.Zotero;
@@ -166,11 +167,32 @@ var Endpoints = {
},
"/refresh":function(input, query, res) {
- // TODO update git checkout
- TranslatorLoader.loadTranslators();
+ var child = child_process.spawn("git", ["pull"], { "cwd":__dirname+"/translators" });
+ child.stdout.setEncoding('utf8');
+ child.stdout.on('data', function (data) {
+ if(data) Zotero.debug("git: "+data.trim());
+ });
+ child.stderr.setEncoding('utf8');
+ child.stderr.on('data', function (data) {
+ if(data) Zotero.debug("git: "+data.trim());
+ });
+ child.on("exit", function() {
+ res.writeHead(200, {'Content-Type': 'text/plain'});
+ res.end("Translators updated.\n");
+ TranslatorLoader.loadTranslators();
+ });
}
};
+var port = config.bind_port;
+if(process.argv.length > 2) {
+ if(process.argv.length !== 4 || process.argv[2] !== "-p") {
+ console.log("Usage: node zotero-node.js [-p port]");
+ process.exit(1);
+ }
+ port = process.argv[3];
+}
+
Zotero.init();
TranslatorLoader.loadTranslators();
http.createServer(function(req, res) {
@@ -195,4 +217,4 @@ http.createServer(function(req, res) {
}
};
for(var i in listeners) req.addListener(i, listeners[i]);
-}).listen(1969, "127.0.0.1");
+}).listen(port, config.bind_addr);

0 comments on commit d93ca79

Please sign in to comment.