locomotivecms_mounter_pull_19 1.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +12 -0
  3. data/.rspec +3 -0
  4. data/.travis.yml +4 -0
  5. data/Gemfile +7 -0
  6. data/Gemfile.lock +131 -0
  7. data/MIT-LICENSE +20 -0
  8. data/NOTES +4 -0
  9. data/README.md +26 -0
  10. data/Rakefile +37 -0
  11. data/TODO +82 -0
  12. data/init.rb +2 -0
  13. data/lib/locomotive/mounter.rb +106 -0
  14. data/lib/locomotive/mounter/config.rb +21 -0
  15. data/lib/locomotive/mounter/engine_api.rb +205 -0
  16. data/lib/locomotive/mounter/exceptions.rb +44 -0
  17. data/lib/locomotive/mounter/extensions/compass.rb +38 -0
  18. data/lib/locomotive/mounter/extensions/httmultiparty.rb +22 -0
  19. data/lib/locomotive/mounter/extensions/sprockets.rb +46 -0
  20. data/lib/locomotive/mounter/extensions/tilt/css.rb +31 -0
  21. data/lib/locomotive/mounter/fields.rb +254 -0
  22. data/lib/locomotive/mounter/models/base.rb +42 -0
  23. data/lib/locomotive/mounter/models/content_asset.rb +84 -0
  24. data/lib/locomotive/mounter/models/content_entry.rb +372 -0
  25. data/lib/locomotive/mounter/models/content_field.rb +190 -0
  26. data/lib/locomotive/mounter/models/content_select_option.rb +29 -0
  27. data/lib/locomotive/mounter/models/content_type.rb +274 -0
  28. data/lib/locomotive/mounter/models/editable_element.rb +27 -0
  29. data/lib/locomotive/mounter/models/page.rb +442 -0
  30. data/lib/locomotive/mounter/models/site.rb +28 -0
  31. data/lib/locomotive/mounter/models/snippet.rb +55 -0
  32. data/lib/locomotive/mounter/models/theme_asset.rb +148 -0
  33. data/lib/locomotive/mounter/models/translation.rb +28 -0
  34. data/lib/locomotive/mounter/mounting_point.rb +65 -0
  35. data/lib/locomotive/mounter/reader/api.rb +64 -0
  36. data/lib/locomotive/mounter/reader/api/base.rb +67 -0
  37. data/lib/locomotive/mounter/reader/api/content_assets_reader.rb +39 -0
  38. data/lib/locomotive/mounter/reader/api/content_entries_reader.rb +142 -0
  39. data/lib/locomotive/mounter/reader/api/content_types_reader.rb +76 -0
  40. data/lib/locomotive/mounter/reader/api/pages_reader.rb +192 -0
  41. data/lib/locomotive/mounter/reader/api/site_reader.rb +42 -0
  42. data/lib/locomotive/mounter/reader/api/snippets_reader.rb +61 -0
  43. data/lib/locomotive/mounter/reader/api/theme_assets_reader.rb +42 -0
  44. data/lib/locomotive/mounter/reader/api/translations_reader.rb +30 -0
  45. data/lib/locomotive/mounter/reader/file_system.rb +43 -0
  46. data/lib/locomotive/mounter/reader/file_system/base.rb +65 -0
  47. data/lib/locomotive/mounter/reader/file_system/content_assets_reader.rb +90 -0
  48. data/lib/locomotive/mounter/reader/file_system/content_entries_reader.rb +97 -0
  49. data/lib/locomotive/mounter/reader/file_system/content_types_reader.rb +88 -0
  50. data/lib/locomotive/mounter/reader/file_system/pages_reader.rb +211 -0
  51. data/lib/locomotive/mounter/reader/file_system/site_reader.rb +27 -0
  52. data/lib/locomotive/mounter/reader/file_system/snippets_reader.rb +115 -0
  53. data/lib/locomotive/mounter/reader/file_system/theme_assets_reader.rb +83 -0
  54. data/lib/locomotive/mounter/reader/file_system/translations_reader.rb +36 -0
  55. data/lib/locomotive/mounter/reader/runner.rb +89 -0
  56. data/lib/locomotive/mounter/utils/hash.rb +31 -0
  57. data/lib/locomotive/mounter/utils/output.rb +124 -0
  58. data/lib/locomotive/mounter/utils/string.rb +40 -0
  59. data/lib/locomotive/mounter/utils/yaml.rb +125 -0
  60. data/lib/locomotive/mounter/utils/yaml_front_matters_template.rb +45 -0
  61. data/lib/locomotive/mounter/version.rb +8 -0
  62. data/lib/locomotive/mounter/writer/api.rb +74 -0
  63. data/lib/locomotive/mounter/writer/api/base.rb +172 -0
  64. data/lib/locomotive/mounter/writer/api/content_assets_writer.rb +74 -0
  65. data/lib/locomotive/mounter/writer/api/content_entries_writer.rb +227 -0
  66. data/lib/locomotive/mounter/writer/api/content_types_writer.rb +151 -0
  67. data/lib/locomotive/mounter/writer/api/pages_writer.rb +250 -0
  68. data/lib/locomotive/mounter/writer/api/site_writer.rb +125 -0
  69. data/lib/locomotive/mounter/writer/api/snippets_writer.rb +111 -0
  70. data/lib/locomotive/mounter/writer/api/theme_assets_writer.rb +201 -0
  71. data/lib/locomotive/mounter/writer/api/translations_writer.rb +85 -0
  72. data/lib/locomotive/mounter/writer/file_system.rb +44 -0
  73. data/lib/locomotive/mounter/writer/file_system/base.rb +70 -0
  74. data/lib/locomotive/mounter/writer/file_system/content_assets_writer.rb +38 -0
  75. data/lib/locomotive/mounter/writer/file_system/content_entries_writer.rb +33 -0
  76. data/lib/locomotive/mounter/writer/file_system/content_types_writer.rb +32 -0
  77. data/lib/locomotive/mounter/writer/file_system/pages_writer.rb +93 -0
  78. data/lib/locomotive/mounter/writer/file_system/site_writer.rb +30 -0
  79. data/lib/locomotive/mounter/writer/file_system/snippets_writer.rb +59 -0
  80. data/lib/locomotive/mounter/writer/file_system/theme_assets_writer.rb +72 -0
  81. data/lib/locomotive/mounter/writer/file_system/translations_writer.rb +29 -0
  82. data/lib/locomotive/mounter/writer/runner.rb +73 -0
  83. data/locomotivecms_mounter.gemspec +64 -0
  84. metadata +539 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 33c876ce4821fca3de1aa2c165e4cf3f894d5615
