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
**/
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);
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;
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'
});
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);
i.set('selected', selected === i);
});
}.observes('selectedItem')
});

View File

@ -5,10 +5,11 @@
<li><a {{action "selectStyle" this}} {{bind-attr class="this.selected:active"}}>{{this.description}}</a></li>
{{/each}}
</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>
{{#if selectedItem}}
<div class='current-style'>
{{#with selectedItem}}
@ -16,34 +17,22 @@
<div class='admin-controls'>
<ul class="nav nav-pills">
<li>
<a {{bind-attr class="view.stylesheetActive:active"}}{{action "selectStylesheet" href="true" target="view"}}>{{i18n admin.customize.css}}</a>
</li>
<li>
<a {{bind-attr class="view.headerActive:active"}}{{action "selectHeader" href="true" target="view"}}>{{i18n admin.customize.header}}</a>
</li>
<li>
<a {{bind-attr class="view.mobileStylesheetActive:active"}}{{action "selectMobileStylesheet" href="true" target="view"}}>{{i18n admin.customize.mobile_css}}</a>
</li>
<li>
<a {{bind-attr class="view.mobileHeaderActive:active"}}{{action "selectMobileHeader" href="true" target="view"}}>{{i18n admin.customize.mobile_header}}</a>
</li>
<li><a {{bind-attr class="view.stylesheetActive:active"}} {{action "selectStylesheet" target="view"}}>{{i18n admin.customize.css}}</a></li>
<li><a {{bind-attr class="view.headerActive:active"}} {{action "selectHeader" target="view"}}>{{i18n admin.customize.header}}</a></li>
<li><a {{bind-attr class="view.footerActive:active"}} {{action "selectFooter" target="view"}}>{{i18n admin.customize.footer}}</a></li>
<li><a {{bind-attr class="view.mobileStylesheetActive:active"}} {{action "selectMobileStylesheet" target="view"}}>{{fa-icon "mobile"}}&nbsp;{{i18n admin.customize.css}}</a></li>
<li><a {{bind-attr class="view.mobileHeaderActive:active"}} {{action "selectMobileHeader" target="view"}}>{{fa-icon "mobile"}}&nbsp;{{i18n admin.customize.header}}</a></li>
<li><a {{bind-attr class="view.mobileFooterActive:active"}} {{action "selectMobileFooter" target="view"}}>{{fa-icon "mobile"}}&nbsp;{{i18n admin.customize.footer}}</a></li>
</ul>
</div>
<div class="admin-container">
{{#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}}
{{#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}}
</div>
{{/with}}
<br>
@ -64,9 +53,7 @@
<span class='saving'>{{selectedItem.savingStatus}}</span>
<a {{action "destroy"}} class='delete-link'>{{i18n admin.customize.delete}}</a>
</div>
</div>
{{else}}
<p class="about">{{i18n admin.customize.about}}</p>
{{/if}}
<div class='clearfix'></div>

View File

@ -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'); }
},

View File

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

View File

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

View File

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

View File

@ -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');
}

View File

@ -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] : '');

View File

@ -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);
}

View File

@ -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'));
},

View File

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

View File

@ -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"
});
}
});

View File

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

View File

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

View File

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

View File

