orbit-4-2/app/controllers/admin/template_store_controller.rb

36 lines
887 B
Ruby

class Admin::TemplateStoreController < OrbitBackendController
@@store_domain = STORE_CONFIG[:store_settings]["url"]
def index
@store = @@store_domain
@templates = JSON.parse(get_templates)
end
def show
@store = @@store_domain
@template = JSON.parse(get_template(params[:id])) rescue nil
end
def download_theme
render :json => {"success"=>true}.to_json
end
protected
def get_template(id)
uri = URI.parse("#{@@store_domain}/api/templates/#{id}")
http = Net::HTTP.new(uri.host, uri.port)
request = Net::HTTP::Get.new(uri.request_uri)
response = http.request(request)
response.body
end
def get_templates
uri = URI.parse("#{@@store_domain}/api/templates")
http = Net::HTTP.new(uri.host, uri.port)
request = Net::HTTP::Get.new(uri.request_uri)
response = http.request(request)
response.body
end
end