UX: better footer handling

This commit is contained in:
Régis Hanol 2014-11-10 21:51:55 +01:00
parent c89064f7c0
commit ec76be964e
31 changed files with 293 additions and 275 deletions

View File

@ -7,47 +7,38 @@
@module Discourse @module Discourse
**/ **/
Discourse.SiteCustomization = Discourse.Model.extend({ 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() { description: function() {
return "" + this.name + (this.enabled ? ' (*)' : ''); return "" + this.name + (this.enabled ? ' (*)' : '');
}.property('selected', 'name'), }.property('selected', 'name'),
changed: function() { 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) { var changed = _.some(this.trackedProperties, function (p) {
return _this.originals[p] !== _this.get(p); return self.originals[p] !== self.get(p);
}); });
if(changed){ if (changed) { this.set('savingStatus', ''); }
this.set('savingStatus','');
}
return changed; 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() { startTrackingChanges: function() {
var _this = this; var self = this;
var originals = {}; var originals = {};
_.each(this.trackedProperties,function(prop) { _.each(this.trackedProperties, function (prop) {
originals[prop] = _this.get(prop); originals[prop] = self.get(prop);
return true;
}); });
this.set('originals', originals); this.set('originals', originals);
}.on('init'), }.on('init'),
previewUrl: function() { previewUrl: function() { return "/?preview-style=" + this.get('key'); }.property('key'),
return "/?preview-style=" + (this.get('key')); disableSave: function() { return !this.get('changed') || this.get('saving'); }.property('changed'),
}.property('key'),
disableSave: function() {
return !this.get('changed') || this.get('saving');
}.property('changed'),
save: function() { save: function() {
this.set('savingStatus', I18n.t('saving')); this.set('savingStatus', I18n.t('saving'));
@ -57,8 +48,10 @@ Discourse.SiteCustomization = Discourse.Model.extend({
enabled: this.enabled, enabled: this.enabled,
stylesheet: this.stylesheet, stylesheet: this.stylesheet,
header: this.header, header: this.header,
footer: this.footer,
mobile_stylesheet: this.mobile_stylesheet, mobile_stylesheet: this.mobile_stylesheet,
mobile_header: this.mobile_header, mobile_header: this.mobile_header,
mobile_footer: this.mobile_footer,
override_default_style: this.override_default_style override_default_style: this.override_default_style
}; };
@ -75,23 +68,19 @@ Discourse.SiteCustomization = Discourse.Model.extend({
siteCustomization.set('saving',false); siteCustomization.set('saving',false);
siteCustomization.startTrackingChanges(); siteCustomization.startTrackingChanges();
}); });
}, },
destroy: function() { destroy: function() {
if(!this.id) return; if (!this.id) return;
return Discourse.ajax("/admin/site_customizations/" + this.id, { return Discourse.ajax("/admin/site_customizations/" + this.id, { type: 'DELETE' });
type: 'DELETE'
});
} }
}); });
var SiteCustomizations = Ember.ArrayProxy.extend({ var SiteCustomizations = Ember.ArrayProxy.extend({
selectedItemChanged: function() { selectedItemChanged: function() {
var selected = this.get('selectedItem'); var selected = this.get('selectedItem');
_.each(this.get('content'),function(i) { _.each(this.get('content'), function (i) {
return i.set('selected', selected === i); i.set('selected', selected === i);
}); });
}.observes('selectedItem') }.observes('selectedItem')
}); });

View File

