mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 17:46:05 -05:00
FEATURE: Export customizations as JSON files
This commit is contained in:
parent
7ab8827c7e
commit
1e53c179a3
6 changed files with 40 additions and 1 deletions
|
@ -84,7 +84,11 @@ Discourse.SiteCustomization = Discourse.Model.extend({
|
||||||
destroy: function() {
|
destroy: function() {
|
||||||
if (!this.id) return;
|
if (!this.id) return;
|
||||||
return Discourse.ajax("/admin/site_customizations/" + this.id, { type: 'DELETE' });
|
return Discourse.ajax("/admin/site_customizations/" + this.id, { type: 'DELETE' });
|
||||||
}
|
},
|
||||||
|
|
||||||
|
download_url: function() {
|
||||||
|
return Discourse.getURL('/admin/site_customizations/' + this.id);
|
||||||
|
}.property('id')
|
||||||
});
|
});
|
||||||
|
|
||||||
var SiteCustomizations = Ember.ArrayProxy.extend({
|
var SiteCustomizations = Ember.ArrayProxy.extend({
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
<div {{bind-attr class=":current-style view.maximized:maximized"}}>
|
<div {{bind-attr class=":current-style view.maximized:maximized"}}>
|
||||||
<div class='wrapper'>
|
<div class='wrapper'>
|
||||||
{{text-field class="style-name" value=selectedItem.name}}
|
{{text-field class="style-name" value=selectedItem.name}}
|
||||||
|
<a class="btn export" download target="_blank" href={{selectedItem.download_url}}>{{fa-icon "download"}} {{i18n 'admin.export_json.button_text'}}</a>
|
||||||
|
|
||||||
<div class='admin-controls'>
|
<div class='admin-controls'>
|
||||||
<ul class="nav nav-pills">
|
<ul class="nav nav-pills">
|
||||||
|
|
|
@ -545,6 +545,9 @@ section.details {
|
||||||
.preview-link {
|
.preview-link {
|
||||||
margin-left: 15px;
|
margin-left: 15px;
|
||||||
}
|
}
|
||||||
|
.export {
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
padding-left: 10px;
|
padding-left: 10px;
|
||||||
width: 70%;
|
width: 70%;
|
||||||
.style-name {
|
.style-name {
|
||||||
|
|
|
@ -2,6 +2,8 @@ class Admin::SiteCustomizationsController < Admin::AdminController
|
||||||
|
|
||||||
before_filter :enable_customization
|
before_filter :enable_customization
|
||||||
|
|
||||||
|
skip_before_filter :check_xhr, only: [:show]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@site_customizations = SiteCustomization.order(:name)
|
@site_customizations = SiteCustomization.order(:name)
|
||||||
|
|
||||||
|
@ -48,6 +50,26 @@ class Admin::SiteCustomizationsController < Admin::AdminController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def show
|
||||||
|
@site_customization = SiteCustomization.find(params[:id])
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.json do
|
||||||
|
check_xhr
|
||||||
|
render json: SiteCustomizationSerializer.new(@site_customization)
|
||||||
|
end
|
||||||
|
|
||||||
|
format.any(:html, :text) do
|
||||||
|
raise RenderEmpty.new if request.xhr?
|
||||||
|
|
||||||
|
response.headers['Content-Disposition'] = "attachment; filename=#{@site_customization.name.parameterize}.dcstyle.json"
|
||||||
|
response.sending_file = true
|
||||||
|
render json: SiteCustomizationSerializer.new(@site_customization)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def site_customization_params
|
def site_customization_params
|
||||||
|
|
7
app/serializers/site_customization_serializer.rb
Normal file
7
app/serializers/site_customization_serializer.rb
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
class SiteCustomizationSerializer < ApplicationSerializer
|
||||||
|
|
||||||
|
attributes :name, :enabled, :created_at, :updated_at,
|
||||||
|
:stylesheet, :header, :footer, :top,
|
||||||
|
:mobile_stylesheet, :mobile_header, :mobile_footer, :mobile_top,
|
||||||
|
:head_tag, :body_tag
|
||||||
|
end
|
|
@ -1863,6 +1863,8 @@ en:
|
||||||
screened_email: "Export full screened email list in CSV format."
|
screened_email: "Export full screened email list in CSV format."
|
||||||
screened_ip: "Export full screened IP list in CSV format."
|
screened_ip: "Export full screened IP list in CSV format."
|
||||||
screened_url: "Export full screened URL list in CSV format."
|
screened_url: "Export full screened URL list in CSV format."
|
||||||
|
export_json:
|
||||||
|
button_text: "Export"
|
||||||
|
|
||||||
invite:
|
invite:
|
||||||
button_text: "Send Invites"
|
button_text: "Send Invites"
|
||||||
|
|
Loading…
Reference in a new issue