2013-02-23 04:41:12 +08:00
|
|
|
/**
|
|
|
|
This controller supports displaying static content.
|
2013-02-21 02:15:50 +08:00
|
|
|
|
2013-02-23 04:41:12 +08:00
|
|
|
@class StaticController
|
|
|
|
@extends Discourse.Controller
|
|
|
|
@namespace Discourse
|
|
|
|
@module Discourse
|
|
|
|
**/
|
|
|
|
Discourse.StaticController = Discourse.Controller.extend({
|
2013-10-26 04:05:59 +08:00
|
|
|
needs: ['header'],
|
|
|
|
path: null,
|
|
|
|
|
|
|
|
showLoginButton: function() {
|
|
|
|
return this.get('path') === '/login';
|
|
|
|
}.property('path'),
|
2013-02-21 02:15:50 +08:00
|
|
|
|
2013-02-23 04:41:12 +08:00
|
|
|
loadPath: function(path) {
|
2013-11-19 00:13:24 +08:00
|
|
|
var self = this;
|
|
|
|
|
|
|
|
this.setProperties({
|
|
|
|
path: path,
|
|
|
|
content: null
|
|
|
|
});
|
2013-02-23 04:41:12 +08:00
|
|
|
|
|
|
|
// Load from <noscript> if we have it.
|
2013-04-09 03:04:40 +08:00
|
|
|
var $preloaded = $("noscript[data-path=\"" + path + "\"]");
|
2013-02-23 04:41:12 +08:00
|
|
|
if ($preloaded.length) {
|
2013-04-09 03:04:40 +08:00
|
|
|
var text = $preloaded.text();
|
2013-11-19 00:13:24 +08:00
|
|
|
text = text.match(/<!-- preload-content: -->((?:.|[\n\r])*)<!-- :preload-content -->/)[1];
|
2013-04-09 03:04:40 +08:00
|
|
|
this.set('content', text);
|
2013-02-23 04:41:12 +08:00
|
|
|
} else {
|
2013-07-17 00:11:30 +08:00
|
|
|
return Discourse.ajax(path, {dataType: 'html'}).then(function (result) {
|
2013-11-19 00:13:24 +08:00
|
|
|
self.set('content', result);
|
2013-02-23 04:41:12 +08:00
|
|
|
});
|
2013-02-21 02:15:50 +08:00
|
|
|
}
|
2013-02-23 04:41:12 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
Discourse.StaticController.reopenClass({
|
2013-06-28 01:01:04 +08:00
|
|
|
pages: ['faq', 'tos', 'privacy', 'login'],
|
|
|
|
configs: {
|
|
|
|
'faq': 'faq_url',
|
|
|
|
'tos': 'tos_url',
|
|
|
|
'privacy': 'privacy_policy_url'
|
|
|
|
}
|
2013-02-23 04:41:12 +08:00
|
|
|
});
|
2013-02-21 02:15:50 +08:00
|
|
|
|
|
|
|
|