locomotivecms_steam 0.1.1 → 0.1.2.pre.beta
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -2
- data/CHANGELOG.md +5 -0
- data/Gemfile +10 -2
- data/Gemfile.lock +37 -49
- data/Rakefile +5 -10
- data/example/server.rb +10 -6
- data/lib/locomotive/steam.rb +46 -0
- data/lib/locomotive/steam/configuration.rb +13 -0
- data/lib/locomotive/steam/decorators.rb +1 -0
- data/lib/locomotive/steam/decorators/page_decorator.rb +50 -0
- data/lib/locomotive/steam/entities/content_type.rb +11 -0
- data/lib/locomotive/steam/entities/page.rb +136 -0
- data/lib/locomotive/steam/entities/site.rb +30 -0
- data/lib/locomotive/steam/initializers/dragonfly.rb +3 -4
- data/lib/locomotive/steam/liquid.rb +1 -12
- data/lib/locomotive/steam/liquid/drops/base.rb +1 -1
- data/lib/locomotive/steam/liquid/drops/content_entry.rb +3 -2
- data/lib/locomotive/steam/liquid/drops/content_types.rb +4 -2
- data/lib/locomotive/steam/liquid/drops/page.rb +4 -3
- data/lib/locomotive/steam/liquid/drops/site.rb +3 -2
- data/lib/locomotive/steam/liquid/patches.rb +4 -8
- data/lib/locomotive/steam/liquid/tags/nav.rb +19 -17
- data/lib/locomotive/steam/loaders/yml/pages_loader.rb +193 -0
- data/lib/locomotive/steam/loaders/yml/site_loader.rb +49 -0
- data/lib/locomotive/steam/loaders/yml/utils/localized_tree.rb +33 -0
- data/lib/locomotive/steam/loaders/yml/utils/yaml_front_matters_template.rb +66 -0
- data/lib/locomotive/steam/loaders/yml_loader.rb +33 -0
- data/lib/locomotive/steam/mapper.rb +86 -0
- data/lib/locomotive/steam/middlewares/base.rb +12 -10
- data/lib/locomotive/steam/middlewares/locale.rb +3 -4
- data/lib/locomotive/steam/middlewares/page.rb +18 -18
- data/lib/locomotive/steam/middlewares/renderer.rb +41 -15
- data/lib/locomotive/steam/middlewares/stack.rb +1 -1
- data/lib/locomotive/steam/monkey_patches.rb +1 -2
- data/lib/locomotive/steam/monkey_patches/haml.rb +1 -1
- data/lib/locomotive/steam/repositories/content_types_repository.rb +14 -0
- data/lib/locomotive/steam/repositories/pages_repository.rb +23 -0
- data/lib/locomotive/steam/repositories/sites_repository.rb +16 -0
- data/lib/locomotive/steam/server.rb +14 -11
- data/lib/locomotive/steam/services/external_api.rb +2 -1
- data/lib/locomotive/steam/services/markdown.rb +3 -12
- data/lib/locomotive/steam/standalone_server.rb +2 -2
- data/lib/locomotive/steam/version.rb +4 -1
- data/locomotivecms_steam.gemspec +11 -5
- data/spec/fixtures/default/app/views/pages/basic.liquid.haml +13 -0
- data/spec/fixtures/default/config/site.yml +2 -2
- data/spec/integration/server/basic_spec.rb +22 -17
- data/spec/integration/server/contact_form_spec.rb +1 -1
- data/spec/integration/server/liquid_spec.rb +2 -2
- data/spec/integration/server/with_scope_spec.rb +2 -2
- data/spec/spec_helper.rb +15 -4
- data/spec/support/helpers.rb +26 -8
- data/spec/unit/decorators/page_decorator_spec.rb +55 -0
- data/spec/unit/entities/page_spec.rb +50 -0
- data/spec/unit/entities/site_spec.rb +12 -0
- data/spec/unit/liquid/tags/nav_spec.rb +159 -0
- data/spec/unit/loaders/pages_loader_spec.rb +42 -0
- data/spec/unit/loaders/site_loader_spec.rb +21 -0
- data/spec/unit/loaders/utils/localized_tree_spec.rb +33 -0
- data/spec/unit/loaders/utils/yaml_front_matters_template_spec.rb +39 -0
- data/spec/unit/middlewares/base_spec.rb +20 -0
- data/spec/unit/middlewares/page_spec.rb +51 -0
- data/spec/unit/repositories/pages_spec.rb +11 -0
- metadata +128 -23
- data/bin/publish +0 -28
- data/lib/locomotive/steam/misc.rb +0 -10
- data/lib/locomotive/steam/monkey_patches/mounter.rb +0 -54
- data/lib/steam.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4698182a220b4ecc84c67e5b713ef8d5d2a3a76e
|
4
|
+
data.tar.gz: 8a219e0e64af25f14f039791f722ea0529f2cbd0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b96b08b781daeb67c36e9cfa1458c8724e89052f1464390e1bc5b7ead26c78c5be45790ca8506f3d17a3997a98602dd05da95f10d1e40a35d152c67d92e35dac
|
7
|
+
data.tar.gz: 31a63e6267459677d2ec76da6f0017deba6ed9044a5a48104a1dc478632d9e4a1f566493df60c4780975e99ca613ad6b73a4fffb4dc6d717df0885cad992da54
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
@@ -3,7 +3,9 @@ source 'https://rubygems.org'
|
|
3
3
|
gemspec
|
4
4
|
|
5
5
|
group :development do
|
6
|
-
gem 'locomotivecms_common', '~> 0.0.
|
6
|
+
#gem 'locomotivecms_common', '~> 0.0.2', path: '../common'
|
7
|
+
# gem 'locomotivecms_models', '~> 0.0.1', path: '../models'
|
8
|
+
gem 'locomotivecms_models', '0.0.1.pre.alpha'
|
7
9
|
gem 'thin'
|
8
10
|
end
|
9
11
|
|
@@ -12,4 +14,10 @@ group :test do
|
|
12
14
|
gem 'coveralls', require: false
|
13
15
|
end
|
14
16
|
|
15
|
-
|
17
|
+
platform :jruby do
|
18
|
+
ruby '1.9.3', engine: 'jruby', engine_version: '1.7.11'
|
19
|
+
end
|
20
|
+
|
21
|
+
platform :ruby do
|
22
|
+
ruby '2.1.2'
|
23
|
+
end
|
data/Gemfile.lock
CHANGED
@@ -1,14 +1,19 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
locomotivecms_steam (0.1.
|
4
|
+
locomotivecms_steam (0.1.2.pre.beta)
|
5
|
+
coffee-script (~> 2.2.0)
|
6
|
+
compass (~> 0.12.2)
|
5
7
|
dragonfly (~> 1.0.3)
|
8
|
+
haml (~> 4.0.3)
|
9
|
+
httmultiparty (~> 0.3.10)
|
10
|
+
httparty (~> 0.13)
|
11
|
+
kramdown (~> 1.3.3)
|
6
12
|
locomotivecms-solid
|
7
|
-
locomotivecms_common (~> 0.0.
|
8
|
-
|
13
|
+
locomotivecms_common (~> 0.0.2)
|
14
|
+
locomotivecms_models (~> 0.0.1.pre.alpha)
|
9
15
|
moneta (~> 0.7.20)
|
10
16
|
rack-cache (~> 1.1)
|
11
|
-
redcarpet (~> 3.1)
|
12
17
|
sprockets (~> 2.0)
|
13
18
|
sprockets-sass (~> 1.0)
|
14
19
|
will_paginate (~> 3.0)
|
@@ -16,21 +21,21 @@ PATH
|
|
16
21
|
GEM
|
17
22
|
remote: https://rubygems.org/
|
18
23
|
specs:
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
24
|
+
activesupport (4.1.1)
|
25
|
+
i18n (~> 0.6, >= 0.6.9)
|
26
|
+
json (~> 1.7, >= 1.7.7)
|
27
|
+
minitest (~> 5.1)
|
28
|
+
thread_safe (~> 0.1)
|
29
|
+
tzinfo (~> 1.1)
|
23
30
|
addressable (2.3.6)
|
24
|
-
|
25
|
-
chunky_png (1.3.0)
|
31
|
+
chunky_png (1.3.1)
|
26
32
|
coderay (1.1.0)
|
27
33
|
coffee-script (2.2.0)
|
28
34
|
coffee-script-source
|
29
35
|
execjs
|
30
36
|
coffee-script-source (1.7.0)
|
31
|
-
colorize (0.
|
32
|
-
|
33
|
-
compass (0.12.5)
|
37
|
+
colorize (0.7.3)
|
38
|
+
compass (0.12.6)
|
34
39
|
chunky_png (~> 1.2)
|
35
40
|
fssm (>= 0.2.7)
|
36
41
|
sass (~> 3.2.19)
|
@@ -45,17 +50,18 @@ GEM
|
|
45
50
|
daemons (1.1.9)
|
46
51
|
diff-lcs (1.2.5)
|
47
52
|
docile (1.1.3)
|
48
|
-
dragonfly (1.0.
|
53
|
+
dragonfly (1.0.5)
|
49
54
|
multi_json (~> 1.0)
|
50
55
|
rack
|
51
56
|
eventmachine (1.0.3)
|
52
|
-
execjs (2.0
|
57
|
+
execjs (2.2.0)
|
53
58
|
fssm (0.2.10)
|
54
59
|
haml (4.0.5)
|
55
60
|
tilt
|
56
61
|
hike (1.2.3)
|
57
|
-
httmultiparty (0.3.
|
62
|
+
httmultiparty (0.3.14)
|
58
63
|
httparty (>= 0.7.3)
|
64
|
+
mimemagic
|
59
65
|
multipart-post
|
60
66
|
httparty (0.13.1)
|
61
67
|
json (~> 1.8)
|
@@ -66,39 +72,22 @@ GEM
|
|
66
72
|
iso (0.2.1)
|
67
73
|
i18n
|
68
74
|
json (1.8.1)
|
75
|
+
kramdown (1.3.3)
|
69
76
|
launchy (2.4.2)
|
70
77
|
addressable (~> 2.3)
|
71
|
-
less (2.2.2)
|
72
|
-
commonjs (~> 0.2.6)
|
73
78
|
locomotivecms-liquid (2.6.0)
|
74
79
|
locomotivecms-solid (0.2.2.1)
|
75
80
|
locomotivecms-liquid (~> 2.6.0)
|
76
|
-
locomotivecms_common (0.0.
|
77
|
-
|
78
|
-
|
79
|
-
activesupport (~>
|
80
|
-
|
81
|
-
|
82
|
-
colorize (~> 0.5.8)
|
83
|
-
compass (~> 0.12.2)
|
84
|
-
haml (~> 4.0.3)
|
85
|
-
httmultiparty (= 0.3.10)
|
86
|
-
i18n (~> 0.6.0)
|
87
|
-
json (~> 1.8.0)
|
88
|
-
less (~> 2.2.1)
|
89
|
-
logger
|
90
|
-
mime-types (~> 1.19)
|
91
|
-
multi_json (~> 1.7.3)
|
92
|
-
sass (~> 3.2.12)
|
93
|
-
sprockets (~> 2.0)
|
94
|
-
sprockets-sass
|
95
|
-
stringex (~> 2.0.3)
|
96
|
-
tilt (= 1.4.1)
|
97
|
-
tzinfo (~> 0.3.29)
|
98
|
-
zip (~> 2.0.2)
|
99
|
-
logger (1.2.8)
|
81
|
+
locomotivecms_common (0.0.2)
|
82
|
+
colorize
|
83
|
+
locomotivecms_models (0.0.1.pre.alpha)
|
84
|
+
activesupport (~> 4.1.0)
|
85
|
+
i18n (~> 0.6.9)
|
86
|
+
locomotivecms_common (~> 0.0.1)
|
100
87
|
method_source (0.8.2)
|
101
88
|
mime-types (1.25.1)
|
89
|
+
mimemagic (0.2.1)
|
90
|
+
minitest (5.3.5)
|
102
91
|
moneta (0.7.20)
|
103
92
|
multi_json (1.7.9)
|
104
93
|
multi_xml (0.5.5)
|
@@ -113,7 +102,6 @@ GEM
|
|
113
102
|
rack-test (0.6.2)
|
114
103
|
rack (>= 1.0)
|
115
104
|
rake (10.2.2)
|
116
|
-
redcarpet (3.1.1)
|
117
105
|
rest-client (1.6.7)
|
118
106
|
mime-types (>= 1.16)
|
119
107
|
rspec (2.14.1)
|
@@ -132,15 +120,14 @@ GEM
|
|
132
120
|
simplecov-html (~> 0.8.0)
|
133
121
|
simplecov-html (0.8.0)
|
134
122
|
slop (3.5.0)
|
135
|
-
sprockets (2.12.
|
123
|
+
sprockets (2.12.1)
|
136
124
|
hike (~> 1.2)
|
137
125
|
multi_json (~> 1.0)
|
138
126
|
rack (~> 1.0)
|
139
127
|
tilt (~> 1.1, != 1.3.0)
|
140
|
-
sprockets-sass (1.0
|
128
|
+
sprockets-sass (1.1.0)
|
141
129
|
sprockets (~> 2.0)
|
142
130
|
tilt (~> 1.1)
|
143
|
-
stringex (2.0.11)
|
144
131
|
term-ansicolor (1.3.0)
|
145
132
|
tins (~> 1.0)
|
146
133
|
thin (1.6.2)
|
@@ -148,15 +135,16 @@ GEM
|
|
148
135
|
eventmachine (>= 1.0.0)
|
149
136
|
rack (>= 1.0.0)
|
150
137
|
thor (0.18.1)
|
138
|
+
thread_safe (0.3.4)
|
151
139
|
tilt (1.4.1)
|
152
140
|
tins (1.0.0)
|
153
|
-
tzinfo (
|
141
|
+
tzinfo (1.2.1)
|
142
|
+
thread_safe (~> 0.1)
|
154
143
|
vcr (2.9.0)
|
155
144
|
webmock (1.8.11)
|
156
145
|
addressable (>= 2.2.7)
|
157
146
|
crack (>= 0.1.7)
|
158
147
|
will_paginate (3.0.5)
|
159
|
-
zip (2.0.2)
|
160
148
|
|
161
149
|
PLATFORMS
|
162
150
|
ruby
|
@@ -166,7 +154,7 @@ DEPENDENCIES
|
|
166
154
|
coveralls
|
167
155
|
i18n-spec
|
168
156
|
launchy
|
169
|
-
|
157
|
+
locomotivecms_models (= 0.0.1.pre.alpha)
|
170
158
|
locomotivecms_steam!
|
171
159
|
pry
|
172
160
|
rack-test
|
data/Rakefile
CHANGED
@@ -1,17 +1,12 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'bundler/setup'
|
3
|
+
require 'bundler/gem_tasks'
|
3
4
|
|
4
5
|
require 'rake'
|
5
6
|
require 'rspec'
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
require_relative 'lib/steam'
|
10
|
-
|
11
|
-
RSpec::Core::RakeTask.new('spec:integration') do |spec|
|
12
|
-
spec.pattern = 'spec/**/*_spec.rb'
|
13
|
-
end
|
8
|
+
require_relative 'lib/locomotive/steam'
|
14
9
|
|
15
|
-
|
16
|
-
|
17
|
-
task default: :spec
|
10
|
+
require 'rspec/core/rake_task'
|
11
|
+
RSpec::Core::RakeTask.new('spec')
|
12
|
+
task default: :spec
|
data/example/server.rb
CHANGED
@@ -6,17 +6,21 @@ require 'bundler/setup'
|
|
6
6
|
Bundler.require
|
7
7
|
|
8
8
|
require 'thin'
|
9
|
-
require 'common'
|
9
|
+
# require 'common'
|
10
|
+
require 'locomotive/common'
|
10
11
|
|
11
|
-
require_relative '../lib/steam'
|
12
|
+
require_relative '../lib/locomotive/steam'
|
12
13
|
require_relative '../lib/locomotive/steam/server'
|
13
14
|
require_relative '../lib/locomotive/steam/initializers'
|
14
15
|
|
15
16
|
path = ENV['SITE_PATH'] || File.join(File.expand_path(File.dirname(__FILE__)), '../spec/fixtures/default')
|
16
|
-
reader = Locomotive::Mounter::Reader::FileSystem.instance
|
17
|
-
reader.run!(path: path)
|
18
17
|
|
19
|
-
|
18
|
+
# reader = Locomotive::Mounter::Reader::FileSystem.instance
|
19
|
+
# reader.run!(path: path)
|
20
|
+
|
21
|
+
datastore = Locomotive::Steam::FileSystemDatastore.new(path: path)
|
22
|
+
|
23
|
+
app = Locomotive::Steam::Server.new(datastore, {
|
20
24
|
serve_assets: true
|
21
25
|
})
|
22
26
|
|
@@ -24,4 +28,4 @@ server = Thin::Server.new('localhost', '3333', app)
|
|
24
28
|
server.threaded = true
|
25
29
|
|
26
30
|
Locomotive::Common::Logger.info 'Server started...'
|
27
|
-
server.start
|
31
|
+
server.start
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'locomotive/models'
|
2
|
+
require 'locomotive/decorators'
|
3
|
+
require 'locomotive/common'
|
4
|
+
|
5
|
+
require_relative 'steam/exceptions'
|
6
|
+
require_relative 'steam/decorators'
|
7
|
+
require_relative 'steam/configuration'
|
8
|
+
|
9
|
+
require 'sprockets'
|
10
|
+
require 'sprockets-sass'
|
11
|
+
require 'haml'
|
12
|
+
require 'compass'
|
13
|
+
|
14
|
+
#require 'httmultiparty'
|
15
|
+
require 'mime/types'
|
16
|
+
|
17
|
+
module Locomotive
|
18
|
+
module Steam
|
19
|
+
TEMPLATE_EXTENSIONS = %w(liquid haml)
|
20
|
+
|
21
|
+
class << self
|
22
|
+
attr_writer :configuration
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.configuration
|
26
|
+
@configuration ||= Configuration.new
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.reset
|
30
|
+
@configuration = Configuration.new
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.configure
|
34
|
+
yield(configuration)
|
35
|
+
end
|
36
|
+
|
37
|
+
class << self
|
38
|
+
def method_missing(name, *args, &block)
|
39
|
+
Locomotive::Steam.configuration.public_send(name)
|
40
|
+
rescue
|
41
|
+
super
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require_relative 'decorators/page_decorator'
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Locomotive
|
2
|
+
module Steam
|
3
|
+
module Decorators
|
4
|
+
class PageDecorator < SimpleDelegator
|
5
|
+
|
6
|
+
# Return the fullpath dasherized and with the "*" character
|
7
|
+
# for the slug of templatized page.
|
8
|
+
#
|
9
|
+
# @return [ hash ] The safe full paths
|
10
|
+
#
|
11
|
+
|
12
|
+
def safe_fullpath
|
13
|
+
if index_or_404?
|
14
|
+
slug[current_locale]
|
15
|
+
else
|
16
|
+
base = parent.safe_fullpath
|
17
|
+
_slug = if templatized? && !templatized_from_parent
|
18
|
+
'*'
|
19
|
+
else
|
20
|
+
slug[current_locale]
|
21
|
+
end
|
22
|
+
(base == 'index' ? _slug : File.join(base, _slug)).dasherize
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def parent
|
27
|
+
Locomotive::Steam::Decorators::PageDecorator.new(
|
28
|
+
Locomotive::Decorators::I18nDecorator.new(
|
29
|
+
__getobj__.parent, current_locale
|
30
|
+
)
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
# Return the Liquid template based on the raw_template property
|
35
|
+
# of the page. If the template is HAML or SLIM, then a pre-rendering to Liquid is done.
|
36
|
+
#
|
37
|
+
# @return [ String ] The liquid template or nil if not template has been provided
|
38
|
+
#
|
39
|
+
def source(locale)
|
40
|
+
@source ||= self.template[locale].source
|
41
|
+
end
|
42
|
+
|
43
|
+
def to_liquid
|
44
|
+
::Locomotive::Steam::Liquid::Drops::Page.new(self)
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,136 @@
|
|
1
|
+
module Locomotive
|
2
|
+
module Steam
|
3
|
+
module Entities
|
4
|
+
class Page
|
5
|
+
include Locomotive::Entity
|
6
|
+
|
7
|
+
## fields ##
|
8
|
+
attributes :parent, :title, :slug, :fullpath, :redirect_url, :redirect_type,
|
9
|
+
:template, :handle, :listed, :searchable, :templatized, :content_type,
|
10
|
+
:published, :cache_strategy, :response_type, :position, :seo_title,
|
11
|
+
:meta_keywords, :meta_description, :editable_elements, :site, :children,
|
12
|
+
:site_id, :parent_id
|
13
|
+
|
14
|
+
## aliases ##
|
15
|
+
alias :listed? :listed
|
16
|
+
alias :published? :published
|
17
|
+
alias :templatized? :templatized
|
18
|
+
alias :searchable? :searchable
|
19
|
+
|
20
|
+
attr_accessor :templatized_from_parent
|
21
|
+
|
22
|
+
# Tell if the page is either the index page.
|
23
|
+
#
|
24
|
+
# @return [ Boolean ] True if index page.
|
25
|
+
#
|
26
|
+
def index?
|
27
|
+
'index' == default_fullpath
|
28
|
+
end
|
29
|
+
|
30
|
+
# Tell if the page is either the index or the 404 page.
|
31
|
+
#
|
32
|
+
# @return [ Boolean ] True if index or 404 page.
|
33
|
+
#
|
34
|
+
def index_or_404?
|
35
|
+
%w(index 404).include?(default_fullpath)
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
# Returns unique fullpath for depth, 404, index calculation.
|
40
|
+
#
|
41
|
+
# @return [String] Fullpath based on first locale found
|
42
|
+
def default_fullpath
|
43
|
+
fullpath.values.first
|
44
|
+
end
|
45
|
+
|
46
|
+
alias :index_or_not_found? :index_or_404?
|
47
|
+
|
48
|
+
def with_cache?
|
49
|
+
self.cache_strategy != 'none'
|
50
|
+
end
|
51
|
+
|
52
|
+
def default_response_type?
|
53
|
+
self.response_type == 'text/html'
|
54
|
+
end
|
55
|
+
|
56
|
+
# Is it a redirect page ?
|
57
|
+
#
|
58
|
+
# @return [ Boolean ] True if the redirect_url property is set
|
59
|
+
#
|
60
|
+
def redirect?
|
61
|
+
false
|
62
|
+
#!self.redirect_url.blank?
|
63
|
+
end
|
64
|
+
|
65
|
+
# Depth of the page in the site tree.
|
66
|
+
# Both the index and 404 pages are 0-depth.
|
67
|
+
#
|
68
|
+
# @return [ Integer ] The depth
|
69
|
+
#
|
70
|
+
def depth
|
71
|
+
return 0 if %w(index 404).include?(default_fullpath)
|
72
|
+
default_fullpath.split('/').size
|
73
|
+
end
|
74
|
+
|
75
|
+
def unpublished?
|
76
|
+
!self.published?
|
77
|
+
end
|
78
|
+
|
79
|
+
# Modified setter in order to set correctly the slug
|
80
|
+
#
|
81
|
+
# @param [ String ] fullpath The fullpath
|
82
|
+
#
|
83
|
+
def fullpath_with_setting_slug=(fullpath)
|
84
|
+
fullpath.each do |key, value|
|
85
|
+
if value && (self.slug ||= {})[key].nil?
|
86
|
+
self.slug[key] = File.basename(value)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
self.fullpath_without_setting_slug = fullpath
|
90
|
+
end
|
91
|
+
|
92
|
+
alias_method_chain :fullpath=, :setting_slug
|
93
|
+
|
94
|
+
# Modified setter in order to set inheritance fields from parent
|
95
|
+
#
|
96
|
+
# @param [ String ] fullpath The fullpath
|
97
|
+
#
|
98
|
+
# def parent_with_inheritance=(parent)
|
99
|
+
# self.templatized_from_parent = parent.templatized?
|
100
|
+
|
101
|
+
# # copy properties from the parent
|
102
|
+
# %w(templatized content_type).each do |name|
|
103
|
+
# self.send(:"#{name}=", parent.send(name.to_sym))
|
104
|
+
# end
|
105
|
+
|
106
|
+
# self.parent_without_inheritance = parent
|
107
|
+
# end
|
108
|
+
# alias_method_chain :parent=, :inheritance
|
109
|
+
|
110
|
+
|
111
|
+
# Find an editable element from its block and slug (the couple is unique)
|
112
|
+
#
|
113
|
+
# @param [ String ] block The name of the block
|
114
|
+
# @param [ String ] slug The slug of the element
|
115
|
+
#
|
116
|
+
# @return [ Object ] The editable element or nil if not found
|
117
|
+
#
|
118
|
+
def find_editable_element(block, slug)
|
119
|
+
(self.editable_elements || []).detect do |el|
|
120
|
+
el.block.to_s == block.to_s && el.slug.to_s == slug.to_s
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
|
125
|
+
# Set the source of the page without any pre-rendering. Used by the API reader.
|
126
|
+
#
|
127
|
+
# @param [ String ] content The HTML raw template
|
128
|
+
#
|
129
|
+
def raw_template=(content, locale)
|
130
|
+
@source ||= {}
|
131
|
+
@source[locale] = content
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|