Skip to content

Commit

Permalink
Merge branch 'master' of github.com:jrconlin/moz_push
Browse files Browse the repository at this point in the history
  • Loading branch information
jrconlin committed Nov 3, 2011
2 parents 5a9c009 + 846e48a commit 5337c42
Show file tree
Hide file tree
Showing 12 changed files with 116 additions and 7 deletions.
7 changes: 6 additions & 1 deletion INSTALL.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ yum install python-setuptools apt-get install python-setuptools
yum install postfix apt-get install postfix
yum install db4-devel apt-get install libdb4.8++-dev
yum install openssl-devel apt-get install libssl-dev
yum install redis apt-get install redis-server
yum install redis apt-get install redis-server*
// this package requires redis 2.4.2 or later Ubuntu currently distributes 1.2.0
yum install nginx apt-get install nginx
apt-get install git-core
apt-get install mercurial
Expand All @@ -28,6 +29,10 @@ $ M2Crypto-0.21.1.tar.gz fedora_setup.py

* Consider swapping out M2Crypto for something more sane

create session dirs
# mkdir -p -m=777 /tmp/notif_sessions/data
# mkdir -p -m=777 /tmp/notif_sessions/lock

start notifserver:
bin/gunicorn -w1 notifserver.run -t 3000 --log-file - --log-level info

Expand Down
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ env:
cd deps && hg clone http://hg.mozilla.org/services/server-core
cd deps/server-core && ../../$(PYTHON) setup.py install

