-
Notifications
You must be signed in to change notification settings - Fork 11
Setting up hacknight for development
Firefox has issues with running lastuser and hacknight on the same ip address. So you might want to give them unique host names.
I differentiate them by accssing lastuser at http://127.0.0.1:7000 and hacknight at http://0.0.0.0:8000
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 ..
git clone https://github.com/hasgeek/lastuser.git
cd lastuser
pip install -r requirements.txt
cp lastuserapp/settings-sample.py lastuserapp/settings.py
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
./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 hacknights site at http://$LASTUSER_URL/apps/new Set the following fields in the form
- Application title
- Description
- Application website $HACKNIGHT_URL
- Redirect URI $HACKNIGHT_URL/login
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 hacknight app to comunicate with lastuser.
git clone https://github.com/hasgeek/hacknight.git
cd hacknight
Check out the develop branch This is where all the work is happening
git checkout develop
pip install -r requirements.txt
edit instance/settings.py
# Lastuser configuration
#LASTUSER_SERVER = "$LASTUSER_URL"
#LASTUSER_CLIENT_ID="client id from lastuser"
#LASTUSER_CLIENT_SECRET="client secret from lastuser"
##: Database backend
#SQLALCHEMY_DATABASE_URI = 'sqlite:///test.db'
##: Secret key
#SECRET_KEY = 'make this something random'
To run the server
# start the server
./runserver.py