allows to disable import sub tasks + new images tag logic (in progress) + handle errors when importing
This commit is contained in:
parent
e31012f861
commit
a5ea70229c
@ -1,12 +1,12 @@
|
|||||||
GIT
|
GIT
|
||||||
remote: git://github.com/locomotivecms/custom_fields.git
|
remote: git://github.com/locomotivecms/custom_fields.git
|
||||||
revision: 89c4d7d21efa4c4715c0e34edcc9ce22c405dcd4
|
revision: 89c4d7d
|
||||||
specs:
|
specs:
|
||||||
custom_fields (0.0.0.2)
|
custom_fields (0.0.0.2)
|
||||||
|
|
||||||
GIT
|
GIT
|
||||||
remote: git://github.com/locomotivecms/liquid.git
|
remote: git://github.com/locomotivecms/liquid.git
|
||||||
revision: b03cdc289ac36c3395459e295c6bf90baa06d256
|
revision: b03cdc2
|
||||||
ref: b03cdc289ac36c339545
|
ref: b03cdc289ac36c339545
|
||||||
specs:
|
specs:
|
||||||
liquid (2.1.3)
|
liquid (2.1.3)
|
||||||
@ -126,7 +126,7 @@ GEM
|
|||||||
rack (1.2.1)
|
rack (1.2.1)
|
||||||
rack-mount (0.6.13)
|
rack-mount (0.6.13)
|
||||||
rack (>= 1.0.0)
|
rack (>= 1.0.0)
|
||||||
rack-test (0.5.5)
|
rack-test (0.5.6)
|
||||||
rack (>= 1.0)
|
rack (>= 1.0)
|
||||||
rails (3.0.0)
|
rails (3.0.0)
|
||||||
actionmailer (= 3.0.0)
|
actionmailer (= 3.0.0)
|
||||||
@ -149,7 +149,7 @@ GEM
|
|||||||
rubyforge (2.0.4)
|
rubyforge (2.0.4)
|
||||||
json_pure (>= 1.1.7)
|
json_pure (>= 1.1.7)
|
||||||
rubyzip (0.9.4)
|
rubyzip (0.9.4)
|
||||||
thor (0.14.1)
|
thor (0.14.2)
|
||||||
treetop (1.4.8)
|
treetop (1.4.8)
|
||||||
polyglot (>= 0.3.1)
|
polyglot (>= 0.3.1)
|
||||||
tzinfo (0.3.23)
|
tzinfo (0.3.23)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
%h1
|
%h1
|
||||||
- if current_admin.sites.size > 1
|
- if current_admin.sites.size > 1
|
||||||
= form_tag new_admin_cross_domain_session_url, :method => 'get' do
|
= form_tag new_admin_cross_domain_session_url, :method => 'get' do
|
||||||
= select_tag 'target_id', options_for_select(current_admin.sites.collect { |site| [site.name, site.id] }, current_site.id), :id => 'site-selector'
|
= select_tag 'target_id', options_for_select(current_admin.sites.collect { |site| [truncate(site.name, :length => 23), site.id] }, current_site.id), :id => 'site-selector'
|
||||||
= submit_tag 'Switch', :style => 'display: none'
|
= submit_tag 'Switch', :style => 'display: none'
|
||||||
- else
|
- else
|
||||||
= link_to current_site.name, admin_root_url, :class => 'single'
|
= link_to current_site.name, admin_root_url, :class => 'single'
|
||||||
|
8
doc/TODO
8
doc/TODO
@ -26,10 +26,10 @@ x create a repo for a tool "a la" vision
|
|||||||
- snippet dependencies => do not work correctly
|
- snippet dependencies => do not work correctly
|
||||||
- images tag to write
|
- images tag to write
|
||||||
- import tool:
|
- import tool:
|
||||||
- disable sub tasks by passing options
|
x select field (see custom fields and nocoffee theme) ?
|
||||||
- select field (see custom fields and nocoffee theme) ?
|
- disable sub tasks by passing options
|
||||||
- exceptions
|
- exceptions
|
||||||
- page to import theme
|
- page to import theme
|
||||||
|
|
||||||
- refactor slugify method (use parameterize + create a module)
|
- refactor slugify method (use parameterize + create a module)
|
||||||
- [content types] the "display column" selector should not include file types
|
- [content types] the "display column" selector should not include file types
|
||||||
|
@ -4,12 +4,12 @@ module Locomotive
|
|||||||
module Import
|
module Import
|
||||||
class Job
|
class Job
|
||||||
|
|
||||||
def initialize(theme_file, site = nil, options = {})
|
def initialize(theme_file, site = nil, enabled = {})
|
||||||
raise "Theme zipfile not found" unless File.exists?(theme_file)
|
raise "Theme zipfile not found" unless File.exists?(theme_file)
|
||||||
|
|
||||||
@theme_file = theme_file
|
@theme_file = theme_file
|
||||||
@site = site
|
@site = site
|
||||||
@options = Hash.new(true).merge(options)
|
@enabled = Hash.new(true).merge(enabled)
|
||||||
end
|
end
|
||||||
|
|
||||||
def perform
|
def perform
|
||||||
@ -20,18 +20,32 @@ module Locomotive
|
|||||||
context = {
|
context = {
|
||||||
:database => @database,
|
:database => @database,
|
||||||
:site => @site,
|
:site => @site,
|
||||||
:theme_path => @theme_path
|
:theme_path => @theme_path,
|
||||||
|
:error => nil
|
||||||
}
|
}
|
||||||
|
|
||||||
Locomotive::Import::Site.process(context)
|
begin
|
||||||
|
%w(site content_types assets snippets pages).each do |part|
|
||||||
Locomotive::Import::ContentTypes.process(context)
|
if @enabled[part]
|
||||||
|
"Locomotive::Import::#{part.camelize}".constantize.process(context)
|
||||||
|
else
|
||||||
|
puts "skipping #{part}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
rescue Exception => e
|
||||||
|
context[:error] = e.message
|
||||||
|
end
|
||||||
|
|
||||||
|
context
|
||||||
|
# Locomotive::Import::Site.process(context)
|
||||||
|
#
|
||||||
|
# Locomotive::Import::ContentTypes.process(context)
|
||||||
|
#
|
||||||
# Locomotive::Import::Assets.process(context)
|
# Locomotive::Import::Assets.process(context)
|
||||||
|
#
|
||||||
Locomotive::Import::Snippets.process(context)
|
# Locomotive::Import::Snippets.process(context)
|
||||||
|
#
|
||||||
Locomotive::Import::Pages.process(context)
|
# Locomotive::Import::Pages.process(context)
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
@ -8,8 +8,9 @@ module Locomotive
|
|||||||
end
|
end
|
||||||
|
|
||||||
def before_method(meth)
|
def before_method(meth)
|
||||||
asset = @site.theme_assets.where(:content_type => 'javascript', :slug => meth.to_s).first
|
@context.registers[:theme_uploader].store_path(meth.gsub('__', '.'))
|
||||||
!asset.nil? ? asset.source.url : nil
|
# asset = @site.theme_assets.where(:content_type => 'javascript', :slug => meth.to_s).first
|
||||||
|
# !asset.nil? ? asset.source.url : nil
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -8,8 +8,9 @@ module Locomotive
|
|||||||
end
|
end
|
||||||
|
|
||||||
def before_method(meth)
|
def before_method(meth)
|
||||||
asset = @site.theme_assets.where(:content_type => 'stylesheet', :slug => meth.to_s).first
|
@context.registers[:theme_uploader].store_path(meth.gsub('__', '.'))
|
||||||
!asset.nil? ? asset.source.url : nil
|
# asset = @site.theme_assets.where(:content_type => 'stylesheet', :slug => meth.to_s).first
|
||||||
|
# !asset.nil? ? asset.source.url : nil
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -8,8 +8,10 @@ module Locomotive
|
|||||||
end
|
end
|
||||||
|
|
||||||
def before_method(meth)
|
def before_method(meth)
|
||||||
asset = @site.theme_assets.where(:content_type => 'image', :slug => meth.to_s).first
|
@context.registers[:theme_uploader].store_path(meth.gsub('__', '.'))
|
||||||
!asset.nil? ? asset.source.url : nil
|
# asset = @site.theme_assets.where(:content_type => 'image', :slug => meth.to_s).first
|
||||||
|
# !asset.nil? ? asset.source.url : nil
|
||||||
|
# "sites/#{@site.id}/theme/#{meth.gsub('__', '.')}"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -71,6 +71,7 @@ module Locomotive
|
|||||||
:site => current_site,
|
:site => current_site,
|
||||||
:page => @page,
|
:page => @page,
|
||||||
:inline_editor => self.editing_page?,
|
:inline_editor => self.editing_page?,
|
||||||
|
:theme_uploader => ThemeAssetUploader.new(current_site.theme_assets.build),
|
||||||
:current_admin => current_admin
|
:current_admin => current_admin
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user