{% extends "base.html" %}
{% load i18n %}
{% load staticfiles %}
{% load wger_extras %}


{% block title %}{% trans "Get the code" %}{% endblock %}

{% block content %}

<a name="stable-version"></a>
<h3>{% trans "Installing the stable version" %}</h3>


<p>{% blocktrans %}Click here to download the last stable version. For
installation instructions see below.{% endblocktrans %}</p>

<p>
<a class="btn btn-primary"
   href="https://pypi.python.org/packages/source/w/wger/wger-1.4.tar.gz">
   {% trans "download stable version:" %} 1.4</a>
</p>

<p>{% blocktrans %}In short, these are the steps needed for an installation
on a linux or OS X machine, with python already installed. If you want to develop,
see the sections below.{% endblocktrans %}</p>

<p>{% blocktrans %}I personally like installing my development
files on a virtualenv, it helps keep the system more or less clean and are very
easy to set up, but you can skip this step if you don't mind installing all
dependencies system-wide (in that case, install django and the other applications
with a <code>sudo</code>).{% endblocktrans %}</p>

<code>
$ sudo apt-get install python-virtualenv
$ sudo apt-get install python-dev
$ virtualenv python-django
$ source python-django/bin/activate
</code>

<p>{% blocktrans %}Get the application from PyPI, initialise and start it.{% endblocktrans %}</p>

<code>
$ pip install wger
$ wger
</code>

<p>{% blocktrans %}The script will, on first run, create a configuration
file and a SQLite database with a standard superuser:{% endblocktrans %}</p>

<ul>
    <li><strong>{% trans "username:" %} admin</strong></li>
    <li><strong>{% trans "password:" %} admin</strong></li>
</ul>

<p>{% blocktrans %}You can later simply call <code>wger</code> again to start
the application.{% endblocktrans %}</p>

<h4>{% trans "Notes" %}</h4>

<ul>
    <li>{% blocktrans %}Use <code>wger --help</code> to see available options{% endblocktrans %}</li>
    <li>{% blocktrans %}You should edit the settings.py and enter your
<a href="https://www.google.com/recaptcha">reCaptcha keys</a>. You can leave
this blank or enter bogus data, but you won't be able e.g. to register new users.{% endblocktrans %}</li>
    <li>{% blocktrans %}For the sitemap.xml file to be correctly generated,
you need to set a correct domain name in the sites app (only needed for search
engines). This is done via django's admin interface (/admin/){% endblocktrans %}</li>
    <li>{% blocktrans %}This is a Django application, so refer for details to its
<a href="https://docs.djangoproject.com/en/1.5/intro/install/">documentation page</a>
if things don't go as expected.{% endblocktrans %}</li>

</ul>




<a name="developer-guide"></a>
<h2>Developer guide</h2>


<a name="get-code"></a>
<h3>How to get the code</h3>
<p>The code is hosted both on github and on bitbucket. If
you are unfamiliar with mercurial or git, take a look at <a href="http://hginit.com/">HG
init</a> or <a href="http://git-scm.com/book">Pro Git</a>. Both repositories
are mantained in sync, so you should be able to work on either one (issues
and pull requests are only collected in github).</p>

<p>
<a class="btn btn-primary" href="https://github.com/rolandgeider/wger">github (GIT) »</a>
    the main repository. All work happens here<br>
    <code>git clone https://github.com/rolandgeider/wger.git</code>
</p>

<p>
<a class="btn btn-primary" href="https://bitbucket.org/rolandgeider/wger">bitbucket (HG) »</a>
    a mirror of the main repo<br>
    <code>hg clone https://bitbucket.org/rolandgeider/wger</code>
</p>


<p>The file structure you get once you clone the repo should be self explaining:</p>

<ul>
    <li>
        <strong>wger:</strong> the django project and its applications
    </li>
    <li>
        <strong>tests:</strong> the tests folder. This actually only imports
        the individual tests from each application and makes it easier to test
        all of them.
    </li>
    <li>
        <strong>extras:</strong> additional helper scrips, e.g. a benchmarking
        script with funkload, a tool to create a local settings.py file, etc.
    </li>
</ul>


<a name="get-started"></a>
<h3>How to get started</h3>
<p>The installation procedure is very similar to the one
described above for the packaged version. The notes and infos there also apply,
so read that section too. First, install all packages (note that you might need
to install more packages if you want the thumbnailer to be able to read more
image formats, consult the documentation <a href="http://pillow.readthedocs.org">for pillow</a>
for more details):</p>

<code>
$ sudo apt-get install python-virtualenv
$ sudo apt-get install python-dev
$ virtualenv python-django
$ source python-django/bin/activate
$ pip install -r requirements.txt
</code>

<p>Get the code, create a superuser and start the webserver:</p>

<code>
$ git clone https://github.com/rolandgeider/wger.git
$ cd wger
$ python start.py
</code>

<p>That's it. You can either start the server again with
<code>start.py</code> or do it the django way with
<code>python manage.py runserver</code>.</p>


