mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-12-01 11:28:15 -05:00
39 lines
963 B
JavaScript
39 lines
963 B
JavaScript
/**
|
|
This controller supports displaying static content.
|
|
|
|
@class StaticController
|
|
@extends Discourse.Controller
|
|
@namespace Discourse
|
|
@module Discourse
|
|
**/
|
|
Discourse.StaticController = Discourse.Controller.extend({
|
|
content: null,
|
|
|
|
loadPath: function(path) {
|
|
var $preloaded, text,
|
|
_this = this;
|
|
this.set('content', null);
|
|
|
|
// Load from <noscript> if we have it.
|
|
$preloaded = $("noscript[data-path=\"" + path + "\"]");
|
|
if ($preloaded.length) {
|
|
text = $preloaded.text();
|
|
text = text.match(/<!-- preload-content: -->((?:.|[\n\r])*)<!-- :preload-content -->/);
|
|
text = text[1];
|
|
return this.set('content', text);
|
|
} else {
|
|
return Discourse.ajax({
|
|
url: Discourse.getURL("" + path + ".json"),
|
|
success: function(result) {
|
|
return _this.set('content', result);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
});
|
|
|
|
Discourse.StaticController.reopenClass({
|
|
pages: ['faq', 'tos', 'privacy']
|
|
});
|
|
|
|
|