From 7da10c01490e2b7ac9055216830dc3d37acad3bf Mon Sep 17 00:00:00 2001 From: Wojciech Zawistowski Date: Wed, 18 Sep 2013 18:40:57 +0200 Subject: [PATCH 01/12] Remove duplicate mixing in of Discourse.Presence AdminEmailIndexController and AdminEmailPreviewDigestController explicitely mix in Discourse.Presence, but they extend base classes Discourse.Controller and Discourse.ObjectController that already mix in Discourse.Presence, so this explicit inclusion is redundant. --- .../admin/controllers/admin_email_index_controller.js | 2 +- .../controllers/admin_email_preview_digest_controller.js | 2 +- .../controllers/admin_email_index_controller_test.js | 5 +++++ .../admin_email_preview_digest_controller_test.js | 5 +++++ 4 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 test/javascripts/controllers/admin_email_index_controller_test.js create mode 100644 test/javascripts/controllers/admin_email_preview_digest_controller_test.js diff --git a/app/assets/javascripts/admin/controllers/admin_email_index_controller.js b/app/assets/javascripts/admin/controllers/admin_email_index_controller.js index 673411d8ea2..8da9fa2d493 100644 --- a/app/assets/javascripts/admin/controllers/admin_email_index_controller.js +++ b/app/assets/javascripts/admin/controllers/admin_email_index_controller.js @@ -6,7 +6,7 @@ @namespace Discourse @module Discourse **/ -Discourse.AdminEmailIndexController = Discourse.Controller.extend(Discourse.Presence, { +Discourse.AdminEmailIndexController = Discourse.Controller.extend({ /** Is the "send test email" button disabled? diff --git a/app/assets/javascripts/admin/controllers/admin_email_preview_digest_controller.js b/app/assets/javascripts/admin/controllers/admin_email_preview_digest_controller.js index 39de14ae996..eb54d21c6fb 100644 --- a/app/assets/javascripts/admin/controllers/admin_email_preview_digest_controller.js +++ b/app/assets/javascripts/admin/controllers/admin_email_preview_digest_controller.js @@ -6,7 +6,7 @@ @namespace Discourse @module Discourse **/ -Discourse.AdminEmailPreviewDigestController = Discourse.ObjectController.extend(Discourse.Presence, { +Discourse.AdminEmailPreviewDigestController = Discourse.ObjectController.extend({ refresh: function() { var model = this.get('model'); diff --git a/test/javascripts/controllers/admin_email_index_controller_test.js b/test/javascripts/controllers/admin_email_index_controller_test.js new file mode 100644 index 00000000000..a5330b3186c --- /dev/null +++ b/test/javascripts/controllers/admin_email_index_controller_test.js @@ -0,0 +1,5 @@ +module("Discourse.AdminEmailIndexController"); + +test("mixes in Discourse.Presence", function() { + ok(Discourse.Presence.detect(Discourse.AdminEmailIndexController.create())); +}); diff --git a/test/javascripts/controllers/admin_email_preview_digest_controller_test.js b/test/javascripts/controllers/admin_email_preview_digest_controller_test.js new file mode 100644 index 00000000000..606caba5ad9 --- /dev/null +++ b/test/javascripts/controllers/admin_email_preview_digest_controller_test.js @@ -0,0 +1,5 @@ +module("Discourse.AdminEmailPreviewDigestController"); + +test("mixes in Discourse.Presence", function() { + ok(Discourse.Presence.detect(Discourse.AdminEmailPreviewDigestController.create())); +}); From e5854b8b4c75a7ffd1dce77160b6cb558cfb498e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Lavoie?= Date: Wed, 18 Sep 2013 13:58:13 -0400 Subject: [PATCH 02/12] Added screencast.com to whitelist.rb Adding onebox support to screencast.com could be useful. --- lib/oneboxer/whitelist.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/oneboxer/whitelist.rb b/lib/oneboxer/whitelist.rb index 1eb56c41e0d..392c788dfb5 100644 --- a/lib/oneboxer/whitelist.rb +++ b/lib/oneboxer/whitelist.rb @@ -87,6 +87,7 @@ module Oneboxer Entry.new(/^https?:\/\/(?:www\.)?screenr\.com\/.+/), Entry.new(/^https?:\/\/(?:www\.)?tumblr\.com\/.+/, false), Entry.new(/^https?:\/\/(?:www\.)?howtogeek\.com\/.+/, false), + Entry.new(/^https?:\/\/(?:www\.)?screencast\.com\/.+/), Entry.new(/\/\d{4}\/\d{2}\/\d{2}\//, false), # wordpress Entry.new(/^https?:\/\/[^\/]+\/t\/[^\/]+\/\d+(\/\d+)?(\?.*)?$/), From e3a56864dd7ac7d3cc3d6c19739f58e8c1e647ff Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Thu, 19 Sep 2013 17:59:17 -0700 Subject: [PATCH 03/12] Changes to support Spoiler Alert plugin --- app/assets/javascripts/discourse.js | 17 +++++++++++++ .../discourse/views/composer/composer_view.js | 25 ++++++++++--------- .../javascripts/discourse/views/post_view.js | 9 ++++--- lib/plugin/instance.rb | 12 ++++++--- 4 files changed, 44 insertions(+), 19 deletions(-) diff --git a/app/assets/javascripts/discourse.js b/app/assets/javascripts/discourse.js index f71d9d104f6..558a06710c7 100644 --- a/app/assets/javascripts/discourse.js +++ b/app/assets/javascripts/discourse.js @@ -208,6 +208,17 @@ Discourse = Ember.Application.createWithMixins(Discourse.Ajax, { } }, + /** + Add an initializer hook for after the Discourse Application starts up. + + @method addInitializer + @param {Function} init the initializer to add. + **/ + addInitializer: function(init) { + Discourse.initializers = Discourse.initializers || []; + Discourse.initializers.push(init); + }, + /** Start up the Discourse application. @@ -223,6 +234,12 @@ Discourse = Ember.Application.createWithMixins(Discourse.Ajax, { // Developer specific functions Discourse.Development.observeLiveChanges(); Discourse.subscribeUserToNotifications(); + + if (Discourse.initializers) { + Discourse.initializers.forEach(function (init) { + init.call(this); + }); + } } }); diff --git a/app/assets/javascripts/discourse/views/composer/composer_view.js b/app/assets/javascripts/discourse/views/composer/composer_view.js index 49bc80801e4..19d05537461 100644 --- a/app/assets/javascripts/discourse/views/composer/composer_view.js +++ b/app/assets/javascripts/discourse/views/composer/composer_view.js @@ -8,7 +8,7 @@ @namespace Discourse @module Discourse **/ -Discourse.ComposerView = Discourse.View.extend({ +Discourse.ComposerView = Discourse.View.extend(Ember.Evented, { templateName: 'composer', elementId: 'reply-control', classNameBindings: ['model.creatingPrivateMessage:private-message', @@ -49,18 +49,17 @@ Discourse.ComposerView = Discourse.View.extend({ }.property('model.createdPost'), observeReplyChanges: function() { - var composerView = this; + var self = this; if (this.get('model.hidePreview')) return; - Ember.run.next(null, function() { - var $wmdPreview, caretPosition; - if (composerView.editor) { - composerView.editor.refreshPreview(); + Ember.run.next(function() { + if (self.editor) { + self.editor.refreshPreview(); // if the caret is on the last line ensure preview scrolled to bottom - caretPosition = Discourse.Utilities.caretPosition(composerView.wmdInput[0]); - if (!composerView.wmdInput.val().substring(caretPosition).match(/\n/)) { - $wmdPreview = $('#wmd-preview'); + var caretPosition = Discourse.Utilities.caretPosition(self.wmdInput[0]); + if (!self.wmdInput.val().substring(caretPosition).match(/\n/)) { + var $wmdPreview = $('#wmd-preview'); if ($wmdPreview.is(':visible')) { - return $wmdPreview.scrollTop($wmdPreview[0].scrollHeight); + $wmdPreview.scrollTop($wmdPreview[0].scrollHeight); } } } @@ -129,8 +128,8 @@ Discourse.ComposerView = Discourse.View.extend({ Discourse.SyntaxHighlighting.apply($wmdPreview); - var post = this.get('model.post'); - var refresh = false; + var post = this.get('model.post'), + refresh = false; // If we are editing a post, we'll refresh its contents once. This is a feature that // allows a user to refresh its contents once. @@ -146,6 +145,8 @@ Discourse.ComposerView = Discourse.View.extend({ $('span.mention', $wmdPreview).each(function(i, e) { Discourse.Mention.load(e, refresh); }); + + this.trigger('previewRefreshed', $wmdPreview); }, 100), initEditor: function() { diff --git a/app/assets/javascripts/discourse/views/post_view.js b/app/assets/javascripts/discourse/views/post_view.js index db155843ef9..57c3f5e548e 100644 --- a/app/assets/javascripts/discourse/views/post_view.js +++ b/app/assets/javascripts/discourse/views/post_view.js @@ -6,7 +6,7 @@ @namespace Discourse @module Discourse **/ -Discourse.PostView = Discourse.GroupedView.extend({ +Discourse.PostView = Discourse.GroupedView.extend(Ember.Evented, { classNames: ['topic-post', 'clearfix'], templateName: 'post', classNameBindings: ['postTypeClass', @@ -193,8 +193,9 @@ Discourse.PostView = Discourse.GroupedView.extend({ }, didInsertElement: function() { - var $post = this.$(); - var post = this.get('post'); + var $post = this.$(), + post = this.get('post'); + this.showLinkCounts(); // Track this post @@ -204,6 +205,8 @@ Discourse.PostView = Discourse.GroupedView.extend({ Discourse.SyntaxHighlighting.apply($post); Discourse.Lightbox.apply($post); + this.trigger('postViewInserted', $post); + // Find all the quotes this.insertQuoteControls(); diff --git a/lib/plugin/instance.rb b/lib/plugin/instance.rb index ca74b9c658c..b73716e22f2 100644 --- a/lib/plugin/instance.rb +++ b/lib/plugin/instance.rb @@ -102,7 +102,7 @@ class Plugin::Instance def automatic_assets css = "" - js = "(function(){" + js = "" css = @styles.join("\n") if @styles js = @javascripts.join("\n") if @javascripts @@ -127,10 +127,14 @@ class Plugin::Instance end end - js << "})();" + # Generate an IIFE for the JS + js = "(function(){#{js}})();" if js.present? - # TODO don't serve blank assets - [[css,"css"],[js,"js"]].map do |asset, extension| + result = [] + result << [css, 'css'] if css.present? + result << [js, 'js'] if js.present? + + result.map do |asset, extension| hash = Digest::SHA1.hexdigest asset ["#{auto_generated_path}/plugin_#{hash}.#{extension}", asset] end From 60abde2253d4a6bb4ccd2f215736ddace7f336c5 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Thu, 19 Sep 2013 18:40:46 -0700 Subject: [PATCH 04/12] FIX: Broken spec --- spec/components/plugin/instance_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/components/plugin/instance_spec.rb b/spec/components/plugin/instance_spec.rb index 6ad7c81f2ca..7f543b99086 100644 --- a/spec/components/plugin/instance_spec.rb +++ b/spec/components/plugin/instance_spec.rb @@ -34,7 +34,7 @@ describe Plugin::Instance do auth_provider.authenticator.name.should == 'ubuntu' # calls ensure_assets! make sure they are there - plugin.assets.count.should == 2 + plugin.assets.count.should == 1 plugin.assets.each do |a| File.exists?(a).should be_true end From 1815a5a30627a1ad79b7667dbad022a6bac9cc9f Mon Sep 17 00:00:00 2001 From: Sam Saffron Date: Thu, 19 Sep 2013 18:33:28 -0700 Subject: [PATCH 05/12] update mini profiler on rails 4 --- Gemfile_rails4.lock | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Gemfile_rails4.lock b/Gemfile_rails4.lock index 1f85f118fdb..2a459f1a0d2 100644 --- a/Gemfile_rails4.lock +++ b/Gemfile_rails4.lock @@ -89,6 +89,13 @@ GIT rake rake-compiler +GIT + remote: https://github.com/MiniProfiler/rack-mini-profiler.git + revision: e08b751091a41f0066a1b28bd4e2b9b3480a1c1b + specs: + rack-mini-profiler (0.1.31) + rack (>= 1.1.3) + GIT remote: https://github.com/SamSaffron/annotate_models.git revision: ebe4ba7e3f6ceeb43e4e40078da2b261a1bb71b2 @@ -146,12 +153,6 @@ GIT activerecord (>= 3.0.0) activesupport (>= 3.0.0) -PATH - remote: /Users/sam/Source/rack-mini-profiler - specs: - rack-mini-profiler (0.1.31) - rack (>= 1.1.3) - PATH remote: vendor/gems/discourse_emoji specs: From 085493e35d41a2c2c846f6d15f8d5339cac7f992 Mon Sep 17 00:00:00 2001 From: Sam Saffron Date: Thu, 19 Sep 2013 18:34:42 -0700 Subject: [PATCH 06/12] optimise regular job to avoid touching posts that have not changed --- app/models/post.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/post.rb b/app/models/post.rb index eca7cee999f..fd892902f98 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -284,7 +284,8 @@ class Post < ActiveRecord::Base AND p2.user_id <> post_timings.user_id GROUP BY post_timings.topic_id, post_timings.post_number) AS x WHERE x.topic_id = posts.topic_id - AND x.post_number = posts.post_number") + AND x.post_number = posts.post_number + AND (posts.avg_time <> (x.gmean / 1000)::int OR posts.avg_time IS NULL)") end end From 58ba8a0e49f0ac875c1eddfff843d3fe1927340f Mon Sep 17 00:00:00 2001 From: Wojciech Zawistowski Date: Fri, 20 Sep 2013 17:52:38 +0200 Subject: [PATCH 07/12] remove unnecessary (empty) view class Discourse.ApplicationView does not provide any functionality above what already automatically happens via Ember's "convention over configuration" behavior and is therefore redundant. --- .../javascripts/discourse/views/application_view.js | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 app/assets/javascripts/discourse/views/application_view.js diff --git a/app/assets/javascripts/discourse/views/application_view.js b/app/assets/javascripts/discourse/views/application_view.js deleted file mode 100644 index 6b18deb0eab..00000000000 --- a/app/assets/javascripts/discourse/views/application_view.js +++ /dev/null @@ -1,13 +0,0 @@ -/** - This view handles rendering of the core application template - - @class ApplicationView - @extends Discourse.View - @namespace Discourse - @module Discourse -**/ -Discourse.ApplicationView = Discourse.View.extend({ - templateName: 'application' -}); - - From 67c2560f8c9818bb2599c21a1c26af5cfa4cf6fa Mon Sep 17 00:00:00 2001 From: Kris Aubuchon Date: Fri, 20 Sep 2013 17:28:00 -0400 Subject: [PATCH 08/12] mobile: fixed quote control jump --- app/assets/stylesheets/mobile/topic-post.css.scss | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/assets/stylesheets/mobile/topic-post.css.scss b/app/assets/stylesheets/mobile/topic-post.css.scss index 6bf5c81f862..6e4cceaa732 100644 --- a/app/assets/stylesheets/mobile/topic-post.css.scss +++ b/app/assets/stylesheets/mobile/topic-post.css.scss @@ -31,6 +31,8 @@ span.badge-posts { } } + + button.create { float: right !important; border: 1px solid #888; @@ -449,6 +451,8 @@ blockquote { margin-left: 8px; color: #323232; font-family: "FontAwesome"; + position: relative; + z-index: 20; } .back:before { content: "\f062"; From e7b5774bc6a748508dda63ef21094c9fa0e1d86c Mon Sep 17 00:00:00 2001 From: Alexander Date: Fri, 20 Sep 2013 14:36:19 -0700 Subject: [PATCH 09/12] make category's RSS feed actually order by topic.created_at --- lib/topic_query.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/topic_query.rb b/lib/topic_query.rb index 43c60315407..26b5a14ba94 100644 --- a/lib/topic_query.rb +++ b/lib/topic_query.rb @@ -176,7 +176,7 @@ class TopicQuery end def list_new_in_category(category) - create_list(:new_in_category) {|l| l.where(category_id: category.id).by_newest.first(25)} + create_list(:new_in_category, unordered: true) {|l| l.where(category_id: category.id).by_newest.first(25)} end def self.new_filter(list, treat_as_new_topic_start_date) From 964809f73be42d049347aca352760a6f018bbaf9 Mon Sep 17 00:00:00 2001 From: Sam Saffron Date: Fri, 20 Sep 2013 14:39:14 -0700 Subject: [PATCH 10/12] if we have not automatic assets, don't try deleting them --- lib/plugin/instance.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/plugin/instance.rb b/lib/plugin/instance.rb index b73716e22f2..60b2f1fef78 100644 --- a/lib/plugin/instance.rb +++ b/lib/plugin/instance.rb @@ -47,6 +47,8 @@ class Plugin::Instance end def delete_extra_automatic_assets(good_paths) + return unless Dir.exists? auto_generated_path + filenames = good_paths.map{|f| File.basename(f)} # nuke old files Dir.foreach(auto_generated_path) do |p| From d8027d119650c58dd2d25e09403dfbba8785a106 Mon Sep 17 00:00:00 2001 From: Aleksandr Kruglov Date: Sat, 21 Sep 2013 10:43:57 +0400 Subject: [PATCH 11/12] Fixed russsian localization --- config/locales/server.ru.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/locales/server.ru.yml b/config/locales/server.ru.yml index 27588458619..82c81477d81 100644 --- a/config/locales/server.ru.yml +++ b/config/locales/server.ru.yml @@ -778,7 +778,7 @@ ru: Если вам интересно, пройдите по ссылке ниже, чтобы попасть в обсуждение: - [Visit %{site_name}[1] + [Visit %{site_name}][1] Вы приглашены доверенным пользователем, поэтому сразу сможете разместить свой ответ без входа на сайт. From 175e48b06161308090755b9e1718a15f23dd3b46 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Sun, 22 Sep 2013 10:38:41 -0700 Subject: [PATCH 12/12] Revert "remove unnecessary (empty) view class" This reverts commit 58ba8a0e49f0ac875c1eddfff843d3fe1927340f. --- .../javascripts/discourse/views/application_view.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 app/assets/javascripts/discourse/views/application_view.js diff --git a/app/assets/javascripts/discourse/views/application_view.js b/app/assets/javascripts/discourse/views/application_view.js new file mode 100644 index 00000000000..6b18deb0eab --- /dev/null +++ b/app/assets/javascripts/discourse/views/application_view.js @@ -0,0 +1,13 @@ +/** + This view handles rendering of the core application template + + @class ApplicationView + @extends Discourse.View + @namespace Discourse + @module Discourse +**/ +Discourse.ApplicationView = Discourse.View.extend({ + templateName: 'application' +}); + +