some refactoring of store url object
This commit is contained in:
parent
bf532bfea9
commit
b47bd031f2
|
@ -1,6 +1,5 @@
|
|||
class Admin::ModuleStoreController < OrbitBackendController
|
||||
before_filter :check_central_server_connection, :only => [:get_extensions]
|
||||
@@store = STORE_CONFIG[:store_settings]["url"]
|
||||
|
||||
def index
|
||||
@extensions = get_extensions
|
||||
|
|
|
@ -3,24 +3,22 @@ require 'uri'
|
|||
require 'fileutils'
|
||||
require 'zip/zip'
|
||||
class Admin::TemplateStoreController < OrbitBackendController
|
||||
before_filter :check_central_server_connection, :only => [:get_extensions]
|
||||
before_filter :check_central_server_connection, :only => [:get_templates]
|
||||
before_filter :set_store
|
||||
|
||||
@@store_domain = STORE_CONFIG[:store_settings]["url"]
|
||||
def index
|
||||
@store_url = @@store_domain
|
||||
@design_ids = Design.all.map{|d| d.template_store_id}
|
||||
@templates = get_templates.parsed_response
|
||||
render :layout => false
|
||||
end
|
||||
|
||||
def show
|
||||
@store = @@store_domain
|
||||
@design_ids = Design.all.map{|d| d.template_store_id}
|
||||
@template = get_template(params[:id]).parsed_response rescue nil
|
||||
end
|
||||
|
||||
def download_theme
|
||||
url = @@store_domain + params["url"]
|
||||
url = @store_url + params["url"]
|
||||
url_base = url.split('/')[2]
|
||||
url_path = '/'+url.split('/')[3..-1].join('/')
|
||||
Net::HTTP.start(url_base) do |http|
|
||||
|
@ -32,7 +30,7 @@ class Admin::TemplateStoreController < OrbitBackendController
|
|||
end
|
||||
upload_package("#{params['slug']}.zip", params["id"])
|
||||
File.delete("public/#{params['slug']}.zip")
|
||||
render :json => {"success"=>true,"url"=>@@store_domain + params["url"]}.to_json
|
||||
render :json => {"success"=>true,"url"=>@store_url + params["url"]}.to_json
|
||||
end
|
||||
protected
|
||||
|
||||
|
@ -93,20 +91,14 @@ class Admin::TemplateStoreController < OrbitBackendController
|
|||
|
||||
def get_template(id)
|
||||
store_session.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
|
||||
extensions = store_session.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
|
||||
store_session.templates
|
||||
end
|
||||
|
||||
def set_store
|
||||
@store_url = STORE_CONFIG[:store_settings]["url"]
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in New Issue