sibu 1.0.7 → 1.0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/sibu/sites_controller.rb +5 -5
- data/app/helpers/sibu/extendable_helper.rb +4 -0
- data/app/helpers/sibu/pages_helper.rb +35 -7
- data/app/models/sibu/dynamic_style.rb +2 -2
- data/app/views/layouts/sibu/edit_content.html.erb +1 -3
- data/app/views/sibu/pages/edit_element.js.erb +3 -3
- data/lib/sibu/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d80e0d86c6b0ae3ee81f45775acf1c021fe15a17
|
4
|
+
data.tar.gz: 712c3383c6bb99034f988e9ecd45933f7cd60957
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a51aca986aff80d8a5c0341aa6081bf464f66ee74eacae47aedf730035a123d19edf9219e4d3df56e00b3adf56dfb2aff72841677b2459ceec37a1892f09ccb5
|
7
|
+
data.tar.gz: 79751582c4674b13b2d7da12cd50224d2073f695bdb746d2d222457eb97c5a4ccb01fb9962777ff71c95313c4c4f554b26a5da8d47661f4200469f9236cf0fe5
|
@@ -38,8 +38,8 @@ module Sibu
|
|
38
38
|
|
39
39
|
def update
|
40
40
|
if @site.update(site_params)
|
41
|
-
if conf[:custom_styles]
|
42
|
-
generate_styles(@site)
|
41
|
+
if conf[:custom_styles]
|
42
|
+
generate_styles(@site, @site.previous_changes.has_key?(:custom_data))
|
43
43
|
end
|
44
44
|
if @site.previous_changes.has_key?(:version)
|
45
45
|
@site.update_paths
|
@@ -61,7 +61,7 @@ module Sibu
|
|
61
61
|
if new_site.save
|
62
62
|
if conf[:custom_styles]
|
63
63
|
generate_styles(@site)
|
64
|
-
generate_styles(new_site)
|
64
|
+
generate_styles(new_site, true)
|
65
65
|
end
|
66
66
|
redirect_to sites_url, notice: "Le site a bien été copié."
|
67
67
|
else
|
@@ -81,8 +81,8 @@ module Sibu
|
|
81
81
|
params.require(:site).permit!
|
82
82
|
end
|
83
83
|
|
84
|
-
def generate_styles(site)
|
85
|
-
ds = Sibu::DynamicStyle.new(site.id)
|
84
|
+
def generate_styles(site, force_styles = false)
|
85
|
+
ds = Sibu::DynamicStyle.new(site.id, force_styles)
|
86
86
|
ds.compile
|
87
87
|
end
|
88
88
|
end
|
@@ -118,6 +118,13 @@ module Sibu
|
|
118
118
|
nested_elts.map {|e| e.merge({"data-id" => join_tokens(element_id_tokens[1..-1], e['id'])})}
|
119
119
|
end
|
120
120
|
|
121
|
+
def each_element(elt_or_id)
|
122
|
+
element_id = elt_id(elt_or_id)
|
123
|
+
@sb_section = (@sb_section + element_id.split("|")).uniq unless element_id.blank?
|
124
|
+
(@sb_entity.elements(*@sb_section) || []).map {|el| yield(el)}
|
125
|
+
@sb_section -= [element_id] unless element_id.blank?
|
126
|
+
end
|
127
|
+
|
121
128
|
def select_element(id)
|
122
129
|
@sb_entity.element(*@sb_section, id)
|
123
130
|
end
|
@@ -146,6 +153,22 @@ module Sibu
|
|
146
153
|
html_output
|
147
154
|
end
|
148
155
|
|
156
|
+
def svg_image(elt, opts = {})
|
157
|
+
size = opts.delete(:size)
|
158
|
+
t_id = elt.is_a?(Hash) ? elt["id"] : elt
|
159
|
+
defaults = {"id" => t_id, "xlink:href" => Sibu::DEFAULT_IMG}
|
160
|
+
content = defaults.merge((elt.is_a?(Hash) ? elt : (select_element(elt) || {})).transform_keys {|k| k == 'src' ? 'xlink:href' : k})
|
161
|
+
@sb_section = (@sb_section || []) + [t_id]
|
162
|
+
if action_name == 'show'
|
163
|
+
content["xlink:href"] = ("/#{conf[:deployment_path]}" + content["xlink:href"]) if @online && conf[:deployment_path]
|
164
|
+
else
|
165
|
+
opts.merge!({data: {id: @sb_section[1..-1].join('|'), type: "media", repeat: false, size: size}})
|
166
|
+
end
|
167
|
+
html_output = content_tag(:image, nil, content.except("id").merge(opts.stringify_keys) {|k, old, new| k == 'class' ? [old, new].join(' ') : new})
|
168
|
+
@sb_section -= [t_id]
|
169
|
+
html_output
|
170
|
+
end
|
171
|
+
|
149
172
|
def grp(elt, opts = {}, &block)
|
150
173
|
wrapper = opts.delete(:wrapper) || :div
|
151
174
|
repeat = opts.delete(:repeat)
|
@@ -169,10 +192,14 @@ module Sibu
|
|
169
192
|
end
|
170
193
|
|
171
194
|
def form_label(elt, html_opts = {}, &block)
|
172
|
-
|
195
|
+
t_id = elt.is_a?(Hash) ? elt["id"] : elt
|
196
|
+
defaults = {"id" => t_id, "text" => Sibu::DEFAULT_TEXT}
|
173
197
|
content = defaults.merge(elt.is_a?(Hash) ? elt : (select_element(elt) || {}))
|
174
|
-
|
175
|
-
|
198
|
+
@sb_section = (@sb_section || []) + [t_id]
|
199
|
+
html_opts.merge!({data: {id: @sb_section[1..-1].join('|'), type: "text"}}) if action_name != 'show'
|
200
|
+
html_output = content_tag(:label, raw(content["text"]).html_safe, html_opts)
|
201
|
+
@sb_section -= [t_id]
|
202
|
+
html_output
|
176
203
|
end
|
177
204
|
|
178
205
|
def form_input(elt, html_opts = {})
|
@@ -238,16 +265,17 @@ module Sibu
|
|
238
265
|
|
239
266
|
alias site sb_site
|
240
267
|
|
241
|
-
def render_page_section(s)
|
268
|
+
def render_page_section(s, set_id = false)
|
242
269
|
@sb_section = [s['id']]
|
243
270
|
@sb_entity = @page
|
244
271
|
render partial: "shared/#{@site.section_template(s)}",
|
245
|
-
locals: {sibu: self, sibu_section: s, sibu_attrs: sibu_attributes(s).html_safe}
|
272
|
+
locals: {sibu: self, sibu_section: s, sibu_attrs: sibu_attributes(s, set_id).html_safe}
|
246
273
|
end
|
247
274
|
|
248
275
|
# Page sections attrs
|
249
|
-
def sibu_attributes(section)
|
250
|
-
|
276
|
+
def sibu_attributes(section, set_id)
|
277
|
+
attrs = set_id ? ('id="' + section['id'] + '" ') : ''
|
278
|
+
attrs + (action_name != 'show' ? ('data-sb-id="' + section['id'] + '" data-sb-entity="page"') : '')
|
251
279
|
end
|
252
280
|
|
253
281
|
# Site sections attrs
|
@@ -3,9 +3,9 @@ module Sibu
|
|
3
3
|
|
4
4
|
attr_reader :site, :body, :env, :filename, :scss_file, :styles_changed
|
5
5
|
|
6
|
-
def initialize(site_id)
|
6
|
+
def initialize(site_id, force_styles = false)
|
7
7
|
@site = Sibu::Site.find(site_id)
|
8
|
-
@styles_changed = styles_changed?(@site.style_url)
|
8
|
+
@styles_changed = @site.style.nil? || force_styles || styles_changed?(@site.style_url)
|
9
9
|
if @styles_changed
|
10
10
|
@filename = "#{site_id}_#{Time.current.to_i}"
|
11
11
|
@scss_file = File.new(scss_file_path, 'w')
|
@@ -65,7 +65,7 @@
|
|
65
65
|
rightOverlay.style.height = height + "px";
|
66
66
|
rightOverlay.style.left = left + width + "px";
|
67
67
|
rightOverlay.style.top = top + "px";
|
68
|
-
editModeActions.style.top = (top
|
68
|
+
editModeActions.style.top = (top + height) + "px";
|
69
69
|
editModeActions.style.left = left + "px";
|
70
70
|
editModeActions.style.width = width + "px";
|
71
71
|
editMode.querySelector("#edit_section_msg").innerText = "Modifier la section";
|
@@ -79,8 +79,6 @@
|
|
79
79
|
editMode.querySelector("#new_section_after").style.display = "block";
|
80
80
|
editMode.querySelector("#delete_section").style.display = "block";
|
81
81
|
}
|
82
|
-
var topPadding = top <= 120 ? 60 : 120;
|
83
|
-
window.scrollTo(0, top - topPadding);
|
84
82
|
section.classList.add('sb-editing');
|
85
83
|
initInnerOverlays(section);
|
86
84
|
document.querySelector("#edit_overlays").innerHTML = "";
|
@@ -49,11 +49,11 @@ setTimeout(function() {
|
|
49
49
|
editPanel.querySelector('.sibu_image.selected').classList.remove('selected');
|
50
50
|
}
|
51
51
|
evt.currentTarget.classList.add('selected');
|
52
|
-
var imgElt = evt.currentTarget.querySelector("img");
|
53
|
-
|
52
|
+
var imgElt = evt.currentTarget.querySelector("img"), eltSrc = document.querySelector("#element_src");
|
53
|
+
eltSrc.value = imgElt.getAttribute("data-src");
|
54
54
|
document.querySelector("#element_alt").value = imgElt.getAttribute("data-alt");
|
55
55
|
editPanel.querySelector(".sibu_center").innerHTML =
|
56
|
-
'<img src="' +
|
56
|
+
'<img src="' + eltSrc.value + '"/>' +
|
57
57
|
'<div id="sibu_center_pos" style="display: none;">✕</div>' +
|
58
58
|
'<div id="sibu_center_desc" style="display: none;"><em>Cliquez sur l\'image pour la recentrer sur un point donné (à utiliser lorsque l\'image est tronquée car la zone d\'affichage est trop petite)</em></div>';
|
59
59
|
if (editPanel.querySelector(".sibu_selected_image > p:first-child")) {
|
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.12
|
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: 2020-
|
11
|
+
date: 2020-12-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -143,6 +143,7 @@ files:
|
|
143
143
|
- app/controllers/sibu/sites_controller.rb
|
144
144
|
- app/helpers/sibu/application_helper.rb
|
145
145
|
- app/helpers/sibu/documents_helper.rb
|
146
|
+
- app/helpers/sibu/extendable_helper.rb
|
146
147
|
- app/helpers/sibu/images_helper.rb
|
147
148
|
- app/helpers/sibu/pages_helper.rb
|
148
149
|
- app/helpers/sibu/sites_helper.rb
|