Showing both login and signup in the same sideoption dialog on blurblogs. Needs to get hooked up.

This commit is contained in:
Samuel Clay 2012-07-09 15:49:57 -07:00
parent 07bd7f5c94
commit 6fb67272ba
3 changed files with 105 additions and 35 deletions

11
fabfile.py vendored
View file

@ -1,13 +1,13 @@
from fabric.api import abort, cd, lcd, env, get, hide, hosts, local, prompt, parallel, serial
from fabric.api import put, require, roles, run, runs_once, settings, show, sudo, warn
from fabric.colors import red, green, blue, cyan, magenta, white, yellow
from fabric.api import cd, env, local, parallel
from fabric.api import put, run, settings, sudo
# from fabric.colors import red, green, blue, cyan, magenta, white, yellow
try:
from boto.s3.connection import S3Connection
from boto.s3.key import Key
except ImportError:
print " ---> Boto not installed yet. No S3 connections available."
from fabric.contrib import django
import os, sys
import os
django.settings_module('settings')
try:
@ -116,11 +116,12 @@ def deploy_code(copy_assets=False, full=False):
transfer_assets()
if full:
with settings(warn_only=True):
run('sudo supervisorctl restart gunicorn')
run('pkill -c gunicorn')
else:
run('kill -HUP `cat logs/gunicorn.pid`')
run('curl -s http://%s > /dev/null' % env.host)
run('curl -s http://%s/api/add_site_load_script/ABCDEF > /dev/null' % env.host)
sudo('supervisorctl restart celery')
def deploy_node():
with cd(env.NEWSBLUR_PATH):

View file