4
+ data.tar.gz: ac281c14ec21593f6c25f5a230192054f5adf5fc
5
+ SHA512:
6
+ metadata.gz: 9f5c8315f81fdf7cebfaf4ef71a06c6849f85ec68d0a3154a5c864fb8d34d5b0f73dc022d805e03068dfbf713e5195aff1c488fc651a44b5f5f356c70626ec4e
7
+ data.tar.gz: f8bb727b4833d2e009770e1109cd4e37c3f32f314c73edfb099755cc4f09755a45652838a27de75296219238bd3919859e587a7269315107d13f28d636b4b756
@@ -0,0 +1,12 @@
1
+ /spec/tmp/trace.log
2
+ /spec/tmp
3
+ .sass-cache/
4
+ .push-tmp/
5
+ .DS_Store
6
+ /spec/fixtures/default/deploy.yml
7
+ pkg
8
+
9
+ .bundle
10
+ .gems
11
+ .ruby-version
12
+ .rbenv-gemsets
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format=doc
2
+ --color
3
+ --backtrace
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ - 2.1.1
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :development, :test do
6
+
7
+ end
@@ -0,0 +1,131 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ locomotivecms_mounter_pull_19 (1.5.4)
5
+ RedCloth (~> 4.2.3)
6
+ activesupport (~> 3.2.21)
7
+ chronic (~> 0.10.2)
8
+ coffee-script (~> 2.2.0)
9
+ colorize (~> 0.5.8)
10
+ compass (~> 1.0.1, >= 0.12)
11
+ haml (~> 4.0.5)
12
+ httmultiparty (= 0.3.10)
13
+ i18n (~> 0.6.11)
14
+ json (~> 1.8.0)
15
+ less (~> 2.2.1)
16
+ logger
17
+ mime-types (~> 1.19)
18
+ multi_json (~> 1.8.4)
19
+ sass (~> 3.4.4)
20
+ sprockets-sass (~> 1.2.0)
21
+ stringex (~> 2.0.3)
22
+ tilt (= 1.4.1)
23
+ tzinfo (~> 0.3.29)
24
+ yui-compressor (~> 0.12.0)
25
+ zip (~> 2.0.2)
26
+
27
+ GEM
28
+ remote: http://rubygems.org/
29
+ specs:
30
+ RedCloth (4.2.9)
31
+ activesupport (3.2.21)
32
+ i18n (~> 0.6, >= 0.6.4)
33
+ multi_json (~> 1.0)
34
+ addressable (2.3.6)
35
+ chronic (0.10.2)
36
+ chunky_png (1.3.4)
37
+ coffee-script (2.2.0)
38
+ coffee-script-source
39
+ execjs
40
+ coffee-script-source (1.9.1.1)
41
+ colorize (0.5.8)
42
+ commonjs (0.2.7)
43
+ compass (1.0.3)
44
+ chunky_png (~> 1.2)
45
+ compass-core (~> 1.0.2)
46
+ compass-import-once (~> 1.0.5)
47
+ rb-fsevent (>= 0.9.3)
48
+ rb-inotify (>= 0.9)
49
+ sass (>= 3.3.13, < 3.5)
50
+ compass-core (1.0.3)
51
+ multi_json (~> 1.0)
52
+ sass (>= 3.3.0, < 3.5)
53
+ compass-import-once (1.0.5)
54
+ sass (>= 3.2, < 3.5)
55
+ crack (0.4.2)
56
+ safe_yaml (~> 1.0.0)
57
+ diff-lcs (1.2.5)
58
+ execjs (2.5.2)
59
+ ffi (1.9.8)
60
+ haml (4.0.6)
61
+ tilt
62
+ hike (1.2.3)
63
+ httmultiparty (0.3.10)
64
+ httparty (>= 0.7.3)
65
+ multipart-post
66
+ httparty (0.13.3)
67
+ json (~> 1.8)
68
+ multi_xml (>= 0.5.2)
69
+ i18n (0.6.11)
70
+ json (1.8.2)
71
+ less (2.2.2)
72
+ commonjs (~> 0.2.6)
73
+ libv8 (3.16.14.3)
74
+ logger (1.2.8)
75
+ mime-types (1.25.1)
76
+ multi_json (1.8.4)
77
+ multi_xml (0.5.5)
78
+ multipart-post (2.0.0)
79
+ rack (1.5.2)
80
+ rack-test (0.6.2)
81
+ rack (>= 1.0)
82
+ rake (0.9.2)
83
+ rb-fsevent (0.9.4)
84
+ rb-inotify (0.9.5)
85
+ ffi (>= 0.5.0)
86
+ ref (1.0.5)
87
+ rspec (2.14.1)
88
+ rspec-core (~> 2.14.0)
89
+ rspec-expectations (~> 2.14.0)
90
+ rspec-mocks (~> 2.14.0)
91
+ rspec-core (2.14.8)
92
+ rspec-expectations (2.14.5)
93
+ diff-lcs (>= 1.1.3, < 2.0)
94
+ rspec-mocks (2.14.6)
95
+ ruby-debug-wrapper (0.0.1)
96
+ safe_yaml (1.0.4)
97
+ sass (3.4.13)
98
+ sprockets (2.12.3)
99
+ hike (~> 1.2)
100
+ multi_json (~> 1.0)
101
+ rack (~> 1.0)
102
+ tilt (~> 1.1, != 1.3.0)
103
+ sprockets-sass (1.2.0)
104
+ sprockets (~> 2.0)
105
+ tilt (~> 1.1)
106
+ stringex (2.0.11)
107
+ therubyracer (0.12.1)
108
+ libv8 (~> 3.16.14.0)
109
+ ref
110
+ tilt (1.4.1)
111
+ tzinfo (0.3.43)
112
+ vcr (2.4.0)
113
+ webmock (1.9.3)
114
+ addressable (>= 2.2.7)
115
+ crack (>= 0.3.2)
116
+ yui-compressor (0.12.0)
117
+ zip (2.0.2)
118
+
119
+ PLATFORMS
120
+ ruby
121
+
122
+ DEPENDENCIES
123
+ libv8 (= 3.16.14.3)
124
+ locomotivecms_mounter_pull_19!
125
+ rack-test (~> 0.6.1)
126
+ rake (= 0.9.2)
127
+ rspec (~> 2.14.1)
128
+ ruby-debug-wrapper (~> 0.0.1)
129
+ therubyracer (~> 0.12.1)
130
+ vcr (= 2.4.0)
131
+ webmock (= 1.9.3)
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 [Didier Lafforgue]
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/NOTES ADDED
@@ -0,0 +1,4 @@
1
+ * Rules:
2
+
3
+ - select options (and their translations) are defined in the content type
4
+ - a content entry can assign an option to a select field only in the default locale
@@ -0,0 +1,26 @@
1
+ # LocomotiveCMS Mounter
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/locomotivecms_mounter.svg)](http://badge.fury.io/rb/locomotivecms_mounter)
4
+ [![Code Climate](https://codeclimate.com/github/locomotivecms/mounter.png)](https://codeclimate.com/github/locomotivecms/mounter)
5
+ [![Dependency Status](https://gemnasium.com/locomotivecms/mounter.png)](https://gemnasium.com/locomotivecms/mounter)
6
+ [![Build Status](https://travis-ci.org/locomotivecms/mounter.svg?branch=master)](https://travis-ci.org/locomotivecms/mounter)
7
+ [![Coverage Status](https://coveralls.io/repos/locomotivecms/mounter/badge.png)](https://coveralls.io/r/locomotivecms/mounter)
8
+
9
+ The "LocomotiveCMS Mounter" is a simple module to store in memory a LocomotiveCMS site whatever the source is:
10
+
11
+ * a site template built with the editor and on the local filesystem
12
+ * a zip file of a site template on the local filesystem
13
+ * a zip file of a site template but online through an url
14
+ * a LocomotiveCMS engine
15
+
16
+ It also includes a mechanism which could save the site from the memory to any targets (filesystem, another LocomotiveCMS engine, ...etc).
17
+ This saving mechanism has to be implemented in the application using that module.
18
+
19
+
20
+ ## Contributing
21
+
22
+ 1. Fork it
23
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
24
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
25
+ 4. Push to the branch (`git push origin my-new-feature`)
26
+ 5. Create new Pull Request
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env rake
2
+ # encoding: utf-8
3
+
4
+ require 'rubygems'
5
+ require 'bundler/setup'
6
+
7
+ require 'rake'
8
+ require 'rspec'
9
+ require 'rspec/core/rake_task'
10
+ require 'rubygems/package_task'
11
+
12
+ $LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
13
+
14
+ require 'locomotive/mounter/version'
15
+
16
+ gemspec = eval(File.read('locomotivecms_mounter.gemspec'))
17
+ Gem::PackageTask.new(gemspec) do |pkg|
18
+ pkg.gem_spec = gemspec
19
+ end
20
+
21
+ desc 'build the gem and release it to rubygems.org'
22
+ task :release => :gem do
23
+ sh "gem push pkg/locomotivecms_mounter-#{gemspec.version}.gem"
24
+ end
25
+
26
+ RSpec::Core::RakeTask.new('spec:unit') do |spec|
27
+ spec.pattern = 'spec/unit/**/*_spec.rb'
28
+
29
+ end
30
+
31
+ RSpec::Core::RakeTask.new('spec:integration') do |spec|
32
+ spec.pattern = 'spec/integration/**/*_spec.rb'
33
+ end
34
+
35
+ task :spec => ['spec:unit', 'spec:integration']
36
+
37
+ task :default => :spec
data/TODO ADDED
@@ -0,0 +1,82 @@
1
+ - readers
2
+ - API
3
+ x site
4
+ x pages
5
+ x fetch all (+ translations)
6
+ x editable elements
7
+ x content assets
8
+ x content type (engine does not return the content_type_id)
9
+ x snippets
10
+ x content types
11
+ x content entries
12
+ - content assets
13
+ x theme assets
14
+ x content assets
15
+ x translations
16
+ - filesystem
17
+ x pages
18
+ x localized fullpath (rebuild the fullpath for localized pages based on the slug / parent slug)
19
+ x editable elements
20
+ x content type
21
+ x snippets
22
+ x content types
23
+ x content entries
24
+ x yaml front matter
25
+ x haml -> liquid
26
+ - theme_assets
27
+ - tests
28
+ - content_assets
29
+ - tests
30
+ - translations
31
+ - test
32
+
33
+ - writers
34
+ - API
35
+ x site
36
+ x create it if it does not exist (admin rights ?)
37
+ x update it
38
+ x theme assets
39
+ x pages
40
+ x layouts first
41
+ x editable elements ?
42
+ x content type
43
+ x content assets
44
+ x snippets
45
+ x content assets
46
+ x content types
47
+ x replace klass_name by the real class name of the content type
48
+ x select type: options
49
+ x content entries
50
+ x create
51
+ x update in another locale (only the translated and non blank fields)
52
+ x update with relationships
53
+ x content assets
54
+ x do not try to replace them every time (in other words, only when they got changed)
55
+ x translations
56
+ - FileSystem
57
+ x site
58
+ x pages
59
+ x page elements (YAML matters)
60
+ x snippets
61
+ x content types
62
+ x content entries
63
+ x theme assets
64
+ x use url instead of source
65
+ x convert in HAML, SASS, Coffeescript
66
+ x content assets
67
+ - translations
68
+ - tests
69
+
70
+
71
+ === case not handled for now ===
72
+
73
+ - a content type gets changed: new fields, renamed ones or deleted.
74
+
75
+ === BUGS ===
76
+
77
+ - theme_assets: some js are not correctly updated
78
+ - manage errors from the engine
79
+
80
+ ====== use case =====
81
+
82
+ -- filesystem -> mongodb (mongoid ?)
data/init.rb ADDED
@@ -0,0 +1,2 @@
1
+ # Init
2
+ require File.dirname(__FILE__) + '/lib/locomotive/mounter'
@@ -0,0 +1,106 @@
1
+ $:.unshift File.expand_path(File.dirname(__FILE__))
2
+
3
+ # Force encoding to UTF-8
4
+ Encoding.default_internal = Encoding.default_external = 'UTF-8'
5
+
6
+ # Remove I18n warnings
7
+ require 'i18n'
8
+ I18n.enforce_available_locales = false
9
+
10
+ require 'logger'
11
+ require 'colorize'
12
+
13
+ require 'active_support'
14
+ require 'active_support/core_ext'
15
+ require 'stringex'
16
+ require 'tempfile'
17
+ require 'digest/sha1'
18
+ require 'chronic'
19
+
20
+ require 'tilt'
21
+ require 'sprockets'
22
+ require 'sprockets-sass'
23
+ require 'haml'
24
+ require 'compass'
25
+
26
+ require 'httmultiparty'
27
+ require 'mime/types'
28
+
29
+ # Utils
30
+ require 'locomotive/mounter/utils/hash'
31
+ require 'locomotive/mounter/utils/yaml'
32
+ require 'locomotive/mounter/utils/string'
33
+ require 'locomotive/mounter/utils/output'
34
+ require 'locomotive/mounter/utils/yaml_front_matters_template'
35
+
36
+ # Main
37
+ require 'locomotive/mounter/version'
38
+ require 'locomotive/mounter/exceptions'
39
+ require 'locomotive/mounter/config'
40
+ require 'locomotive/mounter/fields'
41
+ require 'locomotive/mounter/mounting_point'
42
+ require 'locomotive/mounter/engine_api'
43
+
44
+ # Extensions
45
+ require 'locomotive/mounter/extensions/httmultiparty'
46
+ require 'locomotive/mounter/extensions/sprockets'
47
+ require 'locomotive/mounter/extensions/compass'
48
+ require 'locomotive/mounter/extensions/tilt/css'
49
+
50
+ # Models
51
+ require 'locomotive/mounter/models/base'
52
+ Dir[File.join(File.dirname(__FILE__), 'mounter/models', '*.rb')].each { |lib| require lib }
53
+
54
+ # Readers: Filesystem / API
55
+ require 'locomotive/mounter/reader/runner'
56
+ require 'locomotive/mounter/reader/file_system'
57
+ require 'locomotive/mounter/reader/api'
58
+
59
+ # Writer: Filesystem
60
+ require 'locomotive/mounter/writer/runner'
61
+ require 'locomotive/mounter/writer/file_system'
62
+ require 'locomotive/mounter/writer/api'
63
+
64
+ module Locomotive
65
+
66
+ module Mounter
67
+
68
+ TEMPLATE_EXTENSIONS = %w(liquid haml)
69
+
70
+ @@logger = ::Logger.new(STDOUT).tap { |log| log.level = ::Logger::DEBUG }
71
+
72
+ @@mount_point = nil
73
+
74
+ # default locale
75
+ @@locale = I18n.locale
76
+
77
+ def self.mount(options)
78
+ @@mount_point = Locomotive::Mounter::Config[:reader].run!(options)
79
+ end
80
+
81
+ def self.logger
82
+ @@logger
83
+ end
84
+
85
+ def self.logger=(logger)
86
+ @@logger = logger
87
+ end
88
+
89
+ def self.locale
90
+ @@locale
91
+ end
92
+
93
+ def self.locale=(locale)
94
+ @@locale = locale.to_sym
95
+ end
96
+
97
+ def self.with_locale(locale, &block)
98
+ tmp, @@locale = @@locale, locale.try(:to_sym) || @@locale
99
+ yield.tap do
100
+ @@locale = tmp
101
+ end
102
+ end
103
+
104
+ end
105
+
106
+ end