diff --git a/app/assets/javascripts/admin/models/site_customization.js b/app/assets/javascripts/admin/models/site_customization.js index b9f0042c7f1..0e678185ccf 100644 --- a/app/assets/javascripts/admin/models/site_customization.js +++ b/app/assets/javascripts/admin/models/site_customization.js @@ -7,47 +7,38 @@ @module Discourse **/ Discourse.SiteCustomization = Discourse.Model.extend({ - trackedProperties: ['enabled', 'name', 'stylesheet', 'header', 'mobile_stylesheet', 'mobile_header', 'override_default_style'], + trackedProperties: ['enabled', 'name', 'stylesheet', 'header', 'footer', 'mobile_stylesheet', 'mobile_header', 'mobile_footer', 'override_default_style'], description: function() { return "" + this.name + (this.enabled ? ' (*)' : ''); }.property('selected', 'name'), changed: function() { + var self = this; - var _this = this; - if(!this.originals) return false; + if (!this.originals) { return false; } - var changed = _.some(this.trackedProperties,function(p) { - return _this.originals[p] !== _this.get(p); + var changed = _.some(this.trackedProperties, function (p) { + return self.originals[p] !== self.get(p); }); - if(changed){ - this.set('savingStatus',''); - } + if (changed) { this.set('savingStatus', ''); } return changed; - }.property('override_default_style', 'enabled', 'name', 'stylesheet', 'header', 'mobile_stylesheet', 'mobile_header', 'originals'), + }.property('override_default_style', 'enabled', 'name', 'stylesheet', 'header', 'footer', 'mobile_stylesheet', 'mobile_header', 'mobile_footer', 'originals'), startTrackingChanges: function() { - var _this = this; + var self = this; var originals = {}; - _.each(this.trackedProperties,function(prop) { - originals[prop] = _this.get(prop); - return true; + _.each(this.trackedProperties, function (prop) { + originals[prop] = self.get(prop); }); this.set('originals', originals); }.on('init'), - previewUrl: function() { - return "/?preview-style=" + (this.get('key')); - }.property('key'), - - disableSave: function() { - return !this.get('changed') || this.get('saving'); - }.property('changed'), - + previewUrl: function() { return "/?preview-style=" + this.get('key'); }.property('key'), + disableSave: function() { return !this.get('changed') || this.get('saving'); }.property('changed'), save: function() { this.set('savingStatus', I18n.t('saving')); @@ -57,8 +48,10 @@ Discourse.SiteCustomization = Discourse.Model.extend({ enabled: this.enabled, stylesheet: this.stylesheet, header: this.header, + footer: this.footer, mobile_stylesheet: this.mobile_stylesheet, mobile_header: this.mobile_header, + mobile_footer: this.mobile_footer, override_default_style: this.override_default_style }; @@ -75,23 +68,19 @@ Discourse.SiteCustomization = Discourse.Model.extend({ siteCustomization.set('saving',false); siteCustomization.startTrackingChanges(); }); - }, destroy: function() { - if(!this.id) return; - return Discourse.ajax("/admin/site_customizations/" + this.id, { - type: 'DELETE' - }); + if (!this.id) return; + return Discourse.ajax("/admin/site_customizations/" + this.id, { type: 'DELETE' }); } - }); var SiteCustomizations = Ember.ArrayProxy.extend({ selectedItemChanged: function() { var selected = this.get('selectedItem'); - _.each(this.get('content'),function(i) { - return i.set('selected', selected === i); + _.each(this.get('content'), function (i) { + i.set('selected', selected === i); }); }.observes('selectedItem') }); diff --git a/app/assets/javascripts/admin/templates/customize_css_html.hbs b/app/assets/javascripts/admin/templates/customize_css_html.hbs index c9c6e36d179..57bccda4992 100644 --- a/app/assets/javascripts/admin/templates/customize_css_html.hbs +++ b/app/assets/javascripts/admin/templates/customize_css_html.hbs @@ -2,71 +2,58 @@

{{i18n admin.customize.css_html.long_title}}

- + - {{#if selectedItem}} -
- {{#with selectedItem}} - {{text-field class="style-name" value=name}} +
+ {{#with selectedItem}} + {{text-field class="style-name" value=name}} -
- + + +
+ {{#if view.stylesheetActive}}{{aceEditor content=stylesheet mode="scss"}}{{/if}} + {{#if view.headerActive}}{{aceEditor content=header mode="html"}}{{/if}} + {{#if view.footerActive}}{{aceEditor content=footer mode="html"}}{{/if}} + {{#if view.mobileStylesheetActive}}{{aceEditor content=mobile_stylesheet mode="scss"}}{{/if}} + {{#if view.mobileHeaderActive}}{{aceEditor content=mobile_header mode="html"}}{{/if}} + {{#if view.mobileFooterActive}}{{aceEditor content=mobile_footer mode="html"}}{{/if}} +
+ {{/with}} +
+
+ {{i18n admin.customize.override_default}} {{view Ember.Checkbox checkedBinding="selectedItem.override_default_style"}} + {{i18n admin.customize.enabled}} {{view Ember.Checkbox checkedBinding="selectedItem.enabled"}} + {{#unless selectedItem.changed}} + {{i18n admin.customize.preview}} + | + {{i18n admin.customize.undo_preview}} + | + {{i18n admin.customize.rescue_preview}}
+ {{/unless}}
-
- {{#if view.headerActive}} - {{aceEditor content=header mode="html"}} - {{/if}} - {{#if view.stylesheetActive}} - {{aceEditor content=stylesheet mode="scss"}} - {{/if}} - {{#if view.mobileHeaderActive}} - {{aceEditor content=mobile_header mode="html"}} - {{/if}} - {{#if view.mobileStylesheetActive}} - {{aceEditor content=mobile_stylesheet mode="scss"}} - {{/if}} +
+ + {{selectedItem.savingStatus}} + {{i18n admin.customize.delete}}
- {{/with}} -
-
- {{i18n admin.customize.override_default}} {{view Ember.Checkbox checkedBinding="selectedItem.override_default_style"}} - {{i18n admin.customize.enabled}} {{view Ember.Checkbox checkedBinding="selectedItem.enabled"}} - {{#unless selectedItem.changed}} - {{i18n admin.customize.preview}} - | - {{i18n admin.customize.undo_preview}} - | - {{i18n admin.customize.rescue_preview}}
- {{/unless}}
- -
- - {{selectedItem.savingStatus}} - {{i18n admin.customize.delete}} -
- -
{{else}}

{{i18n admin.customize.about}}

{{/if}} -
diff --git a/app/assets/javascripts/admin/views/admin_customize_view.js b/app/assets/javascripts/admin/views/admin_customize_view.js index de6b7eab949..ac1b0603c01 100644 --- a/app/assets/javascripts/admin/views/admin_customize_view.js +++ b/app/assets/javascripts/admin/views/admin_customize_view.js @@ -12,15 +12,20 @@ Discourse.AdminCustomizeView = Discourse.View.extend({ templateName: 'admin/templates/customize', classNames: ['customize'], selected: 'stylesheet', + headerActive: Em.computed.equal('selected', 'header'), + footerActive: Em.computed.equal('selected', 'footer'), stylesheetActive: Em.computed.equal('selected', 'stylesheet'), mobileHeaderActive: Em.computed.equal('selected', 'mobileHeader'), + mobileFooterActive: Em.computed.equal('selected', 'mobileFooter'), mobileStylesheetActive: Em.computed.equal('selected', 'mobileStylesheet'), actions: { selectHeader: function() { this.set('selected', 'header'); }, + selectFooter: function() { this.set('selected', 'footer'); }, selectStylesheet: function() { this.set('selected', 'stylesheet'); }, selectMobileHeader: function() { this.set('selected', 'mobileHeader'); }, + selectMobileFooter: function() { this.set('selected', 'mobileFooter'); }, selectMobileStylesheet: function() { this.set('selected', 'mobileStylesheet'); } }, diff --git a/app/assets/javascripts/discourse/controllers/discovery.js.es6 b/app/assets/javascripts/discourse/controllers/discovery.js.es6 index 5d4c0f7a858..8f012b42fac 100644 --- a/app/assets/javascripts/discourse/controllers/discovery.js.es6 +++ b/app/assets/javascripts/discourse/controllers/discovery.js.es6 @@ -2,7 +2,7 @@ import ObjectController from 'discourse/controllers/object'; import TopPeriod from 'discourse/models/top-period'; export default ObjectController.extend({ - needs: ['navigation/category'], + needs: ['navigation/category', 'discovery/topics'], loading: false, loadingSpinner: false, scheduledSpinner: null, @@ -10,6 +10,8 @@ export default ObjectController.extend({ category: Em.computed.alias('controllers.navigation/category.category'), noSubcategories: Em.computed.alias('controllers.navigation/category.noSubcategories'), + loadedAllItems: Em.computed.not("controllers.discovery/topics.canLoadMore"), + showMoreUrl: function(period) { var url = '', category = this.get('category'); if (category) { diff --git a/app/assets/javascripts/discourse/controllers/user-notifications.js.es6 b/app/assets/javascripts/discourse/controllers/user-notifications.js.es6 index fc511df4363..e2519e2e5c5 100644 --- a/app/assets/javascripts/discourse/controllers/user-notifications.js.es6 +++ b/app/assets/javascripts/discourse/controllers/user-notifications.js.es6 @@ -3,6 +3,7 @@ export default Ember.ArrayController.extend({ needs: ['user-notifications'], canLoadMore: true, loading: false, + showDismissButton: function() { return this.get('user').total_unread_notifications > 0; }.property('user'), @@ -26,7 +27,7 @@ export default Ember.ArrayController.extend({ var notifications = result.get('content'); self.pushObjects(notifications); // Stop trying if it's the end - if (notifications && notifications.length === 0) { + if (notifications && (notifications.length === 0 || notifications.length < 60)) { self.set('canLoadMore', false); } }).catch(function(error) { diff --git a/app/assets/javascripts/discourse/controllers/user.js.es6 b/app/assets/javascripts/discourse/controllers/user.js.es6 index 39b00bc03c7..c69d1669869 100644 --- a/app/assets/javascripts/discourse/controllers/user.js.es6 +++ b/app/assets/javascripts/discourse/controllers/user.js.es6 @@ -2,6 +2,7 @@ import ObjectController from 'discourse/controllers/object'; import CanCheckEmails from 'discourse/mixins/can-check-emails'; export default ObjectController.extend(CanCheckEmails, { + needs: ['user-notifications', 'user_topics_list'], viewingSelf: function() { return this.get('content.username') === Discourse.User.currentProp('username'); @@ -32,15 +33,31 @@ export default ObjectController.extend(CanCheckEmails, { (this.get('userActionType') === Discourse.UserAction.TYPES.messages_received); }.property('userActionType'), - /** - Can the currently logged in user invite users to the site - - @property canInviteToForum - **/ canInviteToForum: function() { return Discourse.User.currentProp('can_invite_to_forum'); }.property(), + loadedAllItems: function() { + switch (this.get("datasource")) { + case "badges": { return true; } + case "notifications": { return !this.get("controllers.user-notifications.canLoadMore"); } + case "topic_list": { return !this.get("controllers.user_topics_list.canLoadMore"); } + case "stream": { + if (this.get("userActionType")) { + var stat = _.find(this.get("stats"), { action_type: this.get("userActionType") }); + return stat && stat.count <= this.get("stream.itemsLoaded"); + } else { + return this.get("statsCountNonPM") <= this.get("stream.itemsLoaded"); + } + } + } + + return false; + }.property("datasource", + "userActionType", "stats", "stream.itemsLoaded", + "controllers.user_topics_list.canLoadMore", + "controllers.user-notifications.canLoadMore"), + privateMessagesActive: Em.computed.equal('pmView', 'index'), privateMessagesMineActive: Em.computed.equal('pmView', 'mine'), privateMessagesUnreadActive: Em.computed.equal('pmView', 'unread') diff --git a/app/assets/javascripts/discourse/models/topic_list.js b/app/assets/javascripts/discourse/models/topic_list.js index e2e2cb8aa29..d3758dca3e3 100644 --- a/app/assets/javascripts/discourse/models/topic_list.js +++ b/app/assets/javascripts/discourse/models/topic_list.js @@ -31,6 +31,8 @@ function finderFor(filter, params) { } Discourse.TopicList = Discourse.Model.extend({ + canLoadMore: Em.computed.notEmpty("more_topics_url"), + forEachNew: function(topics, callback) { var topicIds = []; _.each(this.get('topics'),function(topic) { @@ -68,7 +70,6 @@ Discourse.TopicList = Discourse.Model.extend({ var moreUrl = this.get('more_topics_url'); if (moreUrl) { - var self = this; this.set('loadingMore', true); @@ -84,7 +85,11 @@ Discourse.TopicList = Discourse.Model.extend({ topics.pushObject(t); }); - self.setProperties({ loadingMore: false, more_topics_url: result.topic_list.more_topics_url }); + self.setProperties({ + loadingMore: false, + more_topics_url: result.topic_list.more_topics_url + }); + Discourse.Session.currentProp('topicList', self); return self.get('more_topics_url'); } diff --git a/app/assets/javascripts/discourse/routes/build-topic-route.js.es6 b/app/assets/javascripts/discourse/routes/build-topic-route.js.es6 index c0eacd91604..f00bd5d1777 100644 --- a/app/assets/javascripts/discourse/routes/build-topic-route.js.es6 +++ b/app/assets/javascripts/discourse/routes/build-topic-route.js.es6 @@ -40,14 +40,12 @@ export default function(filter, extras) { }, setupController: function(controller, model, trans) { - if (trans) { controller.setProperties(Em.getProperties(trans, _.keys(queryParams).map(function(v){ return 'queryParams.' + v; }))); } - var periods = this.controllerFor('discovery').get('periods'), periodId = model.get('for_period') || (filter.indexOf('/') > 0 ? filter.split('/')[1] : ''); diff --git a/app/assets/javascripts/discourse/routes/user-badges.js.es6 b/app/assets/javascripts/discourse/routes/user-badges.js.es6 index 8d68ae0263b..2ec062e5809 100644 --- a/app/assets/javascripts/discourse/routes/user-badges.js.es6 +++ b/app/assets/javascripts/discourse/routes/user-badges.js.es6 @@ -4,7 +4,11 @@ export default Discourse.Route.extend({ }, setupController: function(controller, model) { - this.controllerFor('user').set('indexStream', false); + this.controllerFor('user').setProperties({ + indexStream: false, + datasource: "badges", + }); + if (this.controllerFor('user_activity').get('content')) { this.controllerFor('user_activity').set('userActionType', -1); } diff --git a/app/assets/javascripts/discourse/routes/user-notifications.js.es6 b/app/assets/javascripts/discourse/routes/user-notifications.js.es6 index 91d273a04da..2c40fd8ea88 100644 --- a/app/assets/javascripts/discourse/routes/user-notifications.js.es6 +++ b/app/assets/javascripts/discourse/routes/user-notifications.js.es6 @@ -5,10 +5,15 @@ export default Discourse.Route.extend({ }, setupController: function(controller, model) { - this.controllerFor('user').set('indexStream', false); + this.controllerFor('user').setProperties({ + indexStream: false, + datasource: "notifications" + }); + if (this.controllerFor('user_activity').get('content')) { this.controllerFor('user_activity').set('userActionType', -1); } + controller.set('model', model); controller.set('user', this.modelFor('user')); }, diff --git a/app/assets/javascripts/discourse/routes/user_activity_stream_route.js b/app/assets/javascripts/discourse/routes/user_activity_stream_route.js index 069d465e797..cadcdc7359f 100644 --- a/app/assets/javascripts/discourse/routes/user_activity_stream_route.js +++ b/app/assets/javascripts/discourse/routes/user_activity_stream_route.js @@ -23,7 +23,10 @@ Discourse.UserActivityStreamRoute = Discourse.Route.extend({ controller.set('model', model); this.controllerFor('user_activity').set('userActionType', this.get('userActionType')); - this.controllerFor('user').set('indexStream', !this.get('userActionType')); + this.controllerFor('user').setProperties({ + indexStream: !this.get('userActionType'), + datasource: "stream" + }); }, actions: { diff --git a/app/assets/javascripts/discourse/routes/user_topic_list_routes.js b/app/assets/javascripts/discourse/routes/user_topic_list_routes.js index 12bb0acdb59..2f9df6fe681 100644 --- a/app/assets/javascripts/discourse/routes/user_topic_list_routes.js +++ b/app/assets/javascripts/discourse/routes/user_topic_list_routes.js @@ -4,7 +4,10 @@ Discourse.UserTopicListRoute = Discourse.Route.extend({ }, setupController: function(controller, model) { - this.controllerFor('user').set('indexStream', false); + this.controllerFor('user').setProperties({ + indexStream: false, + datasource: "topic_list" + }); this.controllerFor('user-activity').set('userActionType', this.get('userActionType')); this.controllerFor('user_topics_list').setProperties({ model: model, @@ -30,7 +33,8 @@ function createPMRoute(viewName, path) { }); this.controllerFor('user').setProperties({ pmView: viewName, - indexStream: false + indexStream: false, + datasource: "topic_list" }); } }); diff --git a/app/assets/javascripts/discourse/templates/about.hbs b/app/assets/javascripts/discourse/templates/about.hbs index 09b02a525c3..68efdd25baf 100644 --- a/app/assets/javascripts/discourse/templates/about.hbs +++ b/app/assets/javascripts/discourse/templates/about.hbs @@ -62,3 +62,7 @@
+ +
+ {{custom-html "footer"}} +
diff --git a/app/assets/javascripts/discourse/templates/badges/index.hbs b/app/assets/javascripts/discourse/templates/badges/index.hbs index 35b52a7fe6e..a58d9c4a948 100644 --- a/app/assets/javascripts/discourse/templates/badges/index.hbs +++ b/app/assets/javascripts/discourse/templates/badges/index.hbs @@ -19,3 +19,7 @@
+ +
+ {{custom-html "footer"}} +
diff --git a/app/assets/javascripts/discourse/templates/badges/show.hbs b/app/assets/javascripts/discourse/templates/badges/show.hbs index 9c585d855e0..58b3ebe0040 100644 --- a/app/assets/javascripts/discourse/templates/badges/show.hbs +++ b/app/assets/javascripts/discourse/templates/badges/show.hbs @@ -37,6 +37,10 @@
{{#if canLoadMore}} {{loading-spinner}} + {{else}} +
+ {{custom-html "footer"}} +
{{/if}} {{else}} {{#unless userBadgesLoaded}} diff --git a/app/assets/javascripts/discourse/templates/discovery.hbs b/app/assets/javascripts/discourse/templates/discovery.hbs index eb3a50edb5c..fd43b5395d0 100644 --- a/app/assets/javascripts/discourse/templates/discovery.hbs +++ b/app/assets/javascripts/discourse/templates/discovery.hbs @@ -10,25 +10,28 @@ -
+{{#if loadingSpinner}} {{loading-spinner}} -
- - -
-
-
-
- {{outlet header-list-container}} +{{else}} +
+
+
+
+ {{outlet header-list-container}} +
+
+
+
+
+
+ {{outlet list-container}} +
- -
-
-
- {{outlet list-container}} -
+ {{#if loadedAllItems}} +
+ {{custom-html "footer"}}
-
-
+ {{/if}} +{{/if}} diff --git a/app/assets/javascripts/discourse/templates/static.hbs b/app/assets/javascripts/discourse/templates/static.hbs index e6aa2f99a71..d9795ebc419 100644 --- a/app/assets/javascripts/discourse/templates/static.hbs +++ b/app/assets/javascripts/discourse/templates/static.hbs @@ -7,3 +7,7 @@ {{/if}}
+ +
+ {{custom-html "footer"}} +
diff --git a/app/assets/javascripts/discourse/templates/topic.hbs b/app/assets/javascripts/discourse/templates/topic.hbs index d64415a92cb..8edf4c60aa7 100644 --- a/app/assets/javascripts/discourse/templates/topic.hbs +++ b/app/assets/javascripts/discourse/templates/topic.hbs @@ -43,7 +43,6 @@ {{/if}} - {{#if details.can_edit}} {{fa-icon pencil}} {{/if}} @@ -112,6 +111,9 @@

{{{view.browseMoreMessage}}}

{{/if}} +
+ {{custom-html "footer"}} +
{{/if}} {{/if}} @@ -119,7 +121,6 @@
- {{else}} {{#if hasError}}
@@ -133,11 +134,11 @@ {{/unless}} {{else}} - + {{/if}}
{{#if retrying}} - {{loading-spinner}} + {{loading-spinner}} {{/if}} {{/if}} diff --git a/app/assets/javascripts/discourse/templates/user/notifications.hbs b/app/assets/javascripts/discourse/templates/user/notifications.hbs index 52427b1a34f..9865e88eb7c 100644 --- a/app/assets/javascripts/discourse/templates/user/notifications.hbs +++ b/app/assets/javascripts/discourse/templates/user/notifications.hbs @@ -7,6 +7,7 @@ {{/if}} {{/if}} + {{#if showDismissButton}}
@@ -24,12 +25,12 @@ {{#if loading}} {{loading-spinner}} +{{else}} + {{#unless canLoadMore}} + {{#if showDismissButton}} +
+ +
+ {{/if}} + {{/unless}} {{/if}} -{{#unless canLoadMore}} -
- {{#if showDismissButton}} -
- -
- {{/if}} -{{/unless}} diff --git a/app/assets/javascripts/discourse/templates/user/stream.hbs b/app/assets/javascripts/discourse/templates/user/stream.hbs index 34b46773514..3d9ce13b0bd 100644 --- a/app/assets/javascripts/discourse/templates/user/stream.hbs +++ b/app/assets/javascripts/discourse/templates/user/stream.hbs @@ -25,6 +25,7 @@ {{/grouped-each}}
{{/grouped-each}} + {{#if loading}} {{loading-spinner}} {{/if}} diff --git a/app/assets/javascripts/discourse/templates/user/user.hbs b/app/assets/javascripts/discourse/templates/user/user.hbs index b9174f93b47..edbf1a9944e 100644 --- a/app/assets/javascripts/discourse/templates/user/user.hbs +++ b/app/assets/javascripts/discourse/templates/user/user.hbs @@ -5,7 +5,6 @@ {{#unless loading}}
-
@@ -33,80 +32,54 @@
{{number_of_warnings}} {{i18n user.staff_counters.warnings_received}}
{{/if}}
-
- -
+
- {{bound-avatar model "huge"}} -
- -
    - - {{#if can_send_private_message_to_user}} -
  • - - - {{i18n user.private_message}} - -
  • - {{/if}} - - {{#if viewingSelf}} -
  • - {{i18n user.log_out}} -
  • - {{/if}} - - {{#if currentUser.staff}} -
  • - {{i18n admin.user.show_admin_profile}} -
  • - {{/if}} - - {{#if can_edit}} -
  • - {{#link-to 'preferences' class="btn right"}}{{i18n user.preferences}}{{/link-to}} -
  • - {{/if}} - - {{#if canInviteToForum}} -
  • - {{#link-to 'user.invited' class="btn right"}}{{i18n user.invited.title}}{{/link-to}} -
  • - {{/if}} - -
- +

{{username}} {{{statusIcon}}}

{{name}}

- - {{#if location}} - - {{location}} - {{/if}} - + {{#if location}}{{fa-icon "map-maker"}}{{location}}{{/if}} {{#if websiteName}} - + {{fa-icon "globe"}} {{#if linkWebsite}} {{websiteName}} {{else}} {{websiteName}} {{/if}} {{/if}} -

{{#if isSuspended}}
- + {{fa-icon "ban"}} {{i18n user.suspended_notice date="suspendedTillDate"}}
{{i18n user.suspended_reason}} {{suspend_reason}}
@@ -116,17 +89,13 @@ {{plugin-outlet "user-profile-primary"}} -
-
- -
+
- {{#if created_at}}
{{i18n user.created}}
{{bound-date created_at}}
{{/if}} @@ -162,67 +131,72 @@ {{plugin-outlet "user-profile-secondary"}}
-
- - - {{#if canSeePrivateMessages}} -

{{i18n user.private_messages}}

+
- {{/if}} + + {{#if canSeePrivateMessages}} +

{{fa-icon "envelope"}} {{i18n user.private_messages}}

+ + {{/if}} +
+ + {{outlet userOutlet}}
- - {{outlet userOutlet}} - -
-
+ + {{#if loadedAllItems}} +
+ {{custom-html "footer"}} +
+ {{/if}} + {{/unless}} diff --git a/app/assets/stylesheets/common/base/user.scss b/app/assets/stylesheets/common/base/user.scss index 7f9ed17e343..8f8d35fded2 100644 --- a/app/assets/stylesheets/common/base/user.scss +++ b/app/assets/stylesheets/common/base/user.scss @@ -24,11 +24,6 @@ } } -.end-of-stream { - border: 3px solid $primary; - width: 100%; -} - .notification-buttons { margin: 10px 0; text-align: right; diff --git a/app/assets/stylesheets/mobile/user.scss b/app/assets/stylesheets/mobile/user.scss index 7acd33b6443..c5520432c67 100644 --- a/app/assets/stylesheets/mobile/user.scss +++ b/app/assets/stylesheets/mobile/user.scss @@ -408,9 +408,6 @@ .user-stream { padding: 0 10px; - .end-of-stream { - width: auto; - } .excerpt { margin: 5px 0; font-size: 13px; diff --git a/app/controllers/admin/site_customizations_controller.rb b/app/controllers/admin/site_customizations_controller.rb index a545a82261a..16540daaf27 100644 --- a/app/controllers/admin/site_customizations_controller.rb +++ b/app/controllers/admin/site_customizations_controller.rb @@ -51,7 +51,11 @@ class Admin::SiteCustomizationsController < Admin::AdminController private def site_customization_params - params.require(:site_customization).permit(:name, :stylesheet, :header, :mobile_stylesheet, :mobile_header, :position, :enabled, :key, :override_default_style, :stylesheet_baked) + params.require(:site_customization) + .permit(:name, :stylesheet, :header, :footer, + :mobile_stylesheet, :mobile_header, :mobile_footer, + :position, :enabled, :key, :override_default_style, + :stylesheet_baked) end def log_site_customization_change(old_record, new_params) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 0c2b5c185f6..73b8e32c999 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -261,7 +261,7 @@ class ApplicationController < ActionController::Base def custom_html_json data = { top: SiteText.text_for(:top), - bottom: SiteText.text_for(:bottom) + footer: SiteCustomization.custom_footer(session[:preview_style]) } if DiscoursePluginRegistry.custom_html diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb index c011b742f26..09a1cc6306b 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -21,9 +21,7 @@ class NotificationsController < ApplicationController params[:before] ||= 1.day.from_now user = current_user - if params[:user] - user = User.find_by_username(params[:user].to_s) - end + user = User.find_by_username(params[:user].to_s) if params[:user] unless guardian.can_see_notifications?(user) return render json: {errors: [I18n.t('js.errors.reasons.forbidden')]}, status: 403 diff --git a/app/models/site_customization.rb b/app/models/site_customization.rb index c6f801865da..6b88d9dfdd1 100644 --- a/app/models/site_customization.rb +++ b/app/models/site_customization.rb @@ -17,7 +17,6 @@ class SiteCustomization < ActiveRecord::Base DiscourseSassCompiler.compile(scss, 'custom') rescue => e puts e.backtrace.join("\n") unless Sass::SyntaxError === e - raise e end @@ -34,29 +33,21 @@ class SiteCustomization < ActiveRecord::Base end after_save do - if stylesheet_changed? - File.delete(stylesheet_fullpath) if File.exists?(stylesheet_fullpath) - end - if mobile_stylesheet_changed? - File.delete(stylesheet_fullpath(:mobile)) if File.exists?(stylesheet_fullpath(:mobile)) - end + File.delete(stylesheet_fullpath) if File.exists?(stylesheet_fullpath) && stylesheet_changed? + File.delete(stylesheet_fullpath(:mobile)) if File.exists?(stylesheet_fullpath(:mobile)) && mobile_stylesheet_changed? remove_from_cache! - if stylesheet_changed? or mobile_stylesheet_changed? + if stylesheet_changed? || mobile_stylesheet_changed? ensure_stylesheets_on_disk! # TODO: this is broken now because there's mobile stuff too MessageBus.publish "/file-change/#{key}", stylesheet_hash end MessageBus.publish "/header-change/#{key}", header if header_changed? - + MessageBus.publish "/footer-change/#{key}", footer if footer_changed? end after_destroy do - if File.exists?(stylesheet_fullpath) - File.delete stylesheet_fullpath - end - if File.exists?(stylesheet_fullpath(:mobile)) - File.delete stylesheet_fullpath(:mobile) - end + File.delete(stylesheet_fullpath) if File.exists?(stylesheet_fullpath) + File.delete(stylesheet_fullpath(:mobile)) if File.exists?(stylesheet_fullpath(:mobile)) self.remove_from_cache! end @@ -97,6 +88,16 @@ class SiteCustomization < ActiveRecord::Base end end + def self.custom_footer(preview_style, target=:dekstop) + preview_style ||= enabled_style_key + style = lookup_style(preview_style) + if style && ((target != :mobile && style.footer) || (target == :mobile && style.mobile_footer)) + target == :mobile ? style.mobile_footer.html_safe : style.footer.html_safe + else + "" + end + end + def self.override_default_style(preview_style) preview_style ||= enabled_style_key style = lookup_style(preview_style) diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index b1d4532e0e3..c10937845d3 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -80,7 +80,9 @@ <%= yield :data %> - + <%= render :partial => "common/discourse_javascript" %> diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 5a7474378a1..adb205230c5 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -1682,10 +1682,9 @@ en: customize: title: "Customize" long_title: "Site Customizations" + css: "CSS" header: "Header" - css: "Stylesheet" - mobile_header: "Mobile Header" - mobile_css: "Mobile Stylesheet" + footer: "Footer" override_default: "Do not include standard style sheet" enabled: "Enabled?" preview: "preview" diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index 178e19d1c6a..1836dba4ba3 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -634,7 +634,7 @@ en: description: "HTML that will be added at the top of every page (after the header, before the navigation or the topic title)." bottom: title: "Bottom of the pages" - description: "HTML that will be added at the bottom of every page." + description: "HTML that will be added before the tag." site_settings: censored_words: "Words that will be automatically replaced with ■■■■" diff --git a/db/migrate/20141110150304_add_footer_to_site_customization.rb b/db/migrate/20141110150304_add_footer_to_site_customization.rb new file mode 100644 index 00000000000..c6819230996 --- /dev/null +++ b/db/migrate/20141110150304_add_footer_to_site_customization.rb @@ -0,0 +1,6 @@ +class AddFooterToSiteCustomization < ActiveRecord::Migration + def change + add_column :site_customizations, :footer, :text + add_column :site_customizations, :mobile_footer, :text + end +end