Installation
------------

Create an application user.::

    $ adduser encyc

Clone the `encyc-front` source code, go to the install directory, and run the installer (you may have to use "sudo").  On a fresh Debian install this may take 10-15 minutes.::

    $ git clone https://github.com/densho/encyc-front /usr/local/src/encyc-front
    $ cd /usr/local/src/encyc-front/
    $ make install

Edit the settings file, adding passwords and checking the locations of network resources.::

    $ vi /etc/encyc/front-local.cfg

    # Update the following values:
    [debug]
    debug=1
     
    [elasticsearch]
    hosts=192.168.56.1:9200
    index=encyc-dev
     
    [ddr]
    api_url=https://ddr.densho.org/api/0.2
    media_url=https://ddr.densho.org/media/
    media_url_local=https://ddr.densho.org/media/
    topics_src_url=https://partner.densho.org/vocab/api/0.2/topics.json
    topics_base=https://ddr.densho.org/browse/topics

Restart the application and check status.::

    $ make restart
    $ make status


Manual Update
-------------

The following instructions describe how to pull updates from the source MediaWiki.

The application needs to be able to connect directly to the source MediaWiki.  If this is a dev or stage install you may need to set up a tunnel.  `sshuttle` is installed by the Makefile.  Run the following in a separate terminal on the machine on which `encyc-front` is installed.::

    $ /usr/sbin/sshuttle --dns -r USER@HOST 192.168.0.0/24

Switch to the application user, activate the `virtualenv`, and run the Django shell.::

    $ cd /usr/local/src/encyc-front/front
    $ su encyc
    $ source  ../venv/front/bin/activate
    $ python manage.py shell

Now you are ready to upload the DDR topics file and pull down all the published articles.::

    >>> from wikiprox import models
    >>> models.Elasticsearch().index_topics()
    >>> models.Elasticsearch().update_all()


Automatic Update
----------------

TODO cron settings.
