Commit 148f12d1 by Matěj Cepl

Revert back 8cda4617 it broke things.

parent e46e15df
# -*- coding: utf-8 -*-
import json
import logging
logging.basicConfig(format='%(levelname)s:%(funcName)s:%(message)s',
level=logging.DEBUG)
logging.basicConfig(format='%(levelname)s:%(funcName)s:%(message)s')
import urllib2
import docutils
import docutils.parsers.rst
import zot4rst.jsonencoder
import xciterst
import xciterst.directives
import xciterst.roles
import zot4rst.jsonencoder
#from xciterst.util import html2rst
from xciterst.util import html2rst
DEFAULT_CITATION_STYLE = "http://www.zotero.org/styles/chicago-author-date"
BIBLIOGRAPHY_REQUEST_URL = "http://localhost:23119/zotxt/items"
class ZoteroConnection(xciterst.CiteprocWrapper):
def __init__(self, style, **kwargs):
......@@ -31,22 +28,21 @@ class ZoteroConnection(xciterst.CiteprocWrapper):
return self._in_text_style
def citeproc_process(self, clusters):
logging.debug('clusters = %s', clusters)
request_url = "http://localhost:23119/zotxt/bibliography"
request_json = {
"format": "bibliography",
"styleId": "chicago-author-date",
"citationGroups": clusters
}
data = json.dumps(request_json, indent=2,
cls=zot4rst.jsonencoder.ZoteroJSONEncoder)
try:
req = urllib2.Request(BIBLIOGRAPHY_REQUEST_URL,
req = urllib2.Request(request_url,
data, {'Content-Type': 'application/json'})
f = urllib2.urlopen(req)
resp_json = f.read()
f.close()
except:
logging.warning('cannot open URL %s', BIBLIOGRAPHY_REQUEST_URL)
logging.warning('cannot open URL %s', request_url)
raise
resp = json.loads(resp_json)
return [resp['citationClusters'], resp['bibliography']]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment