Merge remote-tracking branch 'origin/develop' into develop

This commit is contained in:
Anthony Davis 2014-04-14 15:52:52 -05:00
commit 7a5f5ef93c
18 changed files with 489 additions and 48 deletions

View File

@ -2,14 +2,26 @@
"use strict";
context.JK = context.JK || {};
context.JK.BandHoverBubble = function(bandId, position) {
context.JK.BandHoverBubble = function(bandId, x, y) {
var logger = context.JK.logger;
var rest = context.JK.Rest();
var hoverSelector = "#band-hover";
this.showBubble = function() {
$(hoverSelector).css({left: position.left-100, top: position.top});
var mouseLeft = x < (document.body.clientWidth / 2);
var mouseTop = y < (document.body.clientHeight / 2);
var css = {};
if (mouseLeft)
css.left = x + 10 + 'px';
else
css.left = x - (7 + $(hoverSelector).width()) + 'px';
if (mouseTop)
css.top = y + 10 + 'px';
else
css.top = y - (7 + $(hoverSelector).height()) + 'px';
$(hoverSelector).css(css);
$(hoverSelector).fadeIn(500);
rest.getBand(bandId)

View File

@ -2,7 +2,7 @@
"use strict";
context.JK = context.JK || {};
context.JK.FanHoverBubble = function(userId, position) {
context.JK.FanHoverBubble = function(userId, x, y) {
var logger = context.JK.logger;
var rest = context.JK.Rest();
@ -10,7 +10,19 @@
var hoverSelector = "#fan-hover";
this.showBubble = function() {
$(hoverSelector).css({left: position.left-100, top: position.top});
var mouseLeft = x < (document.body.clientWidth / 2);
var mouseTop = y < (document.body.clientHeight / 2);
var css = {};
if (mouseLeft)
css.left = x + 10 + 'px';
else
css.left = x - (7 + $(hoverSelector).width()) + 'px';
if (mouseTop)
css.top = y + 10 + 'px';
else
css.top = y - (7 + $(hoverSelector).height()) + 'px';
$(hoverSelector).css(css);
$(hoverSelector).fadeIn(500);
rest.getUserDetail({id: userId})

View File

@ -2,14 +2,27 @@
"use strict";
context.JK = context.JK || {};
context.JK.MusicianHoverBubble = function(userId, position) {
context.JK.MusicianHoverBubble = function(userId, x, y) {
var logger = context.JK.logger;
var rest = context.JK.Rest();
var hoverSelector = "#musician-hover";
this.showBubble = function() {
$(hoverSelector).css({left: position.left-100, top: position.top});
var mouseLeft = x < (document.body.clientWidth / 2);
var mouseTop = y < (document.body.clientHeight / 2);
var css = {};
if (mouseLeft)
css.left = x + 10 + 'px';
else
css.left = x - (7 + $(hoverSelector).width()) + 'px';
if (mouseTop)
css.top = y + 10 + 'px';
else
css.top = y - (7 + $(hoverSelector).height()) + 'px';
$(hoverSelector).css(css);
$(hoverSelector).fadeIn(500);
rest.getUserDetail({id: userId})

View File

@ -2,7 +2,7 @@
"use strict";
context.JK = context.JK || {};
context.JK.RecordingHoverBubble = function(recordingId, position) {
context.JK.RecordingHoverBubble = function(recordingId, x, y) {
var logger = context.JK.logger;
var rest = context.JK.Rest();
var hoverSelector = "#recording-hover";
@ -38,7 +38,19 @@
}
this.showBubble = function() {
$(hoverSelector).css({left: position.left-100, top: position.top+20});
var mouseLeft = x < (document.body.clientWidth / 2);
var mouseTop = y < (document.body.clientHeight / 2);
var css = {};
if (mouseLeft)
css.left = x + 10 + 'px';
else
css.left = x - (7 + $(hoverSelector).width()) + 'px';
if (mouseTop)
css.top = y + 10 + 'px';
else
css.top = y - (7 + $(hoverSelector).height()) + 'px';
$(hoverSelector).css(css);
$(hoverSelector).fadeIn(500);
rest.getClaimedRecording(recordingId)
@ -76,7 +88,7 @@
claimedRecordingId: claimedRecording.id,
name: claimedRecording.name,
genre: claimedRecording.genre_id.toUpperCase(),
created_at: context.JK.formatDateTime(recording.created_at),
created_at: $.timeago(recording.created_at),
description: response.description ? response.description : "",
play_count: recording.play_count,
comment_count: recording.comment_count,

View File

@ -2,14 +2,26 @@
"use strict";
context.JK = context.JK || {};
context.JK.SessionHoverBubble = function(sessionId, position) {
context.JK.SessionHoverBubble = function(sessionId, x, y) {
var logger = context.JK.logger;
var rest = context.JK.Rest();
var hoverSelector = "#session-hover";
this.showBubble = function() {
$(hoverSelector).css({left: position.left-100, top: position.top+10});
var mouseLeft = x < (document.body.clientWidth / 2);
var mouseTop = y < (document.body.clientHeight / 2);
var css = {};
if (mouseLeft)
css.left = x + 10 + 'px';
else
css.left = x - (7 + $(hoverSelector).width()) + 'px';
if (mouseTop)
css.top = y + 10 + 'px';
else
css.top = y - (7 + $(hoverSelector).height()) + 'px';
$(hoverSelector).css(css);
$(hoverSelector).fadeIn(500);
rest.getSessionHistory(sessionId)
@ -44,7 +56,7 @@
genre: response.genres.toUpperCase(),
comment_count: response.comment_count,
like_count: response.like_count,
created_at: context.JK.formatDateTime(response.created_at),
created_at: $.timeago(response.created_at),
musicians: musicianHtml
});

View File

@ -154,6 +154,8 @@
}
context.JK.bindHoverEvents = function ($parent) {
var timeout = 300;
var fadeoutValue = 100;
if (!$parent) {
$parent = $('body');
@ -165,75 +167,87 @@
}
function hideBubble($hoverElement) {
var bubbleSelector = $hoverElement.attr("bubble-id");
$(bubbleSelector).hover(
function () {
// do nothing when entering the bubble (this should never happen)
// do nothing when entering the bubble
},
function () {
$(this).fadeOut(100);
$(this).fadeOut(fadeoutValue);
}
);
// first check to see if the user isn't hovering over the hover bubble
if (!$(bubbleSelector).is(":hover")) {
$(bubbleSelector).fadeOut(fadeoutValue);
}
}
// MUSICIAN
$("[hoveraction='musician']", $parent).hoverIntent({
over: function () {
var bubble = new JK.MusicianHoverBubble($(this).attr('user-id'), $(this).offset());
over: function(e) {
var bubble = new JK.MusicianHoverBubble($(this).attr('user-id'), e.pageX, e.pageY);
showBubble(bubble, $(this));
},
out: function () { // this registers for leaving the hoverable element
hideBubble($(this));
},
sensitivity: 1
sensitivity: 1,
timeout: timeout
});
// FAN
$("[hoveraction='fan']", $parent).hoverIntent({
over: function () {
var bubble = new JK.FanHoverBubble($(this).attr('user-id'), $(this).offset());
over: function(e) {
var bubble = new JK.FanHoverBubble($(this).attr('user-id'), e.pageX, e.pageY);
showBubble(bubble, $(this));
},
out: function () { // this registers for leaving the hoverable element
hideBubble($(this));
},
sensitivity: 1
sensitivity: 1,
timeout: timeout
});
// BAND
$("[hoveraction='band']", $parent).hoverIntent({
over: function () {
var bubble = new JK.BandHoverBubble($(this).attr('band-id'), $(this).offset());
over: function(e) {
var bubble = new JK.BandHoverBubble($(this).attr('band-id'), e.pageX, e.pageY);
showBubble(bubble, $(this));
},
out: function () { // this registers for leaving the hoverable element
hideBubble($(this));
},
sensitivity: 1
sensitivity: 1,
timeout: timeout
});
// SESSION
$("[hoveraction='session']", $parent).hoverIntent({
over: function () {
var bubble = new JK.SessionHoverBubble($(this).attr('session-id'), $(this).offset());
over: function(e) {
var bubble = new JK.SessionHoverBubble($(this).attr('session-id'), e.pageX, e.pageY);
showBubble(bubble, $(this));
},
out: function () { // this registers for leaving the hoverable element
hideBubble($(this));
},
sensitivity: 1
sensitivity: 1,
timeout: timeout
});
// RECORDING
$("[hoveraction='recording']", $parent).hoverIntent({
over: function () {
var bubble = new JK.RecordingHoverBubble($(this).attr('recording-id'), $(this).offset());
over: function(e) {
var bubble = new JK.RecordingHoverBubble($(this).attr('recording-id'), e.pageX, e.pageY);
showBubble(bubble, $(this));
},
out: function () { // this registers for leaving the hoverable element
hideBubble($(this));
},
sensitivity: 1
sensitivity: 1,
timeout: timeout
});
}

View File

@ -0,0 +1,9 @@
class ExtrasController < ApplicationController
before_filter :signed_in_user
before_filter :admin_user
def settings
render layout: "web"
end
end

View File

@ -396,10 +396,6 @@ class UsersController < ApplicationController
redirect_to(root_url) unless current_user?(@user)
end
def admin_user
redirect_to(root_url) unless current_user.admin?
end
# the User Model expects instruments in a different format than the form submits it
# so we have to fix it up.
def fixup_instruments(original_instruments)

View File

@ -57,6 +57,10 @@ module SessionsHelper
cookies.delete(:remember_token, domain: Rails.application.config.session_cookie_domain)
end
def admin_user
redirect_to(root_url) unless current_user.admin?
end
def redirect_back_or(default)
redirect_to(session[:return_to] || default)
session.delete(:return_to)

View File

@ -0,0 +1,6 @@
%h1 Extra Feature Settings
%form
%button.launch_new_ftue{type: 'button'}

View File

@ -20,10 +20,10 @@
<div user-id="{user_id}" hoveraction="{hoverAction}" class="avatar-small mr10">
<img src="{avatar_url}" alt="" />
</div>
<div class="w80 left p10 lightgrey mt10">
<div class="w80 left p10 lightgrey mt10 comment-text">
<a user-id="{user_id}" hoveraction="{hoverAction}">{name}</a>&nbsp;{comment}
<br />
<div class="f12 grey mt5">{timeago}</div>
<div class="f12 grey mt5 comment-timestamp">{timeago}</div>
</div>
<br clear="all" />
</script>

View File

@ -98,6 +98,8 @@ SampleApp::Application.routes.draw do
# vanilla forums sso
match '/forums/sso', to: 'vanilla_forums#authenticate'
# admin-only page to control settings
match '/extras/settings', to: 'extras#settings'
scope '/corp' do
# about routes

296
web/public/maintenance.html Normal file

File diff suppressed because one or more lines are too long

View File

@ -8,6 +8,10 @@ describe "Reconnect", :js => true, :type => :feature, :capybara_feature => true
let(:user1) { FactoryGirl.create(:user) }
let(:user2) { FactoryGirl.create(:user) }
before(:all) do
User.delete_all
end
before(:each) do
emulate_client
end

View File

@ -12,12 +12,12 @@ describe "Landing", :js => true, :type => :feature, :capybara_feature => true do
before(:each) do
MusicSessionHistory.delete_all
sign_in_poltergeist(user)
end
let (:claimed_recording) { FactoryGirl.create(:claimed_recording) }
it "should render comments" do
pending "weird error"
recording = ClaimedRecording.first
comment = "test comment"
@ -31,10 +31,10 @@ describe "Landing", :js => true, :type => :feature, :capybara_feature => true do
# (1) Test a user creating a comment and ensure it displays.
# comment body
find('div', text: comment)
find('div.comment-text', text: comment)
# timestamp
find('div', text: timestamp)
find('div.comment-timestamp', text: timestamp)
# (2) Test a user visiting a landing page with an existing comment.
@ -42,9 +42,9 @@ describe "Landing", :js => true, :type => :feature, :capybara_feature => true do
visit url
# comment body
find('div', text: comment)
find('div.comment-text', text: comment)
# timestamp
find('div', text: timestamp)
find('div.comment-timestamp', text: timestamp)
end
end

View File

@ -14,7 +14,6 @@ describe "Landing", :js => true, :type => :feature, :capybara_feature => true do
end
it "should render comments" do
pending "weird error"
msh = MusicSessionHistory.first
comment = "test comment"
@ -28,10 +27,10 @@ describe "Landing", :js => true, :type => :feature, :capybara_feature => true do
find('#btnPostComment').trigger(:click)
# comment body
find('div', text: comment)
find('div.comment-text', text: comment)
# timestamp
find('div', text: timestamp)
find('div.comment-timestamp', text: timestamp)
# (2) Test a user visiting a landing page with an existing comment.
@ -39,9 +38,9 @@ describe "Landing", :js => true, :type => :feature, :capybara_feature => true do
visit url
# comment body
find('div', text: comment)
find('div.comment-text', text: comment)
# timestamp
find('div', text: timestamp)
find('div.comment-timestamp', text: timestamp)
end
end

View File

@ -1,3 +1,11 @@
# temporary to debug failing tests on the build server
def bputs(msg)
if ENV["BUILD_PUTS"] == "1"
puts msg
end
end
require 'simplecov'
require 'rubygems'
#require 'spork'
@ -7,18 +15,27 @@ require 'omniauth'
ENV["RAILS_ENV"] ||= 'test'
bputs "before activerecord load"
require 'active_record'
require 'action_mailer'
require 'jam_db'
require "#{File.dirname(__FILE__)}/spec_db"
bputs "before db_config load"
# recreate test database and migrate it
db_config = YAML::load(File.open('config/database.yml'))["test"]
# initialize ActiveRecord's db connection\
bputs "before recreate db"
SpecDb::recreate_database(db_config)
bputs "before connect db"
ActiveRecord::Base.establish_connection(YAML::load(File.open('config/database.yml'))["test"])
bputs "before load jam_ruby"
require 'jam_ruby'
# uncomment this to see active record logs
@ -34,13 +51,21 @@ tests_started = false
Thread.new {
sleep 30
if ENV['BUILD_NUMBER']
sleep 240
else
sleep 30
end
unless tests_started
bputs "tests are hung. exiting..."
puts "tests are hung. exiting..."
exit! 20
end
}
bputs "before load websocket server"
current = Thread.current
Thread.new do
ActiveRecord::Base.connection.disconnect!
@ -59,25 +84,41 @@ Thread.new do
puts "websocket-gateway failed: #{e}"
end
end
bputs "before websocket thread wait"
Thread.stop
bputs "before connection reestablish"
ActiveRecord::Base.connection.disconnect!
bputs "before connection reestablishing"
ActiveRecord::Base.establish_connection(YAML::load(File.open('config/database.yml'))["test"])
#Spork.prefork do
# Loading more in this block will cause your tests to run faster. However,
# if you change any configuration or code from libraries loaded here, you'll
# need to restart spork for it take effect.
# This file is copied to spec/ when you run 'rails generate rspec:install'
bputs "before load environment"
begin
require File.expand_path("../../config/environment", __FILE__)
rescue => e
bputs "exception in load environment"
bputs "e: #{e}"
end
bputs "before loading rails"
require 'rspec/rails'
bputs "before connection autorun"
require 'rspec/autorun'
bputs "before load capybara"
require 'capybara'
require 'capybara/rspec'
require 'capybara-screenshot/rspec'
bputs "before load poltergeist"
require 'capybara/poltergeist'
bputs "before register capybara"
Capybara.register_driver :poltergeist do |app|
driver = Capybara::Poltergeist::Driver.new(app, { debug: false, phantomjs_logger: File.open('log/phantomjs.out', 'w') })
end

View File

@ -4,10 +4,19 @@ include ApplicationHelper
module Capybara
module Node
class Element
def attempt_hover
begin
hover
rescue => e
end
end
def hover_intent
hover
hover
hover
sleep 0.3
attempt_hover
sleep 0.3
attempt_hover
end
end
end