#= This server is a port of https://raw.githubusercontent.com/zotero/zotero/master/chrome/content/zotero/xpcom/server_connector.js =# using Mux, JSON using HttpCommon: parsequerystring using URIParser: unescape_form out = nothing @app connector = ( Mux.defaults, page("/connector/ping", x -> setzoteroheaders(pong(x)...)), page("/connector/getSelectedCollection", x -> setzoteroheaders(collection(x, libraries, currentlibrary)...)), page("/connector/saveSnapshot", x -> setzoteroheaders(savesnapshot(x, libraries, currentlibrary)...)), page("/connector/saveItems", x -> setzoteroheaders(saveitems(x, libraries, currentlibrary)...)), page("ui", x -> """ Insert the bibtex here

"""), page("add", x -> addbibtex!(bibliography, (x[:data] |> String |> parsequerystring)["field"] |> unescape_form)), page("/cli/library/:library", x -> begin currentlibrary!(String(x[:params][:library])) # Prevent copying the old bibliography over! empty!(bibliography) end), Mux.notfound()) """ Starts the `zotero`-compatible connector. It's a web server running (by default) on port 23199 that listens for connection from the zotero web plugin. """ function serve(; host=IPv4(127,0,0,1), port=23119, args...) Mux.serve(connector, host = host, port = port, args...) end keep_running() = while !isinteractive(); sleep(100); end