@ -2,71 +2,58 @@
<h3>{{i18n admin.customize.css_html.long_title}}</h3> <h3>{{i18n admin.customize.css_html.long_title}}</h3>
<ul> <ul>
{{#each model}} {{#each model}}
<li><a {{action "selectStyle" this}} {{bind-attr class="this.selected:active"}}>{{this.description}}</a></li> <li><a {{action "selectStyle" this}} {{bind-attr class="this.selected:active"}}>{{this.description}}</a></li>
{{/each}} {{/each}}
</ul> </ul>
<button {{action "newCustomization"}} class='btn'><i class="fa fa-plus"></i>{{i18n admin.customize.new}}</button> <button {{action "newCustomization"}} class='btn'>
{{fa-icon "plus"}}{{i18n admin.customize.new}}
</button>
</div> </div>
{{#if selectedItem}} {{#if selectedItem}}
<div class='current-style'> <div class='current-style'>
{{#with selectedItem}} {{#with selectedItem}}
{{text-field class="style-name" value=name}} {{text-field class="style-name" value=name}}
<div class='admin-controls'> <div class='admin-controls'>
<ul class="nav nav-pills"> <ul class="nav nav-pills">
<li> <li><a {{bind-attr class="view.stylesheetActive:active"}} {{action "selectStylesheet" target="view"}}>{{i18n admin.customize.css}}</a></li>
<a {{bind-attr class="view.stylesheetActive:active"}}{{action "selectStylesheet" href="true" target="view"}}>{{i18n admin.customize.css}}</a> <li><a {{bind-attr class="view.headerActive:active"}} {{action "selectHeader" target="view"}}>{{i18n admin.customize.header}}</a></li>
</li> <li><a {{bind-attr class="view.footerActive:active"}} {{action "selectFooter" target="view"}}>{{i18n admin.customize.footer}}</a></li>
<li> <li><a {{bind-attr class="view.mobileStylesheetActive:active"}} {{action "selectMobileStylesheet" target="view"}}>{{fa-icon "mobile"}}&nbsp;{{i18n admin.customize.css}}</a></li>
<a {{bind-attr class="view.headerActive:active"}}{{action "selectHeader" href="true" target="view"}}>{{i18n admin.customize.header}}</a> <li><a {{bind-attr class="view.mobileHeaderActive:active"}} {{action "selectMobileHeader" target="view"}}>{{fa-icon "mobile"}}&nbsp;{{i18n admin.customize.header}}</a></li>
</li> <li><a {{bind-attr class="view.mobileFooterActive:active"}} {{action "selectMobileFooter" target="view"}}>{{fa-icon "mobile"}}&nbsp;{{i18n admin.customize.footer}}</a></li>
<li> </ul>
<a {{bind-attr class="view.mobileStylesheetActive:active"}}{{action "selectMobileStylesheet" href="true" target="view"}}>{{i18n admin.customize.mobile_css}}</a> </div>
</li>
<li> <div class="admin-container">
<a {{bind-attr class="view.mobileHeaderActive:active"}}{{action "selectMobileHeader" href="true" target="view"}}>{{i18n admin.customize.mobile_header}}</a> {{#if view.stylesheetActive}}{{aceEditor content=stylesheet mode="scss"}}{{/if}}
</li> {{#if view.headerActive}}{{aceEditor content=header mode="html"}}{{/if}}
</ul> {{#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}}
</div>
{{/with}}
<br>
<div class='status-actions'>
<span>{{i18n admin.customize.override_default}} {{view Ember.Checkbox checkedBinding="selectedItem.override_default_style"}}</span>
<span>{{i18n admin.customize.enabled}} {{view Ember.Checkbox checkedBinding="selectedItem.enabled"}}</span>
{{#unless selectedItem.changed}}
<a class='preview-link' {{bind-attr href="selectedItem.previewUrl"}} target='_blank' title="{{i18n admin.customize.explain_preview}}">{{i18n admin.customize.preview}}</a>
|
<a href="/?preview-style=" target='_blank' title="{{i18n admin.customize.explain_undo_preview}}">{{i18n admin.customize.undo_preview}}</a>
|
<a href="/?preview-style=default" target='_blank' title="{{i18n admin.customize.explain_rescue_preview}}">{{i18n admin.customize.rescue_preview}}</a><br>
{{/unless}}
</div> </div>
<div class="admin-container"> <div class='buttons'>
{{#if view.headerActive}} <button {{action "save"}} {{bind-attr disabled="selectedItem.disableSave"}} class='btn'>{{i18n admin.customize.save}}</button>
{{aceEditor content=header mode="html"}} <span class='saving'>{{selectedItem.savingStatus}}</span>
{{/if}} <a {{action "destroy"}} class='delete-link'>{{i18n admin.customize.delete}}</a>
{{#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}}
</div> </div>
{{/with}}
<br>
<div class='status-actions'>
<span>{{i18n admin.customize.override_default}} {{view Ember.Checkbox checkedBinding="selectedItem.override_default_style"}}</span>
<span>{{i18n admin.customize.enabled}} {{view Ember.Checkbox checkedBinding="selectedItem.enabled"}}</span>
{{#unless selectedItem.changed}}
<a class='preview-link' {{bind-attr href="selectedItem.previewUrl"}} target='_blank' title="{{i18n admin.customize.explain_preview}}">{{i18n admin.customize.preview}}</a>
|
<a href="/?preview-style=" target='_blank' title="{{i18n admin.customize.explain_undo_preview}}">{{i18n admin.customize.undo_preview}}</a>
|
<a href="/?preview-style=default" target='_blank' title="{{i18n admin.customize.explain_rescue_preview}}">{{i18n admin.customize.rescue_preview}}</a><br>
{{/unless}}
</div> </div>
<div class='buttons'>
<button {{action "save"}} {{bind-attr disabled="selectedItem.disableSave"}} class='btn'>{{i18n admin.customize.save}}</button>
<span class='saving'>{{selectedItem.savingStatus}}</span>
<a {{action "destroy"}} class='delete-link'>{{i18n admin.customize.delete}}</a>
</div>
</div>
{{else}} {{else}}
<p class="about">{{i18n admin.customize.about}}</p> <p class="about">{{i18n admin.customize.about}}</p>
{{/if}} {{/if}}
<div class='clearfix'></div>

View File

@ -12,15 +12,20 @@ Discourse.AdminCustomizeView = Discourse.View.extend({
templateName: 'admin/templates/customize', templateName: 'admin/templates/customize',
classNames: ['customize'], classNames: ['customize'],
selected: 'stylesheet', selected: 'stylesheet',
headerActive: Em.computed.equal('selected', 'header'), headerActive: Em.computed.equal('selected', 'header'),
footerActive: Em.computed.equal('selected', 'footer'),
stylesheetActive: Em.computed.equal('selected', 'stylesheet'), stylesheetActive: Em.computed.equal('selected', 'stylesheet'),
mobileHeaderActive: Em.computed.equal('selected', 'mobileHeader'), mobileHeaderActive: Em.computed.equal('selected', 'mobileHeader'),
mobileFooterActive: Em.computed.equal('selected', 'mobileFooter'),
mobileStylesheetActive: Em.computed.equal('selected', 'mobileStylesheet'), mobileStylesheetActive: Em.computed.equal('selected', 'mobileStylesheet'),
actions: { actions: {
selectHeader: function() { this.set('selected', 'header'); }, selectHeader: function() { this.set('selected', 'header'); },
selectFooter: function() { this.set('selected', 'footer'); },
selectStylesheet: function() { this.set('selected', 'stylesheet'); }, selectStylesheet: function() { this.set('selected', 'stylesheet'); },
selectMobileHeader: function() { this.set('selected', 'mobileHeader'); }, selectMobileHeader: function() { this.set('selected', 'mobileHeader'); },
selectMobileFooter: function() { this.set('selected', 'mobileFooter'); },
selectMobileStylesheet: function() { this.set('selected', 'mobileStylesheet'); } selectMobileStylesheet: function() { this.set('selected', 'mobileStylesheet'); }
}, },

View File

@ -2,7 +2,7 @@ import ObjectController from 'discourse/controllers/object';
import TopPeriod from 'discourse/models/top-period'; import TopPeriod from 'discourse/models/top-period';
export default ObjectController.extend({ export default ObjectController.extend({
needs: ['navigation/category'], needs: ['navigation/category', 'discovery/topics'],
loading: false, loading: false,
loadingSpinner: false, loadingSpinner: false,
scheduledSpinner: null, scheduledSpinner: null,
@ -10,6 +10,8 @@ export default ObjectController.extend({
category: Em.computed.alias('controllers.navigation/category.category'), category: Em.computed.alias('controllers.navigation/category.category'),
noSubcategories: Em.computed.alias('controllers.navigation/category.noSubcategories'), noSubcategories: Em.computed.alias('controllers.navigation/category.noSubcategories'),
loadedAllItems: Em.computed.not("controllers.discovery/topics.canLoadMore"),
showMoreUrl: function(period) { showMoreUrl: function(period) {
var url = '', category = this.get('category'); var url = '', category = this.get('category');
if (category) { if (category) {

View File

@ -3,6 +3,7 @@ export default Ember.ArrayController.extend({
needs: ['user-notifications'], needs: ['user-notifications'],
canLoadMore: true, canLoadMore: true,
loading: false, loading: false,
showDismissButton: function() { showDismissButton: function() {
return this.get('user').total_unread_notifications > 0; return this.get('user').total_unread_notifications > 0;
}.property('user'), }.property('user'),
@ -26,7 +27,7 @@ export default Ember.ArrayController.extend({
var notifications = result.get('content'); var notifications = result.get('content');
self.pushObjects(notifications); self.pushObjects(notifications);
// Stop trying if it's the end // Stop trying if it's the end
if (notifications && notifications.length === 0) { if (notifications && (notifications.length === 0 || notifications.length < 60)) {
self.set('canLoadMore', false); self.set('canLoadMore', false);
} }
}).catch(function(error) { }).catch(function(error) {

View File

@ -2,6 +2,7 @@ import ObjectController from 'discourse/controllers/object';
import CanCheckEmails from 'discourse/mixins/can-check-emails'; import CanCheckEmails from 'discourse/mixins/can-check-emails';
export default ObjectController.extend(CanCheckEmails, { export default ObjectController.extend(CanCheckEmails, {
needs: ['user-notifications', 'user_topics_list'],
viewingSelf: function() { viewingSelf: function() {
return this.get('content.username') === Discourse.User.currentProp('username'); 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); (this.get('userActionType') === Discourse.UserAction.TYPES.messages_received);
}.property('userActionType'), }.property('userActionType'),
/**
Can the currently logged in user invite users to the site
@property canInviteToForum
**/
canInviteToForum: function() { canInviteToForum: function() {
return Discourse.User.currentProp('can_invite_to_forum'); return Discourse.User.currentProp('can_invite_to_forum');
}.property(), }.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'), privateMessagesActive: Em.computed.equal('pmView', 'index'),
privateMessagesMineActive: Em.computed.equal('pmView', 'mine'), privateMessagesMineActive: Em.computed.equal('pmView', 'mine'),
privateMessagesUnreadActive: Em.computed.equal('pmView', 'unread') privateMessagesUnreadActive: Em.computed.equal('pmView', 'unread')

View File

@ -31,6 +31,8 @@ function finderFor(filter, params) {
} }
Discourse.TopicList = Discourse.Model.extend({ Discourse.TopicList = Discourse.Model.extend({
canLoadMore: Em.computed.notEmpty("more_topics_url"),
forEachNew: function(topics, callback) { forEachNew: function(topics, callback) {
var topicIds = []; var topicIds = [];
_.each(this.get('topics'),function(topic) { _.each(this.get('topics'),function(topic) {
@ -68,7 +70,6 @@ Discourse.TopicList = Discourse.Model.extend({
var moreUrl = this.get('more_topics_url'); var moreUrl = this.get('more_topics_url');
if (moreUrl) { if (moreUrl) {
var self = this; var self = this;
this.set('loadingMore', true); this.set('loadingMore', true);
@ -84,7 +85,11 @@ Discourse.TopicList = Discourse.Model.extend({
topics.pushObject(t); 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); Discourse.Session.currentProp('topicList', self);
return self.get('more_topics_url'); return self.get('more_topics_url');
} }

View File

@ -40,14 +40,12 @@ export default function(filter, extras) {
}, },
setupController: function(controller, model, trans) { setupController: function(controller, model, trans) {
if (trans) { if (trans) {
controller.setProperties(Em.getProperties(trans, _.keys(queryParams).map(function(v){ controller.setProperties(Em.getProperties(trans, _.keys(queryParams).map(function(v){
return 'queryParams.' + v; return 'queryParams.' + v;
}))); })));
} }
var periods = this.controllerFor('discovery').get('periods'), var periods = this.controllerFor('discovery').get('periods'),
periodId = model.get('for_period') || (filter.indexOf('/') > 0 ? filter.split('/')[1] : ''); periodId = model.get('for_period') || (filter.indexOf('/') > 0 ? filter.split('/')[1] : '');

View File

@ -4,7 +4,11 @@ export default Discourse.Route.extend({
}, },
setupController: function(controller, model) { 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')) { if (this.controllerFor('user_activity').get('content')) {
this.controllerFor('user_activity').set('userActionType', -1); this.controllerFor('user_activity').set('userActionType', -1);
} }

View File

@ -5,10 +5,15 @@ export default Discourse.Route.extend({
}, },
setupController: function(controller, model) { 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')) { if (this.controllerFor('user_activity').get('content')) {
this.controllerFor('user_activity').set('userActionType', -1); this.controllerFor('user_activity').set('userActionType', -1);
} }
controller.set('model', model); controller.set('model', model);
controller.set('user', this.modelFor('user')); controller.set('user', this.modelFor('user'));
}, },

View File

@ -23,7 +23,10 @@ Discourse.UserActivityStreamRoute = Discourse.Route.extend({
controller.set('model', model); controller.set('model', model);
this.controllerFor('user_activity').set('userActionType', this.get('userActionType')); 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: { actions: {

View File

@ -4,7 +4,10 @@ Discourse.UserTopicListRoute = Discourse.Route.extend({
}, },
setupController: function(controller, model) { 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-activity').set('userActionType', this.get('userActionType'));
this.controllerFor('user_topics_list').setProperties({ this.controllerFor('user_topics_list').setProperties({
model: model, model: model,
@ -30,7 +33,8 @@ function createPMRoute(viewName, path) {
}); });
this.controllerFor('user').setProperties({ this.controllerFor('user').setProperties({
pmView: viewName, pmView: viewName,
indexStream: false indexStream: false,
datasource: "topic_list"
}); });
} }
}); });

View File

@ -62,3 +62,7 @@
</section> </section>
</div> </div>
<div class="container">
{{custom-html "footer"}}
</div>

View File

@ -19,3 +19,7 @@
</tbody> </tbody>
</table> </table>
</div> </div>
<div class="container">
{{custom-html "footer"}}
</div>

View File

@ -37,6 +37,10 @@
</div> </div>
{{#if canLoadMore}} {{#if canLoadMore}}
{{loading-spinner}} {{loading-spinner}}
{{else}}
<div class="container">
{{custom-html "footer"}}
</div>
{{/if}} {{/if}}
{{else}} {{else}}
{{#unless userBadgesLoaded}} {{#unless userBadgesLoaded}}

View File

@ -10,25 +10,28 @@
</div> </div>
</div> </div>
<div {{bind-attr class="loadingSpinner::hidden"}}> {{#if loadingSpinner}}
{{loading-spinner}} {{loading-spinner}}
</div> {{else}}
<div {{bind-attr class=":container :list-container loadingSpinner:hidden"}}>
<div class="row">
<div {{bind-attr class=":container :list-container loadingSpinner:hidden"}}> <div class="full-width">
<div class="row"> <div id='header-list-area'>
<div class="full-width"> {{outlet header-list-container}}
<div id='header-list-area'> </div>
{{outlet header-list-container}} </div>
</div>
<div class="row">
<div class="full-width">
<div id='list-area'>
{{outlet list-container}}
</div>
</div> </div>
</div> </div>
</div> </div>
{{#if loadedAllItems}}
<div class="row"> <div class="container">
<div class="full-width"> {{custom-html "footer"}}
<div id='list-area'>
{{outlet list-container}}
</div>
</div> </div>
</div> {{/if}}
</div> {{/if}}

View File

@ -7,3 +7,7 @@
{{/if}} {{/if}}
</div> </div>
</div> </div>
<div class="container">
{{custom-html "footer"}}
</div>

View File

@ -43,7 +43,6 @@
</a> </a>
{{/if}} {{/if}}
{{#if details.can_edit}} {{#if details.can_edit}}
<a href='#' {{action "editTopic"}} class='edit-topic' title='{{i18n edit}}'>{{fa-icon pencil}}</a> <a href='#' {{action "editTopic"}} class='edit-topic' title='{{i18n edit}}'>{{fa-icon pencil}}</a>
{{/if}} {{/if}}
@ -112,6 +111,9 @@
<h3>{{{view.browseMoreMessage}}}</h3> <h3>{{{view.browseMoreMessage}}}</h3>
</div> </div>
{{/if}} {{/if}}
<div class="container">
{{custom-html "footer"}}
</div>
{{/if}} {{/if}}
{{/if}} {{/if}}
@ -119,7 +121,6 @@
</div> </div>
</div> </div>
{{else}} {{else}}
{{#if hasError}} {{#if hasError}}
<div class='container'> <div class='container'>
@ -133,11 +134,11 @@
<button {{action "showLogin"}} class='btn btn-primary topic-retry'>{{fa-icon user}} {{i18n log_in}}</button> <button {{action "showLogin"}} class='btn btn-primary topic-retry'>{{fa-icon user}} {{i18n log_in}}</button>
{{/unless}} {{/unless}}
{{else}} {{else}}
<button class="btn btn-primary topic-retry" {{action "retryLoading"}}><i class="fa fa-refresh"></i> {{i18n errors.buttons.again}}</button> <button class="btn btn-primary topic-retry" {{action "retryLoading"}}>{{fa-icon "refresh"}} {{i18n errors.buttons.again}}</button>
{{/if}} {{/if}}
</div> </div>
{{#if retrying}} {{#if retrying}}
{{loading-spinner}} {{loading-spinner}}
{{/if}} {{/if}}
{{/if}} {{/if}}
</div> </div>

View File

@ -7,6 +7,7 @@
{{/if}} {{/if}}
</div> </div>
{{/if}} {{/if}}
{{#if showDismissButton}} {{#if showDismissButton}}
<div class='notification-buttons'> <div class='notification-buttons'>
<button title="{{i18n user.dismiss_notifications_tooltip}}" id='dismiss-notifications-top' class='btn notifications-read' {{action "resetNew"}}>{{i18n user.dismiss_notifications}}</button> <button title="{{i18n user.dismiss_notifications_tooltip}}" id='dismiss-notifications-top' class='btn notifications-read' {{action "resetNew"}}>{{i18n user.dismiss_notifications}}</button>
@ -24,12 +25,12 @@
{{#if loading}} {{#if loading}}
{{loading-spinner}} {{loading-spinner}}
{{else}}
{{#unless canLoadMore}}
{{#if showDismissButton}}
<div class='notification-buttons'>
<button title="{{i18n user.dismiss_notifications_tooltip}}" id='dismiss-notifications' class='btn notifications-read' {{action "resetNew"}}>{{i18n user.dismiss_notifications}}</button>
</div>
{{/if}}
{{/unless}}
{{/if}} {{/if}}
{{#unless canLoadMore}}
<div class='end-of-stream'></div>
{{#if showDismissButton}}
<div class='notification-buttons'>
<button title="{{i18n user.dismiss_notifications_tooltip}}" id='dismiss-notifications' class='btn notifications-read' {{action "resetNew"}}>{{i18n user.dismiss_notifications}}</button>
</div>
{{/if}}
{{/unless}}

View File

@ -25,6 +25,7 @@
{{/grouped-each}} {{/grouped-each}}
</div> </div>
{{/grouped-each}} {{/grouped-each}}
{{#if loading}} {{#if loading}}
{{loading-spinner}} {{loading-spinner}}
{{/if}} {{/if}}

View File

@ -5,7 +5,6 @@
{{#unless loading}} {{#unless loading}}
<div class="container"> <div class="container">
<section class='user-main'> <section class='user-main'>
<section {{bind-attr class="collapsedInfo :about profileBackground:has-background:no-background"}}> <section {{bind-attr class="collapsedInfo :about profileBackground:has-background:no-background"}}>
<div class='staff-counters'> <div class='staff-counters'>
@ -33,80 +32,54 @@
<div><span class="warnings-received">{{number_of_warnings}}</span>&nbsp;{{i18n user.staff_counters.warnings_received}}</div> <div><span class="warnings-received">{{number_of_warnings}}</span>&nbsp;{{i18n user.staff_counters.warnings_received}}</div>
{{/if}} {{/if}}
</div> </div>
<div class='profile-image' {{bind-attr style="profileBackground"}}> <div class='profile-image' {{bind-attr style="profileBackground"}}></div>
</div>
<div class='details'> <div class='details'>
<div class='primary'> <div class='primary'>
{{bound-avatar model "huge"}} {{bound-avatar model "huge"}}
<section class='controls'> <section class='controls'>
<ul>
<ul> {{#if can_send_private_message_to_user}}
<li>
{{#if can_send_private_message_to_user}} <a class='btn btn-primary right' {{action "composePrivateMessage"}}>
<li> {{fa-icon "envelope"}}
<a class='btn btn-primary right' {{action "composePrivateMessage"}}> {{i18n user.private_message}}
<i class='fa fa-envelope'></i> </a>
{{i18n user.private_message}} </li>
</a> {{/if}}
</li> {{#if viewingSelf}}
{{/if}} <li><a {{action "logout"}} class='btn btn-danger right'>{{fa-icon "sign-out"}}{{i18n user.log_out}}</a></li>
{{/if}}
{{#if viewingSelf}} {{#if currentUser.staff}}
<li> <li><a {{bind-attr href="adminPath"}} class='btn right'>{{fa-icon "wrench"}}{{i18n admin.user.show_admin_profile}}</a></li>
<a {{action "logout"}} class='btn btn-danger right'><i class='fa fa-sign-out'></i>{{i18n user.log_out}}</a> {{/if}}
</li> {{#if can_edit}}
{{/if}} <li>{{#link-to 'preferences' class="btn right"}}{{fa-icon "cog"}}{{i18n user.preferences}}{{/link-to}}</li>
{{/if}}
{{#if currentUser.staff}} {{#if canInviteToForum}}
<li> <li>{{#link-to 'user.invited' class="btn right"}}{{fa-icon "envelope-o"}}{{i18n user.invited.title}}{{/link-to}}</li>
<a {{bind-attr href="adminPath"}} class='btn right'><i class="fa fa-wrench"></i>{{i18n admin.user.show_admin_profile}}</a> {{/if}}
</li> </ul>
{{/if}}
{{#if can_edit}}
<li>
{{#link-to 'preferences' class="btn right"}}<i class='fa fa-cog'></i>{{i18n user.preferences}}{{/link-to}}
</li>
{{/if}}
{{#if canInviteToForum}}
<li>
{{#link-to 'user.invited' class="btn right"}}<i class='fa fa-envelope-o'></i>{{i18n user.invited.title}}{{/link-to}}
</li>
{{/if}}
</ul>
</section> </section>
<div class="primary-textual"> <div class="primary-textual">
<h1>{{username}} {{{statusIcon}}}</h1> <h1>{{username}} {{{statusIcon}}}</h1>
<h2>{{name}}</h2> <h2>{{name}}</h2>
<h3> <h3>
{{#if location}}{{fa-icon "map-maker"}}{{location}}{{/if}}
{{#if location}}
<i class="fa fa-map-marker"></i>
{{location}}
{{/if}}
{{#if websiteName}} {{#if websiteName}}
<i class="fa fa-globe"></i> {{fa-icon "globe"}}
{{#if linkWebsite}} {{#if linkWebsite}}
<a {{bind-attr href="website"}} rel="nofollow" target="_blank">{{websiteName}}</a> <a {{bind-attr href="website"}} rel="nofollow" target="_blank">{{websiteName}}</a>
{{else}} {{else}}
<span {{bind-attr title="website"}}>{{websiteName}}</span> <span {{bind-attr title="website"}}>{{websiteName}}</span>
{{/if}} {{/if}}
{{/if}} {{/if}}
</h3> </h3>
<div class='bio'> <div class='bio'>
{{#if isSuspended}} {{#if isSuspended}}
<div class='suspended'> <div class='suspended'>
<i class='fa fa-ban'></i> {{fa-icon "ban"}}
<b>{{i18n user.suspended_notice date="suspendedTillDate"}}</b><br/> <b>{{i18n user.suspended_notice date="suspendedTillDate"}}</b><br/>
<b>{{i18n user.suspended_reason}}</b> {{suspend_reason}} <b>{{i18n user.suspended_reason}}</b> {{suspend_reason}}
</div> </div>
@ -116,17 +89,13 @@
{{plugin-outlet "user-profile-primary"}} {{plugin-outlet "user-profile-primary"}}
</div> </div>
</div> </div>
<div style='clear: both'></div>
<div style='clear: both'></div>
</div> </div>
<div class='secondary'> <div class='secondary'>
<dl> <dl>
{{#if created_at}} {{#if created_at}}
<dt>{{i18n user.created}}</dt><dd>{{bound-date created_at}}</dd> <dt>{{i18n user.created}}</dt><dd>{{bound-date created_at}}</dd>
{{/if}} {{/if}}
@ -162,67 +131,72 @@
{{plugin-outlet "user-profile-secondary"}} {{plugin-outlet "user-profile-secondary"}}
</div> </div>
</section> </section>
<section class='user-navigation'>
<ul class='action-list nav-stacked'> <section class='user-navigation'>
{{activity-filter count=statsCountNonPM user=model userActionType=userActionType indexStream=indexStream}}
{{#each stat in statsExcludingPms}}
{{activity-filter content=stat user=model userActionType=userActionType indexStream=indexStream}}
{{/each}}
{{#if showBadges}}
{{#link-to 'user.badges' tagName="li"}}
{{#link-to 'user.badges'}}
<i class='glyph fa fa-certificate'></i>
{{i18n badges.title}}
<span class='count'>({{badge_count}})</span>
<span class='fa fa-chevron-right'></span>
{{/link-to}}
{{/link-to}}
{{/if}}
{{#if canSeeNotificationHistory}}
{{#link-to 'user.notifications' tagName="li"}}
{{#link-to 'user.notifications'}}
<i class='glyph fa fa-comment'></i>
{{i18n user.notifications}}
<span class='count'>({{notification_count}})</span>
<span class='fa fa-chevron-right'></span>
{{/link-to}}
{{/link-to}}
{{/if}}
</ul>
{{#if canSeePrivateMessages}}
<h3><i class='fa fa-envelope'></i> {{i18n user.private_messages}}</h3>
<ul class='action-list nav-stacked'> <ul class='action-list nav-stacked'>
<li {{bind-attr class=":noGlyph privateMessagesActive:active"}}> {{activity-filter count=statsCountNonPM user=model userActionType=userActionType indexStream=indexStream}}
{{#link-to 'userPrivateMessages.index' model}} {{#each stat in statsExcludingPms}}
{{i18n user.messages.all}} {{activity-filter content=stat user=model userActionType=userActionType indexStream=indexStream}}
{{#if hasPMs}}<span class='count'>({{private_messages_stats.all}})</span>{{/if}} {{/each}}
<span class='fa fa-chevron-right'></span> {{#if showBadges}}
{{#link-to 'user.badges' tagName="li"}}
{{#link-to 'user.badges'}}
<i class='glyph fa fa-certificate'></i>
{{i18n badges.title}}
<span class='count'>({{badge_count}})</span>
<span class='fa fa-chevron-right'></span>
{{/link-to}}
{{/link-to}} {{/link-to}}
</li> {{/if}}
<li {{bind-attr class=":noGlyph privateMessagesMineActive:active"}}> {{#if canSeeNotificationHistory}}
{{#link-to 'userPrivateMessages.mine' model}} {{#link-to 'user.notifications' tagName="li"}}
{{i18n user.messages.mine}} {{#link-to 'user.notifications'}}
{{#if hasStartedPMs}}<span class='count'>({{private_messages_stats.mine}})</span>{{/if}} <i class='glyph fa fa-comment'></i>
<span class='fa fa-chevron-right'></span> {{i18n user.notifications}}
<span class='count'>({{notification_count}})</span>
<span class='fa fa-chevron-right'></span>
{{/link-to}}
{{/link-to}} {{/link-to}}
</li> {{/if}}
<li {{bind-attr class=":noGlyph privateMessagesUnreadActive:active"}}>
{{#link-to 'userPrivateMessages.unread' model}}
{{i18n user.messages.unread}}
{{#if hasUnreadPMs}}<span class='badge-notification unread-private-messages'>{{private_messages_stats.unread}}</span>{{/if}}
<span class='fa fa-chevron-right'></span>
{{/link-to}}
</li>
</ul> </ul>
{{/if}}
{{#if canSeePrivateMessages}}
<h3>{{fa-icon "envelope"}} {{i18n user.private_messages}}</h3>
<ul class='action-list nav-stacked'>
<li {{bind-attr class=":noGlyph privateMessagesActive:active"}}>
{{#link-to 'userPrivateMessages.index' model}}
{{i18n user.messages.all}}
{{#if hasPMs}}<span class='count'>({{private_messages_stats.all}})</span>{{/if}}
<span class='fa fa-chevron-right'></span>
{{/link-to}}
</li>
<li {{bind-attr class=":noGlyph privateMessagesMineActive:active"}}>
{{#link-to 'userPrivateMessages.mine' model}}
{{i18n user.messages.mine}}
{{#if hasStartedPMs}}<span class='count'>({{private_messages_stats.mine}})</span>{{/if}}
<span class='fa fa-chevron-right'></span>
{{/link-to}}
</li>
<li {{bind-attr class=":noGlyph privateMessagesUnreadActive:active"}}>
{{#link-to 'userPrivateMessages.unread' model}}
{{i18n user.messages.unread}}
{{#if hasUnreadPMs}}<span class='badge-notification unread-private-messages'>{{private_messages_stats.unread}}</span>{{/if}}
<span class='fa fa-chevron-right'></span>
{{/link-to}}
</li>
</ul>
{{/if}}
</section>
{{outlet userOutlet}}
</section> </section>
{{outlet userOutlet}}
</section>
</div> </div>
{{#if loadedAllItems}}
<div class="container">
{{custom-html "footer"}}
</div>
{{/if}}
{{/unless}} {{/unless}}

View File

@ -24,11 +24,6 @@
} }
} }
.end-of-stream {
border: 3px solid $primary;
width: 100%;
}
.notification-buttons { .notification-buttons {
margin: 10px 0; margin: 10px 0;
text-align: right; text-align: right;

View File

@ -408,9 +408,6 @@
.user-stream { .user-stream {
padding: 0 10px; padding: 0 10px;
.end-of-stream {
width: auto;
}
.excerpt { .excerpt {
margin: 5px 0; margin: 5px 0;
font-size: 13px; font-size: 13px;

View File

@ -51,7 +51,11 @@ class Admin::SiteCustomizationsController < Admin::AdminController
private private
def site_customization_params 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 end
def log_site_customization_change(old_record, new_params) def log_site_customization_change(old_record, new_params)

View File

@ -261,7 +261,7 @@ class ApplicationController < ActionController::Base
def custom_html_json def custom_html_json
data = { data = {
top: SiteText.text_for(:top), top: SiteText.text_for(:top),
bottom: SiteText.text_for(:bottom) footer: SiteCustomization.custom_footer(session[:preview_style])
} }
if DiscoursePluginRegistry.custom_html if DiscoursePluginRegistry.custom_html

View File

@ -21,9 +21,7 @@ class NotificationsController < ApplicationController
params[:before] ||= 1.day.from_now params[:before] ||= 1.day.from_now
user = current_user user = current_user
if params[:user] user = User.find_by_username(params[:user].to_s) if params[:user]
user = User.find_by_username(params[:user].to_s)
end
unless guardian.can_see_notifications?(user) unless guardian.can_see_notifications?(user)
return render json: {errors: [I18n.t('js.errors.reasons.forbidden')]}, status: 403 return render json: {errors: [I18n.t('js.errors.reasons.forbidden')]}, status: 403

View File

@ -17,7 +17,6 @@ class SiteCustomization < ActiveRecord::Base
DiscourseSassCompiler.compile(scss, 'custom') DiscourseSassCompiler.compile(scss, 'custom')
rescue => e rescue => e
puts e.backtrace.join("\n") unless Sass::SyntaxError === e puts e.backtrace.join("\n") unless Sass::SyntaxError === e
raise e raise e
end end
@ -34,29 +33,21 @@ class SiteCustomization < ActiveRecord::Base
end end
after_save do after_save do
if stylesheet_changed? File.delete(stylesheet_fullpath) if File.exists?(stylesheet_fullpath) && stylesheet_changed?
File.delete(stylesheet_fullpath) if File.exists?(stylesheet_fullpath) File.delete(stylesheet_fullpath(:mobile)) if File.exists?(stylesheet_fullpath(:mobile)) && mobile_stylesheet_changed?
end
if mobile_stylesheet_changed?
File.delete(stylesheet_fullpath(:mobile)) if File.exists?(stylesheet_fullpath(:mobile))
end
remove_from_cache! remove_from_cache!
if stylesheet_changed? or mobile_stylesheet_changed? if stylesheet_changed? || mobile_stylesheet_changed?
ensure_stylesheets_on_disk! ensure_stylesheets_on_disk!
# TODO: this is broken now because there's mobile stuff too # TODO: this is broken now because there's mobile stuff too
MessageBus.publish "/file-change/#{key}", stylesheet_hash MessageBus.publish "/file-change/#{key}", stylesheet_hash
end end
MessageBus.publish "/header-change/#{key}", header if header_changed? MessageBus.publish "/header-change/#{key}", header if header_changed?
MessageBus.publish "/footer-change/#{key}", footer if footer_changed?
end end
after_destroy do after_destroy do
if File.exists?(stylesheet_fullpath) File.delete(stylesheet_fullpath) if File.exists?(stylesheet_fullpath)
File.delete stylesheet_fullpath File.delete(stylesheet_fullpath(:mobile)) if File.exists?(stylesheet_fullpath(:mobile))
end
if File.exists?(stylesheet_fullpath(:mobile))
File.delete stylesheet_fullpath(:mobile)
end
self.remove_from_cache! self.remove_from_cache!
end end
@ -97,6 +88,16 @@ class SiteCustomization < ActiveRecord::Base
end end
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) def self.override_default_style(preview_style)
preview_style ||= enabled_style_key preview_style ||= enabled_style_key
style = lookup_style(preview_style) style = lookup_style(preview_style)

View File

@ -80,7 +80,9 @@
<%= yield :data %> <%= yield :data %>
<footer id='bottom'><%= raw SiteText.text_for(:bottom) %></footer> <footer id='bottom'>
<%= raw SiteText.text_for(:bottom) %>
</footer>
<%= render :partial => "common/discourse_javascript" %> <%= render :partial => "common/discourse_javascript" %>

View File

@ -1682,10 +1682,9 @@ en:
customize: customize:
title: "Customize" title: "Customize"
long_title: "Site Customizations" long_title: "Site Customizations"
css: "CSS"
header: "Header" header: "Header"
css: "Stylesheet" footer: "Footer"
mobile_header: "Mobile Header"
mobile_css: "Mobile Stylesheet"
override_default: "Do not include standard style sheet" override_default: "Do not include standard style sheet"
enabled: "Enabled?" enabled: "Enabled?"
preview: "preview" preview: "preview"

View File

@ -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)." description: "HTML that will be added at the top of every page (after the header, before the navigation or the topic title)."
bottom: bottom:
title: "Bottom of the pages" 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 </body> tag."
site_settings: site_settings:
censored_words: "Words that will be automatically replaced with &#9632;&#9632;&#9632;&#9632;" censored_words: "Words that will be automatically replaced with &#9632;&#9632;&#9632;&#9632;"

View File

@ -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