Skip to content
Snippets Groups Projects

Pelican sources for netmetr.cz website

Preparation

Creating virtualenv

This is not mandatory, but it's handy to create separate environments for such projects, so you don't have to install (possibly conflicting) dependencies system-wide.

There are good tutorials for virtualenv available online, but essentially it's just this:

>> virtualenv netmetr.cz
>> cd netmetr.cz
>> source bin/activate

You can use either python 2 or 3, the build system works with both (tested on 2.7.x and 3.4.x). However, please test it with python 2.7 after making bigger changes in pelican config or template, as Jenkins uses this version by default. Virtualenv can be told to use specific python binary:

>> virtualenv -p `which python2.7` netmetr.cz

Replace python2.7 with actual binary name of course. This one works at least on Gentoo and Debian/Ubuntu.

Then just clone this repository, cd into it and you are good to go.

Installing dependencies

This is what you need to do only after fetching the source for the first time or after updates.

After cloning the repository, you have to do the following do make it work:

>> git submodule init
>> git submodule update

This will fetch the pelican-plugins and product-template repos as git submodules.

Then you need to install requirements. You can do it by:

>> pip install -r requirements.txt

at best inside a virtualenv specifically created for this application.

If you encounter something like fatal error: Python.h: No such file or directory during pip install and you're on Debian/Ubuntu, you need to install python-dev deb package.

Usage

Building

You can build the website by running:

>> make

in the main directory.

Default make target uses URLs set in publishconf.py. For local development/testing, use:

>> make build-dev

The output is in the output directory, but it is better to view it by doing:

>> cd output
>> python -m SimpleHTTPServer        # for python 2
>> python -m http.server             # for python 3

and opening http://localhost:8000 in your browser, because you will see all the styling etc. as well (not everything works as expected with file:// paths in modern browsers).

You can specify another port if 8000 is used by something else:

>> python -m http.server 1234

Deploy

Website is hosted at devpub.labs.nic.cz (both production and prototype).

Deploy to www.netmetr.cz:

>> export DEVPUB_USER=username
>> make publish-production

Deploy to devpub.labs.nic.cz/netmetr-proto:

>> export DEVPUB_USER=username
>> make publish-prototype

Testing

Run Selenium tests:

>> ./run_tests.sh browser

…where browser is one of chrome, firefox, or phantomjs.

Requirements:

  • Running Selenium server at localhost:4444 (default port, run with java -jar selenium-server-standalone-X.X.X.jar)
  • Working npm
  • Geckodriver binary in PATH (only for Firefox)
  • Browser(s), obviously