sibu 1.0.14 → 1.0.15
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.
- checksums.yaml +4 -4
- data/app/helpers/sibu/pages_helper.rb +30 -19
- data/lib/sibu/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c73b880e87681d9f20c0f5b0a7fe505e226d2cf2
|
4
|
+
data.tar.gz: c9032cab8cb4a7365c5988c43a7e4686485b9e77
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29087a80f2f64240a12c975dc1faf82eb810541b408b839f60181997bcc294b25b79edb8a6b1c8a05e2f6c89db83af445ab896297e617fa5bab71dafbadaac22
|
7
|
+
data.tar.gz: f76234b3d79658d30f120c9a0bd11b4e5d6a8aee814400d29748f43709b4ed3eec86f5d9f903d39c516b25467c49e0d575ddf4db8dc33d9b8fc25c0ea91555b5
|
@@ -53,8 +53,7 @@ module Sibu
|
|
53
53
|
defaults = {"id" => t_id, "text" => (t == :p ? Sibu::DEFAULT_PARAGRAPH : Sibu::DEFAULT_TEXT)}
|
54
54
|
content = defaults.merge(elt.is_a?(Hash) ? elt : (select_element(elt) || {}))
|
55
55
|
html_opts = {"id" => t_id}.merge(opts.except(:repeat, :children).stringify_keys)
|
56
|
-
|
57
|
-
Rails.logger.info("s : #{instance_variable_get("@sb_section")} - t : #{t_id} - content: #{content}")
|
56
|
+
push_section_ids(t_id)
|
58
57
|
if action_name != 'show'
|
59
58
|
html_opts.merge!({
|
60
59
|
"data-id" => instance_variable_get("@sb_section")[1..-1].join('|'),
|
@@ -76,7 +75,7 @@ module Sibu
|
|
76
75
|
html_output = content_tag(t, raw(content["text"]).html_safe, html_opts)
|
77
76
|
end
|
78
77
|
end
|
79
|
-
|
78
|
+
pop_section_id
|
80
79
|
html_output
|
81
80
|
end
|
82
81
|
end
|
@@ -84,7 +83,7 @@ module Sibu
|
|
84
83
|
[:div, :section, :article, :aside, :header, :footer, :nav, :main, :ul, :ol, :wrapper].each do |t|
|
85
84
|
define_method(t) do |elt, opts = {}, &block|
|
86
85
|
t_id = elt.is_a?(Hash) ? elt["id"] : elt
|
87
|
-
|
86
|
+
push_section_ids(t_id)
|
88
87
|
html_opts = {"id" => t_id}.merge(opts.except(:repeat, :children).stringify_keys)
|
89
88
|
if action_name != 'show'
|
90
89
|
html_opts.merge!({
|
@@ -95,7 +94,7 @@ module Sibu
|
|
95
94
|
})
|
96
95
|
end
|
97
96
|
html_output = t == :wrapper ? capture(current_elt(elt), nested_elements(t_id), &block) : content_tag(t, capture(current_elt(elt), nested_elements(t_id), &block), html_opts)
|
98
|
-
|
97
|
+
pop_section_id
|
99
98
|
html_output
|
100
99
|
end
|
101
100
|
end
|
@@ -114,7 +113,7 @@ module Sibu
|
|
114
113
|
# Note : add "each_with_elements" and "elements" on section/elts enumerables
|
115
114
|
def nested_elements(elt_or_id)
|
116
115
|
element_id = elt_id(elt_or_id)
|
117
|
-
element_id_tokens = (@sb_section + element_id.split("|")).uniq
|
116
|
+
element_id_tokens = (instance_variable_get("@sb_section") + element_id.split("|")).uniq
|
118
117
|
nested_elts = @sb_entity.elements(*element_id_tokens)
|
119
118
|
nested_elts.blank? ? [{"id" => element_id.split("|").last, "data-id" => join_tokens(element_id_tokens[1..-1], "#{element_id}0")}] :
|
120
119
|
nested_elts.map {|e| e.merge({"data-id" => join_tokens(element_id_tokens[1..-1], e['id'])})}
|
@@ -122,9 +121,9 @@ module Sibu
|
|
122
121
|
|
123
122
|
def each_element(elt_or_id)
|
124
123
|
element_id = elt_id(elt_or_id)
|
125
|
-
|
126
|
-
(@sb_entity.elements(
|
127
|
-
|
124
|
+
push_section_ids(*element_id.split("|")) unless element_id.blank?
|
125
|
+
(@sb_entity.elements(*instance_variable_get("@sb_section")) || []).map {|el| yield(el)}
|
126
|
+
pop_section_id unless element_id.blank?
|
128
127
|
end
|
129
128
|
|
130
129
|
def select_element(id)
|
@@ -136,6 +135,16 @@ module Sibu
|
|
136
135
|
items.blank? ? [{"id" => "el#{Time.current.to_i}"}] : items
|
137
136
|
end
|
138
137
|
|
138
|
+
def push_section_ids(*section_ids)
|
139
|
+
Rails.logger.debug "push section ids #{section_ids}"
|
140
|
+
instance_variable_set("@sb_section", (instance_variable_get("@sb_section") || []) + section_ids)
|
141
|
+
end
|
142
|
+
|
143
|
+
def pop_section_id
|
144
|
+
instance_variable_set("@sb_section", instance_variable_get("@sb_section")[0..-2])
|
145
|
+
Rails.logger.debug "popped section - now #{instance_variable_get("@sb_section")}"
|
146
|
+
end
|
147
|
+
|
139
148
|
def img(elt, opts = {})
|
140
149
|
wrapper = opts.delete(:wrapper)
|
141
150
|
repeat = opts.delete(:repeat)
|
@@ -143,15 +152,15 @@ module Sibu
|
|
143
152
|
t_id = elt.is_a?(Hash) ? elt["id"] : elt
|
144
153
|
defaults = {"id" => t_id, "src" => Sibu::DEFAULT_IMG}
|
145
154
|
content = defaults.merge(elt.is_a?(Hash) ? elt : (select_element(elt) || {}))
|
146
|
-
|
155
|
+
push_section_ids(t_id)
|
147
156
|
if action_name == 'show'
|
148
157
|
content["src"] = ("/#{conf[:deployment_path]}" + content["src"]) if @online && conf[:deployment_path]
|
149
158
|
else
|
150
|
-
opts.merge!({data: {id: @sb_section[1..-1].join('|'), type: "media", repeat: repeat, size: size}})
|
159
|
+
opts.merge!({data: {id: instance_variable_get("@sb_section")[1..-1].join('|'), type: "media", repeat: repeat, size: size}})
|
151
160
|
end
|
152
161
|
html_output = wrapper ? content_tag(wrapper, content_tag(:img, nil, content.except("id")), opts)
|
153
162
|
: content_tag(:img, nil, content.except("id").merge(opts.stringify_keys) {|k, old, new| k == 'class' ? [old, new].join(' ') : new})
|
154
|
-
|
163
|
+
pop_section_id
|
155
164
|
html_output
|
156
165
|
end
|
157
166
|
|
@@ -267,8 +276,10 @@ module Sibu
|
|
267
276
|
|
268
277
|
alias site sb_site
|
269
278
|
|
279
|
+
# Resets section ids to clean up remaining ids
|
270
280
|
def render_page_section(s, set_id = false)
|
271
|
-
@sb_section
|
281
|
+
instance_variable_set("@sb_section", [])
|
282
|
+
push_section_ids(s['id'])
|
272
283
|
@sb_entity = @page
|
273
284
|
render partial: "shared/#{@site.section_template(s)}",
|
274
285
|
locals: {sibu: self, sibu_section: s, sibu_attrs: sibu_attributes(s, set_id).html_safe}
|
@@ -280,9 +291,10 @@ module Sibu
|
|
280
291
|
attrs + (action_name != 'show' ? ('data-sb-id="' + section['id'] + '" data-sb-entity="page"') : '')
|
281
292
|
end
|
282
293
|
|
283
|
-
# Site sections attrs
|
294
|
+
# Site sections attrs - resets section ids
|
284
295
|
def sibu_attrs(section_id)
|
285
|
-
@sb_section
|
296
|
+
instance_variable_set("@sb_section", [])
|
297
|
+
push_section_ids(section_id)
|
286
298
|
@sb_entity = @site
|
287
299
|
action_name != 'show' ? ('data-sb-id="' + section_id + '" data-sb-entity="site"').html_safe : ''
|
288
300
|
end
|
@@ -315,8 +327,8 @@ module Sibu
|
|
315
327
|
content = defaults.merge(link_elt)
|
316
328
|
val = content.delete("value") || ""
|
317
329
|
text = content.delete("text")
|
318
|
-
|
319
|
-
|
330
|
+
push_section_ids(t_id)
|
331
|
+
|
320
332
|
html_opts.merge!({data: {id: instance_variable_get("@sb_section")[1..-1].join('|'), type: "link", repeat: repeat, children: children}}) if action_name != 'show'
|
321
333
|
if val.to_s.start_with?('http')
|
322
334
|
content["href"] = val
|
@@ -335,8 +347,7 @@ module Sibu
|
|
335
347
|
else
|
336
348
|
html_output = content_tag(:a, raw(text), content.merge(html_opts).except("elements"))
|
337
349
|
end
|
338
|
-
|
339
|
-
# @sb_section -= [t_id]
|
350
|
+
pop_section_id
|
340
351
|
html_output
|
341
352
|
end
|
342
353
|
|
data/lib/sibu/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sibu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jean-Baptiste Vilain
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|