diff --git a/web/app/assets/javascripts/hoverBand.js b/web/app/assets/javascripts/hoverBand.js index 1c29d25b3..d6498f91a 100644 --- a/web/app/assets/javascripts/hoverBand.js +++ b/web/app/assets/javascripts/hoverBand.js @@ -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) diff --git a/web/app/assets/javascripts/hoverFan.js b/web/app/assets/javascripts/hoverFan.js index 1aa510721..f5b9926d0 100644 --- a/web/app/assets/javascripts/hoverFan.js +++ b/web/app/assets/javascripts/hoverFan.js @@ -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}) diff --git a/web/app/assets/javascripts/hoverMusician.js b/web/app/assets/javascripts/hoverMusician.js index e4443a8c4..6ce0368a6 100644 --- a/web/app/assets/javascripts/hoverMusician.js +++ b/web/app/assets/javascripts/hoverMusician.js @@ -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}) diff --git a/web/app/assets/javascripts/hoverRecording.js b/web/app/assets/javascripts/hoverRecording.js index e99d9fedd..20a5b3994 100644 --- a/web/app/assets/javascripts/hoverRecording.js +++ b/web/app/assets/javascripts/hoverRecording.js @@ -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, diff --git a/web/app/assets/javascripts/hoverSession.js b/web/app/assets/javascripts/hoverSession.js index f9bca235e..f6a9843c5 100644 --- a/web/app/assets/javascripts/hoverSession.js +++ b/web/app/assets/javascripts/hoverSession.js @@ -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 }); diff --git a/web/app/assets/javascripts/utils.js b/web/app/assets/javascripts/utils.js index 657ab1ed8..057ffd3f7 100644 --- a/web/app/assets/javascripts/utils.js +++ b/web/app/assets/javascripts/utils.js @@ -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 }); } diff --git a/web/app/controllers/extras_controller.rb b/web/app/controllers/extras_controller.rb new file mode 100644 index 000000000..131a316d0 --- /dev/null +++ b/web/app/controllers/extras_controller.rb @@ -0,0 +1,9 @@ +class ExtrasController < ApplicationController + + before_filter :signed_in_user + before_filter :admin_user + + def settings + render layout: "web" + end +end diff --git a/web/app/controllers/users_controller.rb b/web/app/controllers/users_controller.rb index cea76d118..d31bb4094 100644 --- a/web/app/controllers/users_controller.rb +++ b/web/app/controllers/users_controller.rb @@ -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) diff --git a/web/app/helpers/sessions_helper.rb b/web/app/helpers/sessions_helper.rb index 9966731a6..98b0c9774 100644 --- a/web/app/helpers/sessions_helper.rb +++ b/web/app/helpers/sessions_helper.rb @@ -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) diff --git a/web/app/views/extras/settings.html.haml b/web/app/views/extras/settings.html.haml new file mode 100644 index 000000000..60dfb8d27 --- /dev/null +++ b/web/app/views/extras/settings.html.haml @@ -0,0 +1,6 @@ +%h1 Extra Feature Settings + +%form + %button.launch_new_ftue{type: 'button'} + + diff --git a/web/app/views/shared/_comments.html.erb b/web/app/views/shared/_comments.html.erb index 0dba9f65e..03f348550 100644 --- a/web/app/views/shared/_comments.html.erb +++ b/web/app/views/shared/_comments.html.erb @@ -20,10 +20,10 @@
-
+
{name} {comment}
-
{timeago}
+
{timeago}

\ No newline at end of file diff --git a/web/config/routes.rb b/web/config/routes.rb index e72c9476b..b225e907f 100644 --- a/web/config/routes.rb +++ b/web/config/routes.rb @@ -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 diff --git a/web/public/maintenance.html b/web/public/maintenance.html new file mode 100644 index 000000000..d0641191d --- /dev/null +++ b/web/public/maintenance.html @@ -0,0 +1,296 @@ + + + + + + + + JamKazam | Site Maintenance + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ + JamKazam logo + +
+ +

Play music together over the Internet as if in the same room

+
+ +
+ +
+

JamKazam is currently down for maintenance.

+ +
+ +
+ +
+ + + + + + diff --git a/web/spec/features/reconnect_spec.rb b/web/spec/features/reconnect_spec.rb index b3bd0d2d5..d7d5f11ae 100644 --- a/web/spec/features/reconnect_spec.rb +++ b/web/spec/features/reconnect_spec.rb @@ -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 diff --git a/web/spec/features/recording_landing_spec.rb b/web/spec/features/recording_landing_spec.rb index e186f4c67..eeb426f72 100644 --- a/web/spec/features/recording_landing_spec.rb +++ b/web/spec/features/recording_landing_spec.rb @@ -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 \ No newline at end of file diff --git a/web/spec/features/session_landing_spec.rb b/web/spec/features/session_landing_spec.rb index 6e776ff21..f9530b8c7 100644 --- a/web/spec/features/session_landing_spec.rb +++ b/web/spec/features/session_landing_spec.rb @@ -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 \ No newline at end of file diff --git a/web/spec/spec_helper.rb b/web/spec/spec_helper.rb index 9b179b8b8..d3f3dccbe 100644 --- a/web/spec/spec_helper.rb +++ b/web/spec/spec_helper.rb @@ -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 diff --git a/web/spec/support/utilities.rb b/web/spec/support/utilities.rb index b053f6514..7cd3869c9 100644 --- a/web/spec/support/utilities.rb +++ b/web/spec/support/utilities.rb @@ -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