diff --git a/app/assets/javascripts/admin/models/site_customization.js b/app/assets/javascripts/admin/models/site_customization.js
index 27b6ddbdd..4d9ca8c7b 100644
--- a/app/assets/javascripts/admin/models/site_customization.js
+++ b/app/assets/javascripts/admin/models/site_customization.js
@@ -84,7 +84,11 @@ Discourse.SiteCustomization = Discourse.Model.extend({
destroy: function() {
if (!this.id) return;
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({
diff --git a/app/assets/javascripts/admin/templates/customize_css_html.hbs b/app/assets/javascripts/admin/templates/customize_css_html.hbs
index 004318e1e..8b9fff5fc 100644
--- a/app/assets/javascripts/admin/templates/customize_css_html.hbs
+++ b/app/assets/javascripts/admin/templates/customize_css_html.hbs
@@ -14,6 +14,7 @@
{{text-field class="style-name" value=selectedItem.name}}
+
{{fa-icon "download"}} {{i18n 'admin.export_json.button_text'}}
diff --git a/app/assets/stylesheets/common/admin/admin_base.scss b/app/assets/stylesheets/common/admin/admin_base.scss
index 6659f61a7..fc240b294 100644
--- a/app/assets/stylesheets/common/admin/admin_base.scss
+++ b/app/assets/stylesheets/common/admin/admin_base.scss
@@ -545,6 +545,9 @@ section.details {
.preview-link {
margin-left: 15px;
}
+ .export {
+ float: right;
+ }
padding-left: 10px;
width: 70%;
.style-name {
diff --git a/app/controllers/admin/site_customizations_controller.rb b/app/controllers/admin/site_customizations_controller.rb
index dc104fd74..30929fe4e 100644
--- a/app/controllers/admin/site_customizations_controller.rb
+++ b/app/controllers/admin/site_customizations_controller.rb
@@ -2,6 +2,8 @@ class Admin::SiteCustomizationsController < Admin::AdminController
before_filter :enable_customization
+ skip_before_filter :check_xhr, only: [:show]
+
def index
@site_customizations = SiteCustomization.order(:name)
@@ -48,6 +50,26 @@ class Admin::SiteCustomizationsController < Admin::AdminController
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
def site_customization_params
diff --git a/app/serializers/site_customization_serializer.rb b/app/serializers/site_customization_serializer.rb
new file mode 100644
index 000000000..7d5242355
--- /dev/null
+++ b/app/serializers/site_customization_serializer.rb
@@ -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
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index 7300d658b..9286504b2 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -1863,6 +1863,8 @@ en:
screened_email: "Export full screened email list in CSV format."
screened_ip: "Export full screened IP list in CSV format."
screened_url: "Export full screened URL list in CSV format."
+ export_json:
+ button_text: "Export"
invite:
button_text: "Send Invites"