@ -10,11 +10,9 @@
</div>
</div>
<div {{bind-attr class="loadingSpinner::hidden"}}>
{{#if loadingSpinner}}
{{loading-spinner}}
</div>
{{else}}
<div {{bind-attr class=":container :list-container loadingSpinner:hidden"}}>
<div class="row">
<div class="full-width">
@ -23,7 +21,6 @@
</div>
</div>
</div>
<div class="row">
<div class="full-width">
<div id='list-area'>
@ -32,3 +29,9 @@
</div>
</div>
</div>
{{#if loadedAllItems}}
<div class="container">
{{custom-html "footer"}}
</div>
{{/if}}
{{/if}}

View File

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

View File

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

View File

@ -7,6 +7,7 @@
{{/if}}
</div>
{{/if}}
{{#if showDismissButton}}
<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>
@ -24,12 +25,12 @@
{{#if loading}}
{{loading-spinner}}
{{/if}}
{{else}}
{{#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}}
{{/if}}

View File

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

View File

@ -5,7 +5,6 @@
{{#unless loading}}
<div class="container">
<section class='user-main'>
<section {{bind-attr class="collapsedInfo :about profileBackground:has-background:no-background"}}>
<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>
{{/if}}
</div>
<div class='profile-image' {{bind-attr style="profileBackground"}}>
</div>
<div class='profile-image' {{bind-attr style="profileBackground"}}></div>
<div class='details'>
<div class='primary'>
{{bound-avatar model "huge"}}
<section class='controls'>
<ul>
{{#if can_send_private_message_to_user}}
<li>
<a class='btn btn-primary right' {{action "composePrivateMessage"}}>
<i class='fa fa-envelope'></i>
{{fa-icon "envelope"}}
{{i18n user.private_message}}
</a>
</li>
{{/if}}
{{#if viewingSelf}}
<li>
<a {{action "logout"}} class='btn btn-danger right'><i class='fa fa-sign-out'></i>{{i18n user.log_out}}</a>
</li>
<li><a {{action "logout"}} class='btn btn-danger right'>{{fa-icon "sign-out"}}{{i18n user.log_out}}</a></li>
{{/if}}
{{#if currentUser.staff}}
<li>
<a {{bind-attr href="adminPath"}} class='btn right'><i class="fa fa-wrench"></i>{{i18n admin.user.show_admin_profile}}</a>
</li>
<li><a {{bind-attr href="adminPath"}} class='btn right'>{{fa-icon "wrench"}}{{i18n admin.user.show_admin_profile}}</a></li>
{{/if}}
{{#if can_edit}}
<li>
{{#link-to 'preferences' class="btn right"}}<i class='fa fa-cog'></i>{{i18n user.preferences}}{{/link-to}}
</li>
<li>{{#link-to 'preferences' class="btn right"}}{{fa-icon "cog"}}{{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>
<li>{{#link-to 'user.invited' class="btn right"}}{{fa-icon "envelope-o"}}{{i18n user.invited.title}}{{/link-to}}</li>
{{/if}}
</ul>
</section>
<div class="primary-textual">
<h1>{{username}} {{{statusIcon}}}</h1>
<h2>{{name}}</h2>
<h3>
{{#if location}}
<i class="fa fa-map-marker"></i>
{{location}}
{{/if}}
{{#if location}}{{fa-icon "map-maker"}}{{location}}{{/if}}
{{#if websiteName}}
<i class="fa fa-globe"></i>
{{fa-icon "globe"}}
{{#if linkWebsite}}
<a {{bind-attr href="website"}} rel="nofollow" target="_blank">{{websiteName}}</a>
{{else}}
<span {{bind-attr title="website"}}>{{websiteName}}</span>
{{/if}}
{{/if}}
</h3>
<div class='bio'>
{{#if isSuspended}}
<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_reason}}</b> {{suspend_reason}}
</div>
@ -116,17 +89,13 @@
{{plugin-outlet "user-profile-primary"}}
</div>
</div>
<div style='clear: both'></div>
</div>
<div class='secondary'>
<dl>
{{#if created_at}}
<dt>{{i18n user.created}}</dt><dd>{{bound-date created_at}}</dd>
{{/if}}
@ -162,8 +131,8 @@
{{plugin-outlet "user-profile-secondary"}}
</div>
</section>
<section class='user-navigation'>
<section class='user-navigation'>
<ul class='action-list nav-stacked'>
{{activity-filter count=statsCountNonPM user=model userActionType=userActionType indexStream=indexStream}}
{{#each stat in statsExcludingPms}}
@ -192,7 +161,7 @@
</ul>
{{#if canSeePrivateMessages}}
<h3><i class='fa fa-envelope'></i> {{i18n user.private_messages}}</h3>
<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}}
@ -217,12 +186,17 @@
</li>
</ul>
{{/if}}
</section>
{{outlet userOutlet}}
</section>
</div>
{{#if loadedAllItems}}
<div class="container">
{{custom-html "footer"}}
</div>
{{/if}}
{{/unless}}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -80,7 +80,9 @@
<%= 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" %>

View File

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

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)."
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 </body> tag."
site_settings:
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