From 1096db79b66bc0b50560b13abe4f1e7f42e73a83 Mon Sep 17 00:00:00 2001 From: "Matt K. Fu" Date: Tue, 14 May 2013 10:32:53 +0800 Subject: [PATCH] blank site now can be start from rake site:build --- app/controllers/application_controller.rb | 2 +- app/controllers/pages_controller.rb | 2 +- lib/tasks/site.rake | 19 ++++++++++++++++++- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 70e565c2..c1de055e 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -155,7 +155,7 @@ class ApplicationController < ActionController::Base # Set the site variables def set_site # set site if exist or create site - @site = Site.first || Site.create({:valid_locales => [], :in_use_locales => []}) + @site = Site.first || Site.create({:valid_locales => VALID_LOCALES, :in_use_locales => VALID_LOCALES}) session[:site] = @site.id @site_in_use_locales = site_locales_default_head(@site.in_use_locales) @site_valid_locales = site_locales_default_head(@site.valid_locales) diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index f9bb0c3f..6e72a960 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -5,7 +5,7 @@ class PagesController < ApplicationController # caches_page :index def check_frontend_open - if Me.frontend_closed + if Me.frontend_closed and current_user.nil? #Need to be change redirect_to '/admin/dashboards' end end diff --git a/lib/tasks/site.rake b/lib/tasks/site.rake index 4415aed9..8186c1eb 100644 --- a/lib/tasks/site.rake +++ b/lib/tasks/site.rake @@ -8,7 +8,24 @@ namespace :site do 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') + + put "Run ensureIndex on chunks before you upload something. If You start DB from nothing." + puts 'Please upload design package and run rake site:necessary_data' end + task :necessary_data => :environment do + site = Site.first + site.title = 'RulingOrbit Demo Site' + site.save + + # home_trans = I18nVariable.create!( :document_class => 'Home', :key => 'home', :en => 'Homepage', :zh_tw => '首頁') + design = Design.first + 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 + end + end