FEATURE: Export customizations as JSON files

This commit is contained in:
riking
2015-05-16 18:15:42 -07:00
parent 7ab8827c7e
commit 1e53c179a3
6 changed files with 40 additions and 1 deletions

View File

@ -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