This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Host | |
# ------------------------------------------------------------------------------ | |
# Go to your main code directory | |
cd ~/Code | |
# Clone alaveteli | |
git clone --recursive https://github.com/mysociety/alaveteli.git | |
cd alaveteli | |
git checkout master # Or the specific version a site is running on, e.g. `0.20.0.14` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
require 'sinatra' | |
set server: 'thin', connections: [] | |
get '/' do | |
halt erb(:login) unless params[:user] | |
erb :chat, locals: { user: params[:user].gsub(/\W/, '') } | |
end | |
get '/stream', provides: 'text/event-stream' do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function(newDoc, oldDoc, userCtx) { | |
if (userCtx.roles.indexOf('_admin') !== -1) { | |
return; | |
} else { | |
throw({forbidden: 'Only admins may edit the database'}); | |
} | |
} |