allows to disable import sub tasks + new images tag logic (in progress) + handle errors when importing

This commit is contained in:
dinedine 2010-09-28 10:09:49 +02:00
parent e31012f861
commit a5ea70229c
8 changed files with 46 additions and 27 deletions

View File

@ -1,12 +1,12 @@
GIT
remote: git://github.com/locomotivecms/custom_fields.git
revision: 89c4d7d21efa4c4715c0e34edcc9ce22c405dcd4
revision: 89c4d7d
specs:
custom_fields (0.0.0.2)
GIT
remote: git://github.com/locomotivecms/liquid.git
revision: b03cdc289ac36c3395459e295c6bf90baa06d256
revision: b03cdc2
ref: b03cdc289ac36c339545
specs:
liquid (2.1.3)
@ -126,7 +126,7 @@ GEM
rack (1.2.1)
rack-mount (0.6.13)
rack (>= 1.0.0)
rack-test (0.5.5)
rack-test (0.5.6)
rack (>= 1.0)
rails (3.0.0)
actionmailer (= 3.0.0)
@ -149,7 +149,7 @@ GEM
rubyforge (2.0.4)
json_pure (>= 1.1.7)
rubyzip (0.9.4)
thor (0.14.1)
thor (0.14.2)
treetop (1.4.8)
polyglot (>= 0.3.1)
tzinfo (0.3.23)

View File

@ -1,7 +1,7 @@
%h1
- if current_admin.sites.size > 1
= 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'
- else
= link_to current_site.name, admin_root_url, :class => 'single'

View File

@ -26,10 +26,10 @@ x create a repo for a tool "a la" vision
- snippet dependencies => do not work correctly
- images tag to write
- import tool:
- disable sub tasks by passing options
- select field (see custom fields and nocoffee theme) ?
- exceptions
- page to import theme
x select field (see custom fields and nocoffee theme) ?
- disable sub tasks by passing options
- exceptions
- page to import theme
- refactor slugify method (use parameterize + create a module)
- [content types] the "display column" selector should not include file types

View File

@ -4,12 +4,12 @@ module Locomotive
module Import
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)
@theme_file = theme_file
@site = site
@options = Hash.new(true).merge(options)
@enabled = Hash.new(true).merge(enabled)
end
def perform
@ -20,18 +20,32 @@ module Locomotive
context = {
:database => @database,
:site => @site,
:theme_path => @theme_path
:theme_path => @theme_path,
:error => nil
}
Locomotive::Import::Site.process(context)
Locomotive::Import::ContentTypes.process(context)
begin
%w(site content_types assets snippets pages).each do |part|
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::Snippets.process(context)
Locomotive::Import::Pages.process(context)
#
# Locomotive::Import::Snippets.process(context)
#
# Locomotive::Import::Pages.process(context)
end
protected

View File

@ -8,8 +8,9 @@ module Locomotive
end
def before_method(meth)
asset = @site.theme_assets.where(:content_type => 'javascript', :slug => meth.to_s).first
!asset.nil? ? asset.source.url : nil
@context.registers[:theme_uploader].store_path(meth.gsub('__', '.'))
# asset = @site.theme_assets.where(:content_type => 'javascript', :slug => meth.to_s).first
# !asset.nil? ? asset.source.url : nil
end
end

View File

@ -8,8 +8,9 @@ module Locomotive
end
def before_method(meth)
asset = @site.theme_assets.where(:content_type => 'stylesheet', :slug => meth.to_s).first
!asset.nil? ? asset.source.url : nil
@context.registers[:theme_uploader].store_path(meth.gsub('__', '.'))
# asset = @site.theme_assets.where(:content_type => 'stylesheet', :slug => meth.to_s).first
# !asset.nil? ? asset.source.url : nil
end
end

View File

@ -8,8 +8,10 @@ module Locomotive
end
def before_method(meth)
asset = @site.theme_assets.where(:content_type => 'image', :slug => meth.to_s).first
!asset.nil? ? asset.source.url : nil
@context.registers[:theme_uploader].store_path(meth.gsub('__', '.'))
# 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

View File

@ -71,6 +71,7 @@ module Locomotive
:site => current_site,
:page => @page,
:inline_editor => self.editing_page?,
:theme_uploader => ThemeAssetUploader.new(current_site.theme_assets.build),
:current_admin => current_admin
}