# Installation and configuration
## Requirements
The system has been tested and found to run well on Ubuntu >= 22
* The programming language is Python >= 3.8 
* The web framework is currently [Django 4.2](https://docs.djangoproject.com/en/4.2/)
* Apache web server with mod_wsgi compiled for Python 3
* memcached

## Install and setup
1. Install and activate a virtual Python environment

```
python3 -m venv my_venv
source my_env/bin/activate

```

2. Install all the requirements into the virtual environment. 
Remember to be in the folder where the requirements.txt file is

```
pip install -r requirements.txt
```

3. Copy VIPSWeb/local_settings_sample.py into VIPSWeb/local_settings.py and adapt to your needs

4. Run all database migrations

```
./manage.py migrate
```

5. Run application
```
python3 manage.py runserver
```

## Running with mod_wsgi
The official Django documentation for this [can be found here](https://docs.djangoproject.com/en/3.1/howto/deployment/wsgi/modwsgi/) 

* If running on e.g. Ubuntu 18, please remember to install the `libapache2-mod-wsgi-py3` and not the `libapache2-mod-wsgi` package
* Here's an example mod_wsgi configuration in an Apache2 virtualhost

```
        WSGIDaemonProcess vipsweb python-path=/opt/VIPSWeb/VIPSWeb python-home=/opt/VIPSWeb/py3dj3
        WSGIProcessGroup vipsweb

        WSGIScriptAlias / /opt/VIPSWeb/VIPSWeb/VIPSWeb/wsgi.py

        <Directory /opt/VIPSWeb/VIPSWeb/VIPSWeb>
                <Files wsgi.py>
                        Require all granted
                </Files>
        </Directory>

```

## Instance configuration
Each installation of VIPSWeb can be customized in several ways
* The page title
* Site owner/URL
* Languages
* Time zone
* Point in time (for demoing out of season)
* Which backend servers (instances of VIPSCoreManager and VIPSLogic) to use
* Which organization(s) to show data from
* Front page map configurations (center, zoom and height/width)
* Which news message types to show on the front page
* The menu items in the page header
* The menus in columns below the map
* Text in the footer
* Settings for the date picker

This is done by making a copy of `local_settings_sample.py` to `local_settings.py` and customizing it. `local_settings.py` is ignored by Git.

## Configuration of VIPSLogic
TODO

## Deployment of updates (AKA pipeline)
### Updating translations
VIPSWeb/Django is using the GNU gettext system for translating phrases. In the git repository, the sourece `.po` files are updated, but the compiled `.mo` files are ignored. Thus, if an update of VIPSWeb contains new or updated translated texts/phrases, you need to compile them using the command 

```bash
$ django-admin compilemessages
```

This requires that you have [GNU gettext](https://www.gnu.org/software/gettext/) installed on your server.