Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/caiorss/zhserver

Haskell Webserver for Zotero reference manager - based on Zotero.
https://github.com/caiorss/zhserver

app application books document education haskell http papers reference rest search server zotero

Last synced: 6 days ago
JSON representation

Haskell Webserver for Zotero reference manager - based on Zotero.

Awesome Lists containing this project

README

        

#+TITLE: ZHServer - Haskell Book shelve Webserver
#+AUTHOR: Caio Rodrigues
#+EMAIL:
#+KEYWORKDS: zotero papers docs documents patent search metadata notes haskell database
#+STARTUP: contents

#+INFOJS_OPT: view:info toc:t ltoc:t ftoc:nil mouse:underline button:nil path:theme/org-info.js
#+HTML_HEAD:

* User Guide
** Overview

_Zhserver_ is an application server that provides a json REST API to
interface [[https://www.zotero.org/][Zotero]] database and allows multiple users and third party
apps to search documents by collections, tags, author and so on.

Disclaimer: It is still a work in progress.

*Benefits*

Find, classify information, books, magazines, laws, patents, technical
standards, web page snapshots and papers fast.

*Features*

- Manage collections of documents like pdf files, books, magazines,
thesis, papers, patents, technical documentation and any type of
file.

- Find documents by author.

- Find documents by collections. Any item or document can belong to
multiple collections.

- Find documents by tags.

- Search documents by content, title and tags.

- Single page web application with URLs that can be bookmarked.

- Web Application and REST API.


*Screenshots*

#+CAPTION: Display all collections
[[file:images/collections.png][file:images/collections.png]]

#+CAPTION: Display top subcollections.
[[file:images/subcollections1.png][file:images/subcollections1.png]]

#+CAPTION: Display subcollections and items of collection 'Embedded Systems'.
[[file:images/subcollections2.png][file:images/subcollections2.png]]

#+CAPTION: Display all tags
[[file:images/tags.png][file:images/tags.png]]

#+CAPTION: Display tag items.
[[file:images/tag-items.png][file:images/tag-items.png]]

#+CAPTION: Display all authors
[[file:images/authors1.png][file:images/authors1.png]]

#+CAPTION: Display all authors which starts with 'simon'
[[file:images/authors-all.png]]

#+CAPTION: Display all author's items.
[[file:images/author-items.png][file:images/author-items.png]]

*Repository*

- https://github.com/caiorss/zhserver

*Zhserver Web Site*

- https://caiorss.github.io/zhserver

** Build Instructions
*** Install Dependencies

Install system dependencies (Arch Linux)

#+BEGIN_SRC sh
sudo pacman -S postgresql extra/postgresql-libs
#+END_SRC

Install Haskell dependencies with stack

#+BEGIN_SRC sh
stack install HDBC-sqlite3
stack install HDBC-postgresql
stack install happstack-server
#+END_SRC

Additional Dependencies:

- Sqlite to run the demonstration database

- PostgresSQL database server for production

*** Compile

#+BEGIN_SRC sh
$ stack exec -- ghc --make Server
Linking Server ...
#+END_SRC
*** Run tests

This server comes with a sample database dump for testing. To test the
server just run =$ make run-test= it will create the database
_testdb/zotero.sqlite_ from the sample sql dump _database/zotero-test.sql_
The server will listen the port 8000 and it can be accessed from
http://127.0.0.1:8000 or http://localhost:8000 .

#+BEGIN_SRC sh
$ make run-test
stack exec -- ghc --make -o zhserver.bin src/ZHServer.hs src/Zotero.hs
[2 of 2] Compiling Main ( src/ZHServer.hs, src/ZHServer.o )
Linking zhserver.bin ...
# stack exec -- ghc src/ZHServer.hs -o bin/ZHServer.bin
./zhserver.bin --conf src/zhserver.conf
Server Running
------------------
#+END_SRC

** Usage
*** Show Help

#+BEGIN_SRC sh
$ ./zhserver.bin
Zhserver -- Your cloud book shelve web server

Commands

--env - Load configuration file from ZHSERVER_CONFIG environment variable
--conf - Load configuration file from

Start server with all configuration passed through command line

--params [host] [port] [dbUri] [staticPath] [storagePath]

- [host] - Hostname like 0.0.0.0 to listen all hosts
- [port] - Port like 8080
- [dbUri] - Database URI
- [staticPath] - Path to server static files like index.html *.js files
- [storagePath] - Path to Zotero storage directory

#+END_SRC

*** Find the Zotero sqlite database

Find the sqlite databases for testing

#+BEGIN_SRC sh
$ find ~/.mozilla -name zotero.sqlite
/home/arch/.mozilla/firefox/dic34vce.default/zotero/zotero.sqlite
/home/arch/.mozilla/firefox/mwad0hks.zotero/zotero/zotero.sqlite
#+END_SRC

*** Find storage directory

#+BEGIN_SRC sh
$ find ~/.mozilla -name 'storage' | grep zotero
/home/arch/.mozilla/firefox/dic34vce.default/zotero/storage
/home/arch/.mozilla/firefox/mwad0hks.zotero/zotero/storage
/home/arch/.mozilla/firefox/mwad0hks.zotero/storage

$ ls /home/arch/.mozilla/firefox/mwad0hks.zotero/zotero/storage | head -n16
22HUC5F9/
22NEC2IE/
236SC55S/
2372MKGN/
23K7EW4R/
24P9755W/
258V847Q/
25F3TBCX/
25HSTF7M/
267B6WPX/
26B3KTBR/
26W3KU88/
27B9VSG4/
27ERHSIM/
27FEX8GN/
27GZRZ49/

$ ls /home/arch/.mozilla/firefox/mwad0hks.zotero/zotero/storage/267B6WPX
3512243057-widgets.js ghosh_cover150.jpg plusone.js
'3ZGfnXYPgAVNngtqatUNgAAAABJRU5ErkJggg==' gplus-32.png product.jpg
anon16-rounded.gif gprofile_button-16.png s_bottom.png
b16-rounded.gif gradients_light.png share_buttons_20_3.png
body_gradient_tile_light.png icon18_edit_allbkg.gif shAutoloader.js
brand icon18_email.gif shCore.js
cm.002.png icon18_wrench_allbkg.png show_ads.js
combinators-as-sublanguage-of-dsl.css icon_delete13.gif stats-flipper.png
combinators-as-sublanguage-of-dsl.html icon_wikipedia_search.png s_top.png
diagram-trans.gif KhUMAAAAAElFTkSuQmCC triangle_ltr.gif
'DLgASBKnApgkVgXIkhgKiNKJ005s4gDLbCZBiSxfygAAAABJRU5ErkJggg==' mobile_share_icons4.png triangle_open.gif
favicon.ico openid16-rounded.gif untitled
feed-icon32x32.png photo.jpg

$ ls /home/arch/.mozilla/firefox/mwad0hks.zotero/zotero/storage/26B3KTBR/
'Translatable Finite State Time Machine.pdf'

#+END_SRC

*** Set the configuration file

The file zotserver.conf stores the server configuration such as port
and host which the server will listen to, the storage path and the
database.

Example:

#+BEGIN_SRC sh
ServerConfig {
serverPort = 8000
, serverHost = "0.0.0.0"
, serverStoragePath = "/home/arch/.mozilla/firefox/mwad0hks.zotero/zotero/zotero"
, serverDatabase = "sqlite:///home/arch/.mozilla/firefox/mwad0hks.zotero/zotero/zotero.sqlite"
}
#+END_SRC

The serverHost variable sets what address the server will listen to:

- 0.0.0.0 - Listen to all hosts
- 127.0.0.1 - Listen to localhost only

The serverDatabase variable sets the database used by the server. The
databases Sqlite and Postgres are supported.

- SQlite URI:

#+BEGIN_SRC text
sqlite:///home/arch/.mozilla/firefox/mwad0hks.zotero/zotero/zotero.sqlite
#+END_SRC

- Postgres URI:

#+BEGIN_SRC text
postgres://postgres@localhost/zotero
#+END_SRC
*** Run the server
**** Run with Configuration file in Environment Variable

Pass the configuration file by enviroment variable:

#+BEGIN_SRC sh
$ env ZHSERVER_CONFIG=./zhserver.conf ./ZHServer --env
Server Running
------------------
Loading default configuration file from ZHSERVER_CONFIG environment variable.
sqlite://testdb/zotero.sqlite
testdb/zotero.sqlite

#+END_SRC

or

#+BEGIN_SRC sh
$ export ZHSERVER_CONFIG=./zhserver.conf

$ ./ZHServer
Server Running
------------------
Loading default configuration file from ZHSERVER_CONFIG environment variable.
sqlite://testdb/zotero.sqlite
testdb/zotero.sqlite

#+END_SRC

**** Pass Configuration file by command line:

#+BEGIN_SRC sh
$ ./ZHServer --conf zhserver.conf
Server Running
------------------
sqlite://testdb/zotero.sqlite
testdb/zotero.sqlite
#+END_SRC

**** Run with all server parameters passed by command line

#+BEGIN_SRC sh
$ ./zhserver.bin --params 0.0.0.0 9090 "sqlite://testdb/zotero.sqlite" ./assets/ testdb/storage
Server Running
------------------
#+END_SRC

** Documentation

- [[file:Documentation.org][Documentation - Development Notes]]

- [[https://caiorss.github.io/zhserver/docs/index.html][API Documentation]] - Generated by Haddock

** TODO Road map - Tasks

- [X] Find items by tag
- [X] Find items by ID
- [X] Find items by collection
- [X] Find items by author
- [X] Navigate through collections hierarchy
- [X] Display all items with paging.
- [ ] Find items by a group of authors
- [ ] Convert database schema from SQLite to Postgres SQL
- [X] Add logging to the server.
- [ ] Display all items from a collections, including items from subcollections.
- [ ] Improve Front End
- [ ] Improve Web User Interface Functionality
- [ ] Improve Web User Interface Design
- [ ] Improve design for mobile devices
- [ ] Add tag search
- [ ] Search with multiple tags
- [ ] Add the database documentation
- [ ] Add database schema
- [ ] Add tests
- [X] Add authentication
- Added two authentication options. Basic http authentication or no
authentication.
- [ ] Build a docker to host the server