installation procedure allows to install the default site template if provided
This commit is contained in:
parent
c6b272f9f9
commit
61886ec1b1
@ -42,13 +42,7 @@ module Admin
|
|||||||
@site = Site.create_first_one(params[:site])
|
@site = Site.create_first_one(params[:site])
|
||||||
|
|
||||||
if @site.valid?
|
if @site.valid?
|
||||||
begin
|
Site.install_template(@site, params)
|
||||||
unless params[:zipfile].blank?
|
|
||||||
Locomotive::Import::Job.run!(params[:zipfile], @site, { :samples => true })
|
|
||||||
end
|
|
||||||
rescue Exception => e
|
|
||||||
logger.error "Import failed because of #{e.message}"
|
|
||||||
end
|
|
||||||
|
|
||||||
redirect_to last_url
|
redirect_to last_url
|
||||||
else
|
else
|
||||||
@ -61,8 +55,8 @@ module Admin
|
|||||||
def is_step_already_done?
|
def is_step_already_done?
|
||||||
case params[:step].to_i
|
case params[:step].to_i
|
||||||
when 1 # already an account in db
|
when 1 # already an account in db
|
||||||
if Account.count > 0
|
if account = Account.first
|
||||||
@step_done = t('admin.installation.step_1.done', Account.first.attributes)
|
@step_done = I18n.t('admin.installation.step_1.done', :name => account.name, :email => account.email)
|
||||||
render 'step_1' and return false
|
render 'step_1' and return false
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
@ -13,6 +13,24 @@ module Extensions
|
|||||||
site
|
site
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def install_template(site, options = {})
|
||||||
|
default_template = Boolean.set(options.delete(:default_site_template)) || false
|
||||||
|
|
||||||
|
zipfile = options.delete(:zipfile)
|
||||||
|
|
||||||
|
# do not try to process anything if said so
|
||||||
|
return unless default_template || zipfile.present?
|
||||||
|
|
||||||
|
# default template options has a higher priority than the zipfile
|
||||||
|
source = default_template ? Locomotive.default_site_template_path : zipfile
|
||||||
|
|
||||||
|
begin
|
||||||
|
Locomotive::Import::Job.run!(source, site, { :samples => true })
|
||||||
|
rescue Exception => e
|
||||||
|
logger.error "The import of the site template failed because of #{e.message}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
- content_for :head do
|
- content_for :head do
|
||||||
= include_stylesheets :installation
|
= include_stylesheets :installation
|
||||||
|
= include_javascripts :installation
|
||||||
|
|
||||||
= semantic_form_for(@site, :url => admin_installation_step_url(2), :html => { :multipart => true }) do |f|
|
= semantic_form_for(@site, :url => admin_installation_step_url(2), :html => { :multipart => true }) do |f|
|
||||||
.inner
|
.inner
|
||||||
@ -18,9 +19,16 @@
|
|||||||
- if multi_sites?
|
- if multi_sites?
|
||||||
= f.input :subdomain, :required => true
|
= f.input :subdomain, :required => true
|
||||||
|
|
||||||
%li{ :class => 'string optional', :id => 'zipfile_input' }
|
- if Locomotive.default_site_template_present?
|
||||||
|
%li{ :class => 'question', :id => 'default_site_template_input' }
|
||||||
|
= check_box_tag 'default_site_template', '1', params[:default_site_template].blank? || params[:default_site_template] == '1'
|
||||||
|
%label{ :for => 'default_site_template' }!= t('formtastic.labels.import.new.default_site_template')
|
||||||
|
|
||||||
|
%li{ :class => 'string optional', :id => 'zipfile_input', :style => "#{'display: none' if Locomotive.default_site_template_present?}" }
|
||||||
%label{ :for => 'zipfile' }= t('formtastic.labels.import.new.source')
|
%label{ :for => 'zipfile' }= t('formtastic.labels.import.new.source')
|
||||||
= file_field_tag 'zipfile'
|
= file_field_tag 'zipfile'
|
||||||
|
- if Locomotive.default_site_template_present?
|
||||||
|
%p.inline-hints!= t('.back_to_default_template')
|
||||||
|
|
||||||
.footer
|
.footer
|
||||||
= box_button_tag t('.next')
|
= box_button_tag t('.next')
|
@ -7,6 +7,9 @@ s3_secret_access_key: <%= ENV['S3_SECRET_KEY'] %>
|
|||||||
javascripts:
|
javascripts:
|
||||||
box:
|
box:
|
||||||
- public/javascripts/admin/jquery.js
|
- public/javascripts/admin/jquery.js
|
||||||
|
installation:
|
||||||
|
- public/javascripts/admin/jquery.js
|
||||||
|
- public/javascripts/admin/installation.js
|
||||||
common:
|
common:
|
||||||
- public/javascripts/admin/jquery.js
|
- public/javascripts/admin/jquery.js
|
||||||
- public/javascripts/admin/jquery.ui.js
|
- public/javascripts/admin/jquery.ui.js
|
||||||
|
@ -4,7 +4,7 @@ Locomotive::Application.configure do
|
|||||||
# In the development environment your application's code is reloaded on
|
# In the development environment your application's code is reloaded on
|
||||||
# every request. This slows down response time but is perfect for development
|
# every request. This slows down response time but is perfect for development
|
||||||
# since you don't have to restart the webserver when you make code changes.
|
# since you don't have to restart the webserver when you make code changes.
|
||||||
config.cache_classes = true #false
|
config.cache_classes = false
|
||||||
|
|
||||||
# Log error messages when you accidentally call methods on nil.
|
# Log error messages when you accidentally call methods on nil.
|
||||||
config.whiny_nils = true
|
config.whiny_nils = true
|
||||||
@ -30,11 +30,11 @@ Locomotive::Application.configure do
|
|||||||
|
|
||||||
# set up the bushido stub (uncomment it)
|
# set up the bushido stub (uncomment it)
|
||||||
# config.bushido_stub_env = false
|
# config.bushido_stub_env = false
|
||||||
config.bushido_stub_env = {
|
# config.bushido_stub_env = {
|
||||||
'APP_TLD' => 'bushi.do',
|
# 'APP_TLD' => 'bushi.do',
|
||||||
'BUSHIDO_APP' => 'san_francisco',
|
# 'BUSHIDO_APP' => 'san_francisco',
|
||||||
'BUSHIDO_HOST' => 'bushi.do',
|
# 'BUSHIDO_HOST' => 'bushi.do',
|
||||||
'LOCOMOTIVE_SITE_NAME' => 'Locomotive TEST',
|
# 'LOCOMOTIVE_SITE_NAME' => 'Locomotive TEST',
|
||||||
'BUSHIDO_CLAIMED' => 'true'
|
# 'BUSHIDO_CLAIMED' => 'true'
|
||||||
}
|
# }
|
||||||
end
|
end
|
@ -289,5 +289,6 @@ en:
|
|||||||
next: Create account
|
next: Create account
|
||||||
step_2:
|
step_2:
|
||||||
title: "Step 2/2 — Create your first site"
|
title: "Step 2/2 — Create your first site"
|
||||||
explanations: "This is the last step of the installation. You can upload a theme as a zip file. We have free available themes <a href=\"http://www.locomotivecms.com/support/themes\">here</a>."
|
explanations: "If you already uploaded the default site template (see instructions), you can use it right away. Or you can upload a site template as a zip file (free available templates <a href=\"http://www.locomotivecms.com/support/themes\">here</a>)."
|
||||||
|
back_to_default_template: "Click <a href='#'>here</a> to select the default site template instead"
|
||||||
next: Create site
|
next: Create site
|
||||||
|
@ -36,6 +36,7 @@ en:
|
|||||||
source: File
|
source: File
|
||||||
samples: Copy samples
|
samples: Copy samples
|
||||||
reset: Reset site
|
reset: Reset site
|
||||||
|
default_site_template: "Use the default site template. Click <a href='#'>here</a> to upload a site template as a zip file instead."
|
||||||
content_type:
|
content_type:
|
||||||
api_accounts: Notified Accounts
|
api_accounts: Notified Accounts
|
||||||
account:
|
account:
|
||||||
|
@ -39,6 +39,14 @@ module Locomotive
|
|||||||
self.const_defined?('Engine')
|
self.const_defined?('Engine')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.default_site_template_present?
|
||||||
|
File.exists?(self.default_site_template_path)
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.default_site_template_path
|
||||||
|
File.join(Rails.root, 'tmp/default_site_template.zip')
|
||||||
|
end
|
||||||
|
|
||||||
def self.configure
|
def self.configure
|
||||||
self.config ||= Configuration.new
|
self.config ||= Configuration.new
|
||||||
|
|
||||||
@ -96,7 +104,7 @@ module Locomotive
|
|||||||
if self.config.multi_sites?
|
if self.config.multi_sites?
|
||||||
self.config.manage_subdomain = self.config.manage_domains = true
|
self.config.manage_subdomain = self.config.manage_domains = true
|
||||||
else
|
else
|
||||||
# Note: (Did) modify the code below if Locomotive handles a new hosting solution
|
# Note: (Did) modify the code below if Locomotive handles a new hosting solution (not a perfect solution though)
|
||||||
self.config.manage_domains = self.heroku? || self.bushido?
|
self.config.manage_domains = self.heroku? || self.bushido?
|
||||||
self.config.manage_subdomain = self.bushido?
|
self.config.manage_subdomain = self.bushido?
|
||||||
end
|
end
|
||||||
|
@ -15,7 +15,7 @@ module Locomotive
|
|||||||
if ::Locomotive.bushido_app_claimed?
|
if ::Locomotive.bushido_app_claimed?
|
||||||
require_admin_without_bushido
|
require_admin_without_bushido
|
||||||
else
|
else
|
||||||
# open back-office for everybody as long as the application has not been claimed
|
# open back-office for everybody as long as the application is not claimed
|
||||||
sign_in(Account.order_by(:created_at).first)
|
sign_in(Account.order_by(:created_at).first)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
17
public/javascripts/admin/installation.js
Normal file
17
public/javascripts/admin/installation.js
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
$(document).ready(function() {
|
||||||
|
|
||||||
|
$('#default_site_template_input label a').click(function(e) {
|
||||||
|
$('#default_site_template_input input[type=checkbox]').attr('checked', '');
|
||||||
|
$('#default_site_template_input').hide();
|
||||||
|
$('#zipfile_input').show();
|
||||||
|
e.preventDefault();
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#zipfile_input p.inline-hints a').click(function(e) {
|
||||||
|
$('#default_site_template_input input[type=checkbox]').attr('checked', 'checked');
|
||||||
|
$('#zipfile_input').hide();
|
||||||
|
$('#default_site_template_input').show();
|
||||||
|
e.preventDefault();
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
@ -4,20 +4,20 @@
|
|||||||
color: #222;
|
color: #222;
|
||||||
}
|
}
|
||||||
|
|
||||||
#panel .inner p.explanations {
|
#panel .inner a {
|
||||||
margin-top: 10px;
|
|
||||||
font-size: 1.2em;
|
|
||||||
}
|
|
||||||
|
|
||||||
#panel .inner p.explanations a {
|
|
||||||
color: #1F82BC;
|
color: #1F82BC;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
#panel .inner p.explanations a:hover {
|
#panel .inner a:hover {
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#panel .inner p.explanations {
|
||||||
|
margin-top: 10px;
|
||||||
|
font-size: 1.2em;
|
||||||
|
}
|
||||||
|
|
||||||
#panel .inner p.done {
|
#panel .inner p.done {
|
||||||
margin: 20px 0px 15px;
|
margin: 20px 0px 15px;
|
||||||
font-size: 1.2em;
|
font-size: 1.2em;
|
||||||
@ -45,6 +45,18 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
#panel .inner dd p {
|
#panel .inner dd p {
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ___ custom ___ */
|
||||||
|
|
||||||
|
#panel fieldset ol li.question input[type=checkbox] {
|
||||||
|
display: inline;
|
||||||
|
width: auto;
|
||||||
|
margin-right: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#panel fieldset ol li.question label {
|
||||||
|
display: inline;
|
||||||
|
font-weight: normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user