@ -971,11 +971,25 @@ header {
border-bottom: 1px solid #F6F6F6;
height: 0;
}
.NB-sideoption-login-wrapper {
position: relative;
}
.NB-sideoption-login,
.NB-sideoption-signup {
position: absolute;
top: 0;
left: 0;
width: 138px;
}
.NB-sideoption-signup {
left: 162px;
}
.NB-sideoption-login-wrapper .NB-input {
width: 140px;
width: 132px;
margin: 0 0 8px;
}
.NB-sideoption-login-wrapper .NB-sideoption-login-signup {
.NB-sideoption-login-wrapper .NB-sideoption-login-signup,
.NB-sideoption-login-wrapper .NB-sideoption-signup-login {
margin: 12px 0 16px;
line-height: 14px;
color: white;
@ -985,7 +999,8 @@ header {
box-shadow: 2px 2px 0 #95AB76;
}
.NB-sideoption-login-wrapper .NB-sideoption-login-button {
.NB-sideoption-login-wrapper .NB-sideoption-login-button,
.NB-sideoption-login-wrapper .NB-sideoption-signup-button {
line-height: 14px;
margin: 8px 0 2px;
-moz-box-shadow: 2px 2px 0 #95AB76;

View file

@ -3,32 +3,36 @@ NEWSBLUR.Views.SocialPageLoginView = Backbone.View.extend({
events: {
"click .NB-feed-story-login" : "toggle_login_dialog",
"click .NB-sideoption-login-button" : "login",
"click .NB-sideoption-login-signup" : "signup"
"click .NB-sideoption-login-signup" : "switch_to_signup",
"click .NB-sideoption-signup-login" : "switch_to_login",
"click .NB-sideoption-signup-button" : "signup"
},
initialize: function() {
},
render: function() {
this.$el.html(this.template({
story: this.model,
social_services: NEWSBLUR.assets.social_services
}));
return this;
},
template: _.template('\
<div class="NB-sideoption-share-wrapper NB-sideoption-login-wrapper">\
<div class="NB-sideoption-share NB-sideoption-login">\
<div class="NB-sideoption-share NB-sideoption-login NB-active">\
<div class="NB-modal-submit-close NB-sideoption-login-signup NB-modal-submit-button">Create an account</div>\
<div class="NB-sideoption-divider"></div>\
<div class="NB-sideoption-share-title">Username or email:</div>\
<input type="text" name="username" class="NB-input" />\
<input type="text" name="login_username" class="NB-input" />\
<div class="NB-sideoption-share-title">Password:</div>\
<input type="password" name="password" class="NB-input" />\
<input type="password" name="login_password" class="NB-input" />\
<div class="NB-modal-submit-green NB-sideoption-login-button NB-modal-submit-button">Login</div>\
</div>\
<div class="NB-sideoption-share NB-sideoption-signup">\
<div class="NB-modal-submit-close NB-sideoption-signup-login NB-modal-submit-button"><small>Have an account?</small><br />Login</div>\
<div class="NB-sideoption-divider"></div>\
<div class="NB-sideoption-share-title">Username:</div>\
<input type="text" name="signup_username" class="NB-input" />\
<div class="NB-sideoption-share-title">Password:</div>\
<input type="password" name="signup_password" class="NB-input" />\
<div class="NB-sideoption-share-title">Email address:</div>\
<input type="text" name="signup_email" class="NB-input" />\
<div class="NB-modal-submit-green NB-sideoption-signup-button NB-modal-submit-button">Create Account</div>\
</div>\
</div>\
'),
@ -39,8 +43,11 @@ NEWSBLUR.Views.SocialPageLoginView = Backbone.View.extend({
var $dialog = this.$('.NB-sideoption-login-wrapper');
var $story_content = this.$('.NB-feed-story-content,.NB-story-content');
var $story_comments = this.$('.NB-feed-story-comments');
var $username = this.$('input[name=username]');
var $password = this.$('input[name=password]');
var $login_username = this.$('input[name=login_username]');
var $login_password = this.$('input[name=login_password]');
var $signup_username = this.$('input[name=signup_username]');
var $signup_password = this.$('input[name=signup_password]');
var $signup_email = this.$('input[name=signup_email]');
if (options.close ||
($sideoption.hasClass('NB-active') && !options.resize_open)) {
@ -73,31 +80,38 @@ NEWSBLUR.Views.SocialPageLoginView = Backbone.View.extend({
}
$sideoption.addClass('NB-active');
var $clone = $dialog.clone();
var full_height = $clone.css({
$clone.find('.NB-active').css({
'position': 'relative'
});
var dialog_height = $clone.css({
'height': 'auto',
'position': 'absolute',
'visibility': 'hidden'
}).appendTo($dialog.parent()).outerHeight(true);
$clone.remove();
$dialog.animate({
'height': full_height
'height': dialog_height
}, {
'duration': options.immediate ? 0 : 350,
'easing': 'easeInOutQuint',
'queue': false,
'complete': function() {
$username.focus();
}
'complete': _.bind(function() {
if (this.$('.NB-sideoption-login').hasClass('NB-active')) {
$login_username.focus();
} else {
$signup_username.focus();
}
}, this)
});
var sideoptions_height = this.$('.NB-feed-story-sideoptions-container').innerHeight() + 12;
var sideoptions_height = $sideoption.innerHeight() + 12;
var content_height = $story_content.innerHeight() + $story_comments.innerHeight();
if (sideoptions_height + full_height > content_height) {
if (sideoptions_height + dialog_height > content_height) {
var original_height = $story_content.height();
var original_outerHeight = $story_content.outerHeight(true);
$story_content.animate({
'height': original_outerHeight + ((full_height + sideoptions_height) - content_height)
'height': original_outerHeight + ((dialog_height + sideoptions_height) - content_height)
}, {
'duration': 350,
'easing': 'easeInOutQuint',
@ -107,17 +121,31 @@ NEWSBLUR.Views.SocialPageLoginView = Backbone.View.extend({
NEWSBLUR.app.story_list.fetch_story_locations_in_feed_view();
}
}
}).data('original_height', original_height);
});
if (!$story_content.data('original_height')) {
$story_content.data('original_height', original_height);
}
}
var login = _.bind(function(e) {
e.preventDefault();
this.login();
}, this);
$username.add($password).unbind('keydown.login')
$login_username.add($login_password)
.unbind('keydown.login')
.bind('keydown.login', 'ctrl+return', login)
.bind('keydown.login', 'meta+return', login)
.bind('keydown.login', 'return', login);
var signup = _.bind(function(e) {
e.preventDefault();
this.signup();
}, this);
$signup_username.add($signup_password).add($signup_email)
.unbind('keydown.login')
.bind('keydown.login', 'ctrl+return', signup)
.bind('keydown.login', 'meta+return', signup)
.bind('keydown.login', 'return', signup);
}
},
@ -126,12 +154,38 @@ NEWSBLUR.Views.SocialPageLoginView = Backbone.View.extend({
// = Events =
// ==========
login: function() {
},
signup: function() {
},
login: function() {
switch_to_signup: function() {
this.switch_logins({signup: true});
},
switch_to_login: function() {
this.switch_logins({login: true});
},
switch_logins: function(options) {
var $login = this.$('.NB-sideoption-login');
var $signup = this.$('.NB-sideoption-signup');
var width = $login.closest('.NB-sideoption-share-wrapper').width();
$login.toggleClass('NB-active', !!options.login);
$signup.toggleClass('NB-active', !!options.signup);
$login.animate({
left: !!options.login ? 0 : -1 * width
});
$signup.animate({
left: !!options.signup ? 0 : width
});
this.toggle_login_dialog({resize_open: true});
}
});