public
Fork of halorgium/mephisto
Description: A mirror of the mephisto code-base
Homepage: http://mephistoblog.com/
Clone URL: git://github.com/technoweenie/mephisto.git
Click here to lend your support to: mephisto and make a donation at www.pledgie.com !
EXPERIMENTAL multi-site support for mephisto

git-svn-id: http://svn.techno-weenie.net/projects/mephisto/trunk@1046 
567b1171-46fb-0310-a4c9-b4bef9110e78
technoweenie (author)
Mon Apr 03 22:19:44 -0700 2006
commit  e30b05e4c54c8a033ed8970caf1d83b19b1210f5
tree    44406c8fdb9b801df7ad1a630f0d01195ea6e89a
parent  05198d01aa48c659c9eee8a491b5983b47cf7a9a
...
1
2
 
3
4
5
...
1
 
2
3
4
5
0
@@ -1,5 +1,5 @@
0
 class TemplateSweeper < ActionController::Caching::Sweeper
0
- observe Template, LayoutTemplate
0
+ observe Template
0
 
0
   # only sweep updates, not creations
0
   # tagged 'lame hack'
...
9
10
11
12
13
14
 
 
 
15
16
17
18
19
20
21
 
22
23
24
 
25
26
27
28
 
29
30
31
32
 
33
34
35
36
37
 
 
 
 
 
38
39
40
...
44
45
46
47
 
48
49
50
51
 
52
53
54
55
56
57
 
58
59
60
...
72
73
74
75
 
76
77
78
79
80
81
 
 
82
83
84
85
 
86
87
88
89
90
91
 
92
93
94
...
9
10
11
 
 
 
12
13
14
15
16
17
18
19
20
 
21
22
23
 
24
25
26
27
 
28
29
30
31
 
32
33
34
35
36
 
37
38
39
40
41
42
43
44
...
48
49
50
 
51
52
53
54
 
55
56
57
58
59
60
 
61
62
63
64
...
76
77
78
 
79
80
81
82
83
 
 
84
85
86
87
88
 
89
90
91
92
93
94
95
96
97
98
99
0
@@ -9,32 +9,36 @@ class Admin::ArticlesController < Admin::BaseController
0
   before_filter :load_sections, :only => [:new, :edit, :draft]
0
 
0
   def index
