Skip to content
This repository
branch: master
Octocat-spinner-32 bin Ensure master branch is used in update-in-production.sh December 18, 2013
Octocat-spinner-32 css Move recent css changes from mustache templates to style.less April 09, 2014
Octocat-spinner-32 en New i18n aware request route logic. June 15, 2012
Octocat-spinner-32 fi New i18n aware request route logic. June 15, 2012
Octocat-spinner-32 id Quick symlink fix for "/id/*" request's static assets. June 11, 2012
Octocat-spinner-32 img Make the beta banner smaller (70%). February 25, 2013
Octocat-spinner-32 js External link to personnel search by lib id or slug April 15, 2014
Octocat-spinner-32 locale Sv-translation update. April 11, 2014
Octocat-spinner-32 node_modules Varnish works now. Remove all debug code. October 11, 2012
Octocat-spinner-32 sv Added symlinks for swedish locale static assets. June 18, 2012
Octocat-spinner-32 tests Add more tests March 18, 2014
Octocat-spinner-32 upstart-scripts Update upstart-script for elastic version bump. December 18, 2013
Octocat-spinner-32 views Temporarily disable week browser from json widget 5. April 15, 2014
Octocat-spinner-32 .buildignore Grunt build now works, just run 'h5bp' and then view result via server. May 12, 2012
Octocat-spinner-32 .gitignore Compress all needed js files, inverted nav bar April 07, 2014
Octocat-spinner-32 .jshintrc Jshint server.js, fixed main issues: indentation, missing columns, br… November 27, 2013
Octocat-spinner-32 LICENSE-AGPL Added AGPL license May 12, 2012
Octocat-spinner-32 Makefile Add more tests March 18, 2014
Octocat-spinner-32 README.md Update README.md April 07, 2014
Octocat-spinner-32 apple-touch-icon-114x114-precomposed.png New icons replace default HTML5 boilerplate icons. June 10, 2012
Octocat-spinner-32 apple-touch-icon-57x57-precomposed.png New icons replace default HTML5 boilerplate icons. June 10, 2012
Octocat-spinner-32 apple-touch-icon-72x72-precomposed.png New icons replace default HTML5 boilerplate icons. June 10, 2012
Octocat-spinner-32 apple-touch-icon-precomposed.png New icons replace default HTML5 boilerplate icons. June 10, 2012
Octocat-spinner-32 apple-touch-icon.png New icons replace default HTML5 boilerplate icons. June 10, 2012
Octocat-spinner-32 config.json-template Introduced conf setting default_lang October 10, 2012
Octocat-spinner-32 favicon.ico New icons replace default HTML5 boilerplate icons. June 10, 2012
Octocat-spinner-32 grunt.js Change bower folder to default js/libs March 24, 2014
Octocat-spinner-32 humans.txt Initialized H5BP with this projects variables, made first build and d… February 28, 2012
Octocat-spinner-32 package.json Fix express-form version February 07, 2014
Octocat-spinner-32 proxy.js Compress proxy response data if browser accepts compressed data. October 10, 2012
Octocat-spinner-32 robots.txt Initial usage of Node.js build script and h5bp May 11, 2012
Octocat-spinner-32 screenshot-mobile.png Restructured readme, added About section. July 09, 2012
Octocat-spinner-32 screenshot-tablet-detailspage.png Restructured readme, added About section. July 09, 2012
Octocat-spinner-32 screenshot.png Restructured readme, added About section. July 09, 2012
Octocat-spinner-32 server.js Convert tabs into spaces within server.js April 15, 2014
Octocat-spinner-32 start-development-server.sh Small bugfixes after feedback from client. June 29, 2012
Octocat-spinner-32 start-production-server.sh Added node environment varible dev in readme and startup scripts. June 15, 2012
Octocat-spinner-32 usability-testing.md Added usability testing tasks, so that usability tests can be reteste… July 03, 2012
README.md

About

