From 6e4844629a5f46ad93d3af4d1beec7c1d628c2b5 Mon Sep 17 00:00:00 2001 From: David Morley Date: Sun, 19 Feb 2012 15:29:07 -0600 Subject: [PATCH 1/7] admin cleanup --- app/views/admins/_admin_bar.haml | 1 + app/views/admins/user_search.html.haml | 2 +- app/views/admins/weekly_user_stats.haml | 6 +++--- config/routes.rb | 1 + 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/views/admins/_admin_bar.haml b/app/views/admins/_admin_bar.haml index a366c187c..e616148ee 100644 --- a/app/views/admins/_admin_bar.haml +++ b/app/views/admins/_admin_bar.haml @@ -7,6 +7,7 @@ %li= link_to 'Pod Stats', pod_stats_path %li= link_to 'Correlations', correlations_path - if AppConfig[:mount_resque_web] + %li= link_to 'Resque', '/admins/resque' %li= link_to 'Resque Overview', resque_web_path diff --git a/app/views/admins/user_search.html.haml b/app/views/admins/user_search.html.haml index 900e78ee7..ff74732ff 100644 --- a/app/views/admins/user_search.html.haml +++ b/app/views/admins/user_search.html.haml @@ -21,7 +21,7 @@ email: = text_field_tag 'user[email]', params[:user][:email] - invitation identifier + invitation identifier: = text_field_tag 'user[invitation_identifier]', params[:user][:invitation_identifier] invitation token: diff --git a/app/views/admins/weekly_user_stats.haml b/app/views/admins/weekly_user_stats.haml index 621798d85..6816c324e 100644 --- a/app/views/admins/weekly_user_stats.haml +++ b/app/views/admins/weekly_user_stats.haml @@ -5,9 +5,9 @@ %br .span-24.last - %h1 + %h2 = "Users per week (Current server date is: #{Time.now.to_date}) " %ul - - @created_users_by_week.keys.sort.each do |k| + - @created_users_by_week.keys.sort.reverse.each do |k| %li - = "Week stating on #{k} , #{@created_users_by_week[k]}" + = "Week starting on #{k} , #{@created_users_by_week[k]}" diff --git a/config/routes.rb b/config/routes.rb index 4b32af38c..efea3c00f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -110,6 +110,7 @@ Diaspora::Application.routes.draw do get :admin_inviter get :weekly_user_stats get :correlations + get :resque get :stats, :as => 'pod_stats' end From c41923081ae842d8820bde8aef6b7129aacdb821 Mon Sep 17 00:00:00 2001 From: David Morley Date: Sun, 19 Feb 2012 15:50:12 -0600 Subject: [PATCH 2/7] resque with header --- app/views/admins/resque.html.haml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 app/views/admins/resque.html.haml diff --git a/app/views/admins/resque.html.haml b/app/views/admins/resque.html.haml new file mode 100644 index 000000000..32b5ec42b --- /dev/null +++ b/app/views/admins/resque.html.haml @@ -0,0 +1,6 @@ +-# Copyright (c) 2010-2011, Diaspora Inc. This file is +-# licensed under the Affero General Public License version 3 or later. See +-# the COPYRIGHT file. + +.stream + = render :partial => resque_web_path From a63bcd008083b0976fdc0344e8dcf74bc73c18dd Mon Sep 17 00:00:00 2001 From: David Morley Date: Sun, 19 Feb 2012 21:28:12 -0600 Subject: [PATCH 3/7] make popular tags human readable --- app/controllers/admins_controller.rb | 2 +- app/views/admins/_admin_bar.haml | 1 - app/views/admins/resque.html.haml | 6 --- app/views/admins/stats.html.haml | 67 +++------------------------- config/routes.rb | 1 - 5 files changed, 8 insertions(+), 69 deletions(-) delete mode 100644 app/views/admins/resque.html.haml diff --git a/app/controllers/admins_controller.rb b/app/controllers/admins_controller.rb index 7dd8a8df6..d6ea8e217 100644 --- a/app/controllers/admins_controller.rb +++ b/app/controllers/admins_controller.rb @@ -36,7 +36,7 @@ class AdminsController < ApplicationController end def stats - @popular_tags = ActsAsTaggableOn::Tagging.joins(:tag).limit(15).count(:group => :tag, :order => 'count(taggings.id) DESC') + @popular_tags = ActsAsTaggableOn::Tagging.joins(:tag).limit(50).count(:group => :tag, :order => 'count(taggings.id) DESC') case params[:range] when "week" diff --git a/app/views/admins/_admin_bar.haml b/app/views/admins/_admin_bar.haml index e616148ee..a366c187c 100644 --- a/app/views/admins/_admin_bar.haml +++ b/app/views/admins/_admin_bar.haml @@ -7,7 +7,6 @@ %li= link_to 'Pod Stats', pod_stats_path %li= link_to 'Correlations', correlations_path - if AppConfig[:mount_resque_web] - %li= link_to 'Resque', '/admins/resque' %li= link_to 'Resque Overview', resque_web_path diff --git a/app/views/admins/resque.html.haml b/app/views/admins/resque.html.haml deleted file mode 100644 index 32b5ec42b..000000000 --- a/app/views/admins/resque.html.haml +++ /dev/null @@ -1,6 +0,0 @@ --# Copyright (c) 2010-2011, Diaspora Inc. This file is --# licensed under the Affero General Public License version 3 or later. See --# the COPYRIGHT file. - -.stream - = render :partial => resque_web_path diff --git a/app/views/admins/stats.html.haml b/app/views/admins/stats.html.haml index 17ae0f654..66a87413c 100644 --- a/app/views/admins/stats.html.haml +++ b/app/views/admins/stats.html.haml @@ -49,8 +49,6 @@ %span.percent_change{:class => (model[:change] > 0 ? "green" : "red")} = "(#{model[:change]}%)" - %br - %br %br %br %br @@ -65,63 +63,12 @@ %b #{@posts[:day_before]/@user_count.to_f} - /%h3 - / Posts over time - - /#stats_graph{:style => "text-align:right;position:relative;vertical-align:bottom;background-color:#eee;"} - / = @posts_per_day.inspect - / /- @posts_per_day.each do |key, val| - / /.asdo{:style => "display:inline-block;width:35px;vertical-align:bottom;background-color:#666;height:#{(val/@most_posts_within)*200}px;"} - - - %br - %br - %br - %br - - - -%br -%br -%br -%br -%br -%br -%br -%br -%br -%br -%br -%br -%br -%br -%br -%br -%br -%br -%br - .span-24.last - %h2 - Misc Stuff - %br - %br - %h3 - = for tg in @popular_tags - = link_to tg, tags_path(tg) - -%br -%br - -.span-12 - %h3 - New public posts - /.stream - / /= render 'shared/stream', :posts => @new_public_posts - -.span-12.last - %h3 - Most Liked - .stream - = render 'shared/stream', :posts => @most_liked_posts + 50 Most Popular Tags + - @popular_tags.each do |name,count| + Tag Name: + %b= name + Count: + %b= count + %br diff --git a/config/routes.rb b/config/routes.rb index efea3c00f..4b32af38c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -110,7 +110,6 @@ Diaspora::Application.routes.draw do get :admin_inviter get :weekly_user_stats get :correlations - get :resque get :stats, :as => 'pod_stats' end From 0430d940f14c3daef8ab60b4198069b9cad0bf91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonne=20Ha=C3=9F?= Date: Wed, 22 Feb 2012 12:29:15 +0100 Subject: [PATCH 4/7] git urls are still better than http ones :P, close #2915 --- Gemfile | 2 +- Gemfile.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index 5aed8adde..57330e614 100644 --- a/Gemfile +++ b/Gemfile @@ -82,7 +82,7 @@ gem 'ruby-oembed' # queue gem 'resque', '1.19.0' -gem 'resque-ensure-connected', :git => 'https://github.com/socialcast/resque-ensure-connected.git' +gem 'resque-ensure-connected', :git => 'git://github.com/socialcast/resque-ensure-connected.git' gem 'resque-timeout', '1.0.0' gem 'SystemTimer', '1.2.3', :platforms => :ruby_18 diff --git a/Gemfile.lock b/Gemfile.lock index 496428559..17d50e443 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -32,7 +32,7 @@ GIT sinatra GIT - remote: https://github.com/socialcast/resque-ensure-connected.git + remote: git://github.com/socialcast/resque-ensure-connected.git revision: 8ac0f9e4658495097fb333a93db81d54ba9a5311 specs: resque-ensure-connected (0.2.0) From 412853bfcce680972c105b2b0ae601a70824eac2 Mon Sep 17 00:00:00 2001 From: Florian Staudacher Date: Wed, 22 Feb 2012 14:45:43 +0100 Subject: [PATCH 5/7] make lightbox work for photos page (+tests) --- public/javascripts/app/views/photos_view.js | 6 +- public/javascripts/widgets/lightbox.js | 13 ++- spec/javascripts/widgets/lightbox-spec.js | 95 +++++++++++++++++++++ 3 files changed, 111 insertions(+), 3 deletions(-) create mode 100644 spec/javascripts/widgets/lightbox-spec.js diff --git a/public/javascripts/app/views/photos_view.js b/public/javascripts/app/views/photos_view.js index d9161356e..2f930f018 100644 --- a/public/javascripts/app/views/photos_view.js +++ b/public/javascripts/app/views/photos_view.js @@ -7,7 +7,7 @@ app.views.Photos = Backbone.View.extend({ this.collection = this.model.photos; this.setupEvents(); - //this.setupLightbox(); ERROR: "imageThumb is undefined" ... + this.setupLightbox(); }, setupEvents : function(){ @@ -50,6 +50,10 @@ app.views.Photos = Backbone.View.extend({ setupLightbox : function(){ this.lightbox = Diaspora.BaseWidget.instantiate("Lightbox"); + this.lightbox.set({ + imageParent: '#main_stream', + imageSelector: 'img.photo' + }); $(this.el).delegate("a.photo-link", "click", this.lightbox.lightboxImageClicked); }, diff --git a/public/javascripts/widgets/lightbox.js b/public/javascripts/widgets/lightbox.js index 89186f841..30c969845 100644 --- a/public/javascripts/widgets/lightbox.js +++ b/public/javascripts/widgets/lightbox.js @@ -20,6 +20,11 @@ jQuery.fn.center = (function() { var Lightbox = function() { var self = this; + self.options = { + imageParent: '.stream_element', + imageSelector: 'img.stream-photo' + }; + this.subscribe("widget/ready", function(evt) { $.extend(self, { lightbox: $("#lightbox"), @@ -88,9 +93,9 @@ jQuery.fn.center = (function() { this.lightboxImageClicked = function(evt) { evt.preventDefault(); - var selectedImage = $(this).find("img.stream-photo"), + var selectedImage = $(this).find(self.options.imageSelector), imageUrl = selectedImage.attr("data-full-photo"), - images = selectedImage.parents('.stream_element').find('img.stream-photo'), + images = selectedImage.parents(self.options.imageParent).find(self.options.imageSelector), imageThumb; if( $.browser.msie ) { @@ -147,6 +152,10 @@ jQuery.fn.center = (function() { self.lightbox.hide(); self.body.removeClass("lightboxed"); }; + + this.set = function(opts) { + $.extend(self.options, opts); + }; }; Diaspora.Widgets.Lightbox = Lightbox; diff --git a/spec/javascripts/widgets/lightbox-spec.js b/spec/javascripts/widgets/lightbox-spec.js new file mode 100644 index 000000000..d821dfa0f --- /dev/null +++ b/spec/javascripts/widgets/lightbox-spec.js @@ -0,0 +1,95 @@ +/* Copyright (c) 2010-2012, Diaspora Inc. This file is + * licensed under the Affero General Public License version 3 or later. See + * the COPYRIGHT file. + */ + +describe("Diaspora.Widgets.Lighbox", function() { + var photos; + + var createDummyMarkup = function(opts){ + var defaults = { + linkClass: 'stream-photo-link', + imageParent: 'stream_element', + imageClass: 'stream-photo' + }; + + classes = _.extend(defaults, opts); + + var output = $('
').addClass(classes.imageParent); + _.each(photos, function(photo){ + output.append( + $('') + .attr('href', '#') + .addClass(classes.linkClass) + .append( + $('') + .attr('src', photo.sizes.large) + .addClass(classes.imageClass) + .data({ + 'small-photo': photo.sizes.small, + 'full-photo': photo.sizes.large + }) + ) + ); + }); + + return output; + }; + + beforeEach(function(){ + $("#jasmine_content").html( + '' + + '' + + '' + + '' + ); + + photos = $.parseJSON(spec.readFixture("photos_json"))["photos"]; + }); + + context("opens the lightbox correctly", function() { + var lightbox, page, photoElement; + + beforeEach(function() { + $("#jasmine_content").append(createDummyMarkup()); + photoElement = $('.stream-photo').first(); + + lightbox = Diaspora.BaseWidget.instantiate("Lightbox"); + $('.stream_element').delegate("a.stream-photo-link", "click", lightbox.lightboxImageClicked); + }); + + it("shows the lightbox when a photo is clicked", function() { + spyOn(lightbox, 'revealLightbox'); + photoElement.trigger('click'); + expect(lightbox.revealLightbox).toHaveBeenCalled(); + }); + + }); + + context("opens lightbox for differently named elements", function(){ + var lightbox, page, photoElement; + + beforeEach(function() { + $("#jasmine_content").append(createDummyMarkup({ + linkClass: 'photo-link', + imageParent: 'main_stream', + imageClass: 'photo' + })); + photoElement = $('.photo').first(); + + lightbox = Diaspora.BaseWidget.instantiate("Lightbox"); + lightbox.set({ + imageParent: '.main_stream', + imageSelector: 'img.photo' + }); + $('.main_stream').delegate("a.photo-link", "click", lightbox.lightboxImageClicked); + }); + + it("shows the lightbox when a photo is clicked", function() { + spyOn(lightbox, 'revealLightbox'); + photoElement.trigger('click'); + expect(lightbox.revealLightbox).toHaveBeenCalled(); + }); + }); + +}); From 019b68281e48efc2fd4910920347ac22100209b2 Mon Sep 17 00:00:00 2001 From: Diaspora Europe Date: Thu, 23 Feb 2012 12:21:01 +0100 Subject: [PATCH 6/7] handle text-overflow for long usernames #2557 --- public/stylesheets/sass/application.sass | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index cee46c3c5..f6248c104 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -1737,6 +1737,9 @@ ul#press_logos :top 14px :padding :bottom 5px + :text-overflow ellipsis + :overflow hidden + :white-space nowrap a :color inherit @@ -2725,6 +2728,9 @@ a.toggle_selector :bottom 10px h1,h3 :color #fff + :text-overflow ellipsis + :overflow hidden + :white-space nowrap :background orange &:hover #gs-skip-x From 663a5a0e7cc5a73d5325a01775ec48563bf0de60 Mon Sep 17 00:00:00 2001 From: Florian Staudacher Date: Fri, 24 Feb 2012 14:09:54 +0100 Subject: [PATCH 7/7] escape all passed params in js - fixes #2922 --- app/views/status_messages/bookmarklet.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/status_messages/bookmarklet.html.haml b/app/views/status_messages/bookmarklet.html.haml index 04e5d41bd..2ce78d895 100644 --- a/app/views/status_messages/bookmarklet.html.haml +++ b/app/views/status_messages/bookmarklet.html.haml @@ -47,7 +47,7 @@ window.setTimeout(window.close, 2000, true); }); - var contents = "#{params[:title]} - #{params[:url]}"; + var contents = "#{escape_javascript params[:title]} - #{escape_javascript params[:url]}"; var notes = "#{escape_javascript params[:notes]}"; if (notes.length > 0){ contents = contents + " - " + notes;