Download Extensions now working
This commit is contained in:
parent
c0ea38475c
commit
5a9e60174d
|
@ -13,18 +13,19 @@ class Admin::ModuleStoreController < OrbitBackendController
|
||||||
def download
|
def download
|
||||||
#get extension related values
|
#get extension related values
|
||||||
extension = get_extension(params[:id]) rescue nil
|
extension = get_extension(params[:id]) rescue nil
|
||||||
download_link = @@store + "/"+ extension["extension"]["extension"]["url"]
|
extension_name = extension["key"].to_s
|
||||||
downloaded_file_name = extension["extension_filename"]
|
git_repository_url = extension["git_url"]
|
||||||
module_app_name = downloaded_file_name.split(/(.zip)/).first
|
version = extension["version"]
|
||||||
|
module_installed = File.read("downloaded_extensions.rb").include?(extension["key"])
|
||||||
|
|
||||||
#check if the directory exists or not
|
if module_installed.eql?(false)
|
||||||
@module_status = Dir.exists?("#{Rails.root}/vendor/built_in_modules/#{module_app_name}")
|
@download_link = "gem '#{extension_name}', '#{version}', :git => '#{git_repository_url}'"
|
||||||
if @module_status.eql?(true)
|
File.open("downloaded_extensions.rb", 'a') do |file|
|
||||||
flash[:notice] = "This module is already installed"
|
file.puts @download_link
|
||||||
else
|
end
|
||||||
download_extension(download_link, downloaded_file_name,module_app_name)
|
|
||||||
flash[:notice] = "This module has been successfully installed"
|
|
||||||
end
|
end
|
||||||
|
%w(bundle install)
|
||||||
|
site_restart
|
||||||
redirect_to admin_module_store_path
|
redirect_to admin_module_store_path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -37,12 +38,4 @@ class Admin::ModuleStoreController < OrbitBackendController
|
||||||
def get_extension(id)
|
def get_extension(id)
|
||||||
JSON.parse(open("#{@@store}/api/extensions/#{id}").read)
|
JSON.parse(open("#{@@store}/api/extensions/#{id}").read)
|
||||||
end
|
end
|
||||||
|
|
||||||
def download_extension(download_link, downloaded_file_name,module_app_name)
|
|
||||||
puts %x(wget "#{download_link}")
|
|
||||||
puts %x(unzip "#{downloaded_file_name}")
|
|
||||||
puts %x(mv #{module_app_name} "#{Rails.root}/vendor/built_in_modules/")
|
|
||||||
puts %x(rm "#{downloaded_file_name}")
|
|
||||||
site_restart
|
|
||||||
end
|
|
||||||
end
|
end
|
|
@ -44,18 +44,12 @@
|
||||||
<td>
|
<td>
|
||||||
<%= extension["description"].html_safe%> <%= link_to 'Read More', admin_module_store_show_path(extension["_slugs"][0]) %>
|
<%= extension["description"].html_safe%> <%= link_to 'Read More', admin_module_store_show_path(extension["_slugs"][0]) %>
|
||||||
</td>
|
</td>
|
||||||
<!-- <td class="active"><button class="act btn btn-mini" type="button">Uninstall</button></td>
|
<% @module_installed = File.read("downloaded_extensions.rb").include?(extension["key"])%>
|
||||||
-->
|
<% if @module_installed.eql?(true)%>
|
||||||
<% download_link = STORE_CONFIG[:store_settings]["url"] + "/"+ extension["extension"]["extension"]["url"]
|
<td class="active">Installed</td>
|
||||||
downloaded_file_name = extension["extension_filename"]
|
<% else %>
|
||||||
module_app_name = downloaded_file_name.split(/(.zip)/).first
|
<td class="active"><%= link_to 'Download', admin_module_store_download_path(:id => extension["_slugs"][0]), :class=>"act btn btn-mini btn-success" %></td>
|
||||||
@module_status = Dir.exists?("#{Rails.root}/vendor/built_in_modules/#{module_app_name}")
|
<% end %>
|
||||||
%>
|
|
||||||
<% if @module_status.eql?(true)%>
|
|
||||||
<td class="active">Installed</td>
|
|
||||||
<% else %>
|
|
||||||
<td class="active"><%= link_to 'Download', admin_module_store_download_path(:id => extension["_slugs"][0]), :class=>"act btn btn-mini btn-success" %></td>
|
|
||||||
<% end %>
|
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
gem 'archive', '0.0.1', :git => 'git@gitlab.tp.rulingcom.com:root/orbit-archive.git'
|
gem 'archive', '0.0.1', :git => 'git@gitlab.tp.rulingcom.com:root/orbit-archive.git'
|
||||||
gem 'calendar', '0.0.1', :git => 'git@gitlab.tp.rulingcom.com:root/orbit-calendar.git'
|
gem 'calendar', '0.0.1', :git => 'git@gitlab.tp.rulingcom.com:root/orbit-calendar.git'
|
||||||
gem 'location', '0.0.1', :git => 'git@gitlab.tp.rulingcom.com:root/orbit-location.git'
|
gem 'location', '0.0.1', :git => 'git@gitlab.tp.rulingcom.com:root/orbit-location.git'
|
||||||
gem 'ask', '0.0.1', :git => 'git@gitlab.tp.rulingcom.com:root/orbit-ask.git'
|
|
||||||
gem 'video', '0.0.1', :git => 'git@gitlab.tp.rulingcom.com:root/orbit-video.git'
|
gem 'video', '0.0.1', :git => 'git@gitlab.tp.rulingcom.com:root/orbit-video.git'
|
||||||
gem 'faq', '0.0.1', :git => 'git@gitlab.tp.rulingcom.com:root/orbit-faq.git'
|
gem 'faq', '0.0.1', :git => 'git@gitlab.tp.rulingcom.com:root/orbit-faq.git'
|
||||||
|
gem 'ask', '0.0.1', :git => 'git@gitlab.tp.rulingcom.com:root/orbit-ask.git'
|
||||||
|
|
Loading…
Reference in New Issue