sibu 0.9.3 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +81 -4
- data/app/assets/javascripts/sibu/sibu.js.erb +17 -3
- data/app/assets/javascripts/tabs/van11y-accessible-tab-panel-aria.js +122 -124
- data/app/assets/stylesheets/sibu/defaults.scss +76 -80
- data/app/assets/stylesheets/sibu/sibu.css +8 -0
- data/app/controllers/sibu/application_controller.rb +8 -0
- data/app/controllers/sibu/pages_controller.rb +11 -4
- data/app/controllers/sibu/sites_controller.rb +4 -0
- data/app/helpers/sibu/application_helper.rb +1 -1
- data/app/helpers/sibu/pages_helper.rb +104 -23
- data/app/models/sibu/page.rb +3 -3
- data/app/models/sibu/site.rb +15 -1
- data/app/models/sibu/site_template.rb +1 -1
- data/app/views/layouts/sibu/edit_content.html.erb +184 -125
- data/app/views/sibu/images/edit.js.erb +5 -3
- data/app/views/sibu/pages/_code_edit_panel.html.erb +3 -2
- data/app/views/sibu/pages/_form.html.erb +8 -0
- data/app/views/sibu/pages/_link_edit_panel.html.erb +6 -6
- data/app/views/sibu/pages/_map_edit_panel.html.erb +3 -2
- data/app/views/sibu/pages/_media_edit_panel.html.erb +6 -6
- data/app/views/sibu/pages/_new_section_panel.html.erb +1 -1
- data/app/views/sibu/pages/_paragraph_edit_panel.html.erb +2 -2
- data/app/views/sibu/pages/_text_edit_panel.html.erb +2 -2
- data/app/views/sibu/pages/child_element.js.erb +2 -2
- data/app/views/sibu/pages/clone_element.js.erb +2 -2
- data/app/views/sibu/pages/create_section.js.erb +1 -1
- data/app/views/sibu/pages/delete_element.js.erb +1 -1
- data/app/views/sibu/pages/delete_section.js.erb +1 -1
- data/app/views/sibu/pages/edit_element.js.erb +68 -66
- data/app/views/sibu/pages/edit_section.js.erb +6 -5
- data/app/views/sibu/pages/index.html.erb +2 -2
- data/app/views/sibu/pages/new_section.js.erb +22 -13
- data/app/views/sibu/pages/update_element.js.erb +2 -2
- data/app/views/sibu/pages/update_section.js.erb +3 -3
- data/config/initializers/constants.rb +5 -3
- data/db/migrate/20200401130601_add_ref_to_site_templates.rb +5 -0
- data/lib/sibu/engine.rb +0 -2
- data/lib/sibu/version.rb +1 -1
- metadata +3 -18
- data/app/views/sibu/pages/destroy.html.erb +0 -2
- data/app/views/sibu/pages/update.html.erb +0 -2
@@ -41,6 +41,10 @@ $sibu-color3 : #333 !default;
|
|
41
41
|
font-weight: bold;
|
42
42
|
}
|
43
43
|
}
|
44
|
+
|
45
|
+
img {
|
46
|
+
max-height: 45vh;
|
47
|
+
}
|
44
48
|
}
|
45
49
|
|
46
50
|
.sibu_image {
|
@@ -234,101 +238,93 @@ $sibu-color3 : #333 !default;
|
|
234
238
|
}
|
235
239
|
|
236
240
|
#sections_panel {
|
237
|
-
|
238
|
-
|
239
|
-
&:before {
|
240
|
-
box-shadow: 0 -15px 15px -15px inset;
|
241
|
-
content: " ";
|
242
|
-
width: 100%;
|
243
|
-
left: 0;
|
244
|
-
top: -15px;
|
245
|
-
position: absolute;
|
246
|
-
z-index: 0;
|
247
|
-
height: 15px;
|
248
|
-
opacity: 0.4;
|
249
|
-
color: $sibu-color3;
|
250
|
-
}
|
251
|
-
|
252
|
-
.sibu_sections_tabs, .tabs {
|
253
|
-
height: 100%;
|
254
|
-
}
|
255
|
-
|
256
|
-
.sibu_sections {
|
241
|
+
.sibu_site_content {
|
257
242
|
padding: 2rem;
|
258
243
|
max-height: 60vh;
|
259
244
|
overflow-y: scroll;
|
260
245
|
|
261
|
-
.
|
262
|
-
|
263
|
-
padding: 0;
|
264
|
-
display: table;
|
265
|
-
width: 100%;
|
266
|
-
}
|
267
|
-
.tabs__item {
|
268
|
-
display: table-cell;
|
269
|
-
> a {
|
270
|
-
text-decoration: none;
|
271
|
-
}
|
272
|
-
}
|
246
|
+
& > .sibu_sections_tabs {
|
247
|
+
height: 100%;
|
273
248
|
|
274
|
-
|
275
|
-
|
276
|
-
cursor: pointer;
|
277
|
-
margin-bottom: -2px;
|
278
|
-
padding: 1rem 2.5rem;
|
279
|
-
border-bottom: 4px solid transparent;
|
280
|
-
color: $sibu-color1;
|
281
|
-
text-decoration: none;
|
282
|
-
border-radius: 0 0 0 0;
|
283
|
-
transition: .25s;
|
284
|
-
transition-property: color, border, background-color;
|
285
|
-
font-size: 2rem;
|
286
|
-
&:focus {
|
287
|
-
border-bottom-color: $sibu-color2;
|
288
|
-
color: $sibu-color2;
|
289
|
-
outline: 0;
|
290
|
-
}
|
291
|
-
}
|
249
|
+
& > .tabs {
|
250
|
+
height: 100%;
|
292
251
|
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
252
|
+
& > .tabs__list {
|
253
|
+
margin: 0;
|
254
|
+
padding: 0;
|
255
|
+
display: table;
|
256
|
+
width: 100%;
|
298
257
|
|
299
|
-
|
300
|
-
|
301
|
-
background-color: white;
|
302
|
-
max-height: calc(100% - 40px);
|
303
|
-
overflow-y: scroll;
|
258
|
+
.tabs__item {
|
259
|
+
display: table-cell;
|
304
260
|
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
box-shadow: 0 0 5px #cdcdcd;
|
261
|
+
> a {
|
262
|
+
text-decoration: none;
|
263
|
+
}
|
264
|
+
}
|
310
265
|
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
266
|
+
.tabs__link {
|
267
|
+
display: inline-block;
|
268
|
+
cursor: pointer;
|
269
|
+
margin-bottom: -2px;
|
270
|
+
padding: 1rem 2.5rem;
|
271
|
+
border-bottom: 4px solid transparent;
|
272
|
+
color: $sibu-color1;
|
273
|
+
text-decoration: none;
|
274
|
+
border-radius: 0 0 0 0;
|
275
|
+
transition: .25s;
|
276
|
+
transition-property: color, border, background-color;
|
277
|
+
font-size: 2rem;
|
278
|
+
|
279
|
+
&:focus {
|
280
|
+
border-bottom-color: $sibu-color2;
|
281
|
+
color: $sibu-color2;
|
282
|
+
outline: 0;
|
283
|
+
}
|
284
|
+
}
|
316
285
|
|
317
|
-
|
318
|
-
|
319
|
-
|
286
|
+
[aria-selected="true"].tabs__link {
|
287
|
+
border-bottom-color: $sibu-color2;
|
288
|
+
color: $sibu-color2;
|
289
|
+
outline: 0;
|
290
|
+
}
|
320
291
|
}
|
321
292
|
|
322
|
-
>
|
323
|
-
|
324
|
-
|
293
|
+
& > .tabs__content {
|
294
|
+
padding: 2rem 0;
|
295
|
+
background-color: white;
|
296
|
+
max-height: calc(100% - 40px);
|
297
|
+
overflow-y: scroll;
|
298
|
+
|
299
|
+
> * {
|
300
|
+
padding: 4px 0;
|
301
|
+
margin: 0 1rem 2rem 1rem;
|
302
|
+
min-height: auto;
|
303
|
+
box-shadow: 0 0 5px #cdcdcd;
|
304
|
+
|
305
|
+
&:hover {
|
306
|
+
cursor: pointer;
|
307
|
+
outline: dashed $sibu-color2 4px;
|
308
|
+
outline-offset: -5px;
|
309
|
+
}
|
310
|
+
|
311
|
+
&.selected {
|
312
|
+
outline: solid $sibu-color1 5px;
|
313
|
+
outline-offset: -5px;
|
314
|
+
}
|
315
|
+
|
316
|
+
> * {
|
317
|
+
margin-top: 0 !important;
|
318
|
+
margin-bottom: 0 !important;
|
319
|
+
}
|
320
|
+
}
|
321
|
+
|
322
|
+
&[aria-hidden="true"] {
|
323
|
+
display: none;
|
324
|
+
}
|
325
325
|
}
|
326
326
|
}
|
327
327
|
}
|
328
|
-
|
329
|
-
[aria-hidden="true"].tabs__content {
|
330
|
-
display: none;
|
331
|
-
}
|
332
328
|
}
|
333
329
|
|
334
330
|
.sibu_actions {
|
@@ -63,6 +63,10 @@
|
|
63
63
|
background-color: white;
|
64
64
|
}
|
65
65
|
|
66
|
+
#edit_panel.active, #sections_panel.active {
|
67
|
+
display: block;
|
68
|
+
}
|
69
|
+
|
66
70
|
#element_actions button {
|
67
71
|
display: none;
|
68
72
|
}
|
@@ -78,6 +82,10 @@
|
|
78
82
|
cursor: pointer;
|
79
83
|
}
|
80
84
|
|
85
|
+
#edit_overlays > *:hover {
|
86
|
+
opacity: 1;
|
87
|
+
}
|
88
|
+
|
81
89
|
.sb-editing [data-type] {
|
82
90
|
min-width: 1em;
|
83
91
|
min-height: 0.5em;
|
@@ -10,5 +10,13 @@ module Sibu
|
|
10
10
|
def sibu_user
|
11
11
|
send(conf[:current_user])
|
12
12
|
end
|
13
|
+
|
14
|
+
def check_site_ownership!
|
15
|
+
if conf[:multi_user] && conf[:admin_filter]
|
16
|
+
unless @site.nil? || @site.user_id == sibu_user.id || conf[:admin_filter].call(sibu_user)
|
17
|
+
redirect_to main_app.root_url, alert: "Vous n'êtes pas autorisé(e) à consulter cette page."
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
13
21
|
end
|
14
22
|
end
|
@@ -2,6 +2,7 @@ require_dependency "sibu/application_controller"
|
|
2
2
|
|
3
3
|
module Sibu
|
4
4
|
class PagesController < ApplicationController
|
5
|
+
before_action :compile_assets, only: [:show, :edit_content]
|
5
6
|
before_action :set_page, only: [:edit, :update, :destroy, :duplicate, :edit_element, :update_element, :clone_element,
|
6
7
|
:delete_element, :child_element, :new_section, :create_section, :edit_section,
|
7
8
|
:update_section, :delete_section]
|
@@ -10,6 +11,7 @@ module Sibu
|
|
10
11
|
:child_element, :new_section, :create_section, :edit_section,
|
11
12
|
:update_section, :delete_section]
|
12
13
|
before_action :set_online, only: [:show, :edit]
|
14
|
+
|
13
15
|
skip_before_action Rails.application.config.sibu[:auth_filter], only: [:show]
|
14
16
|
|
15
17
|
def index
|
@@ -44,7 +46,7 @@ module Sibu
|
|
44
46
|
end
|
45
47
|
|
46
48
|
def new
|
47
|
-
@page = Sibu::Page.new(site_id: @site.id)
|
49
|
+
@page = Sibu::Page.new(site_id: @site.id, source: 'Saisie manuelle')
|
48
50
|
end
|
49
51
|
|
50
52
|
def create
|
@@ -101,9 +103,9 @@ module Sibu
|
|
101
103
|
@content_type = params[:content_type]
|
102
104
|
@links = @site.pages_path_by_id if @site
|
103
105
|
@element = @entity.element(*@section_id.split('|'), *@element_id.split('|'))
|
104
|
-
@repeat = params[:repeat]
|
106
|
+
@repeat = params[:repeat] == 'true'
|
107
|
+
@children = params[:children] == 'true'
|
105
108
|
@size = params[:size].blank? ? :medium : params[:size].to_sym
|
106
|
-
@children = params[:children]
|
107
109
|
end
|
108
110
|
|
109
111
|
def update_element
|
@@ -146,7 +148,6 @@ module Sibu
|
|
146
148
|
end
|
147
149
|
|
148
150
|
def update_section
|
149
|
-
# {"utf8"=>"✓", "section"=>{"color"=>"#AFCA0B", "filters"=>"school_camps"}, "section_id"=>"cs1536301729", "refresh"=>"true", "commit"=>"Valider", "site_id"=>"3", "id"=>"1392"}
|
150
151
|
@entity.section(params[:section_id]).merge!(section_params)
|
151
152
|
logger.debug @entity.section(params[:section_id])
|
152
153
|
@updated = @entity.save
|
@@ -161,10 +162,12 @@ module Sibu
|
|
161
162
|
def set_page
|
162
163
|
@page = Sibu::Page.find(params[:id])
|
163
164
|
@site = Sibu::Site.includes(:pages).find(@page.site_id) if @page
|
165
|
+
check_site_ownership!
|
164
166
|
end
|
165
167
|
|
166
168
|
def set_site
|
167
169
|
@site = Sibu::Site.find(params[:site_id])
|
170
|
+
check_site_ownership!
|
168
171
|
end
|
169
172
|
|
170
173
|
def set_edit_context
|
@@ -193,5 +196,9 @@ module Sibu
|
|
193
196
|
def show_params
|
194
197
|
params.permit!
|
195
198
|
end
|
199
|
+
|
200
|
+
def compile_assets
|
201
|
+
Sibu::DynamicStyle.new(params[:site_id]).compile if Rails.env.development? && conf[:custom_styles] && !params[:site_id].blank?
|
202
|
+
end
|
196
203
|
end
|
197
204
|
end
|
@@ -37,6 +37,9 @@ module Sibu
|
|
37
37
|
if conf[:custom_styles] && @site.previous_changes.has_key?(:custom_data)
|
38
38
|
generate_styles(@site)
|
39
39
|
end
|
40
|
+
if @site.previous_changes.has_key?(:version)
|
41
|
+
@site.update_paths
|
42
|
+
end
|
40
43
|
redirect_to sites_url, notice: "Le site a bien été mis à jour."
|
41
44
|
else
|
42
45
|
flash.now[:alert] = "Une erreur s'est produite lors de l'enregistrement du site."
|
@@ -67,6 +70,7 @@ module Sibu
|
|
67
70
|
|
68
71
|
def set_site
|
69
72
|
@site = Sibu::Site.find(params[:id])
|
73
|
+
check_site_ownership!
|
70
74
|
end
|
71
75
|
|
72
76
|
def site_params
|
@@ -7,6 +7,10 @@ module Sibu
|
|
7
7
|
p ? (request.host == conf[:host] ? site_page_path(@site.id, p.id) : (conf[:deployment_path] ? "/#{conf[:deployment_path]}/#{p.path}" : "/#{p.path}")) : "#"
|
8
8
|
end
|
9
9
|
|
10
|
+
def is_current_page(link_val)
|
11
|
+
/\d+/.match?(link_val) && link_val.to_i == @page.id
|
12
|
+
end
|
13
|
+
|
10
14
|
def sections_templates
|
11
15
|
@site.site_template.available_sections
|
12
16
|
end
|
@@ -35,27 +39,78 @@ module Sibu
|
|
35
39
|
end
|
36
40
|
end
|
37
41
|
|
38
|
-
[:h1, :h2, :h3, :h4, :h5, :h6, :span].each do |t|
|
39
|
-
define_method(t) do |elt,
|
40
|
-
|
42
|
+
[:h1, :h2, :h3, :h4, :h5, :h6, :span, :p, :li].each do |t|
|
43
|
+
define_method(t) do |elt, opts = {}, &block|
|
44
|
+
t_id = elt.is_a?(Hash) ? elt["id"] : elt
|
45
|
+
defaults = {"id" => t_id, "text" => (t == :p ? Sibu::DEFAULT_PARAGRAPH : Sibu::DEFAULT_TEXT)}
|
41
46
|
content = defaults.merge(elt.is_a?(Hash) ? elt : (select_element(elt) || {}))
|
42
|
-
html_opts
|
43
|
-
|
47
|
+
html_opts = {"id" => t_id}.merge(opts.except(:repeat, :children).stringify_keys)
|
48
|
+
@sb_section = (@sb_section || []) + [t_id]
|
49
|
+
if action_name != 'show'
|
50
|
+
html_opts.merge!({
|
51
|
+
"data-id" => @sb_section[1..-1].join('|'),
|
52
|
+
"data-type" => (t == :p ? "paragraph" : "text"),
|
53
|
+
"data-repeat" => opts.delete(:repeat),
|
54
|
+
"data-children" => opts.delete(:children)
|
55
|
+
})
|
56
|
+
end
|
57
|
+
if block
|
58
|
+
if t == :p
|
59
|
+
html_output = content_tag(:div, content_tag(t, capture(content, nested_elements(elt), &block)), html_opts)
|
60
|
+
else
|
61
|
+
html_output = content_tag(t, capture(content, nested_elements(t_id), &block), html_opts)
|
62
|
+
end
|
63
|
+
else
|
64
|
+
if t == :p
|
65
|
+
html_output = content_tag(:div, content_tag(t, raw(content["text"]).html_safe), html_opts)
|
66
|
+
else
|
67
|
+
html_output = content_tag(t, raw(content["text"]).html_safe, html_opts)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
@sb_section -= [t_id]
|
71
|
+
html_output
|
44
72
|
end
|
45
73
|
end
|
46
74
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
75
|
+
[:div, :section, :article, :aside, :header, :footer, :nav, :main, :ul, :ol, :wrapper].each do |t|
|
76
|
+
define_method(t) do |elt, opts = {}, &block|
|
77
|
+
t_id = elt.is_a?(Hash) ? elt["id"] : elt
|
78
|
+
@sb_section = (@sb_section || []) + [t_id]
|
79
|
+
html_opts = {"id" => t_id}.merge(opts.except(:repeat, :children).stringify_keys)
|
80
|
+
if action_name != 'show'
|
81
|
+
html_opts.merge!({
|
82
|
+
"data-id" => @sb_section[1..-1].join('|'),
|
83
|
+
"data-type" => "group",
|
84
|
+
"data-repeat" => opts.delete(:repeat),
|
85
|
+
"data-children" => opts.delete(:children)
|
86
|
+
})
|
87
|
+
end
|
88
|
+
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)
|
89
|
+
@sb_section -= [t_id]
|
90
|
+
html_output
|
91
|
+
end
|
53
92
|
end
|
54
93
|
|
55
94
|
def sb
|
56
95
|
self
|
57
96
|
end
|
58
97
|
|
98
|
+
def join_tokens(tokens, suffix)
|
99
|
+
(tokens + [suffix]).select {|t| !t.blank?}.join("|")
|
100
|
+
end
|
101
|
+
|
102
|
+
# Note : the best option is probably a "section" helper that is instantiated from the section hash
|
103
|
+
# and that provides all the logic for elements manipulation (ex: section.h3(), section.elements, section.elements(nested_id), etc...)
|
104
|
+
# That will also remove the entity type references (site / page) from the partials (but is still has to be figured out by Sibu)
|
105
|
+
# Note : add "each_with_elements" and "elements" on section/elts enumerables
|
106
|
+
def nested_elements(elt_or_id)
|
107
|
+
element_id = elt_id(elt_or_id)
|
108
|
+
element_id_tokens = (@sb_section + element_id.split("|")).uniq
|
109
|
+
nested_elts = @sb_entity.elements(*element_id_tokens)
|
110
|
+
nested_elts.blank? ? [{"id" => element_id.split("|").last, "data-id" => join_tokens(element_id_tokens[1..-1], "#{element_id}0")}] :
|
111
|
+
nested_elts.map {|e| e.merge({"data-id" => join_tokens(element_id_tokens[1..-1], e['id'])})}
|
112
|
+
end
|
113
|
+
|
59
114
|
def select_element(id)
|
60
115
|
@sb_entity.element(*@sb_section, id)
|
61
116
|
end
|
@@ -69,7 +124,7 @@ module Sibu
|
|
69
124
|
wrapper = opts.delete(:wrapper)
|
70
125
|
repeat = opts.delete(:repeat)
|
71
126
|
size = opts.delete(:size)
|
72
|
-
defaults = {"id" => elt.is_a?(Hash) ? elt["id"] : elt, "src" => DEFAULT_IMG}
|
127
|
+
defaults = {"id" => elt.is_a?(Hash) ? elt["id"] : elt, "src" => Sibu::DEFAULT_IMG}
|
73
128
|
content = defaults.merge(elt.is_a?(Hash) ? elt : (select_element(elt) || {}))
|
74
129
|
if action_name == 'show'
|
75
130
|
content["src"] = ("/#{conf[:deployment_path]}" + content["src"]) if @online && conf[:deployment_path]
|
@@ -99,7 +154,7 @@ module Sibu
|
|
99
154
|
end
|
100
155
|
|
101
156
|
def form_label(elt, html_opts = {}, &block)
|
102
|
-
defaults = {"id" => elt.is_a?(Hash) ? elt["id"] : elt, "text" => DEFAULT_TEXT}
|
157
|
+
defaults = {"id" => elt.is_a?(Hash) ? elt["id"] : elt, "text" => Sibu::DEFAULT_TEXT}
|
103
158
|
content = defaults.merge(elt.is_a?(Hash) ? elt : (select_element(elt) || {}))
|
104
159
|
html_opts.merge!({data: {id: elt_id(elt), type: "text"}}) if action_name != 'show'
|
105
160
|
content_tag(:label, raw(content["text"]).html_safe, html_opts)
|
@@ -133,9 +188,28 @@ module Sibu
|
|
133
188
|
|
134
189
|
alias site sb_site
|
135
190
|
|
191
|
+
def render_page_section(s)
|
192
|
+
@sb_section = [s['id']]
|
193
|
+
@sb_entity = @page
|
194
|
+
render partial: "shared/#{@site.section_template(s)}",
|
195
|
+
locals: {sibu: self, sibu_section: s, sibu_attrs: sibu_attributes(s).html_safe}
|
196
|
+
end
|
197
|
+
|
198
|
+
# Page sections attrs
|
199
|
+
def sibu_attributes(section)
|
200
|
+
action_name != 'show' ? ('data-sb-id="' + section['id'] + '" data-sb-entity="page"') : ''
|
201
|
+
end
|
202
|
+
|
203
|
+
# Site sections attrs
|
204
|
+
def sibu_attrs(section_id)
|
205
|
+
@sb_section = [section_id]
|
206
|
+
@sb_entity = @site
|
207
|
+
action_name != 'show' ? ('data-sb-id="' + section_id + '" data-sb-entity="site"').html_safe : ''
|
208
|
+
end
|
209
|
+
|
136
210
|
def section(id, tag, html_opts = {}, &block)
|
137
211
|
@sb_section = [id]
|
138
|
-
opts = action_name != 'show' ? html_opts.merge({"data-sb-id" => id, "data-sb-
|
212
|
+
opts = action_name != 'show' ? html_opts.merge({"data-sb-id" => id, "data-sb-entity" => @sb_entity == @site ? 'site' : 'page'}) : html_opts
|
139
213
|
content_tag(tag, capture(self, &block), opts)
|
140
214
|
end
|
141
215
|
|
@@ -155,8 +229,9 @@ module Sibu
|
|
155
229
|
def link(elt, html_opts = {}, &block)
|
156
230
|
repeat = html_opts.delete(:repeat)
|
157
231
|
children = html_opts.delete(:children)
|
158
|
-
defaults = {"id" => elt_id(elt), "value" => "", "text" => DEFAULT_TEXT}
|
159
|
-
|
232
|
+
defaults = {"id" => elt_id(elt), "value" => "", "text" => Sibu::DEFAULT_TEXT}
|
233
|
+
link_elt = current_elt(elt)
|
234
|
+
content = defaults.merge(link_elt)
|
160
235
|
val = content.delete("value") || ""
|
161
236
|
text = content.delete("text")
|
162
237
|
html_opts.merge!({data: {id: elt_id(elt), type: "link", repeat: repeat, children: children}}) if action_name != 'show'
|
@@ -172,16 +247,18 @@ module Sibu
|
|
172
247
|
else
|
173
248
|
content["href"] = @links.keys.include?(val.to_s) ? (action_name == 'show' ? link_path(val) : site_page_edit_content_path(@site.id, val)) : '#'
|
174
249
|
end
|
175
|
-
# Note : sends elts in given order
|
176
250
|
if block_given?
|
177
|
-
|
251
|
+
@sb_section = (@sb_section || []) + [elt_id(elt)]
|
252
|
+
html_output = content_tag(:a, capture(link_elt, elts(elt), &block), content.merge(html_opts).except("elements"))
|
253
|
+
@sb_section -= [elt_id(elt)]
|
254
|
+
html_output
|
178
255
|
else
|
179
256
|
content_tag(:a, raw(text), content.merge(html_opts).except("elements"))
|
180
257
|
end
|
181
258
|
end
|
182
259
|
|
183
260
|
def interactive_map(elt, html_opts = {})
|
184
|
-
defaults = {"data-lat" => "
|
261
|
+
defaults = {"data-lat" => "46.1988027", "data-lng" => "5.1748288", "data-title" => Sibu::DEFAULT_TEXT}
|
185
262
|
content = defaults.merge(elt.is_a?(Hash) ? elt : (select_element(elt) || {"id" => elt}))
|
186
263
|
html_opts.merge!({data: {id: elt_id(elt), type: "map"}}) if action_name != 'show'
|
187
264
|
content_tag(:div, nil, content.merge(html_opts))
|
@@ -191,16 +268,20 @@ module Sibu
|
|
191
268
|
elt.is_a?(Hash) ? (elt["data-id"] || elt["id"]) : elt
|
192
269
|
end
|
193
270
|
|
271
|
+
def current_elt(elt)
|
272
|
+
(elt.is_a?(Hash) ? elt : (select_element(elt) || {})).except('elements')
|
273
|
+
end
|
274
|
+
|
194
275
|
def default_content(type)
|
195
276
|
case type
|
196
277
|
when "text"
|
197
|
-
{"text" => DEFAULT_TEXT}
|
278
|
+
{"text" => Sibu::DEFAULT_TEXT}
|
198
279
|
when "link"
|
199
|
-
{"value" => "", "text" => DEFAULT_TEXT}
|
280
|
+
{"value" => "", "text" => Sibu::DEFAULT_TEXT}
|
200
281
|
when "paragraph"
|
201
|
-
{"text" => DEFAULT_PARAGRAPH}
|
282
|
+
{"text" => Sibu::DEFAULT_PARAGRAPH}
|
202
283
|
when "media"
|
203
|
-
{"src" => DEFAULT_IMG}
|
284
|
+
{"src" => Sibu::DEFAULT_IMG}
|
204
285
|
when "embed"
|
205
286
|
{"code" => '<p>Contenu HTML personnalisé (iframe, etc...)</p>'}
|
206
287
|
end
|