69 lines
2.9 KiB
Ruby
69 lines
2.9 KiB
Ruby
# encoding: utf-8
|
|
require 'erb'
|
|
|
|
namespace :site do
|
|
|
|
task :build => :environment do
|
|
Site.destroy_all
|
|
Purchase.destroy_all
|
|
|
|
Site.create( :school => 'RulingDigital University', :department => 'Computer Science', :valid_locales => [ 'en', 'zh_tw' ], :in_use_locales => [ 'zh_tw', 'en' ])
|
|
User.create!(:email=>'chris@rulingcom.com',:admin=>true,:user_id=>'chris',:password=>'password')
|
|
`mongo #{Mongoid.config.database.name} --eval "db.fs.chunks.ensureIndex({files_id: 1, n: 1})"`
|
|
|
|
puts "Congres you can now login within url"
|
|
puts 'Please upload design package (/admin/designs/upload_package ) and run rake site:necessary_data'
|
|
I18nVariable.create!( :document_class => 'language', :key => 'en', :en => 'English', :zh_tw => '英文' )
|
|
I18nVariable.create!( :document_class => 'language', :key => 'zh_tw', :en => 'Chinese', :zh_tw => '中文' )
|
|
Info.create!(key: "profile", built_in: true, disabled: false, title: {"zh_tw"=>"基本欄位", "en"=>"Basic Info"}, to_search: false)
|
|
end
|
|
|
|
task :necessary_data => :environment do
|
|
puts "Enter your resque namespace[Orbit]:......"
|
|
@resque_namespace = STDIN.gets.gsub("\n",'')
|
|
@resque_namespace = APP_CONFIG['orbit'] if @resque_namespace.empty?
|
|
|
|
puts "Is this a primary site?[Default No]:......"
|
|
site_is_primary = false
|
|
site_is_primary = STDIN.gets.gsub("\n",'')
|
|
site_is_primary = true if site_is_primary.downcase == 'yes'
|
|
|
|
puts "Is this the only site on this mechine?[Default No]:......"
|
|
site_is_alone = false
|
|
site_is_alone = STDIN.gets.gsub("\n",'')
|
|
site_is_alone = true if site_is_alone.downcase == 'yes'
|
|
|
|
@resque_workers = site_is_alone ? 5 : 2
|
|
|
|
resque_setting = ERB.new(File.new("lib/template/setting/resque.god.erb").read)
|
|
File.open("config/resque.god", 'w') { |file| file.write(resque_setting.result) }
|
|
|
|
resque_schedule_setting = ERB.new(File.new("lib/template/setting/resque_schedule.god.erb").read)
|
|
File.open("config/resque_schedule.god", 'w') { |file| file.write(resque_schedule_setting.result) }
|
|
|
|
if site_is_primary
|
|
solr_setting = ERB.new(File.new("lib/template/setting/solr.god.erb").read)
|
|
File.open("config/solr.god", 'w') { |file| file.write(solr_setting.result) }
|
|
end
|
|
|
|
site = Site.first
|
|
site.title = 'RulingOrbit Demo Site'
|
|
site.resque_namespace = @resque_namespace
|
|
site.save
|
|
|
|
# home_trans = I18nVariable.create!( :document_class => 'Home', :key => 'home', :en => 'Homepage', :zh_tw => '首頁')
|
|
design = Design.first
|
|
site = Site.first
|
|
site.design = design
|
|
site.save
|
|
theme = design.themes.first
|
|
home = Page.new( :design_id => design.id, :name => 'home', :is_published => true, :theme_id => theme.id )
|
|
|
|
home.title_translations = {"zh_tw"=>"首頁", "en"=>"Home"}
|
|
home.save
|
|
|
|
puts "Rember to restart server after you setup all sites for starting God"
|
|
end
|
|
|
|
end
|