====== Nikoa ======
See also: [[development:Python]], [[software:software]], [[software:Software Categories]], [[software:Blogging]]
===== nikola =====
Nikola is a command line tool for generating blog posts from static files (in a variety of formats). If you so desire, it can create galleries from groupings of photos and will also build a RSS feed (for updates) and an index of all your posts (as well as a cloud of tags to group related posts).
Information about the static site generator Nikola.
More information can also be found at: http://getnikola.com/
===== Virtual Machine "nikola" =====
I have a virtual machine called nikola. This system is used to update the software and so I don't have to worry about python incompatibilities.
The nikola VM was created (originally on PC027) with the following command:
lxc-create -t download -n nikola -- -d ubuntu -r trusty -a amd64
This created the base install. Of course, the default user was Ubuntu, so I had to login and change the default user and password right away. Look at my instructions on the [[software:lxc]] page for my next steps (configuring the base system, to include changing the passwords).
===== Nikola Installation on Xubuntu1604 =====
See also: [[development:virtualenv]]
Create an apps directory.
$ mkdir ~/apps/
Then create a python virtual environment for Nikola.
$ virtualenv nikola
$ cd nikola
$ source bin/activate
$ pip install --upgrade pip setuptools wheel
$ pip install --upgrade "Nikola[extras]"
Some information came from this website: https://www.getnikola.com/getting-started.html
===== Nikola Installation on host Nikola =====
Then I had to install nikola (and pip).
sudo apt-get install python-pip
sudo apt-get install git
sudo pip install nikola
The pip install brought a lot of dependencies with it. However, it did not bring some system libraries needed. Based on this page (http://stackoverflow.com/questions/11094718/error-command-gcc-failed-with-exit-status-1-while-installing-eventlet) I installed the python development tools and tired to pip install nikola again.
sudo apt-get install python-dev
My next error came from lxml.
/tmp/pip_build_root/lxml/src/lxml/includes/etree_defs.h:9:31: fatal error: libxml/xmlversion.h:
No such file or directory
#include "libxml/xmlversion.h"
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Cleaning up...
Command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip_build_root/lxml/setup.py';
exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))"
install --record /tmp/pip-e6RpZ6-record/install-record.txt --single-version-externally-managed --compile
failed with error code 1 in /tmp/pip_build_root/lxml
Traceback (most recent call last):
File "/usr/bin/pip", line 9, in
load_entry_point('pip==1.5.4', 'console_scripts', 'pip')()
File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 185, in main
return command.main(cmd_args)
File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 161, in main
text = '\n'.join(complete_log)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 35: ordinal not in range(128)
I solved this with install python-libxml
sudo apt-get install python-lxml
sudo pip install nikola
Now I have Nikola installed. However, I'm still missing some components:
timb@nikola:~$ nikola --help
[2014-08-18T00:56:57Z] WARNING: Nikola: In order to USE_BUNDLES, you must install the "webassets"
Python package.
[2014-08-18T00:56:57Z] WARNING: Nikola: Setting USE_BUNDLES to False.
Nikola is a tool to create static websites and blogs. For full documentation and more information,
please visit http://getnikola.com/
Available commands:
nikola auto automatically detect site changes, rebuild and optionally refresh a browser
nikola bootswatch_theme given a swatch name from bootswatch.com and a parent theme, creates a
custom theme
nikola build run tasks
nikola check check links and files in the generated site
nikola clean clean action / remove targets
nikola console start an interactive Python console with access to your site
nikola deploy deploy the site
nikola doit_auto automatically execute tasks when a dependency changes
nikola dumpdb dump dependency DB
nikola forget clear successful run status from internal DB
nikola github_deploy deploy the site to GitHub pages
nikola help show help
nikola ignore ignore task (skip) on subsequent runs
nikola import_wordpress import a WordPress dump
nikola init create a Nikola site in the specified folder
nikola install_theme install theme into current site
nikola list list tasks from dodo file
nikola new_page create a new page in the site
nikola new_post create a new blog post or site page
nikola orphans list all orphans
nikola plugin manage plugins
nikola serve start the test webserver
nikola strace use strace to list file_deps and targets
nikola tabcompletion generate script for tab-complention
nikola version print the Nikola version number
nikola help show help / reference
nikola help show command usage
nikola help show task usage
timb@nikola:~$ apt-cache search webasset
cssmin - YUI CSS compression algorithm in Python
python-webassets - Asset management application for Python web development
python-webassets-doc - Asset management application for Python web development - doc
python3-webassets - Asset management application for Python web development (Python 3)
timb@nikola:~$ which python
/usr/bin/python
timb@nikola:~$ python --version
Python 2.7.6
timb@nikola:~$ sudo apt-get install python-webassets
[sudo] password for timb:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
python-webassets-doc yui-compressor node-uglify python-cssutils node-less
ruby-sass cssmin
The following NEW packages will be installed:
python-webassets
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 84.1 kB of archives.
After this operation, 436 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu/ trusty/universe python-webassets all 3:0.9-1 [84.1 kB]
Fetched 84.1 kB in 1s (72.6 kB/s)
Selecting previously unselected package python-webassets.
(Reading database ... 21824 files and directories currently installed.)
Preparing to unpack .../python-webassets_3%3a0.9-1_all.deb ...
Unpacking python-webassets (3:0.9-1) ...
Setting up python-webassets (3:0.9-1) ...
The -lz means a library file named libz.so. This file is provided by the zlib1g-dev package. Run sudo apt-get install zlib1g-dev to install the package, and try your original command again (without STATIC_DEPS).
Reference: http://askubuntu.com/questions/485642/cannot-install-lxml-in-virtualenv-python
===== Using Nikola =====
Initial Book blog Config on Xubuntu1604
This created the applications. Next I had to create the data directory for my Book Blog and initialize it.
$ cd ~/apps/nikola/
$ source bin/activate
(nikola)$ mkdir -p ~/Documents/blogs/
(nikola)$ cd ~/Documents/blogs/
(nikola)$ nikola init books
I also needed to create a serve.sh (for the book blog) file:
#! /bin/bash
cd output
nikola serve --port 8042 --address 0.0.0.0
cd ..
The port (above in ''source.sh'') needs to be changed as follows:
^ Port ^ Blog ^
| 8042 | books |
| 8041 | bruce4 |
| 8040 | tbruce |
Using the IP Address of 0.0.0.0 means it is accessible from any host on the network.
===== Initial Generic Config =====
==== Nikola Host ====
Now I had to build a Nikola "site" to start working in.
Using ''nikola --help'' I got a list of commands.
timb@nikola:~$ nikola --help
[2014-08-16T23:22:05Z] WARNING: Nikola: In order to USE_BUNDLES, you must install the "webassets" Python package.
[2014-08-16T23:22:05Z] WARNING: Nikola: Setting USE_BUNDLES to False.
Nikola is a tool to create static websites and blogs. For full documentation and more information, please visit http://getnikola.com/
Available commands:
nikola auto automatically detect site changes, rebuild and optionally refresh a browser
nikola bootswatch_theme given a swatch name from bootswatch.com and a parent theme, creates a custom theme
nikola build run tasks
nikola check check links and files in the generated site
nikola clean clean action / remove targets
nikola console start an interactive Python console with access to your site
nikola deploy deploy the site
nikola doit_auto automatically execute tasks when a dependency changes
nikola dumpdb dump dependency DB
nikola forget clear successful run status from internal DB
nikola github_deploy deploy the site to GitHub pages
nikola help show help
nikola ignore ignore task (skip) on subsequent runs
nikola import_wordpress import a WordPress dump
nikola init create a Nikola site in the specified folder
nikola install_theme install theme into current site
nikola list list tasks from dodo file
nikola new_page create a new page in the site
nikola new_post create a new blog post or site page
nikola orphans list all orphans
nikola plugin manage plugins
nikola serve start the test webserver
nikola strace use strace to list file_deps and targets
nikola tabcompletion generate script for tab-complention
nikola version print the Nikola version number
nikola help show help / reference
nikola help show command usage
nikola help show task usage
nikola help show task usage
So now I can build my site:
timb@nikola:~$ nikola init --help
Purpose: create a Nikola site in the specified folder
Usage: nikola init [--demo] [--quiet] folder
Options:
-q, --quiet Do not ask questions about config.
-d, --demo Create a site filled with example data.
timb@nikola:~$ nikola init bruce4
Creating Nikola Site
====================
This is Nikola v7.0.1. We will now ask you a few easy questions about your new site.
If you do not want to answer and want to go with the defaults instead, simply restart with the `-q` parameter.
--- Questions about the site ---
Site title [My Nikola Site]: Bruce Family Web Site
Site author [Nikola Tesla]: Timothy J Bruce
Site author's e-mail [n.tesla@example.com]: tim@^H^[[K@bruce4.com
Site description [This is a demo site for Nikola.]: Tim's Personal Blog
Site URL [http://getnikola.com/]: http://www.bruce4.com
--- Questions about languages and locales ---
We will now ask you to provide the list of languages you want to use.
Please list all the desired languages, comma-separated, using ISO 639-1 codes. The first language will be used as the default.
Type '?' (a question mark, sans quotes) to list available languages.
Language(s) to use [en]:
Please choose the correct time zone for your blog. Nikola uses the tz database.
You can find your time zone here:
http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
Time zone [UTC]: America/Los_Angeles
Current time in America/Los_Angeles: 18:02:10
Use this time zone? [Y/n] y
--- Questions about comments ---
You can configure comments now. Type '?' (a question mark, sans quotes) to list available comment systems. If you do not want any comments, just leave the field blank.
Comment system:
That's it, Nikola is now configured. Make sure to edit conf.py to your liking.
If you are looking for themes and addons, check out http://themes.getnikola.com/ and http://plugins.getnikola.com/.
Have fun!
INFO: init: Created empty site at bruce4.