0
- @drafts = Article::Draft.find_new
0
- @article_pages = Paginator.new self, Article.count, 30, params[:page]
0
- @articles = Article.find(:all, :order => 'contents.created_at DESC',
0
+ @drafts = site.drafts.find_new
0
+ @article_pages = Paginator.new self, site.articles.count, 30, params[:page]
0
+ @articles = site.articles.find(:all, :order => 'contents.created_at DESC',
0
                        :include => [:user, :draft],
0
                        :limit => @article_pages.items_per_page,
0
                        :offset => @article_pages.current.offset)
0
   end
0
 
0
   def show
0
- @article = Article.find_by_id(params[:id], :include => :comments)
0
+ @article = site.articles.find_by_id(params[:id], :include => :comments)
0
     @comments = @article.comments.collect { |c| c.to_liquid }
0
     @article = @article.to_liquid(:single)
0
- render :text => Template.render_liquid_for(:single, 'articles' => [@article], 'article' => @article, 'comments' => @comments, 'site' => current_site.to_liquid)
0
+ render :text => Template.render_liquid_for(:single, 'articles' => [@article], 'article' => @article, 'comments' => @comments, 'site' => site.to_liquid)
0
   end
0
 
0
   def new
0
- @article = Article.new
0
+ @article = site.articles.build
0
   end
0
 
0
   def edit
0
- @article = Article.find(params[:id], :include => :draft)
0
+ @article = site.articles.find(params[:id], :include => :draft)
0
     @version = params[:version] ? @article.find_version(params[:version]) : @article
0
   end
0
 
0
   def create
0
- @article = current_user.articles.create params[:article].merge(:updater => current_user, :draft => Article::Draft.find_by_id(params[:draft]))
0
+ @article = current_user.articles.create params[:article].merge(
0
+ :updater => current_user,
0
+ :draft => Article::Draft.find_by_id(params[:draft]),
0
+ :site => site)
0
+
0
     if @article.new_record?
0
       load_sections
0
       render :action => 'new'
0
@@ -44,17 +48,17 @@ class Admin::ArticlesController < Admin::BaseController
0
   end
0
   
0
   def update
0
- @article = Article.find(params[:id])
0
+ @article = site.articles.find(params[:id])
0
     if @article.update_attributes(params[:article].merge(:updater => current_user))
0
       redirect_to :action => 'index'
0
     else
0
- @sections = Section.find :all
0
+ @sections = site.sections
0
       render :action => 'edit'
0
     end
0
   end
0
 
0
   def draft
0
- @draft = Article::Draft.find(params[:id], :include => :article)
0
+ @draft = site.drafts.find(params[:id], :include => :article)
0
     @article = @draft.to_article
0
     render :action => (@article.new_record? ? :new : :edit)
0
   end
0
@@ -72,23 +76,24 @@ class Admin::ArticlesController < Admin::BaseController
0
   end
0
 
0
   def update_draft
0
- @article = Article.find(params[:id])
0
+ @article = site.articles.find(params[:id])
0
     @article.attributes = params[:article]
0
   end
0
 
0
   def create_draft
0
- @article = Article.new(params[:article])
0
- @article.draft = Article::Draft.find(params[:draft]) if params[:draft]
0
+ @article = site.articles.build(params[:article])
0
+ @article.draft = site.drafts.find(params[:draft]) if params[:draft]
0
   end
0
 
0
   def load_sections
0
- @sections = Section.find :all, :order => 'name'
0
+ @sections = site.sections.find :all, :order => 'name'
0
     home = @sections.find { |s| s.name == 'home' }
0
     @sections.delete home
0
     @sections.unshift home
0
   end
0
 
0
   def set_default_section_ids
0
+ params[:article] ||= {}
0
     params[:article][:section_ids] ||= []
0
   end
0
 
...
3
4
5
6
 
7
8
9
...
3
4
5
 
6
7
8
9
0
@@ -3,7 +3,7 @@ class Admin::BaseController < ApplicationController
0
   before_filter :login_required, :except => :feed
0
 
0
   def find_templates_and_resources!
0
- @resources, @templates = Theme.find_current.partition do |asset|
0
+ @resources, @templates = site.attachments.find_theme_files.partition do |asset|
0
       asset.is_a?(Resource)
0
     end
0
     @resources = @resources.sort_by { |r| r.full_path }
...
4
5
6
7
 
8
9
10
11
12
13
 
14
15
 
16
17
 
18
19
20
...
4
5
6
 
7
8
9
10
11
12
 
13
14
 
15
16
 
17
18
19
20
0
@@ -4,17 +4,17 @@ class Admin::DesignController < Admin::BaseController
0
   before_filter :find_templates_and_resources!
0
 
0
   def index
0
- @resource = Resource.new
0
+ @resource = site.resources.build
0
   end
0
 
0
   def create
0
     @resource = case params[:resource_type]
0
       when /css/i
0
- Resource.create params[:resource].merge(:content_type => 'text/css')
0
+ site.resources.create params[:resource].merge(:content_type => 'text/css')
0
       when /javascript/i
0
- Resource.create params[:resource].merge(:content_type => 'text/javascript')
0
+ site.resources.create params[:resource].merge(:content_type => 'text/javascript')
0
       else
0
- Template.create params[:resource]
0
+ site.templates.create params[:resource]
0
     end
0
 
0
     if @resource.new_record?
...
1
2
3
4
5
6
...
1
2
 
3
4
5
0
@@ -1,6 +1,5 @@
0
 class Admin::OverviewController < Admin::BaseController
0
   session :off, :only => :feed
0
- before_filter :current_site
0
   before_filter :basic_auth_required, :only => :feed
0
   caches_page :feed
0
   
...
26
27
28
29
 
30
31
32
...
26
27
28
 
29
30
31
32
0
@@ -26,7 +26,7 @@ class Admin::ResourcesController < Admin::BaseController
0
   end
0
 
0
   def upload
0
- @resource = Resource.new params[:resource]
0
+ @resource = site.resources.build params[:resource]
0
     if @resource.image? and @resource.save
0
       flash[:notice] = "'#{@resource.filename}' was uploaded successfully."
0
     else
...
6
7
8
9
 
10
11
12
13
 
14
15
16
...
35
36
37
38
 
39
40
41
42
43
 
 
44
45
46
...
50
51
52
53
 
54
55
56
...
6
7
8
 
9
10
11
12
 
13
14
15
16
...
35
36
37
 
38
39
40
41
 
 
42
43
44
45
46
...
50
51
52
 
53
54
55
56
0
@@ -6,11 +6,11 @@ class Admin::SectionsController < Admin::BaseController
0
   before_filter :preprocess_section_params, :only => [:create, :update]
0
 
0
   def index
0
- @section = Section.new
0
+ @section = site.sections.build
0
   end
0
 
0
   def create
0
- @section = Section.create(params[:section])
0
+ @section = site.sections.create(params[:section])
0
   end
0
 
0
   def destroy
0
@@ -35,12 +35,12 @@ class Admin::SectionsController < Admin::BaseController
0
 
0
   protected
0
   def find_and_sort_templates
0
- @layouts, @templates = Template.find_custom.partition { |t| t.layout? }
0
+ @layouts, @templates = site.templates.find_custom.partition { |t| t.layout? }
0
   end
0
 
0
   def find_and_reorder_sections
0
- @article_count = Section.articles_count
0
- @sections = Section.find :all
0
+ @article_count = site.sections.articles_count
0
+ @sections = site.sections.find :all
0
     @sections.each do |s|
0
       @home = s if s.name.downcase == 'home'
0
       @section = s if params[:id].to_s == s.id.to_s
0
@@ -50,7 +50,7 @@ class Admin::SectionsController < Admin::BaseController
0
   end
0
 
0
   def find_section
0
- @section = Section.find params[:id]
0
+ @section = site.sections.find params[:id]
0
   end
0
 
0
   def preprocess_section_params
...
1
2
 
 
3
4
 
5
6
7
...
1
 
2
3
4
 
5
6
7
8
0
@@ -1,7 +1,8 @@
0
 class Admin::SettingsController < Admin::BaseController
0
- before_filter :current_site
0
+ before_filter :site
0
+
0
   def update
0
- if current_site.update_attributes params[:current_site]
0
+ if site.update_attributes params[:site]
0
       redirect_to :action => 'index'
0
     else
0
       render :action => 'index'
...
29
30
31
32
 
33
34
...
29
30
31
 
32
33
34
0
@@ -29,6 +29,6 @@ class Admin::TemplatesController < Admin::BaseController
0
   # Create system template if it does not exist
0
   def select_template
0
     @tmpl = @templates.detect { |t| t.filename == params[:id] }
0
- @tmpl ||= Template.find_or_create_by_filename(params[:id]) if Template.template_types.include?(params[:id].to_sym)
0
+ @tmpl ||= site.templates.find_or_create_by_filename(params[:id]) if Template.template_types.include?(params[:id].to_sym)
0
   end
0
 end
...
1
2
3
4
5
6
 
 
 
 
 
 
7
8
9
...
14
15
16
17
18
 
 
19
 
 
 
 
 
20
21
...
1
2
3
 
 
 
4
5
6
7
8
9
10
11
12
...
17
18
19
 
 
20
21
22
23
24
25
26
27
28
29
0
@@ -1,9 +1,12 @@
0
 # Filters added to this controller will be run for all controllers in the application.
0
 # Likewise, all the methods added will be available for all controllers.
0
 class ApplicationController < ActionController::Base
0
- helper_method :current_site
0
- def current_site
0
- @current_site ||= Site.find :first
0
+ before_filter :set_cache_root
0
+ helper_method :site
0
+
0
+ def site
0
+ # Redefine this method if you wish to fail on host without a site
0
+ @site ||= Site.find_by_host(request.host) || Site.find(:first)
0
   end
0
 
0
   def render_liquid_template_for(template_type, assigns = {})
0
@@ -14,7 +17,12 @@ class ApplicationController < ActionController::Base
0
       assigns['articles'] = assigns['articles'].collect { |a| a.to_liquid }
0
     end
0
     
0
- assigns.update 'site' => current_site.to_liquid
0
- render :text => Template.render_liquid_for(template_type, assigns)
0
+ assigns.update 'site' => site.to_liquid
0
+ render :text => site.templates.render_liquid_for(template_type, assigns)
0
   end
0
+
0
+ protected
0
+ def set_cache_root
0
+ self.class.page_cache_directory = File.join([RAILS_ROOT, (RAILS_ENV == 'test' ? 'tmp' : 'public'), 'cache', site.host].compact)
0
+ end
0
 end
0
\ No newline at end of file
...
3
4
5
6
 
7
8
9
...
3
4
5
 
6
7
8
9
0
@@ -3,7 +3,7 @@ class CommentsController < ApplicationController
0
   verify :params => [:year, :month, :day, :permalink], :redirect_to => { :controller => 'mephisto', :action => 'list', :sections => [] }
0
 
0
   def create
0
- @article = Article.find_by_permalink(params[:year], params[:month], params[:day], params[:permalink])
0
+ @article = site.articles.find_by_permalink(params[:year], params[:month], params[:day], params[:permalink])
0
     
0
     redirect_to(section_url(:sections => [])) and return unless @article
0
     if request.get? or params[:comment].blank?
...
8
9
10
11
 
12
13
14
...
8
9
10
 
11
12
13
14
0
@@ -8,7 +8,7 @@ class FeedController < ApplicationController
0
     last = sections.last
0
     sections.delete(last) if last =~ /\.xml$/
0
     
0
- @section = Section.find_by_name(sections.blank? ? 'home' : sections.join('/'))
0
+ @section = site.sections.find_by_name(sections.blank? ? 'home' : sections.join('/'))
0
     @articles = @section.articles.find_by_date(:limit => 15)
0
     self.cached_references += @articles
0
   end
...
4
5
6
7
 
8
9
10
 
 
11
12
13
...
15
16
17
18
19
 
 
20
21
22
...
27
28
29
30
 
31
32
33
...
35
36
37
38
 
39
40
41
42
43
 
44
45
 
46
47
48
...
4
5
6
 
7
8
 
 
9
10
11
12
13
...
15
16
17
 
 
18
19
20
21
22
...
27
28
29
 
30
31
32
33
...
35
36
37
 
38
39
40
41
42
 
43
44
 
45
46
47
48
0
@@ -4,10 +4,10 @@ class MephistoController < ApplicationController
0
 
0
   def list
0
     if params[:sections].blank?
0
- @section = Section.find_by_name('home')
0
+ @section = site.sections.find_by_name('home')
0
       list_section_articles_with(:main)
0
- else
0
- @section, page_name = Section.find_section_and_page_name(params[:sections])
0
+ else
0
+ @section, page_name = site.sections.find_section_and_page_name(params[:sections])
0
       @section.show_paged_articles? ? show_section_page_with(page_name, :page) : list_section_articles_with(:section)
0
     end
0
   end
0
@@ -15,8 +15,8 @@ class MephistoController < ApplicationController
0
   def search
0
     conditions = ['published_at <= :now AND title LIKE :q OR excerpt LIKE :q OR body LIKE :q',
0
                      { :now => Time.now.utc, :q => "%#{params[:q]}%" }]
0
- @article_pages = Paginator.new self, Article.count(conditions), 15, params[:page]
0
- @articles = Article.find(:all, :conditions => conditions, :order => 'published_at DESC',
0
+ @article_pages = Paginator.new self, site.articles.count(conditions), 15, params[:page]
0
+ @articles = site.articles.find(:all, :conditions => conditions, :order => 'published_at DESC',
0
                        :include => [:user, :sections],
0
                        :limit => @article_pages.items_per_page,
0
                        :offset => @article_pages.current.offset)
0
@@ -27,7 +27,7 @@ class MephistoController < ApplicationController
0
   end
0
 
0
   def show
0
- @article = Article.find_by_permalink(params[:year], params[:month], params[:day], params[:permalink])
0
+ @article = site.articles.find_by_permalink(params[:year], params[:month], params[:day], params[:permalink])
0
     @comments = @article.comments.collect { |c| c.to_liquid }
0
     self.cached_references << @article
0
     @article = @article.to_liquid(:single)
0
@@ -35,14 +35,14 @@ class MephistoController < ApplicationController
0
   end
0
 
0
   def day
0
- @articles = Article.find_all_by_published_date(params[:year], params[:month], params[:day], :include => [:user, :sections])
0
+ @articles = site.articles.find_all_by_published_date(params[:year], params[:month], params[:day], :include => [:user, :sections])
0
     render_liquid_template_for(:archive, 'articles' => @articles)
0
   end
0
 
0
   def month
0
- count = Article.count_by_published_date(params[:year], params[:month], params[:day])
0
+ count = site.articles.count_by_published_date(params[:year], params[:month], params[:day])
0
     @article_pages = Paginator.new self, count, 15, params[:page]
0
- @articles = Article.find_all_by_published_date(params[:year], params[:month], params[:day],
0
+ @articles = site.articles.find_all_by_published_date(params[:year], params[:month], params[:day],
0
                   :include => [:user, :sections],
0
                   :limit => @article_pages.items_per_page,
0
                   :offset => @article_pages.current.offset)
...
56
57
58
59
 
60
61
62
...
56
57
58
 
59
60
61
62
0
@@ -56,7 +56,7 @@ class Article < Content
0
   end
0
 
0
   def has_section?(section)
0
- (new_record? and section.name == 'home') or sections.include? section
0
+ (new_record? && section.name == 'home') || sections.include?(section)
0
   end
0
 
0
   def section_ids=(new_sections)
...
3
4
5
6
7
 
8
...
3
4
5
 
 
6
7
0
@@ -3,6 +3,5 @@
0
 # If it's a User Asset, it's a profile image.
0
 # Template and Resource inherit from Asset but serve different purposes.
0
 class Asset < Attachment
0
- validates_presence_of :attachable_id, :attachable_type
0
- belongs_to :attachable, :polymorphic => true
0
+ include ActsAsAttachable
0
 end
...
1
2
3
4
 
5
6
7
...
33
34
35
36
 
 
 
37
38
39
...
1
2
3
 
4
5
6
7
...
33
34
35
 
36
37
38
39
40
41
0
@@ -1,7 +1,7 @@
0
 # Base file attachment method
0
 class Attachment < ActiveRecord::Base
0
   before_validation :sanitize_path_if_available
0
- validates_uniqueness_of :filename, :scope => :path
0
+ validates_uniqueness_of :filename, :scope => [:path, :site_id]
0
   acts_as_attachment
0
 
0
   class << self
0
@@ -33,7 +33,9 @@ class Attachment < ActiveRecord::Base
0
 
0
   module TemplateAndResourceMixin
0
     def self.included(base)
0
- base.validate :path_exists_and_valid?
0
+ base.belongs_to :site
0
+ base.validates_presence_of :site
0
+ base.validate :path_exists_and_valid?
0
     end
0
 
0
     protected
...
1
2
3
 
 
 
 
 
 
4
5
6
...
 
 
 
1
2
3
4
5
6
7
8
9
0
@@ -1,6 +1,9 @@
0
-class Avatar < Asset
0
- after_validation :set_path_and_filename
0
- acts_as_attachment :content_type => :image, :resize_to => '75x75>'
0
+class Avatar < Attachment
0
+ include ActsAsAttachable
0
+
0
+ validates_presence_of :attachable_id, :attachable_type
0
+ after_validation :set_path_and_filename
0
+ acts_as_attachment :content_type => :image, :resize_to => '75x75>'
0
 
0
   protected
0
   def set_path_and_filename
...
2
3
4
 
5
6
...
2
3
4
5
6
7
0
@@ -2,4 +2,5 @@ class Content < ActiveRecord::Base
0
   filtered_column :body, :excerpt, :only => :textile_filter
0
   validates_presence_of :body
0
   belongs_to :user
0
+ belongs_to :site
0
 end
0
\ No newline at end of file
...
1
2
3
 
4
5
6
...
1
2
3
4
5
6
7
0
@@ -1,6 +1,7 @@
0
 class Section < ActiveRecord::Base
0
   ARTICLES_COUNT_SQL = 'INNER JOIN assigned_sections ON contents.id = assigned_sections.article_id INNER JOIN sections ON sections.id = assigned_sections.section_id' unless defined?(ARTICLES_COUNT)
0
   validates_presence_of :name
0
+ belongs_to :site
0
   has_many :assigned_sections, :dependent => :delete_all
0
   has_many :articles, :order => 'position', :through => :assigned_sections do
0
     def find_by_date(options = {})
...
1
 
 
 
 
2
 
 
 
 
3
 
 
4
5
6
...
9
10
11
12
 
 
13
14
15
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
...
19
20
21
 
22
23
24
25
26
0
@@ -1,6 +1,16 @@
0
 class Site < ActiveRecord::Base
0
+ has_many :sections
0
+ has_many :articles
0
+ has_many :drafts, :class_name => 'Article::Draft'
0
+
0
   has_many :assets, :as => :attachable
0
+ has_many :templates
0
+ has_many :resources
0
+ has_many :attachments, :extend => Theme
0
+
0
   serialize :filters, Array
0
+
0
+ validates_uniqueness_of :host
0
 
0
   def filters=(value)
0
     write_attribute :filters, [value].flatten.collect(&:to_sym)
0
@@ -9,7 +19,8 @@ class Site < ActiveRecord::Base
0
   def to_liquid
0
     {
0
       'title' => title,
0
- 'subtitle' => subtitle
0
+ 'subtitle' => subtitle,
0
+ 'host' => host
0
     }
0
   end
0
 end
...
15
16
17
18
19
20
 
21
22
23
24
 
25
26
27
...
44
45
46
47
 
48
49
50
...
53
54
55
56
 
57
58
59
...
15
16
17
 
18
 
19
20
21
22
 
23
24
25
26
...
43
44
45
 
46
47
48
49
...
52
53
54
 
55
56
57
58
0
@@ -15,13 +15,12 @@ class Template < Attachment
0
     :author => [:author, :archive, :index],
0
     :error => [:error, :index]
0
   }
0
- @@template_classes = %w(Template LayoutTemplate)
0
   @@template_types = @@hierarchy.values.flatten.uniq << :layout
0
- cattr_reader :hierarchy, :template_types, :template_classes
0
+ cattr_reader :hierarchy, :template_types
0
 
0
   class << self
0
     def find_all_by_filename(template_type)
0
- Attachment.find_with_data(:all, :conditions => ['filename IN (?) AND type IN (?)', (hierarchy[template_type] + [:layout]).collect { |v| v.to_s }, template_classes])
0
+ find_with_data(:all, :conditions => ["filename IN (?)", (hierarchy[template_type] + [:layout]).collect { |v| v.to_s }])
0
     end
0
 
0
     def templates_for(template_type)
0
@@ -44,7 +43,7 @@ class Template < Attachment
0
     end
0
 
0
     def find_custom
0
- Attachment.find(:all, :conditions => ['type IN (?) AND filename NOT IN (?)', template_classes, template_types.map(&:to_s)])
0
+ find(:all, :conditions => ['filename NOT IN (?)', template_types.map(&:to_s)])
0
     end
0
   end
0
 
0
@@ -53,7 +52,7 @@ class Template < Attachment
0
   end
0
 
0
   def layout?
0
- false
0
+ filename.to_s =~ /layout$/
0
   end
0
 
0
   def to_param
...
1
2
3
4
5
 
 
 
 
6
7
8
9
10
11
12
 
 
 
 
 
13
 
14
15
16
17
18
19
 
 
 
 
 
20
21
22
23
24
25
26
27
28
29
 
 
 
 
 
 
30
 
31
32
33
34
...
 
 
 
 
 
1
2
3
4
5
 
 
 
 
 
 
6
7
8
9
10
11
12
13
 
 
 
 
 
14
15
16
17
18
19
 
 
 
 
 
 
 
 
 
20
21
22
23
24
25
26
27
28
29
30
31
0
@@ -1,33 +1,30 @@
0
-class Theme
0
- class << self
0
- def find_current(options = {})
0
- Attachment.find(:all, {:conditions => ['attachments.type in (?)', %w(Resource Template LayoutTemplate)], :order => 'attachments.filename'}.merge(options))
0
- end
0
+module Theme
0
+ def find_theme_files(options = {})
0
+ find(:all, {:conditions => ['attachments.type in (?)', %w(Resource Template)], :order => 'attachments.filename'}.merge(options))
0
+ end
0
 
0
- def export_as_zip(name, options = {})
0
- path = options[:to] || '.'
0
- Zip::ZipFile.open(File.join(path, "#{name}.zip"), Zip::ZipFile::CREATE) do |zip|
0
- %w(templates layouts javascripts stylesheets images).each { |d| zip.dir.mkdir(d) }
0
- write_files_with zip.file
0
- end
0
+ def export_as_zip(name, options = {})
0
+ path = options[:to] || '.'
0
+ Zip::ZipFile.open(File.join(path, "#{name}.zip"), Zip::ZipFile::CREATE) do |zip|
0
+ %w(templates layouts javascripts stylesheets images).each { |d| zip.dir.mkdir(d) }
0
+ write_files_with zip.file
0
     end
0
+ end
0
 
0
- def export(name, options = {})
0
- path = File.join(options[:to] || '.', name)
0
- %w(templates layouts javascripts stylesheets images).each { |d| FileUtils.mkdir_p File.join(path, d) }
0
- write_files_with File, path
0
- end
0
+ def export(name, options = {})
0
+ path = File.join(options[:to] || '.', name)
0
+ %w(templates layouts javascripts stylesheets images).each { |d| FileUtils.mkdir_p File.join(path, d) }
0
+ write_files_with File, path
0
+ end
0
 
0
- private
0
- def write_files_with(file_object, path = '')
0
- find_current.each do |file|
0
- filename = case file
0
- when Resource then file.full_path
0
- when LayoutTemplate then File.join('layouts', file.file