Skip to content

Setting up HasgeekTv for development

haseebgit edited this page Dec 20, 2012 · 2 revisions

Instruction for setting up a development environment for HasgeekTv.

Prerequisites

  • Python 2.7
  • SQLite 3

A quick note on urls.

Give unique host names to lastuser at http://127.0.0.1:7000 and hasgeek.tv at http://0.0.0.0:8000

Download the standard hasgeek libraries from git

First checkout and configure development versions of baseframe, coaster and flask-lastuser. These packages are being update continously so you will need to keep them updated (git pull).

git clone https://github.com/hasgeek/baseframe.git
cd baseframe/baseframe
make tinymce
cd ..
python setup.py develop
cd ..

git clone coaster
cd coaster
python setup.py develop
cd ..

git clone flask-lastuser
cd flask-lastuser
python setup.py develop
cd ..

Install pip

Install virtualenv and pip

$ curl -O https://raw.github.com/pypa/virtualenv/master/virtualenv.py
$ python virtualenv.py hasgeek_env
$ . hasgeek_env/bin/activate

Download and set up lastuser

git clone https://github.com/hasgeek/lastuser.git
cd lastuser
pip install -r requirements.txt
cp lastuserapp/settings-sample.py lastuserapp/settings.py

Note: settings.py is necessary to run the lastuser.

Edit settings.py to add the recaptcha keys You might want to disable recaptcha so that new users can be created using automated scripts.

RECAPTCHA_PUBLIC_KEY = 'RECAPTCHA_PUBLIC_KEY'
RECAPTCHA_PRIVATE_KEY = 'RECAPTCHA_PRIVATE_KEY'
TESTING = True #Disables recaptcha by going into testing mode.

Alternatively, you can commit out the following lines in forms/user.py. This is usefull if you don't want to use recaptcha or don't have the keys,

recaptcha = wtf.RecaptchaField('Are you human?',
    description="Type both words into the text box")

To run the server

# start the server
 $ python runserver.py

Now that the server is set up you should be able to log in and register a new user

Here's a shell script for creating a new user.

#This needs a bit of a circus to work with csrf.
CSRF_TOKEN=`curl -s --cookie-jar lastuser.cookies $LASTUSER_URL/register | grep -P -o '(?<=name="csrf_token" type="hidden" value=")([^"]+)'`
CSRF_TOKEN_BASE64=`echo $CSRF_TOKEN | base64`
NAME='Person'
EMAIL='[email protected]'
USERNAME='person'
PASSWORD='person'
curl -X POST -d "form.id=register&csrf_token=$CSRF_TOKEN&fullname=$NAME&email=$EMAIL&username=$USERNAME&password=$PASSWORD&confirm_password=$PASSWORD" --cookie lastuser.cookies $LASTUSER_URL/register

Register the hasgeektv site at http://$LASTUSER_URL/apps/new Set the following fields in the form

  • Application title
  • Description
  • Application website $HASGEEKTV_URL
  • Redirect URI $HASGEEKTV_URL/login/redirect

When you create the site in lastuser you will find two values, "Client id (key)" and "Client secret" Copy these, they will be required by the hasgeektv app to comunicate with lastuser.

Download and setup the hasgeektv site

git clone https://github.com/hasgeek/hasgeek.tv.git
cd hasgeek.tv

Check out the develop branch This is where all the work is happening

git checkout develop

pip install -r requirements.txt

Note: settings.py file is necessary to run the hasgeektv

edit instance/settings.py

# Lastuser configuration
#LASTUSER_SERVER = "$LASTUSER_URL"
#LASTUSER_CLIENT_ID="client id from lastuser"
#LASTUSER_CLIENT_SECRET="client secret from lastuser"
##: Secret key
#SECRET_KEY = 'make this something random'

To run the server

 # start the server
  $ python runserver.py

Questions

We hang around IRC "hasgeek" on Freenode.

We also have [Mailinglist] (http://groups.google.com/group/hasgeek-code )