The Library Directory (published at http://hakemisto.kirjastot.fi/) is a website by Seravo Oy on comission from Kirjastot.fi / City of Helsinki. It provides an easy to use interface for the public to search libraries and their details, like open times, contact information, list of services etc. It also provides widgets that web developers can embed, for example if somebody wants to display local library information on the city or muncipality website.

The site is available in Finnish, Swedish and English. A gettext-based translation systems makes it easy to add more languages.

The source, comments and other project documentation is in English. The code is designed for reuse in other countries and is not limited just to Finland.

Ohloh profile: https://www.ohloh.net/p/libdir

Screenshots

Screenshot of main page Screenshot

Screenshot of main page with narrow screen (mobile). Showcases responsive design. Screenshot

Screenshot of details page with medium screen (tablet). Screenshot

Credits

Project built on HTM5boilerplate for Node.js (http//github.com/h5bp/html5-boilerplate) and HTM5boilerplate for Twitter Bootstrap Responsive.

Other libraries are:

Icons by Glyphicons (http://glyphicons.com/), license CC-BY-3.0.

The Dark theme for OpenLayers by MapBox (from http://zzolo.org/thoughts/openlayers-facelift), license GPL2+ (as modules in Drupal-git are derivates of Drupal).

Thank you also for all the great Node.js packages we use in this project!

Installation

Dependencies

Instructions for Ubuntu 12.04, where the required dependencies can be installed with:

Node.js, Node Package Manager, h5bp and Java dependencies

$ sudo apt-get install nodejs npm node-less libjpeg-progs optipng default-jre-headless
$ cd Library-Directory
# make sure modules in path, otherwise require('connect') will fail
$ export NODE_PATH="/usr/local/lib/node_modules/" # example on Ubuntu 12.04

# Installing Node modules based on dependencies in package.json does not work,
# some Node.js cannot find libs or bins when dependencies installed like this:
$ # sudo npm install -g -d

# Instead install globally manually:
$ sudo npm install -g connect locale express express-form nodemailer hogan grunt nodewatch https://github.com/h5bp/node-build-script/tarball/master
# Normal "npm install -g gettext" no possible, library broken with TypeError: Object #<Object> has no method 'dcnpgettext'
# Install a fixed fork
$ sudo npm install -g git://github.com/dodo/node-gettext.git

# Form the feedback form to work, you need to have some [Nodemailer](http://documentup.com/andris9/nodemailer/) compatible SMTP server credentials in config.json
$ cp config.json-template config.json
$ nano config.json # e.g. add the credentials of a dummy GMail account

Elastic Search (Java server)

$ wget https://github.com/downloads/elasticsearch/elasticsearch/elasticsearch-0.18.7.tar.gz
$ tar xvf elasticsearch-0.18.7.tar.gz
$ ln -s elasticsearch-0.18.7 elasticsearch
# Download and extract library database file to data/
# To force binding to localhost, you might want to set
# in config/elasticsearch.yml network.host: 127.0.0.1

Read-only proxy (https://github.com/lukas-vlcek/node.es)

# Useable out of the box.
# In server/proxy.json defined to use port 8888 
# sudo required for port 80
# expects back-end Elastic Search server at localhost:9200

Generating CSS from LESS

Compile .less into .css

$ cd css
$ lessc style.less > style.css

Starting development server

  1. Start Elastic Search backend

    $ elasticsearch/bin/elasticsearch -f
    
  2. Start proxy for ES

    $ node proxy.js
    
  3. Start HTTP server

    $ NODE_ENV=dev node server.js
    

Finally open localhost:8080 to use server.

Running production server

Execute each step in dedicated terminal or screen.

  1. Start Elastic Search backend

    $ elasticsearch/bin/elasticsearch -f
    
  2. Build project, will output static files in folder output

    $ h5bp
    
  3. Start proxy for ES

    $ node proxy.js
    
  4. Start HTTP server with production variable

    $ NODE_ENV=prod node server.js
    

Finally open localhost:8080 to use server.

Running a production server permanently

Following steps assume you already have a working version at Library-Directory.

  1. Add use libdir to system to avoid running server directly as root:

    $ sudo adduser \
        --system \
        --shell /bin/bash \
        --gecos 'User for running library directory server' \
        --group \
        --disabled-password \
        --home /home/libdir \
        libdir
    
  2. Move files to system location and make sure they are up to date

    $ sudo mkdir /var/www
    $ sudo mv Library-Directory /var/www/libdir
    $ sudo chown -R libdir:libdir /var/www/libdir
    
  3. Install Upstart scripts

    $ sudo cd /var/www/libdir/
    $ sudo cp upstart-scripts/* /etc/init/
    
  4. Start servers

    $ sudo start libdir-server
    # elasticsearch and elasticsearch-proxy will be started automatically
    

Server will now be running in port 80 and logging to /var/log/upstart/<service name>.log. Additionally Elastic Search has its own log under its own folder in logs.

There is also a script update-in-production.sh that will automatically check out the latest version, modify sources to use port 80 and server name and build the project. Make your own copy of it for your own production installation. Invoke it as sudo -u libdir ./update-in-production.sh.

Note! If you want to run the server in port 80, you need to grant special permissions, since ports below 1024 are normally reserved only for the root user: $ sudo apt-get install libcap2-bin $ sudo setcap 'cap_net_bind_service=+ep' /usr/bin/node

Possibly also: $ sudo chmod +s /usb/bin/node

If Elastic Search complains about too few file descriptors, try $ ulimit -n 5000

Database

Elastic Serach is used as the database and search backend. More documentation about the database and administration UI will be written soon..

Something went wrong with that request. Please try again.