{% extends "base.html" %}
{% load i18n %}
{% load staticfiles %}
{% load manager_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.2rc1.tar.gz">
   {% trans "download stable version:" %} 1.2rc1</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>{% trans "Developer guide" %}</h2>


<a name="get-code"></a>
<h3>{% trans "How to get the code" %}</h3>
<p>{% blocktrans %}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
are only collected in github).{% endblocktrans %}</p>

<p>
<a class="btn btn-primary" href="https://github.com/rolandgeider/wger">github (GIT) »</a>
    {% trans "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>
    {% trans "a mirror of the main repo." %}<br>
    <code>hg clone https://bitbucket.org/rolandgeider/wger</code>
</p>


<p>{% blocktrans %}The file structure you get once you clone the repo should
be self explaining:{% endblocktrans %}</p>

<ul>
    <li>{% blocktrans %}<strong>wger:</strong> the django project and its applications{% endblocktrans %}</li>
    <li>{% blocktrans %}<strong>tests:</strong> the tests folder. This actually only
imports the individial tests from each application and makes it easier to test
all of them.{% endblocktrans %}</li>
    <li>{% blocktrans %}<strong>extras:</strong> additional scrips, a benchmarking
script with funkload and a simple tool to create a local settings.py
file.{% endblocktrans %}</li>
</ul>



<a name="get-started"></a>
<h3>{% trans "How to get started" %}</h3>
<p>{% blocktrans %}The installation procedure is very similar to the one
described above. The notes and infos there also apply, so read that section
too. First, install all packages:{% endblocktrans %}</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>{% blocktrans %}Get the code and create a superuser:{% endblocktrans %}</p>

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

<p>{% blocktrans %}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>.{% endblocktrans %}</p>


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




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

<ul>
    <li>{% blocktrans %}<strong>Send pull requests:</strong> for new code
you want to share, please send pull requests (either in bitbucket or in
github). Sending patches by email or attaching them to an issue means a lot
more of work.{% endblocktrans %}</li>

    <li>{% blocktrans %}<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.{% endblocktrans %}</li>

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



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

<p>{% blocktrans %}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.{% endblocktrans %}</p>

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

<p>{% blocktrans %}Initialise the database, create a super user and load these
fixtures:{% endblocktrans %}</p>

<code>
$ python manage.py syncdb
$ python manage.py migrate --all
$ python manage.py loaddata languages
$ python manage.py loaddata days_of_week
$ 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>{% blocktrans %}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.{% endblocktrans %}</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">{% trans "Developer guide" %}</a></li>
        <ul>
            <li><a href="#get-code">{% trans "How to get the code" %}</a></li>
            <li><a href="#get-started">{% trans "How to get started" %}</a></li>
            <li><a href="#contribute-code">{% trans "How to contribute code" %}</a></li>
            <li><a href="#custom-hosting">{% trans "Custom hosting" %}</a></li>
        </ul>
</ul>
{% endblock %}
