Merge branch 'november_presentation' of github.com:Rulingcom/orbit into november_presentation
This commit is contained in:
commit
bcf487f264
1
Gemfile
1
Gemfile
|
@ -1,5 +1,4 @@
|
||||||
source 'http://rubygems.org'
|
source 'http://rubygems.org'
|
||||||
|
|
||||||
gem 'rails'
|
gem 'rails'
|
||||||
gem 'yajl-ruby', :require => 'yajl'
|
gem 'yajl-ruby', :require => 'yajl'
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,12 @@ class Admin::PurchasesController < ApplicationController
|
||||||
redirect_to admin_purchases_url
|
redirect_to admin_purchases_url
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def install_app
|
||||||
|
unzip_app
|
||||||
|
redirect_to admin_purchases_url
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def download_purchase(purchase, url)
|
def download_purchase(purchase, url)
|
||||||
|
@ -77,6 +83,36 @@ class Admin::PurchasesController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def unzip_app
|
||||||
|
zip_name = "NewBlog"
|
||||||
|
file = "#{Rails.root}/lib/NewBlog.zip"
|
||||||
|
destination = "#{Rails.root}/vendor/plugins"
|
||||||
|
|
||||||
|
Zip::ZipFile.open(file) do |zip_file|
|
||||||
|
orig_file = file
|
||||||
|
|
||||||
|
temp_file = Tempfile.new("temp_file_zip")
|
||||||
|
temp_file.binmode
|
||||||
|
temp_file.write orig_file
|
||||||
|
temp_file.rewind
|
||||||
|
|
||||||
|
app = AppModule.new.from_json(zip_file.read("#{zip_name}/#{zip_name}/#{zip_name}.json"))
|
||||||
|
zip_file.each do |f|
|
||||||
|
if (f.to_s=~/^#{zip_name}\/#{zip_name}\/*/)
|
||||||
|
f_path=File.join(destination, f.name.gsub(/^#{zip_name}\//, ''))
|
||||||
|
FileUtils.mkdir_p(File.dirname(f_path))
|
||||||
|
zip_file.extract(f, f_path) unless File.exist?(f_path)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
log = Logger.new(STDOUT)
|
||||||
|
log.level = Logger::WARN
|
||||||
|
log.warn("App unzip procress is finished,please restart the server to apply effect")
|
||||||
|
|
||||||
|
#TODO Perform touch tmp/restart to restart in production env
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def build_file(orig_zip, zip_name, dir, object, type = nil)
|
def build_file(orig_zip, zip_name, dir, object, type = nil)
|
||||||
title = object.file_filename
|
title = object.file_filename
|
||||||
temp = File.new(dir + '/' + title, 'w+')
|
temp = File.new(dir + '/' + title, 'w+')
|
||||||
|
@ -85,4 +121,8 @@ class Admin::PurchasesController < ApplicationController
|
||||||
object.to_save = true
|
object.to_save = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def unzip_file (file, destination)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
|
@ -0,0 +1,13 @@
|
||||||
|
class AppModule
|
||||||
|
include Mongoid::Document
|
||||||
|
include Mongoid::Timestamps
|
||||||
|
|
||||||
|
field :name_of_app
|
||||||
|
field :version
|
||||||
|
field :organization
|
||||||
|
field :author
|
||||||
|
field :intro
|
||||||
|
field :update_info
|
||||||
|
field :create_date
|
||||||
|
|
||||||
|
end
|
|
@ -36,6 +36,9 @@ PrototypeR4::Application.routes.draw do
|
||||||
end
|
end
|
||||||
resources :page_parts
|
resources :page_parts
|
||||||
resources :purchases do
|
resources :purchases do
|
||||||
|
collection do
|
||||||
|
get 'install_app'
|
||||||
|
end
|
||||||
member do
|
member do
|
||||||
get 'download'
|
get 'download'
|
||||||
end
|
end
|
||||||
|
|
Binary file not shown.
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
"name_of_app": "NewBlog",
|
||||||
|
"version": "0.1",
|
||||||
|
"organization": "Rulingcom",
|
||||||
|
"author": "RD dep",
|
||||||
|
"intro": "A simple blog……",
|
||||||
|
"update_info": "Some info",
|
||||||
|
"create_date": "11-11-2011"
|
||||||
|
}
|
Binary file not shown.
Loading…
Reference in New Issue