EnigmaCurry/blogofile — pull request #117 by driquet (2011-12-09 15:42:56+00:00)
Title: Plugins - Auto-reload while serving

This patch propose a way to rebuild the site while blogofile is serving it.
This is a feature requested in the [Issue 108](https://github.com/EnigmaCurry/blogofile/issues/108).

## What changed
To do that, I did several things :

1. create a monitor.py file and a Monitor class,
2. edit main.py to add the *--reload-auto* optionnal argument to serve command,
3. edit main.py to add the *-o* or *--output-dir* argument to build command,
4. edit site_init/_config.py to add default configuration values of the monitor,
5. edit config.py to add the monitor configuration.

## How it works
The monitor is a thread, like the Server class, launched when the *--reload-auto* argument is set.
Every **monitor.timer** (an argument set in _config.py file) seconds, the monitor updates itself and looks for changes (addition, modification or deletion of files) in the source tree and rebuilds the site if it detects changes.

Users can specify which files have to be monitored. The config file contains an argument, called *pattern*.
For example, monitor.pattern equals `.*(\.markdown|\.md|\.mako)$`.

The output argument was needed to build the site in a temporary directory. In the current version, the output dir is hardcoded.

## Usage
To rebuild dynamically the site, just do: `blogofile serve --auto-reload`.
This will build once the site, serve it and dynamically rebuild it.

## Possible enhancement

* Add configuration argument : monitor.except_pattern (to not detect changes of these files)