mirror of
https://github.com/discourse/discourse.git
synced 2025-03-22 13:36:39 +08:00
Make DISCOURSE_NO_CONSTANTS work in anon for home page
This commit is contained in:
parent
cf389e0137
commit
09bedfd4c0
@ -44,7 +44,7 @@ function loadDraft(store, opts) {
|
|||||||
export default Ember.Controller.extend({
|
export default Ember.Controller.extend({
|
||||||
needs: ['modal', 'topic', 'composer-messages', 'application'],
|
needs: ['modal', 'topic', 'composer-messages', 'application'],
|
||||||
|
|
||||||
replyAsNewTopicDraft: Em.computed.equal('model.draftKey', Discourse.Composer.REPLY_AS_NEW_TOPIC_KEY),
|
replyAsNewTopicDraft: Em.computed.equal('model.draftKey', Composer.REPLY_AS_NEW_TOPIC_KEY),
|
||||||
checkedMessages: false,
|
checkedMessages: false,
|
||||||
|
|
||||||
showEditReason: false,
|
showEditReason: false,
|
||||||
@ -166,7 +166,7 @@ export default Ember.Controller.extend({
|
|||||||
|
|
||||||
openIfDraft() {
|
openIfDraft() {
|
||||||
if (this.get('model.viewDraft')) {
|
if (this.get('model.viewDraft')) {
|
||||||
this.set('model.composeState', Discourse.Composer.OPEN);
|
this.set('model.composeState', Composer.OPEN);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -179,17 +179,17 @@ export default Ember.Controller.extend({
|
|||||||
toggle() {
|
toggle() {
|
||||||
this.closeAutocomplete();
|
this.closeAutocomplete();
|
||||||
switch (this.get('model.composeState')) {
|
switch (this.get('model.composeState')) {
|
||||||
case Discourse.Composer.OPEN:
|
case Composer.OPEN:
|
||||||
if (Ember.isEmpty(this.get('model.reply')) && Ember.isEmpty(this.get('model.title'))) {
|
if (Ember.isEmpty(this.get('model.reply')) && Ember.isEmpty(this.get('model.title'))) {
|
||||||
this.close();
|
this.close();
|
||||||
} else {
|
} else {
|
||||||
this.shrink();
|
this.shrink();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Discourse.Composer.DRAFT:
|
case Composer.DRAFT:
|
||||||
this.set('model.composeState', Discourse.Composer.OPEN);
|
this.set('model.composeState', Composer.OPEN);
|
||||||
break;
|
break;
|
||||||
case Discourse.Composer.SAVING:
|
case Composer.SAVING:
|
||||||
this.close();
|
this.close();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -413,7 +413,7 @@ export default Ember.Controller.extend({
|
|||||||
// If we want a different draft than the current composer, close it and clear our model.
|
// If we want a different draft than the current composer, close it and clear our model.
|
||||||
if (composerModel &&
|
if (composerModel &&
|
||||||
opts.draftKey !== composerModel.draftKey &&
|
opts.draftKey !== composerModel.draftKey &&
|
||||||
composerModel.composeState === Discourse.Composer.DRAFT) {
|
composerModel.composeState === Composer.DRAFT) {
|
||||||
this.close();
|
this.close();
|
||||||
composerModel = null;
|
composerModel = null;
|
||||||
}
|
}
|
||||||
@ -422,15 +422,15 @@ export default Ember.Controller.extend({
|
|||||||
if (composerModel && composerModel.get('replyDirty')) {
|
if (composerModel && composerModel.get('replyDirty')) {
|
||||||
|
|
||||||
// If we're already open, we don't have to do anything
|
// If we're already open, we don't have to do anything
|
||||||
if (composerModel.get('composeState') === Discourse.Composer.OPEN &&
|
if (composerModel.get('composeState') === Composer.OPEN &&
|
||||||
composerModel.get('draftKey') === opts.draftKey && !opts.action) {
|
composerModel.get('draftKey') === opts.draftKey && !opts.action) {
|
||||||
return resolve();
|
return resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
// If it's the same draft, just open it up again.
|
// If it's the same draft, just open it up again.
|
||||||
if (composerModel.get('composeState') === Discourse.Composer.DRAFT &&
|
if (composerModel.get('composeState') === Composer.DRAFT &&
|
||||||
composerModel.get('draftKey') === opts.draftKey) {
|
composerModel.get('draftKey') === opts.draftKey) {
|
||||||
composerModel.set('composeState', Discourse.Composer.OPEN);
|
composerModel.set('composeState', Composer.OPEN);
|
||||||
if (!opts.action) return resolve();
|
if (!opts.action) return resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -467,7 +467,7 @@ export default Ember.Controller.extend({
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.set('model', composerModel);
|
this.set('model', composerModel);
|
||||||
composerModel.set('composeState', Discourse.Composer.OPEN);
|
composerModel.set('composeState', Composer.OPEN);
|
||||||
composerModel.set('isWarning', false);
|
composerModel.set('isWarning', false);
|
||||||
|
|
||||||
if (opts.topicTitle && opts.topicTitle.length <= this.siteSettings.max_topic_title_length) {
|
if (opts.topicTitle && opts.topicTitle.length <= this.siteSettings.max_topic_title_length) {
|
||||||
@ -567,7 +567,7 @@ export default Ember.Controller.extend({
|
|||||||
|
|
||||||
collapse() {
|
collapse() {
|
||||||
this._saveDraft();
|
this._saveDraft();
|
||||||
this.set('model.composeState', Discourse.Composer.DRAFT);
|
this.set('model.composeState', Composer.DRAFT);
|
||||||
},
|
},
|
||||||
|
|
||||||
close() {
|
close() {
|
||||||
|
@ -74,6 +74,24 @@ module Tilt
|
|||||||
rval
|
rval
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def whitelisted?(path)
|
||||||
|
|
||||||
|
@@whitelisted ||= Set.new(
|
||||||
|
["discourse/models/nav-item",
|
||||||
|
"discourse/models/user-action",
|
||||||
|
"discourse/routes/discourse",
|
||||||
|
"discourse/models/category",
|
||||||
|
"discourse/models/trust-level",
|
||||||
|
"discourse/models/site",
|
||||||
|
"discourse/models/user",
|
||||||
|
"discourse/models/session",
|
||||||
|
"discourse/models/model",
|
||||||
|
"discourse/views/grouped"]
|
||||||
|
)
|
||||||
|
|
||||||
|
@@whitelisted.include?(path) || path =~ /discourse\/mixins/
|
||||||
|
end
|
||||||
|
|
||||||
def evaluate(scope, locals, &block)
|
def evaluate(scope, locals, &block)
|
||||||
return @output if @output
|
return @output if @output
|
||||||
|
|
||||||
@ -86,7 +104,7 @@ module Tilt
|
|||||||
# For backwards compatibility with plugins, for now export the Global format too.
|
# For backwards compatibility with plugins, for now export the Global format too.
|
||||||
# We should eventually have an upgrade system for plugins to use ES6 or some other
|
# We should eventually have an upgrade system for plugins to use ES6 or some other
|
||||||
# resolve based API.
|
# resolve based API.
|
||||||
if ENV['DISCOURSE_NO_CONSTANTS'].nil? &&
|
if (ENV['DISCOURSE_NO_CONSTANTS'].nil? || whitelisted?(scope.logical_path)) &&
|
||||||
scope.logical_path =~ /(discourse|admin)\/(controllers|components|views|routes|mixins|models)\/(.*)/
|
scope.logical_path =~ /(discourse|admin)\/(controllers|components|views|routes|mixins|models)\/(.*)/
|
||||||
|
|
||||||
type = Regexp.last_match[2]
|
type = Regexp.last_match[2]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user