mirror of
https://github.com/discourse/discourse.git
synced 2025-01-22 19:39:46 +08:00
16dfedef8f
of confusion and bugs.
21 lines
792 B
JavaScript
21 lines
792 B
JavaScript
Discourse.StaticPage = Em.Object.extend();
|
|
|
|
Discourse.StaticPage.reopenClass({
|
|
find: function(path) {
|
|
return new Em.RSVP.Promise(function(resolve) {
|
|
// Models shouldn't really be doing Ajax request, but this is a huge speed boost if we
|
|
// preload content.
|
|
var $preloaded = $("noscript[data-path=\"/" + path + "\"]");
|
|
if ($preloaded.length) {
|
|
var text = $preloaded.text();
|
|
text = text.match(/<!-- preload-content: -->((?:.|[\n\r])*)<!-- :preload-content -->/)[1];
|
|
resolve(Discourse.StaticPage.create({path: path, html: text}));
|
|
} else {
|
|
Discourse.ajax(path + ".html", {dataType: 'html'}).then(function (result) {
|
|
resolve(Discourse.StaticPage.create({path: path, html: result}));
|
|
});
|
|
}
|
|
});
|
|
}
|
|
});
|