Fix bug with loading token
Updated readme
Remove realms-wiki bash script (redundant)

Updated install.sh
Using setuptools to create cli entry point
Upstart script sets gid and uid
Esse commit está contido em:
Matthew Scragg 2014-09-18 10:13:33 -05:00
commit 2856dc076f
5 arquivos alterados com 65 adições e 45 exclusões

Ver arquivo

@ -25,7 +25,7 @@ This domain is being used temporarily as a demo so expect it to change.
## Requirements
- Python 2.7
- Git
- NodeJS (needed for bower/cleancss, distro packages shouldn't need this in future)
- NodeJS (needed for bower, distro packages shouldn't need this in future)
**Optional**
- Nginx (if you want proxy requests, this is recommended)
@ -34,24 +34,57 @@ This domain is being used temporarily as a demo so expect it to change.
Anon or single user does not require a database.
## Installation
Install script only tested with Ubuntu 14.04.
Please refer to the script for package requisites if needed
### Ubuntu
If you are using Ubuntu 14.04, you can use install.sh.
```
git clone https://github.com/scragg0x/realms-wiki
cd realms-wiki
sudo bash install.sh
```
**Nginx**
### OSX / Windows
```sudo apt-get install -y nginx```
This app is designed to run in Linux and I recommend using Vagrant to install on OSX or Windows.
### Vagrant
Vagrantfile is included for development or running locally.
To get started with Vagrant, download and install Vagrant and Virtualbox for your platform with the links provided
https://www.vagrantup.com/downloads.html
https://www.virtualbox.org/wiki/Downloads
Then execute the following in the terminal:
git clone https://github.com/scragg0x/realms-wiki
cd realms-wiki
vagrant up
vagrant ssh
realms-wiki dev
Check ```http://127.0.0.1:5000/``` to make sure it's running.
## Config and Setup
You should be able to run this right out of the box with the default config values.
You may want to customize your app and the easiest way is the setup command.
realms-wiki setup
This will ask you questions and create a config.json file in the app root directory.
Of course you can manually edit this file as well.
Any config value set in config.json will override values set in ```realms/config/__init__.py```
## Nginx Setup
sudo apt-get install -y nginx
Create a file called realms.conf in /etc/nginx/conf.d
```
/etc/nginx/conf.d/realms.conf
```
sudo nano /etc/nginx/conf.d/realms.conf
Put the following sample configuration in that file.
@ -61,6 +94,12 @@ Put the following sample configuration in that file.
# Your domain here
server_name wiki.example.org;
# Settings to by-pass for static files
location ^~ /static/ {
# Example:
root /full/path/to/realms/static/;
}
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
@ -74,10 +113,12 @@ Put the following sample configuration in that file.
Test Nginx config
```sudo nginx -t```
sudo nginx -t
Reload Nginx
```sudo service nginx reload```
sudo service nginx reload
## Running
@ -93,23 +134,12 @@ Current there are different ways.
- Debug mode
```realms-wiki runserver```
```realms-wiki dev```
Access from your browser
http://localhost:5000
## Vagrant
Vagrantfile is included for development.
```
git clone https://github.com/scragg0x/realms-wiki
cd realms-wiki
vagrant up
vagrant ssh
realms-wiki runserver
```
## Author

Ver arquivo

@ -11,14 +11,17 @@ if [ -d "/vagrant" ]; then
APP_USER="vagrant"
fi
echo ${APP_DIR}
echo ${APP_USER}
if [ "${APP_USER}" == "root" ]; then
echo "Installing app as root is not recommended"
echo "Username is determined by owner of application directory."
fi
echo "Provisioning..."
sudo apt-get update
sudo apt-get install -y software-properties-common python-software-properties
sudo add-apt-repository -y ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install -y python build-essential git libpcre3-dev python-software-properties \
sudo apt-get install -y python build-essential git libpcre3-dev \
python-pip python-virtualenv python-dev pkg-config curl libxml2-dev libxslt1-dev zlib1g-dev \
libffi-dev nodejs libyaml-dev
@ -47,18 +50,17 @@ sudo -iu ${APP_USER} bower --config.cwd=${APP_DIR} --config.directory=realms/sta
sudo -iu ${APP_USER} virtualenv ${APP_DIR}/.venv
sudo -iu ${APP_USER} ${APP_DIR}/.venv/bin/pip install -r ${APP_DIR}/requirements.txt
sudo -iu ${APP_USER} ${APP_DIR}/.venv/bin/pip install ${APP_DIR}
echo "Installing start scripts"
cat << EOF > /usr/local/bin/realms-wiki
#!/bin/bash
${APP_DIR}/.venv/bin/python ${APP_DIR}/manage.py "\$@"
EOF
sudo ln -s ${APP_DIR}/.venv/bin/realms-wiki /usr/local/bin/realms-wiki
sudo chmod +x /usr/local/bin/realms-wiki
cat << EOF > /etc/init/realms-wiki.conf
description "Realms Wiki"
author "scragg@gmail.com"
setuid ${APP_USER}
setgid ${APP_USER}
start on runlevel [2345]
stop on runlevel [!2345]
respawn

Ver arquivo

@ -1,11 +0,0 @@
#!/bin/bash
APP_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
APP_USER="$( stat -c '%U' ${APP_DIR} )"
CURRENT_USER=`whoami`
if [ "${CURRENT_USER}" != "${APP_USER}" ]; then
echo "Warning: Running as ${CURRENT_USER}, app dir owned by ${APP_USER}"
fi
${APP_DIR}/.venv/bin/python ${APP_DIR}/manage.py "$@"

Ver arquivo

@ -15,7 +15,7 @@ def load_user(user_id):
@login_manager.token_loader
def load_token(token):
# Load unsafe because payload is needed for sig
sig_okay, payload = URLSafeSerializer(None).load_unsafe(token)
sig_okay, payload = URLSafeSerializer(None).loads_unsafe(token)
if not payload:
return False

Ver arquivo

@ -62,11 +62,10 @@ def edit(name):
if edit_cname.lower() != cname.lower():
wiki.rename_page(cname, edit_cname)
"""
wiki.write_page(edit_cname,
request.form['content'],
message=request.form['message'],
username=current_user.username)"""
username=current_user.username)
else:
if data:
name = remove_ext(data['name'])