mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 03:29:31 +08:00
39 lines
946 B
JavaScript
39 lines
946 B
JavaScript
/**
|
|
Our data model for interacting with custom site content
|
|
|
|
@class SiteContent
|
|
@extends Discourse.Model
|
|
@namespace Discourse
|
|
@module Discourse
|
|
**/
|
|
Discourse.SiteContent = Discourse.Model.extend({
|
|
|
|
markdown: Ember.computed.equal('format', 'markdown'),
|
|
plainText: Ember.computed.equal('format', 'plain'),
|
|
html: Ember.computed.equal('format', 'html'),
|
|
css: Ember.computed.equal('format', 'css'),
|
|
|
|
/**
|
|
Save the content
|
|
|
|
@method save
|
|
@return {jqXHR} a jQuery Promise object
|
|
**/
|
|
save: function() {
|
|
return Discourse.ajax(Discourse.getURL("/admin/site_contents/" + this.get('content_type')), {
|
|
type: 'PUT',
|
|
data: {content: this.get('content')}
|
|
});
|
|
}
|
|
|
|
});
|
|
|
|
Discourse.SiteContent.reopenClass({
|
|
|
|
find: function(type) {
|
|
return Discourse.ajax(Discourse.getURL("/admin/site_contents/" + type)).then(function (data) {
|
|
return Discourse.SiteContent.create(data.site_content);
|
|
});
|
|
}
|
|
|
|
}); |