comfortable_mexican_sofa 1.8.3 → 1.8.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -1
- data/Gemfile +2 -2
- data/README.md +3 -3
- data/app/assets/stylesheets/comfortable_mexican_sofa/base.css.sass +11 -11
- data/app/assets/stylesheets/comfortable_mexican_sofa/bootstrap_overrides.css.sass +2 -2
- data/app/controllers/cms_admin/base_controller.rb +1 -1
- data/app/controllers/cms_content_controller.rb +1 -1
- data/app/models/cms/block.rb +1 -1
- data/app/models/cms/file.rb +4 -1
- data/config/database.yml +1 -1
- data/db/cms_fixtures/sample-site/categories/files.yml +1 -0
- data/db/cms_fixtures/sample-site/categories/pages.yml +1 -0
- data/db/cms_fixtures/sample-site/categories/snippets.yml +1 -0
- data/db/cms_fixtures/sample-site/files/_sample.jpg.yml +5 -0
- data/db/cms_fixtures/sample-site/files/sample.jpg +0 -0
- data/db/cms_fixtures/sample-site/layouts/default/{_default.yml → attributes.yml} +0 -0
- data/db/cms_fixtures/sample-site/layouts/default/{js.js → javascript.js} +0 -0
- data/db/cms_fixtures/sample-site/layouts/default/nested/{_nested.yml → attributes.yml} +0 -0
- data/db/cms_fixtures/sample-site/layouts/default/nested/{js.js → javascript.js} +0 -0
- data/db/cms_fixtures/sample-site/layouts/default/nested/{css.css → stylesheet.css} +0 -0
- data/db/cms_fixtures/sample-site/layouts/default/{css.css → stylesheet.css} +0 -0
- data/db/cms_fixtures/sample-site/pages/index/attributes.yml +6 -0
- data/db/cms_fixtures/sample-site/pages/index/child/{_child.yml → attributes.yml} +0 -0
- data/db/cms_fixtures/sample-site/snippets/default/attributes.yml +4 -0
- data/lib/comfortable_mexican_sofa.rb +25 -23
- data/lib/comfortable_mexican_sofa/fixture.rb +77 -0
- data/lib/comfortable_mexican_sofa/fixture/category.rb +35 -0
- data/lib/comfortable_mexican_sofa/fixture/file.rb +70 -0
- data/lib/comfortable_mexican_sofa/fixture/layout.rb +90 -0
- data/lib/comfortable_mexican_sofa/fixture/page.rb +122 -0
- data/lib/comfortable_mexican_sofa/fixture/snippet.rb +71 -0
- data/lib/comfortable_mexican_sofa/version.rb +1 -1
- data/lib/tasks/comfortable_mexican_sofa.rake +17 -20
- data/test/fixtures/cms/files.yml +2 -2
- data/test/functional/cms_admin/base_controller_test.rb +1 -1
- data/test/functional/cms_admin/categories_controller_test.rb +1 -1
- data/test/functional/cms_admin/files_controller_test.rb +1 -1
- data/test/functional/cms_admin/layouts_controller_test.rb +1 -1
- data/test/functional/cms_admin/pages_controller_test.rb +1 -1
- data/test/functional/cms_admin/revisions_controller_test.rb +1 -1
- data/test/functional/cms_admin/sites_controller_test.rb +1 -1
- data/test/functional/cms_admin/snippets_controller_test.rb +1 -1
- data/test/functional/cms_content_controller_test.rb +1 -1
- data/test/gemfiles/Gemfile.rails.3.1 +2 -1
- data/test/gemfiles/Gemfile.rails.3.2 +2 -1
- data/test/integration/authentication_test.rb +1 -1
- data/test/integration/fixtures_test.rb +5 -3
- data/test/integration/mirrors_test.rb +1 -1
- data/test/integration/render_cms_test.rb +1 -1
- data/test/integration/sites_test.rb +1 -1
- data/test/integration/view_hooks_test.rb +1 -1
- data/test/test_helper.rb +1 -0
- data/test/unit/configuration_test.rb +1 -1
- data/test/unit/fixtures/_sample.jpg.yml +0 -0
- data/test/unit/fixtures/categories_test.rb +35 -0
- data/test/unit/fixtures/files_test.rb +100 -0
- data/test/unit/fixtures/layouts_test.rb +135 -0
- data/test/unit/fixtures/pages_test.rb +152 -0
- data/test/unit/fixtures/snippets_test.rb +101 -0
- data/test/unit/fixtures_test.rb +11 -325
- data/test/unit/mirrors_test.rb +1 -1
- data/test/unit/models/block_test.rb +1 -1
- data/test/unit/models/categorization_test.rb +1 -1
- data/test/unit/models/category_test.rb +1 -1
- data/test/unit/models/file_test.rb +11 -6
- data/test/unit/models/layout_test.rb +1 -1
- data/test/unit/models/page_test.rb +2 -1
- data/test/unit/models/site_test.rb +1 -1
- data/test/unit/models/snippet_test.rb +1 -1
- data/test/unit/revisions_test.rb +1 -1
- data/test/unit/sitemap_test.rb +1 -1
- data/test/unit/tag_test.rb +1 -1
- data/test/unit/tags/asset_test.rb +1 -1
- data/test/unit/tags/collection_test.rb +1 -1
- data/test/unit/tags/field_datetime_test.rb +1 -1
- data/test/unit/tags/field_integer_test.rb +1 -1
- data/test/unit/tags/field_rich_text_test.rb +1 -1
- data/test/unit/tags/field_string_test.rb +1 -1
- data/test/unit/tags/field_text_test.rb +1 -1
- data/test/unit/tags/file_test.rb +1 -1
- data/test/unit/tags/helper_test.rb +1 -1
- data/test/unit/tags/page_datetime_test.rb +1 -1
- data/test/unit/tags/page_file_test.rb +1 -1
- data/test/unit/tags/page_files_test.rb +1 -1
- data/test/unit/tags/page_integer_test.rb +1 -1
- data/test/unit/tags/page_markdown_test.rb +1 -1
- data/test/unit/tags/page_rich_text_test.rb +1 -1
- data/test/unit/tags/page_string_test.rb +1 -1
- data/test/unit/tags/page_text_test.rb +1 -1
- data/test/unit/tags/partial_test.rb +1 -1
- data/test/unit/tags/snippet_test.rb +1 -1
- data/test/unit/view_methods_test.rb +1 -1
- metadata +28 -12
- data/db/cms_fixtures/sample-site/pages/index/_index.yml +0 -2
- data/db/cms_fixtures/sample-site/snippets/default/_default.yml +0 -1
- data/lib/comfortable_mexican_sofa/fixtures.rb +0 -289
data/.gitignore
CHANGED
data/Gemfile
CHANGED
@@ -6,6 +6,6 @@ group :test do
|
|
6
6
|
gem 'sqlite3', :platform => [:ruby, :mswin, :mingw]
|
7
7
|
gem 'jdbc-sqlite3', :platform => :jruby
|
8
8
|
gem 'activerecord-jdbcsqlite3-adapter', :platform => :jruby
|
9
|
-
|
10
|
-
gem 'coveralls',
|
9
|
+
gem 'mocha', :require => false
|
10
|
+
gem 'coveralls', :require => false
|
11
11
|
end
|
data/README.md
CHANGED
@@ -16,13 +16,13 @@ Features
|
|
16
16
|
|
17
17
|
Installation for Rails 4
|
18
18
|
------------------------
|
19
|
-
For Rails 4 apps feel free to use [2.0.0.beta1](https://github.com/comfy/comfortable-mexican-sofa/tree/
|
19
|
+
For Rails 4 apps feel free to use [2.0.0.beta1](https://github.com/comfy/comfortable-mexican-sofa/tree/1.9) release.
|
20
20
|
|
21
21
|
gem 'comfortable_mexican_sofa', '~> 2.0.0.beta1'
|
22
22
|
|
23
|
-
Or even better work with the latest
|
23
|
+
Or even better work with the latest 1.9 branch:
|
24
24
|
|
25
|
-
gem 'comfortable_mexican_sofa', :github => 'comfy/comfortable-mexican-sofa', :branch => '
|
25
|
+
gem 'comfortable_mexican_sofa', :github => 'comfy/comfortable-mexican-sofa', :branch => '1.9'
|
26
26
|
|
27
27
|
Installation
|
28
28
|
------------
|
@@ -54,7 +54,7 @@ body#comfy
|
|
54
54
|
display: block
|
55
55
|
height: 16px
|
56
56
|
width: 8px
|
57
|
-
background: transparent url("
|
57
|
+
background: transparent url(image-path("comfortable_mexican_sofa/nav_arrow.png"))
|
58
58
|
|
59
59
|
// -- Right Side Boxes ----------------------------------------------------
|
60
60
|
.right-column-content
|
@@ -118,7 +118,7 @@ body#comfy
|
|
118
118
|
height: 60px
|
119
119
|
width: 80px
|
120
120
|
float: left
|
121
|
-
background: url("
|
121
|
+
background: url(image-path("comfortable_mexican_sofa/checkerboard.gif"))
|
122
122
|
.details
|
123
123
|
margin-left: 85px
|
124
124
|
font-size: 11px
|
@@ -136,11 +136,11 @@ body#comfy
|
|
136
136
|
.icon
|
137
137
|
width: 28px
|
138
138
|
height: 28px
|
139
|
-
background: url("
|
139
|
+
background: url(image-path("comfortable_mexican_sofa/icon_page.gif"))
|
140
140
|
.dragger
|
141
141
|
width: 28px
|
142
142
|
height: 28px
|
143
|
-
background: url("
|
143
|
+
background: url(image-path("comfortable_mexican_sofa/icon_move.gif"))
|
144
144
|
cursor: move
|
145
145
|
display: none
|
146
146
|
span
|
@@ -244,18 +244,18 @@ body#comfy
|
|
244
244
|
height: 28px
|
245
245
|
width: 28px
|
246
246
|
&.open a
|
247
|
-
background-image: url("
|
247
|
+
background-image: url(image-path("comfortable_mexican_sofa/arrow_bottom.gif"))
|
248
248
|
a
|
249
249
|
display: block
|
250
250
|
height: 28px
|
251
251
|
width: 28px
|
252
|
-
background: url("
|
252
|
+
background: url(image-path("comfortable_mexican_sofa/arrow_right.gif")) center center no-repeat
|
253
253
|
span
|
254
254
|
display: none
|
255
255
|
.icon
|
256
256
|
float: left
|
257
257
|
&.draft
|
258
|
-
background: url("
|
258
|
+
background: url(image-path("comfortable_mexican_sofa/icon_draft.gif"))
|
259
259
|
.item-content
|
260
260
|
margin-left: 60px
|
261
261
|
a.item-label
|
@@ -269,14 +269,14 @@ body#comfy
|
|
269
269
|
// -- Sites ---------------------------------------------------------------
|
270
270
|
&.c-cms-admin-sites
|
271
271
|
table .icon
|
272
|
-
background: url("
|
272
|
+
background: url(image-path("comfortable_mexican_sofa/icon_site.gif"))
|
273
273
|
|
274
274
|
// -- Layouts -------------------------------------------------------------
|
275
275
|
&.c-cms-admin-layouts
|
276
276
|
ul.list
|
277
277
|
.item
|
278
278
|
.icon
|
279
|
-
background: url("
|
279
|
+
background: url(image-path("comfortable_mexican_sofa/icon_layout.gif"))
|
280
280
|
.item-content
|
281
281
|
margin-left: 35px
|
282
282
|
|
@@ -304,12 +304,12 @@ body#comfy
|
|
304
304
|
// -- Snippets ------------------------------------------------------------
|
305
305
|
&.c-cms-admin-snippets
|
306
306
|
table .icon
|
307
|
-
background: url("
|
307
|
+
background: url(image-path("comfortable_mexican_sofa/icon_snippet.gif"))
|
308
308
|
|
309
309
|
// -- Files ---------------------------------------------------------------
|
310
310
|
&.c-cms-admin-files
|
311
311
|
table .icon
|
312
|
-
background: url("
|
312
|
+
background: url(image-path("comfortable_mexican_sofa/icon_file.gif"))
|
313
313
|
|
314
314
|
// -- Revisions -----------------------------------------------------------
|
315
315
|
&.c-cms-admin-revisions
|
@@ -15,9 +15,9 @@ body#comfy
|
|
15
15
|
text-align: right
|
16
16
|
|
17
17
|
[class^="icon-"], [class*=" icon-"]
|
18
|
-
background-image: url("
|
18
|
+
background-image: url(image-path("comfortable_mexican_sofa/bootstrap/glyphicons-halflings.png"))
|
19
19
|
.icon-white
|
20
|
-
background-image: url("
|
20
|
+
background-image: url(image-path("comfortable_mexican_sofa/bootstrap/glyphicons-halflings-white.png"))
|
21
21
|
|
22
22
|
// -- Setting up border-box sizing, letting fields size themselves --------
|
23
23
|
*
|
@@ -44,7 +44,7 @@ protected
|
|
44
44
|
def load_fixtures
|
45
45
|
return unless ComfortableMexicanSofa.config.enable_fixtures
|
46
46
|
if %w(cms_admin/layouts cms_admin/pages cms_admin/snippets).member?(params[:controller])
|
47
|
-
ComfortableMexicanSofa::
|
47
|
+
ComfortableMexicanSofa::Fixture::Importer.new(@site.identifier).import!
|
48
48
|
flash.now[:error] = I18n.t('cms.base.fixtures_enabled')
|
49
49
|
end
|
50
50
|
end
|
@@ -36,7 +36,7 @@ protected
|
|
36
36
|
|
37
37
|
def load_fixtures
|
38
38
|
return unless ComfortableMexicanSofa.config.enable_fixtures
|
39
|
-
ComfortableMexicanSofa::
|
39
|
+
ComfortableMexicanSofa::Fixture::Importer.new(@cms_site.identifier).import!
|
40
40
|
end
|
41
41
|
|
42
42
|
def load_cms_site
|
data/app/models/cms/block.rb
CHANGED
data/app/models/cms/file.rb
CHANGED
@@ -36,8 +36,11 @@ class Cms::File < ActiveRecord::Base
|
|
36
36
|
belongs_to :block
|
37
37
|
|
38
38
|
# -- Validations ----------------------------------------------------------
|
39
|
-
validates :site_id,
|
39
|
+
validates :site_id,
|
40
|
+
:presence => true
|
40
41
|
validates_attachment_presence :file
|
42
|
+
validates :file_file_name,
|
43
|
+
:uniqueness => {:scope => :site_id}
|
41
44
|
|
42
45
|
# -- Callbacks ------------------------------------------------------------
|
43
46
|
before_save :assign_label
|
data/config/database.yml
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
- File Category
|
@@ -0,0 +1 @@
|
|
1
|
+
- Page Category
|
@@ -0,0 +1 @@
|
|
1
|
+
- Snippet Category
|
Binary file
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,32 +1,34 @@
|
|
1
1
|
# Loading engine only if this is not a standalone installation
|
2
2
|
unless defined? ComfortableMexicanSofa::Application
|
3
|
-
|
3
|
+
require_relative 'comfortable_mexican_sofa/engine'
|
4
4
|
end
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
6
|
+
require_relative 'comfortable_mexican_sofa/version'
|
7
|
+
require_relative 'comfortable_mexican_sofa/error'
|
8
|
+
require_relative 'comfortable_mexican_sofa/configuration'
|
9
|
+
require_relative 'comfortable_mexican_sofa/routing'
|
10
|
+
require_relative 'comfortable_mexican_sofa/authentication/http_auth'
|
11
|
+
require_relative 'comfortable_mexican_sofa/authentication/dummy_auth'
|
12
|
+
require_relative 'comfortable_mexican_sofa/render_methods'
|
13
|
+
require_relative 'comfortable_mexican_sofa/view_hooks'
|
14
|
+
require_relative 'comfortable_mexican_sofa/view_methods'
|
15
|
+
require_relative 'comfortable_mexican_sofa/form_builder'
|
16
|
+
require_relative 'comfortable_mexican_sofa/tag'
|
17
|
+
require_relative 'comfortable_mexican_sofa/sitemap'
|
18
|
+
require_relative 'comfortable_mexican_sofa/fixture'
|
19
|
+
require_relative 'comfortable_mexican_sofa/fixture/category'
|
20
|
+
require_relative 'comfortable_mexican_sofa/fixture/layout'
|
21
|
+
require_relative 'comfortable_mexican_sofa/fixture/page'
|
22
|
+
require_relative 'comfortable_mexican_sofa/fixture/snippet'
|
23
|
+
require_relative 'comfortable_mexican_sofa/fixture/file'
|
24
|
+
require_relative 'comfortable_mexican_sofa/extensions/rails'
|
25
|
+
require_relative 'comfortable_mexican_sofa/extensions/acts_as_tree'
|
26
|
+
require_relative 'comfortable_mexican_sofa/extensions/has_revisions'
|
27
|
+
require_relative 'comfortable_mexican_sofa/extensions/is_mirrored'
|
28
|
+
require_relative 'comfortable_mexican_sofa/extensions/is_categorized'
|
27
29
|
|
28
30
|
Dir.glob(File.expand_path('comfortable_mexican_sofa/tags/*.rb', File.dirname(__FILE__))).each do |path|
|
29
|
-
|
31
|
+
require_relative path
|
30
32
|
end
|
31
33
|
|
32
34
|
module ComfortableMexicanSofa
|
@@ -0,0 +1,77 @@
|
|
1
|
+
module ComfortableMexicanSofa::Fixture
|
2
|
+
|
3
|
+
class Importer
|
4
|
+
attr_accessor :site,
|
5
|
+
:path,
|
6
|
+
:from,
|
7
|
+
:to,
|
8
|
+
:fixture_ids,
|
9
|
+
:force_import
|
10
|
+
|
11
|
+
def initialize(from, to = from, force_import = false)
|
12
|
+
self.from = from
|
13
|
+
self.to = to
|
14
|
+
self.site = Cms::Site.where(:identifier => to).first!
|
15
|
+
self.fixture_ids = []
|
16
|
+
self.force_import = force_import
|
17
|
+
|
18
|
+
dir = self.class.name.split('::')[2].downcase.pluralize
|
19
|
+
self.path = ::File.join(ComfortableMexicanSofa.config.fixtures_path, from, dir, '/')
|
20
|
+
end
|
21
|
+
|
22
|
+
def fresh_fixture?(object, file_path)
|
23
|
+
object.new_record? || self.force_import || ::File.mtime(file_path) > object.updated_at
|
24
|
+
end
|
25
|
+
|
26
|
+
def get_attributes(file_path)
|
27
|
+
YAML.load_file(file_path)
|
28
|
+
end
|
29
|
+
|
30
|
+
def save_categorizations!(object, categories)
|
31
|
+
object.categorizations.delete_all
|
32
|
+
[categories].flatten.compact.each do |label|
|
33
|
+
category = self.site.categories.find_or_create_by_label_and_categorized_type(label, object.class.to_s)
|
34
|
+
category.categorizations.create!(
|
35
|
+
:categorized => object
|
36
|
+
)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def import!
|
41
|
+
ComfortableMexicanSofa::Fixture::Category::Importer.new(from, to, force_import).import!
|
42
|
+
ComfortableMexicanSofa::Fixture::File::Importer.new( from, to, force_import).import!
|
43
|
+
ComfortableMexicanSofa::Fixture::Layout::Importer.new( from, to, force_import).import!
|
44
|
+
ComfortableMexicanSofa::Fixture::Page::Importer.new( from, to, force_import).import!
|
45
|
+
ComfortableMexicanSofa::Fixture::Snippet::Importer.new( from, to, force_import).import!
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
class Exporter
|
50
|
+
attr_accessor :site,
|
51
|
+
:path,
|
52
|
+
:from,
|
53
|
+
:to
|
54
|
+
|
55
|
+
def initialize(from, to = from)
|
56
|
+
self.from = from
|
57
|
+
self.to = to
|
58
|
+
self.site = Cms::Site.where(:identifier => from).first!
|
59
|
+
dir = self.class.name.split('::')[2].downcase.pluralize
|
60
|
+
self.path = ::File.join(ComfortableMexicanSofa.config.fixtures_path, to, dir)
|
61
|
+
end
|
62
|
+
|
63
|
+
def prepare_folder!(path)
|
64
|
+
FileUtils.rm_rf(path)
|
65
|
+
FileUtils.mkdir_p(path)
|
66
|
+
end
|
67
|
+
|
68
|
+
def export!
|
69
|
+
ComfortableMexicanSofa::Fixture::File::Exporter.new( from, to).export!
|
70
|
+
ComfortableMexicanSofa::Fixture::Category::Exporter.new(from, to).export!
|
71
|
+
ComfortableMexicanSofa::Fixture::Layout::Exporter.new( from, to).export!
|
72
|
+
ComfortableMexicanSofa::Fixture::Page::Exporter.new( from, to).export!
|
73
|
+
ComfortableMexicanSofa::Fixture::Snippet::Exporter.new( from, to).export!
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module ComfortableMexicanSofa::Fixture::Category
|
2
|
+
class Importer < ComfortableMexicanSofa::Fixture::Importer
|
3
|
+
def import!
|
4
|
+
{
|
5
|
+
'files' => 'Cms::File',
|
6
|
+
'pages' => 'Cms::Page',
|
7
|
+
'snippets' => 'Cms::Snippet'
|
8
|
+
}.each do |file, type|
|
9
|
+
if File.exists?(attrs_path = File.join(path, "#{file}.yml"))
|
10
|
+
categories = get_attributes(attrs_path)
|
11
|
+
[categories].flatten.each do |label|
|
12
|
+
self.site.categories.find_or_create_by_label_and_categorized_type(label, type)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
class Exporter < ComfortableMexicanSofa::Fixture::Exporter
|
20
|
+
def export!
|
21
|
+
prepare_folder!(self.path)
|
22
|
+
{
|
23
|
+
'files' => 'Cms::File',
|
24
|
+
'pages' => 'Cms::Page',
|
25
|
+
'snippets' => 'Cms::Snippet'
|
26
|
+
}.each do |file, type|
|
27
|
+
if (categories = self.site.categories.of_type(type)).present?
|
28
|
+
open(File.join(self.path, "#{file}.yml"), 'w') do |f|
|
29
|
+
f.write(categories.map{|c| c.label}.to_yaml)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
module ComfortableMexicanSofa::Fixture::File
|
2
|
+
class Importer < ComfortableMexicanSofa::Fixture::Importer
|
3
|
+
def import!
|
4
|
+
Dir["#{self.path}[^_]*"].each do |file_path|
|
5
|
+
filename = ::File.basename(file_path)
|
6
|
+
file = self.site.files.where(:file_file_name => filename).first || self.site.files.new
|
7
|
+
|
8
|
+
# setting attributes
|
9
|
+
categories = []
|
10
|
+
if File.exists?(attrs_path = File.join(self.path, "_#{filename}.yml"))
|
11
|
+
if fresh_fixture?(file, attrs_path)
|
12
|
+
attrs = get_attributes(attrs_path)
|
13
|
+
file.label = attrs['label']
|
14
|
+
file.description = attrs['description']
|
15
|
+
categories = attrs['categories']
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# setting actual file
|
20
|
+
if fresh_fixture?(file, file_path)
|
21
|
+
file.file = open(file_path)
|
22
|
+
end
|
23
|
+
|
24
|
+
if file.changed? || self.force_import
|
25
|
+
if file.save
|
26
|
+
save_categorizations!(file, categories)
|
27
|
+
ComfortableMexicanSofa.logger.warn("[FIXTURES] Imported File \t #{file.file_file_name}")
|
28
|
+
else
|
29
|
+
ComfortableMexicanSofa.logger.warn("[FIXTURES] Failed to import File \n#{file.errors.inspect}")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
self.fixture_ids << file.id
|
34
|
+
end
|
35
|
+
|
36
|
+
# cleaning up
|
37
|
+
self.site.files.where('id NOT IN (?)', fixture_ids).each{ |s| s.destroy }
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
class Exporter < ComfortableMexicanSofa::Fixture::Exporter
|
42
|
+
def export!
|
43
|
+
prepare_folder!(self.path)
|
44
|
+
|
45
|
+
self.site.files.each do |file|
|
46
|
+
file_path = File.join(self.path, file.file_file_name)
|
47
|
+
|
48
|
+
# writing attributes
|
49
|
+
open(::File.join(self.path, "_#{file.file_file_name}.yml"), 'w') do |f|
|
50
|
+
f.write({
|
51
|
+
'label' => file.label,
|
52
|
+
'description' => file.description,
|
53
|
+
'categories' => file.categories.map{|c| c.label}
|
54
|
+
}.to_yaml)
|
55
|
+
end
|
56
|
+
|
57
|
+
# writing content
|
58
|
+
data_path = file.file.options[:storage] == :filesystem ?
|
59
|
+
file.file.path :
|
60
|
+
file.file.url
|
61
|
+
|
62
|
+
open(::File.join(self.path, ::File.basename(file_path)), 'w') do |f|
|
63
|
+
f.write(open(data_path))
|
64
|
+
end
|
65
|
+
|
66
|
+
ComfortableMexicanSofa.logger.warn("[FIXTURES] Exported File \t #{file.file_file_name}")
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|