sibu 1.0.13 → 1.0.14

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dd539c6932c5892e902387c23af671662ef5e6f0
4
- data.tar.gz: 3479e3686c6e4eb316c4717e720424ffa98175b3
3
+ metadata.gz: 269f3881e2c48664a07b538764e527e174a8ae39
4
+ data.tar.gz: 8ec378a884b7d26ff5b400241cd6333ac0177aa1
5
5
  SHA512:
6
- metadata.gz: f1893df21c5e7b14cd4504744851ea2916bd0c4773245936899fafcc66832c8ebda987e93b24b07489eca3574a6d0c5a9f0584efe7daec8a53040b783d19f4aa
7
- data.tar.gz: e152ccc9a2afc46648b5a53a9a5801e4f02fa6aba8a3feb79f41e036b424ff8592bd25859c812e67137322cdfcc538d0c445cd41181a936e5c2f99c312a7deda
6
+ metadata.gz: db8306822fca5383613540b03d8e2e26ba0a511aa4e0c5ae62e30a6ada43778a442551cb8b9a1b11a9d6c79417ec60d24ddb53750acafd7fa0f11cd92419402e
7
+ data.tar.gz: 59f03f99a1920ae2a406ae657a043e8f216c952514ff3e8a4488023ae9a1bf8b7da89d81782821c5776780ef9fb54c12604b07302203c2242fd25c8f3b9e32ab
@@ -1,3 +1,4 @@
1
+ # Note : methods defined here are included in ActionView::Base
1
2
  module Sibu
2
3
  module PagesHelper
3
4
  include Sibu::Engine.routes.url_helpers
@@ -52,10 +53,11 @@ module Sibu
52
53
  defaults = {"id" => t_id, "text" => (t == :p ? Sibu::DEFAULT_PARAGRAPH : Sibu::DEFAULT_TEXT)}
53
54
  content = defaults.merge(elt.is_a?(Hash) ? elt : (select_element(elt) || {}))
54
55
  html_opts = {"id" => t_id}.merge(opts.except(:repeat, :children).stringify_keys)
55
- @sb_section = (@sb_section || []) + [t_id]
56
+ instance_variable_set("@sb_section", (instance_variable_get("@sb_section") || []) + [t_id])
57
+ Rails.logger.info("s : #{instance_variable_get("@sb_section")} - t : #{t_id} - content: #{content}")
56
58
  if action_name != 'show'
57
59
  html_opts.merge!({
58
- "data-id" => @sb_section[1..-1].join('|'),
60
+ "data-id" => instance_variable_get("@sb_section")[1..-1].join('|'),
59
61
  "data-type" => (t == :p ? "paragraph" : "text"),
60
62
  "data-repeat" => opts.delete(:repeat),
61
63
  "data-children" => opts.delete(:children)
@@ -74,7 +76,7 @@ module Sibu
74
76
  html_output = content_tag(t, raw(content["text"]).html_safe, html_opts)
75
77
  end
76
78
  end
77
- @sb_section -= [t_id]
79
+ instance_variable_set("@sb_section", instance_variable_get("@sb_section")[0..-2])
78
80
  html_output
79
81
  end
80
82
  end
@@ -82,18 +84,18 @@ module Sibu
82
84
  [:div, :section, :article, :aside, :header, :footer, :nav, :main, :ul, :ol, :wrapper].each do |t|
83
85
  define_method(t) do |elt, opts = {}, &block|
84
86
  t_id = elt.is_a?(Hash) ? elt["id"] : elt
85
- @sb_section = (@sb_section || []) + [t_id]
87
+ instance_variable_set("@sb_section", (instance_variable_get("@sb_section") || []) + [t_id])
86
88
  html_opts = {"id" => t_id}.merge(opts.except(:repeat, :children).stringify_keys)
87
89
  if action_name != 'show'
88
90
  html_opts.merge!({
89
- "data-id" => @sb_section[1..-1].join('|'),
91
+ "data-id" => instance_variable_get("@sb_section")[1..-1].join('|'),
90
92
  "data-type" => "group",
91
93
  "data-repeat" => opts.delete(:repeat),
92
94
  "data-children" => opts.delete(:children)
93
95
  })
94
96
  end
95
97
  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)
96
- @sb_section -= [t_id]
98
+ instance_variable_set("@sb_section", instance_variable_get("@sb_section")[0..-2])
97
99
  html_output
98
100
  end
99
101
  end
@@ -126,7 +128,7 @@ module Sibu
126
128
  end
127
129
 
128
130
  def select_element(id)
129
- @sb_entity.element(*@sb_section, id)
131
+ @sb_entity.element(*instance_variable_get("@sb_section"), id)
130
132
  end
131
133
 
132
134
  def elements(id = nil)
@@ -313,8 +315,9 @@ module Sibu
313
315
  content = defaults.merge(link_elt)
314
316
  val = content.delete("value") || ""
315
317
  text = content.delete("text")
316
- @sb_section = (@sb_section || []) + [t_id]
317
- html_opts.merge!({data: {id: @sb_section[1..-1].join('|'), type: "link", repeat: repeat, children: children}}) if action_name != 'show'
318
+ instance_variable_set("@sb_section", (instance_variable_get("@sb_section") || []) + [t_id])
319
+ # @sb_section = (@sb_section || []) + [t_id]
320
+ html_opts.merge!({data: {id: instance_variable_get("@sb_section")[1..-1].join('|'), type: "link", repeat: repeat, children: children}}) if action_name != 'show'
318
321
  if val.to_s.start_with?('http')
319
322
  content["href"] = val
320
323
  elsif val.to_s.start_with?('#')
@@ -332,7 +335,8 @@ module Sibu
332
335
  else
333
336
  html_output = content_tag(:a, raw(text), content.merge(html_opts).except("elements"))
334
337
  end
335
- @sb_section -= [t_id]
338
+ instance_variable_set("@sb_section", instance_variable_get("@sb_section") - [t_id])
339
+ # @sb_section -= [t_id]
336
340
  html_output
337
341
  end
338
342
 
data/lib/sibu/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Sibu
2
- VERSION = '1.0.13'
2
+ VERSION = '1.0.14'
3
3
  end
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.13
4
+ version: 1.0.14
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-03-25 00:00:00.000000000 Z
11
+ date: 2021-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails