FEATURE: refactor notice code, add optional global notice.

Set the global_notice site setting to notify users of a critical event.
This commit is contained in:
Sam 2014-03-24 16:51:48 +11:00
parent b5208081b3
commit c27c87911e
7 changed files with 29 additions and 15 deletions

View File

@ -1,9 +1,5 @@
<div class="container">
{{#if Discourse.isReadOnly}}
<div class="row">
<div class="alert alert-info">{{i18n "read_only_mode.enabled"}}</div>
</div>
{{/if}}
{{Discourse.globalNotice}}
<div class="row">
<div class="full-width">

View File

@ -143,7 +143,25 @@ window.Discourse = Ember.Application.createWithMixins(Discourse.Ajax, {
}
}
return this.get("currentAssetVersion");
}.property()
}.property(),
globalNotice: function(){
var notices = [];
if(this.get("isReadOnly")){
notices.push(I18n.t("read_only_mode.enabled"));
}
if(!_.isEmpty(Discourse.SiteSettings.global_notice)){
notices.push(Discourse.SiteSettings.global_notice);
}
if(notices.length > 0) {
return new Handlebars.SafeString(_.map(notices, function(text) {
return "<div class='row'><div class='alert alert-info'>" + text + "</div></div>";
}).join(""));
}
}.property("isReadOnly")
});

View File

@ -1,8 +1,6 @@
<div class='container'>
{{customHTML "top"}}
{{#if Discourse.isReadOnly}}
<div class="alert alert-info">{{i18n "read_only_mode.enabled"}}</div>
{{/if}}
{{Discourse.globalNotice}}
</div>
<div class='list-controls'>

View File

@ -1,8 +1,6 @@
<div class='container'>
{{customHTML "top"}}
{{#if Discourse.isReadOnly}}
<div class="alert alert-info">{{i18n "read_only_mode.enabled"}}</div>
{{/if}}
{{Discourse.globalNotice}}
</div>
{{#if postStream.loaded}}

View File

@ -1,8 +1,6 @@
<div class='container'>
{{customHTML "top"}}
{{#if Discourse.isReadOnly}}
<div class="alert alert-info">{{i18n "read_only_mode.enabled"}}</div>
{{/if}}
{{Discourse.globalNotice}}
</div>
{{#unless loading}}

View File

@ -848,6 +848,8 @@ en:
suppress_uncategorized_badge: "Don't show the badge for uncategorized topics in topic lists"
min_posts_for_search_in_topic: "Disable search within topic if topics have less than minimum number posts"
global_notice: "Display a global banner to all users of the site, change to blank to hide it (HTML is allowed)"
enable_names: "Allow users to show their full names"
display_name_on_posts: "Also show a user's full name on their posts"
invites_shown: "Maximum invites shown on a user page"

View File

@ -476,6 +476,10 @@ uncategorized:
sequential_replies_threshold: 2
dominating_topic_minimum_percent: 20
global_notice:
default: ""
client: true
# Category IDs
lounge_category_id:
default: -1