<p>If you pull updates and there were database changes, you
can apply them with a simple <code>python manage.py migrate --all</code>.</p>

<h4>Management commands</h4>
<p>wger also implements a series of django commands that perform different
management functions that are sometimes needed:</p>

<p>
    <code>python manage.py ...</code>
</p>

<ul>
    <li>
        <code>download-exercise-images</code> - synchronizes the exercise
        images from wger.de to the local installation. Read its help text
        as it could save the wrong image to the wrong exercise should different
        IDs match.
    </li>
    <li>
        <code>extract-i18n</code> - extract strings from the database
        that have to be inserted manually in the PO file when translating. These
        include e.g. exercise categories.
    </li>
    <li>
        <code>delete-temp-users</code> - deletes all guest users older than 1 week.
        You will probably want to run this regularly via a cron job.
    </li>
    <li>
        <code>email-remainders</code> - sends out email remainders for user that
        need to create a new workout. Usually run via cron job.
    </li>
    <li>
        <code>submitted-exercises</code> - prints a list of user submitted
        exercises
    </li>
</ul>

<h4>Settings files</h4>
<p>wger uses two settings files to configure django:</p>

<ul>
    <li>
        <strong>settings.py:</strong> the settings for the local installation.
        You can overwrite global settings here, the output of <em>python start.py
        --show-config</em> will show you the default location.
    </li>
    <li>
        <strong>settings_global.py:</strong> global settings, usually this file
        is never edited.
    </li>
</ul>




<a name="contribute-code"></a>
<h3>How to contribute code</h3>
<p>For other ways of contributing besides code, you might
want to take a look at <a href="{% url 'software:contribute' %}">the contribute page</a></p>

<ul>
    <li>
        <strong>Send pull requests:</strong> for new code
        you want to share, please send pull requests in github. Sending patches by
        email or attaching them to an issue means a lot more of work. It's
        recommended that you work on a feature branch when working on something,
        specially when it's something bigger. While you can rebase before sending
        a pull request, it's not necessary.
    </li>

    <li><strong>Run the tests:</strong> wger is proud to
have a test coverage of over 90%. When you implement something new, don't forget
to run the testsuite and write approriate tests for the new code. If you use
github, configure the awesome <a href="http://travis-ci.org/">Travis CI</a>,
there is already a .travis file in the sources.</li>

    <li><strong>Code according to PEP8:</strong> check that
        the code is structured as per pep8 but with a maximum line length of 100.
        This can be checked automatically with the pep8 tool (pip install pep8)
        from the command line (travis will do this as part of the tests):
        <code>pep8 --max-line-length=100--exclude="urls.py,*migrations*" wger</code>
    </li>
</ul>



<a name="custom-hosting"></a>
<h3>Custom hosting</h3>
<p>If you want to host this with some other environment (apache,
postgreSQL, etc.), you need to perform some steps manually. First, install
the necessary packages and dependencies as described before.</p>

<p>wger is regularly tested with the following software versions:</p>
<ul>
    <li><strong>Django:</strong> 1.6</li>
    <li><strong>Databases:</strong> sqlite, mysql, postgres</li>
    <li><strong>Python:</strong> 2.7</li>
</ul>

<p>Setup any database
<a href="https://docs.djangoproject.com/en/1.5/ref/databases/">that Django
supports</a>. Then create a settings file and edit it as needed. There is
another configuration file, settings_global.py that contains other global
settings.</p>

<code>
$ python extras/scripts/create_local_settings.py
</code>

<p>Initialise the database, create a super user and load these
fixtures:</p>

<code>
$ python manage.py syncdb
$ python manage.py migrate core
$ python manage.py migrate --all
$ python manage.py loaddata licenses
$ python manage.py loaddata languages
$ python manage.py loaddata language_config
$ python manage.py loaddata days_of_week
$ python manage.py loaddata equipment
$ python manage.py loaddata muscles
$ python manage.py loaddata categories
$ python manage.py loaddata exercises
$ python manage.py loaddata ingredients
$ python manage.py loaddata weight_units
$ python manage.py loaddata ingredient_units
</code>

<p>What you do next depends on the server you use and how you
want to serve the application (mod_wsgi, fastCGI). There is a sample <code>wsgi.py</code>
file in the wger folder, edit it and adapt it to your needs and make the server
serve it, e.g. per mod_wsgi. Consult in any case the
<a href="https://docs.djangoproject.com/en/1.5/howto/deployment/">django
documentation</a> on the topic.</p>


{% endblock %}

{% block sidebar %}
<h3>{% trans "Overview" %}</h3>

<ul>
    <li><a href="#stable-version">{% trans "Installing the stable version" %}</a></li>
    <li>
        <a href="#developer-guide">Developer guide</a></li>
        <ul>
            <li><a href="#get-code">How to get the code</a></li>
            <li><a href="#get-started">How to get started</a></li>
            <li><a href="#contribute-code">How to contribute code</a></li>
            <li><a href="#custom-hosting">Custom hosting</a></li>
        </ul>
</ul>
{% endblock %}
