2013-04-04 12:59:44 -04:00
|
|
|
/**
|
|
|
|
Our data model for interacting with custom site content
|
|
|
|
|
|
|
|
@class SiteContent
|
|
|
|
@extends Discourse.Model
|
|
|
|
@namespace Discourse
|
|
|
|
@module Discourse
|
|
|
|
**/
|
|
|
|
Discourse.SiteContent = Discourse.Model.extend({
|
|
|
|
|
2014-05-15 01:52:09 -04:00
|
|
|
markdown: Em.computed.equal('format', 'markdown'),
|
|
|
|
plainText: Em.computed.equal('format', 'plain'),
|
|
|
|
html: Em.computed.equal('format', 'html'),
|
|
|
|
css: Em.computed.equal('format', 'css'),
|
2013-04-04 12:59:44 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
Save the content
|
|
|
|
|
|
|
|
@method save
|
|
|
|
@return {jqXHR} a jQuery Promise object
|
|
|
|
**/
|
|
|
|
save: function() {
|
2013-05-07 13:30:12 -04:00
|
|
|
return Discourse.ajax("/admin/site_contents/" + this.get('content_type'), {
|
2013-04-04 12:59:44 -04:00
|
|
|
type: 'PUT',
|
|
|
|
data: {content: this.get('content')}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
Discourse.SiteContent.reopenClass({
|
|
|
|
|
|
|
|
find: function(type) {
|
2013-05-07 13:30:12 -04:00
|
|
|
return Discourse.ajax("/admin/site_contents/" + type).then(function (data) {
|
2013-04-04 12:59:44 -04:00
|
|
|
return Discourse.SiteContent.create(data.site_content);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2014-05-15 01:52:09 -04:00
|
|
|
});
|