2014-01-06 06:47:44 +00:00
|
|
|
class Admin::TemplateStoreController < OrbitBackendController
|
2012-11-28 09:27:23 +00:00
|
|
|
|
2014-01-06 06:47:44 +00:00
|
|
|
|
2014-01-14 03:20:30 +00:00
|
|
|
@@store_domain = STORE_CONFIG[:store_settings]["url"]
|
2012-11-28 09:27:23 +00:00
|
|
|
def index
|
2014-01-06 06:47:44 +00:00
|
|
|
@store = @@store_domain
|
2012-12-06 15:20:27 +00:00
|
|
|
@templates = JSON.parse(get_templates)
|
2012-11-28 09:27:23 +00:00
|
|
|
end
|
|
|
|
|
2012-11-28 18:02:37 +00:00
|
|
|
def show
|
2014-01-06 06:47:44 +00:00
|
|
|
@store = @@store_domain
|
2012-12-06 18:37:05 +00:00
|
|
|
@template = JSON.parse(get_template(params[:id])) rescue nil
|
2012-12-06 15:20:27 +00:00
|
|
|
end
|
|
|
|
|
2014-01-06 06:47:44 +00:00
|
|
|
def download_theme
|
|
|
|
render :json => {"success"=>true}.to_json
|
|
|
|
end
|
2012-12-06 15:20:27 +00:00
|
|
|
protected
|
|
|
|
|
|
|
|
def get_template(id)
|
2014-01-06 06:47:44 +00:00
|
|
|
uri = URI.parse("#{@@store_domain}/api/templates/#{id}")
|
2012-12-06 15:20:27 +00:00
|
|
|
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
|
2014-01-06 06:47:44 +00:00
|
|
|
uri = URI.parse("#{@@store_domain}/api/templates")
|
2012-12-06 15:20:27 +00:00
|
|
|
http = Net::HTTP.new(uri.host, uri.port)
|
|
|
|
request = Net::HTTP::Get.new(uri.request_uri)
|
|
|
|
response = http.request(request)
|
|
|
|
response.body
|
2012-11-28 18:02:37 +00:00
|
|
|
end
|
|
|
|
|
2012-11-28 09:27:23 +00:00
|
|
|
end
|