This repository has been archived on 2024-03-16. You can view files and clone it, but cannot push or open issues or pull requests.
orbit-4-1/app/controllers/admin/template_store_controller.rb

31 lines
750 B
Ruby

class Admin::TemplateStoreController < ApplicationController
layout "back_end"
def index
@templates = JSON.parse(get_templates)
end
def show
@template = JSON.parse(get_template(params[:id])) rescue nil
end
protected
def get_template(id)
uri = URI.parse("http://#{APP_CONFIG['store_ip']}/store/design/#{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("http://#{APP_CONFIG['store_ip']}/store/designs")
http = Net::HTTP.new(uri.host, uri.port)
request = Net::HTTP::Get.new(uri.request_uri)
response = http.request(request)
response.body
end
end