Saturday, August 4, 2012

Zotero Data Server Installation

This tutorial contains installation instructions for setting up Zotero data server on the computer running Arch Linux.

Retrieving Sources

Change directory to "/srv/http/": Dowload Zotero data server source code from github repository: Rename the directory (important!): Download Zend framework: Decompress part of the archive ("ZendFramework-1.11.12/library/Zend") to the "include" directory ("/srv/http/ZoteroDataServer/include/Zend"):

Configuring Apache HTTP Server and PHP Engine

Install Apache server: Create a virtual host for Zotero data server. To do that, append the following configuration into "/etc/httpd/conf/extra/httpd-vhosts.conf". The directory for data server is "/srv/http/ZoteroDataServer/". Make sure that the following modules are loaded in "/etc/httpd/conf/httpd.conf" (uncomment these lines if necessary): Check whether additional configuration files are included. If not, place this at the end of the "Include" list ( "/etc/httpd/conf/httpd.conf") Make sure that the following line is uncommented in "/etc/httpd/conf/httpd.conf" in the section/(after the line) <IfModule mime_module> Make Apache server listen to port number 85 which points to Zotero virtual host by adding the following line to "/etc/httpd/conf/httpd.conf": Start Apache server: Add or uncomment the following lines in "/etc/php/php.ini": and check whether thsese libraries (shared objects) exist in "/usr/lib/php/modules/".

Configuring MySQL

Install MySQL: Zotero data server is configured to use "SecurePassword" as a root password. You have to reset root password to "SecurePassword" or modify source codes of the data server. To reset the root password, stop the MySQL daemon if it is running: Restart MySQL daemon and bypass authentication: Connect to the MySQL server: Change root password: Change MySQL time zone to UTC by modifying the following line in "/etc/mysql/my.cnf": Install PHPMyAdmin to control databases using WEB interface:

Configuring Zotero Data Server

Main settings are stored in "/srv/http/ZoteroDataServer/include/config/config.inc.php" file: Sync domain is configured to localhost so it won't accept connections from other IPs. But the goal is to make data server work at least on local host. If you want to change the data server root directory by editting $CLI_DOCUMENT_ROOT do not forget the trailing slash "/" at the end of the path. Interaction with MySQL database through PHP is done using credentials in "/srv/http/ZoteroDataServer/include/config/config.inc.php" file. You can change default root password ("SecurePassword") only by editting this file.

Setting Up Zotero Data Server

Start MySQL daemon first: Change directory to "/srv/http/ZoteroDataServer/misc" Run "test_reset" script which deletes all existing Zotero data server databases (if they exist) and creates new databases from scratch. Now you can run "test_setup" script which adds some items to the "zoterotest1" database: If you see "Test setup is successfull." this means items were successfully added to the database. To check this, log into MySQL: Now check for the created databases: Now it is possible to open three terminals and start upload, download and error daemons separately in foreground:
In the 1st terminal: In the 2nd terminal: In the 3rd terminal:

Testing Authentication on Zotero Data Server

To test authentication on the server, post the following request: It should return something like: Now using provided "sessionID" you can post request to "updated" action: The answer will be similar to:

Installing Zotero Attachment Server

In order to be able to upload attachment files you need to provide your Zotero client with a WebDAV server. Distributed authoring and versioning (WebDAV). For example, you can use YandexDisk with WebDAV protcocol. It provides 5 GB disc space for free! Files are also accessible through its e-mail web-client. If you are paranoid enough not to trust anyone, you can set up a WebDAV server by yourself. Uncomment (or add) the following lines in "/etc/httpd/conf/httpd.conf" Now create WebDAV lock directory and file: Create directory to store uploaded Zotero attachments: Append or add the following configuration to "/etc/httpd/conf/extra/httpd-dav.conf" Now create an MD5 hash for user "testuser" in realm "WebDAV" authorized by some password and store it in "/etc/httpd/conf/extra/AuthWebDAV.passwd" : Restart Apache server: In order to test your WebDAV server you have to install "cadaver" package: Now connect to your WebDAV server using "cadaver" program:

Installing Zotero Client

Right now only Zotero Firefox extension is available. Zotero standalone will be available soon.

Zotero Firefox Extension

Install Firefox extension from "/srv/http/ZoteroDataServer/zotero-3.0.8-patched.xpi". It is patched such that you can add custom data servers as shown in the figure:

Testing Zotero Data Server: Synchronization Process

Now open your Firefox and click on the "sync" button with an round green arrow on it:

Debugging

You can see what is going by capturing the traffic between the client and the server or by enabling debugging in the client.

Capturing Traffic

You can capture the traffic using Wireshark. Select loopback interface (lo) to filter all other IP addresses except localhost (127.0.0.1). You should change HTTP port preferences in Wireshark to be able to analyze traffic. In Wireshark -> Preferences -> Protocols -> HTTP -> TCP Ports add port 85. In the capture filter field, enter "http". Turn on capture.

Enabling Debugging in the Client 

Enable debugging by setting Zotero -> Preferences -> Advanced -> Debug Output Logging to "Enable" to see what is going on.

Friday, August 3, 2012

Adding SyntaxHighlighter Support to Blogger.com

To add Alex Gorbatchev's SyntaxHighlighter script just insert the following HTML code befre the </head> tag. If you are placing HTML code inside SyntaxHighlighter Displaying listing is easy: just place your code as shown below. Be careful with HTML code. To display HTML code inside an HTML page regular characters should be translated into escape characters first. This can be done by using HTML-encoder, e.g. http://www.string-functions.com/htmlencode.aspx. Output code will be difficult to read: <br> will be encoded to &lt;br&gt; To display you should post