install:
mkdir -p /etc/notifserver/
cp etc/notifserver/* /etc/notifserver/
echo "nginx NOT auto-configured."
echo "Please see etc/nginx/nginx.conf.diff for changes."

clean-env:
rm -rf bin build deps include lib lib64

Expand Down
6 changes: 6 additions & 0 deletions etc/nginx/conf.d/astatic.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
location ^~ /s/ {
allow all;
alias /home/jconlin/src/moz_push/notifserver/static/;
}


18 changes: 18 additions & 0 deletions etc/nginx/conf.d/notifserver.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#Admin interface
location /__admin__ {
allow 10.0.0.0/8;
deny all;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://localhost:8000;
}

# Main handler (for all other URLs)
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://localhost:8000;
}

21 changes: 21 additions & 0 deletions etc/nginx/nginx.conf.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
7c7
< error_log /var/logs/nginx/error.log info;
---
> #error_log logs/error.log info;
36c36
< listen 80 default;
---
> listen 80;
39,40d38
< include /etc/nginx/conf.d/*.conf;
<
45,48c43,46
< # location / {
< # root html;
< # index index.html index.htm;
< # }
---
> location / {
> root html;
> index index.html index.htm;
> }
4 changes: 4 additions & 0 deletions etc/notifserver/production.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ debug = False
translogger = False
profile = False

beaker.session.cookie_expires = true
beaker.session.data_dir = /tmp/notif_sessions/data
beaker.session.lock_dir = /tmp/notif_sessions/lock

[server:main]
use = egg:Paste#http
host = 0.0.0.0
Expand Down
6 changes: 5 additions & 1 deletion notifserver/auth/browserid.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ def __init__(self, *args, **kw):
def authenticate_user(self, user_name, password, request = None):
""" Return a validated user id """
if password is None:
return None
# Perhaps the UI folks messed up. Try to get the
# assertion from the arguments.
if request.params.get('assertion', None) is None:
return None
password = request.params.get('assertion')
try:
if request:
self.environ = request.environ
Expand Down
3 changes: 2 additions & 1 deletion notifserver/controllers/uiagent.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ def index(self, request, **kw):
# display login page
template = self.get_template("not_logged_in")
else:
self.client_agent.new_queue(request)
# Create the user queue if necessary.
self.client_agent.user_queue(request)
template = self.get_template("logged_in")
response['user_info'] = self.msg_backend.user_info(username)
response['subscriptions'] = self.msg_backend.get_queues(username)
Expand Down
Binary file added notifserver/static/default.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 40 additions & 0 deletions notifserver/static/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
body {padding:0;margin:0 auto;text-align:center;font:80% Arial;width:475px;min-height:380px;}
h1 {margin:0 auto;padding:0;width:100%;font-size:200%}
h2 {text-align:left; border:1px solid #bbf;border-width:1px 0 0 1px;margin:5px 0 0 0;padding:5px;}
h3 {text-align:left;}
.error {display:inline-block; color:red;}
form {width:475px;text-align:left;margin:0 auto;}
label {display:inline-block;width:80px;}
.useDefault { display:none;}
input {border:1px solid #888; padding:2px;width:255px;}
input.radio {width:auto;}
.buttons{margin:0;padding:0;text-align:right;border-top:2px solid #e3ebf3;background:#f4f7fb;display:block;width:100%;padding:5px;height:4em;}
header{position:fixed;top:0;width:475px;height:9EM;overflow:auto;margin;0;padding:0;background-image:-moz-linear-gradient(#FFF 80%,rgba(255,255,255,0)100%);z-index:100;}
header img {float:left;}
footer{position:fixed;bottom:0;width:475px;;height:4EM;margin:0;padding:0;background-image:-moz-linear-gradient(rgba(255,255,255,0) 0%,#FFF 30%,#f4f7fb 30%,#f4f7fb 100%)}
main{position:relative;display:block;padding:9EM 0;}
.commands {padding:1em 0;width:475px;}
.message {text-align:left;}
.message .email {font-weight:bold;}
.registered {text-align:left;}
.registered div {min-height:4EM;}
.registered div:nth-child(odd) {background:#F8F8F8;}
.registered .email {padding:8px;font-weight:bold;}
.registered .meta {float:right;}
.registered .meta .del {display:block;}
.registered .meta .date {font:6pt arial; }
button,.fakebutton {background-image:-moz-linear-gradient(center bottom,#E9E9E9,#FbFbFb);width:100px;padding:2px;margin:2px;display:inline-block;border-radius:5px;border:1px solid #888;}
button.submit,button.rsubmit {background-image:-moz-linear-gradient(center bottom,#007dd6,#0093fa);color:#FFF;border:0;font-weight:bold;}
button.go_back {position:relative;left:-120px;}
.fakebutton {background-color:#CCC;color:black;text-decoration:none;text-align:center;}
.subs {text-align:left;}
.subs b {display: inline-block; width:5em; text-align: right;}
#user p {text-align:left;}
table.user {width:100%;background-color:#EEE;}
table.user th {background-color:#EEE;}
table.user tr {margin:0;padding:0;}
table.user td {background-color:#FFF;}
table.user td.button {width:105px;text-align:center;}
table.user button {padding:0;margin:0;}
#unv_emails button {width:8ex;}
#unv_emails td.button {width:9ex;}
8 changes: 6 additions & 2 deletions notifserver/templates/logged_in.mako
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@
import time
response = pageargs.get('response')
config = pageargs.get('config', {})
request = pageargs.get('request', {})
username = response.get('username')
bihost = config.get('bipostal.mailhost', 'localhost')
gravatar = "http://www.gravatar.com/avatar/%s?s=%s&d=%s" % \
(hashlib.md5(username).hexdigest().lower(),
100,
urllib.quote('http://push1.mtv1.dev.svc.mozilla.com/s/default.jpg'))
urllib.quote('http://%s/s/default.jpg' % bihost))
user_info = response.get('user_info')
auth = response.get('auth')
queues = response.get('subscriptions')
Expand All @@ -35,7 +39,7 @@
%if queues is not None:
%for queue in queues.values():
<div id="${queue.get('queue_id')}" class="subs">
<div class="email"><a href="mailto:${queue.get('queue_id')}@push1.mtv1.dev.svc.mozilla.com">${queue.get('queue_id')}@push1.mtv1.dev.svc.mozilla.com</a></div>
<div class="email"><a href="mailto:${queue.get('queue_id')}@${bihost}">${queue.get('queue_id')}@${bihost}</a></div>
<div class="info">
<div class="site"><b>Site:</b> ${queue.get('origin')}</div>
<div class="status"><b>Status:</b> ${queue.get('state')}</div>
Expand Down
4 changes: 2 additions & 2 deletions start.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#bin/gunicorn -w1 notifserver.run -t 3000 --log-file - --log-level info
bin/paster serve etc/notifserver/production.ini
bin/gunicorn -w1 notifserver.run -t 3000 --log-file - --log-level info
#bin/paster serve etc/notifserver/production.ini

0 comments on commit 5337c42

Please sign in to comment.