sibu 0.1.20 → 0.1.21
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/assets/stylesheets/sibu/sibu.css +7 -2
- data/app/controllers/sibu/pages_controller.rb +18 -6
- data/app/helpers/sibu/pages_helper.rb +29 -23
- data/app/models/concerns/sibu/sections_concern.rb +87 -65
- data/app/models/sibu/page.rb +6 -5
- data/app/models/sibu/site.rb +2 -2
- data/app/models/sibu/site_template.rb +4 -0
- data/app/views/layouts/sibu/edit_content.html.erb +39 -19
- data/app/views/sibu/pages/_custom_styles.html.erb +4 -4
- data/app/views/sibu/pages/_element_actions.html.erb +3 -2
- data/app/views/sibu/pages/_form.html.erb +0 -7
- data/app/views/sibu/pages/_media_edit_panel.html.erb +1 -1
- data/app/views/sibu/pages/_new_section_panel.html.erb +25 -0
- data/app/views/sibu/pages/child_element.js.erb +6 -0
- data/app/views/sibu/pages/{clone_section.js.erb → create_section.js.erb} +1 -1
- data/app/views/sibu/pages/edit_element.js.erb +9 -2
- data/app/views/sibu/pages/index.html.erb +0 -2
- data/app/views/sibu/pages/new_section.js.erb +17 -0
- data/app/views/sibu/pages/show.html.erb +3 -1
- data/config/initializers/constants.rb +3 -0
- data/config/routes.rb +3 -2
- data/lib/sibu/utils.rb +15 -0
- data/lib/sibu/version.rb +1 -1
- metadata +8 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c5d82061f85ff21bd3989f9b12554ed157a9338
|
4
|
+
data.tar.gz: b11f19b5ee199a81cea6dbbd5703916349e01bb0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75fe75f7afaa6dd93753f4c11c4106f5dd386244daab9765733ad73651091f6e76e86012ca6209096bba78898659fef9450dfeb3549541c02f8810b5369e9c22
|
7
|
+
data.tar.gz: 7a88ff8ceddec27e47629ddad26c66636670290fbef6e4eb8a581f444b79050ed1678856abe495758b352c12260c40eeb31c7e78a1a959031dcfd2e832a5d60b
|
@@ -49,7 +49,7 @@
|
|
49
49
|
right: 0;
|
50
50
|
}
|
51
51
|
|
52
|
-
#edit_panel {
|
52
|
+
#edit_panel, #sections_panel {
|
53
53
|
position: fixed;
|
54
54
|
left: 0;
|
55
55
|
bottom: 0;
|
@@ -59,7 +59,12 @@
|
|
59
59
|
background-color: white;
|
60
60
|
}
|
61
61
|
|
62
|
-
#
|
62
|
+
#sections_panel .sibu_sections {
|
63
|
+
max-height: 60vh;
|
64
|
+
overflow-y: scroll;
|
65
|
+
}
|
66
|
+
|
67
|
+
#element_actions button {
|
63
68
|
display: none;
|
64
69
|
}
|
65
70
|
|
@@ -3,10 +3,10 @@ require_dependency "sibu/application_controller"
|
|
3
3
|
module Sibu
|
4
4
|
class PagesController < ApplicationController
|
5
5
|
before_action :set_page, only: [:edit, :update, :destroy, :edit_element, :update_element, :clone_element,
|
6
|
-
:delete_element, :
|
6
|
+
:delete_element, :child_element, :new_section, :create_section, :delete_section]
|
7
7
|
before_action :set_site, only: [:index, :new]
|
8
8
|
before_action :set_edit_context, only: [:edit_element, :update_element, :clone_element, :delete_element,
|
9
|
-
:
|
9
|
+
:child_element, :new_section, :create_section, :delete_section]
|
10
10
|
skip_before_action Rails.application.config.sibu[:auth_filter], only: [:show]
|
11
11
|
|
12
12
|
def index
|
@@ -75,6 +75,7 @@ module Sibu
|
|
75
75
|
@element = @entity.element(*@section_id.split('|'), *@element_id.split('|'))
|
76
76
|
@repeat = params[:repeat]
|
77
77
|
@size = params[:size].blank? ? :medium : params[:size].to_sym
|
78
|
+
@children = params[:children]
|
78
79
|
end
|
79
80
|
|
80
81
|
def update_element
|
@@ -90,14 +91,21 @@ module Sibu
|
|
90
91
|
@deleted = @entity.delete_element(*@section_id.split('|'), *@element_id.split('|'))
|
91
92
|
end
|
92
93
|
|
93
|
-
def
|
94
|
+
def child_element
|
95
|
+
@added = @entity.child_element(*@section_id.split('|'), *@element_id.split('|'))
|
94
96
|
end
|
95
97
|
|
96
|
-
|
98
|
+
# Todo - init available sections properly and fix dynamic sections creation (init needed)
|
99
|
+
def new_section
|
100
|
+
@after = params[:after]
|
101
|
+
@links = @site.pages_path_by_id
|
102
|
+
@page.sections << {"id" => "sibu_template_free_text", "elements" => [{"id" => "paragraph0"}]}
|
103
|
+
@page.sections << {"id" => "sibu_template_gallery",
|
104
|
+
"elements" => [{"id" => "slide0", "elements" => [{"id" => "slide0"}, {"id" => "slide1"}, {"id" => "slide2"}]}]}
|
97
105
|
end
|
98
106
|
|
99
|
-
def
|
100
|
-
@
|
107
|
+
def create_section
|
108
|
+
@created = @entity.create_section(*@section_id.split('|'), params[:after], section_params)
|
101
109
|
end
|
102
110
|
|
103
111
|
def delete_section
|
@@ -129,5 +137,9 @@ module Sibu
|
|
129
137
|
def element_params
|
130
138
|
params.require(:element).permit!
|
131
139
|
end
|
140
|
+
|
141
|
+
def section_params
|
142
|
+
params.require(:section).permit!
|
143
|
+
end
|
132
144
|
end
|
133
145
|
end
|
@@ -11,6 +11,11 @@ module Sibu
|
|
11
11
|
[['Accueil', 'home'], ['Offre', 'offer'], ['Galerie', 'gallery'], ['Destination', 'destination'], ['Mentions légales', 'text']]
|
12
12
|
end
|
13
13
|
|
14
|
+
def sections_templates
|
15
|
+
Dir.glob(File.join(Rails.root, "app/views/shared/#{@site.site_template.path}/*.erb")).map {|f| f.split('/').last}
|
16
|
+
.map {|f| f[1..-1].gsub('.html.erb', '')}.select {|f| f != 'site'}.map {|f| {"id" => "sibu_template_#{f}", "template" => f}}
|
17
|
+
end
|
18
|
+
|
14
19
|
def page_languages
|
15
20
|
[['Français', 'fr'], ['Anglais', 'en']]
|
16
21
|
end
|
@@ -29,7 +34,7 @@ module Sibu
|
|
29
34
|
|
30
35
|
[:h1, :h2, :h3, :h4, :h5, :h6, :span].each do |t|
|
31
36
|
define_method(t) do |elt, html_opts = {}|
|
32
|
-
defaults = {"id" => elt.is_a?(Hash) ? elt["id"] : elt, "text" =>
|
37
|
+
defaults = {"id" => elt.is_a?(Hash) ? elt["id"] : elt, "text" => DEFAULT_TEXT}
|
33
38
|
content = defaults.merge(elt.is_a?(Hash) ? elt : (select_element(elt) || {}))
|
34
39
|
html_opts.merge!({data: {id: elt_id(elt), type: "text"}}) if action_name != 'show'
|
35
40
|
content_tag(t, raw(content["text"]).html_safe, html_opts)
|
@@ -37,7 +42,7 @@ module Sibu
|
|
37
42
|
end
|
38
43
|
|
39
44
|
def p(elt, html_opts = {})
|
40
|
-
defaults = {"id" => elt.is_a?(Hash) ? elt["id"] : elt, "text" =>
|
45
|
+
defaults = {"id" => elt.is_a?(Hash) ? elt["id"] : elt, "text" => DEFAULT_PARAGRAPH}
|
41
46
|
content = defaults.merge(elt.is_a?(Hash) ? elt : (select_element(elt) || {}))
|
42
47
|
html_opts.merge!({data: {id: elt_id(elt), type: "paragraph"}}) if action_name != 'show'
|
43
48
|
content_tag(:div, content_tag(:p, raw(content["text"]).html_safe), html_opts)
|
@@ -48,18 +53,19 @@ module Sibu
|
|
48
53
|
end
|
49
54
|
|
50
55
|
def select_element(id)
|
51
|
-
@sb_entity.
|
56
|
+
@sb_entity.element(*@sb_section, id)
|
52
57
|
end
|
53
58
|
|
54
59
|
def elements(id = nil)
|
55
|
-
id ? select_element(id)["elements"] : @sb_entity.
|
60
|
+
items = id ? select_element(id)["elements"] : @sb_entity.find_or_init(*@sb_section)["elements"]
|
61
|
+
items.blank? ? [{"id" => ""}] : items
|
56
62
|
end
|
57
63
|
|
58
64
|
def img(elt, opts = {})
|
59
65
|
wrapper = opts.delete(:wrapper)
|
60
66
|
repeat = opts.delete(:repeat)
|
61
67
|
size = opts.delete(:size)
|
62
|
-
defaults = {"id" => elt.is_a?(Hash) ? elt["id"] : elt, "src" =>
|
68
|
+
defaults = {"id" => elt.is_a?(Hash) ? elt["id"] : elt, "src" => DEFAULT_IMG}
|
63
69
|
content = defaults.merge(elt.is_a?(Hash) ? elt : (select_element(elt) || {}))
|
64
70
|
opts.merge!({data: {id: elt_id(elt), type: "media", repeat: repeat, size: size}}) if action_name != 'show'
|
65
71
|
wrapper ? content_tag(wrapper, content_tag(:img, nil, content.except("id")), opts) : content_tag(:img, nil, content.except("id").merge(opts))
|
@@ -80,61 +86,61 @@ module Sibu
|
|
80
86
|
|
81
87
|
def section(id, tag, html_opts = {}, &block)
|
82
88
|
@sb_section = [id]
|
83
|
-
|
84
|
-
opts = action_name != 'show' ? html_opts.merge({"data-sb-id" => id, "data-sb-repeat" => rpt, "data-sb-entity" => @sb_entity == @site ? 'site' : 'page'}) : html_opts
|
89
|
+
opts = action_name != 'show' ? html_opts.merge({"data-sb-id" => id, "data-sb-repeat" => @sb_entity != @site, "data-sb-entity" => @sb_entity == @site ? 'site' : 'page'}) : html_opts
|
85
90
|
content_tag(tag, capture(self, &block), opts)
|
86
91
|
end
|
87
92
|
|
93
|
+
# Todo : voir comment générer une section par défaut en mode liste des sections et insertion d'un bloc avec sections
|
88
94
|
def sections(id, tag, html_opts = {}, &block)
|
89
|
-
(@sb_entity.
|
95
|
+
(@sb_entity.find_or_init(id)["elements"].map.with_index do |elt, i|
|
90
96
|
@sb_section = [id, elt["id"]]
|
91
97
|
opts = action_name != 'show' ? html_opts.merge({"data-sb-id" => @sb_section.join('|'), "data-sb-repeat" => true, "data-sb-entity" => @sb_entity == @site ? 'site' : 'page'}) : html_opts
|
92
98
|
content_tag(tag, capture(self, i, &block), opts)
|
93
99
|
end).join('').html_safe
|
94
100
|
end
|
95
101
|
|
96
|
-
def elt(id)
|
97
|
-
select_element(id)
|
98
|
-
end
|
99
|
-
|
100
|
-
# Note : could work well - set the ids hierarchy in elements retrieved from the db
|
101
102
|
def elts(id)
|
102
103
|
items = []
|
103
|
-
|
104
|
-
|
105
|
-
|
104
|
+
element_id = elt_id(id)
|
105
|
+
elemnts = @sb_entity.elements(*(@sb_section + element_id.split("|")).uniq)
|
106
|
+
if elemnts
|
107
|
+
elemnts.each do |e|
|
108
|
+
e["data-id"] = [element_id, e["id"]].join("|")
|
109
|
+
items << e
|
110
|
+
end
|
106
111
|
end
|
107
|
-
items
|
112
|
+
items.blank? ? [{"id" => element_id.split("|").last, "data-id" => [element_id, "#{id}0"].join("|")}] : items
|
108
113
|
end
|
109
114
|
|
110
115
|
def link(elt, html_opts = {}, &block)
|
111
116
|
repeat = html_opts.delete(:repeat)
|
112
|
-
|
117
|
+
children = html_opts.delete(:children)
|
118
|
+
defaults = {"id" => elt_id(elt), "value" => "", "text" => DEFAULT_TEXT}
|
113
119
|
content = defaults.merge(elt.is_a?(Hash) ? elt : (select_element(elt) || {}))
|
114
120
|
val = content.delete("value") || ""
|
115
121
|
text = content.delete("text");
|
116
|
-
html_opts.merge!({data: {id: elt_id(elt), type: "link", repeat: repeat}}) if action_name != 'show'
|
122
|
+
html_opts.merge!({data: {id: elt_id(elt), type: "link", repeat: repeat, children: children}}) if action_name != 'show'
|
117
123
|
if val.to_s.include?('http')
|
118
124
|
content["href"] = val
|
119
125
|
else
|
120
126
|
content["href"] = @links.keys.include?(val.to_s) ? (action_name == 'show' ? link_path(val) : site_page_edit_content_path(@site.id, val)) : '#'
|
121
127
|
end
|
122
128
|
if block_given?
|
123
|
-
content_tag(:a, content.merge(html_opts), &block)
|
129
|
+
content_tag(:a, content.merge(html_opts).except("elements"), &block)
|
124
130
|
else
|
125
|
-
content_tag(:a, text, content.merge(html_opts))
|
131
|
+
content_tag(:a, text, content.merge(html_opts).except("elements"))
|
126
132
|
end
|
127
133
|
end
|
128
134
|
|
129
135
|
def interactive_map(elt, html_opts = {}, &block)
|
130
|
-
defaults = {"data-lat" => "45.68854", "data-lng" => "5.91587", "data-title" =>
|
136
|
+
defaults = {"data-lat" => "45.68854", "data-lng" => "5.91587", "data-title" => DEFAULT_TEXT}
|
131
137
|
content = elt.is_a?(Hash) ? defaults.merge(elt) : (select_element(elt) || {"id" => elt}).merge(defaults)
|
132
138
|
html_opts.merge!({data: {id: elt_id(elt), type: "map"}}) if action_name != 'show'
|
133
139
|
content_tag(:div, nil, content.merge(html_opts))
|
134
140
|
end
|
135
141
|
|
136
142
|
def elt_id(elt)
|
137
|
-
elt.is_a?(Hash) ? elt["id"] : elt
|
143
|
+
elt.is_a?(Hash) ? (elt["data-id"] || elt["id"]) : elt
|
138
144
|
end
|
139
145
|
end
|
140
146
|
end
|
@@ -2,68 +2,54 @@ module Sibu
|
|
2
2
|
module SectionsConcern
|
3
3
|
include ActiveSupport::Concern
|
4
4
|
|
5
|
-
def section(
|
6
|
-
if
|
7
|
-
|
8
|
-
|
9
|
-
self.sections = {}
|
10
|
-
else
|
11
|
-
s = sections[ids[0]]
|
12
|
-
end
|
13
|
-
if s.nil?
|
14
|
-
logger.debug("init section #{ids[0]}")
|
15
|
-
s = []
|
16
|
-
self.sections[ids[0]] = s
|
17
|
-
save
|
18
|
-
end
|
19
|
-
s
|
20
|
-
elsif ids.length == 2
|
21
|
-
subsection(*ids)
|
22
|
-
elsif ids.length == 3
|
23
|
-
sub = subsection(*ids[0..1])
|
24
|
-
elt_idx = sub.index {|elt| elt["id"] == ids.last}
|
25
|
-
sub[elt_idx]["elements"]
|
5
|
+
def section(id)
|
6
|
+
if id
|
7
|
+
pos = sections.index {|s| s["id"] == id}
|
8
|
+
pos ? sections[pos] : {"id" => id}
|
26
9
|
end
|
27
10
|
end
|
28
11
|
|
29
|
-
def
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
12
|
+
def elements(*ids)
|
13
|
+
unless ids.blank?
|
14
|
+
s = section(ids.first)
|
15
|
+
unless s["elements"].blank?
|
16
|
+
ids[1..-1].each do |elt_id|
|
17
|
+
pos = s["elements"].index {|e| e["id"] == elt_id.split('|').last}
|
18
|
+
s = pos ? s["elements"][pos] : {"id" => elt_id, "elements" => []}
|
19
|
+
end
|
20
|
+
s["elements"]
|
21
|
+
end
|
38
22
|
end
|
39
|
-
sub["elements"]
|
40
|
-
end
|
41
|
-
|
42
|
-
def element(*ids, element_id)
|
43
|
-
elt = section(*ids).select {|e| e["id"] == element_id}.first
|
44
|
-
elt || {"id" => element_id}
|
45
23
|
end
|
46
24
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
25
|
+
def element(*ids)
|
26
|
+
unless ids.blank?
|
27
|
+
if ids.length == 1
|
28
|
+
section(ids.first)
|
29
|
+
else
|
30
|
+
elts = elements(*ids[0..-2]) || []
|
31
|
+
pos = elts.index {|e| e["id"] == ids.last}
|
32
|
+
pos ? elts[pos] : {"id" => ids.last}
|
33
|
+
end
|
34
|
+
end
|
51
35
|
end
|
52
36
|
|
53
37
|
def update_element(*ids, value)
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
38
|
+
unless ids.blank?
|
39
|
+
parent_section = find_or_init(*ids)["elements"]
|
40
|
+
if parent_section.any? {|elt| elt["id"] == value["id"]}
|
41
|
+
parent_section.map! {|elt| elt["id"] == value["id"] ? value : elt}
|
42
|
+
else
|
43
|
+
parent_section << value.to_h
|
44
|
+
end
|
61
45
|
|
62
|
-
|
46
|
+
value if save
|
47
|
+
end
|
63
48
|
end
|
64
49
|
|
65
50
|
def clone_element(*ids, element_id)
|
66
|
-
|
51
|
+
src_elt = find_or_init(*ids, element_id)
|
52
|
+
siblings = find_or_init(*ids)["elements"]
|
67
53
|
ref_index = siblings.index {|s| s["id"] == element_id}
|
68
54
|
new_elt = siblings[ref_index].deep_dup
|
69
55
|
new_elt["id"] = element_id + '§'
|
@@ -72,7 +58,8 @@ module Sibu
|
|
72
58
|
end
|
73
59
|
|
74
60
|
def delete_element(*ids, element_id)
|
75
|
-
|
61
|
+
src_elt = find_or_init(*ids, element_id)
|
62
|
+
siblings = find_or_init(*ids)["elements"]
|
76
63
|
if siblings.length > 1
|
77
64
|
ref_index = siblings.index {|s| s["id"] == element_id}
|
78
65
|
siblings.delete_at(ref_index)
|
@@ -82,30 +69,65 @@ module Sibu
|
|
82
69
|
end
|
83
70
|
end
|
84
71
|
|
85
|
-
def
|
86
|
-
siblings =
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
72
|
+
def child_element(*ids, element_id)
|
73
|
+
siblings = elements(*ids)
|
74
|
+
parent_elt = siblings[siblings.index {|s| s["id"] == element_id}]
|
75
|
+
if parent_elt["elements"].blank?
|
76
|
+
parent_elt["elements"] = [{"id" => "#{element_id}*"}]
|
77
|
+
else
|
78
|
+
parent_elt["elements"] << [{"id" => "#{parent_elt["elements"].last["id"]}§"}]
|
79
|
+
end
|
80
|
+
save
|
81
|
+
end
|
82
|
+
|
83
|
+
def create_section(*ids, after, new_section)
|
84
|
+
new_section["id"] = "#{new_section["template"]}-#{Time.current.to_i}"
|
85
|
+
if ids.length == 1
|
86
|
+
parent = sections
|
87
|
+
else
|
88
|
+
parent = find_or_init(*ids[0..-2])["elements"]
|
89
|
+
end
|
90
|
+
ref_pos = parent.index {|s| s["id"] == ids.last}
|
91
|
+
parent.insert(after.to_s == 'true' ? ref_pos + 1 : ref_pos, new_section)
|
91
92
|
save ? new_section : nil
|
92
93
|
end
|
93
94
|
|
94
95
|
def delete_section(*ids)
|
95
|
-
|
96
|
-
|
97
|
-
|
96
|
+
if ids.length == 1
|
97
|
+
if sections.length == 1
|
98
|
+
nil
|
99
|
+
else
|
100
|
+
ref_index = sections.index {|s| s["id"] == ids.first}
|
101
|
+
sections.delete_at(ref_index)
|
102
|
+
save
|
103
|
+
end
|
98
104
|
else
|
99
|
-
|
100
|
-
|
105
|
+
parent = find_or_init(*ids[0..-2])
|
106
|
+
ref_index = parent["elements"].index {|s| s["id"] == ids.last}
|
107
|
+
parent["elements"].delete_at(ref_index)
|
101
108
|
save
|
102
109
|
end
|
103
110
|
end
|
104
111
|
|
105
|
-
def
|
106
|
-
|
107
|
-
|
108
|
-
|
112
|
+
def elt(siblings, elt_id, default_elt = nil)
|
113
|
+
pos = siblings.index {|e| e["id"] == elt_id}
|
114
|
+
pos ? siblings[pos] : default_elt
|
115
|
+
end
|
116
|
+
|
117
|
+
def find_or_init(*ids)
|
118
|
+
node = nil
|
119
|
+
siblings = sections
|
120
|
+
ids.each do |elt_id|
|
121
|
+
node = elt(siblings, elt_id)
|
122
|
+
if node.nil?
|
123
|
+
node = {"id" => elt_id, "elements" => []}
|
124
|
+
siblings << node
|
125
|
+
elsif node["elements"].nil?
|
126
|
+
node["elements"] = []
|
127
|
+
end
|
128
|
+
siblings = node["elements"]
|
129
|
+
end
|
130
|
+
node
|
109
131
|
end
|
110
132
|
end
|
111
133
|
end
|
data/app/models/sibu/page.rb
CHANGED
@@ -6,19 +6,20 @@ module Sibu
|
|
6
6
|
|
7
7
|
store :metadata, accessors: [:title, :description, :keywords], coder: JSON
|
8
8
|
|
9
|
-
before_save :
|
10
|
-
validates_presence_of :name, :site, :language
|
9
|
+
before_save :update_path
|
10
|
+
validates_presence_of :name, :site, :language
|
11
11
|
|
12
12
|
def save_and_init
|
13
13
|
if valid?
|
14
|
-
template_defaults = site.site_template.pages.
|
14
|
+
template_defaults = site.site_template.pages.first
|
15
15
|
self.sections = template_defaults[:sections] if template_defaults
|
16
16
|
end
|
17
17
|
save
|
18
18
|
end
|
19
19
|
|
20
|
-
|
21
|
-
|
20
|
+
# Todo : fix me (is_home flag ?)
|
21
|
+
def update_path
|
22
|
+
self.path = name.parameterize if self.path.blank? && name != 'Accueil'
|
22
23
|
end
|
23
24
|
end
|
24
25
|
end
|
data/app/models/sibu/site.rb
CHANGED
@@ -26,6 +26,7 @@
|
|
26
26
|
<%= render conf[panel] %>
|
27
27
|
<% if panel == :content_panel %>
|
28
28
|
<div id="edit_panel" class="sibu_panel sibu_view"></div>
|
29
|
+
<div id="sections_panel"></div>
|
29
30
|
<div id="edit_mode_overlay" class="sibu_panel sibu_view">
|
30
31
|
<div class="overlay_top"></div>
|
31
32
|
<div class="overlay_right"></div>
|
@@ -33,7 +34,8 @@
|
|
33
34
|
<div class="overlay_bottom"></div>
|
34
35
|
<div class="edit_mode_actions">
|
35
36
|
<p id="edit_section_msg">Modifier la section</p>
|
36
|
-
<button id="
|
37
|
+
<button id="new_section_before" onclick="newSection(false)">Insérer avant</button>
|
38
|
+
<button id="new_section_after" onclick="newSection(true)">Insérer après</button>
|
37
39
|
<button id="delete_section" onclick="deleteSection()">Supprimer</button>
|
38
40
|
<button onclick="cancelEditMode()">Fermer</button>
|
39
41
|
</div>
|
@@ -60,10 +62,12 @@
|
|
60
62
|
editMode.find("#edit_section_msg").text("Modifier la section");
|
61
63
|
editMode.show();
|
62
64
|
if(!section.data('sb-repeat')) {
|
63
|
-
editMode.find("#
|
65
|
+
editMode.find("#new_section_before").hide();
|
66
|
+
editMode.find("#new_section_after").hide();
|
64
67
|
editMode.find("#delete_section").hide();
|
65
68
|
} else {
|
66
|
-
editMode.find("#
|
69
|
+
editMode.find("#new_section_before").show();
|
70
|
+
editMode.find("#new_section_after").show();
|
67
71
|
editMode.find("#delete_section").show();
|
68
72
|
}
|
69
73
|
rootElt.animate({scrollTop: top}, 500);
|
@@ -82,18 +86,17 @@
|
|
82
86
|
}
|
83
87
|
}
|
84
88
|
|
85
|
-
function
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
}
|
89
|
+
function newSection(isAfter) {
|
90
|
+
var section = $(".sb-editing").first();
|
91
|
+
$.ajax({
|
92
|
+
url: "<%= new_section_site_page_path(@site.id, @page.id) %>",
|
93
|
+
method: "GET",
|
94
|
+
data: {
|
95
|
+
section_id: section.data("sb-id"),
|
96
|
+
entity: section.data("sb-entity"),
|
97
|
+
after: isAfter
|
98
|
+
}
|
99
|
+
})
|
97
100
|
}
|
98
101
|
|
99
102
|
function deleteSection() {
|
@@ -138,11 +141,26 @@
|
|
138
141
|
}
|
139
142
|
}
|
140
143
|
|
144
|
+
function addChildElement(entity, sectionId, elementId) {
|
145
|
+
if (window.confirm("Ajouter un sous-menu ?")) {
|
146
|
+
$.ajax({
|
147
|
+
url: "<%= child_element_site_page_path(@site.id, @page.id) %>",
|
148
|
+
method: "POST",
|
149
|
+
data: {
|
150
|
+
section_id: sectionId,
|
151
|
+
element_id: elementId,
|
152
|
+
entity: entity
|
153
|
+
}
|
154
|
+
})
|
155
|
+
}
|
156
|
+
}
|
157
|
+
|
141
158
|
function cancelEdit() {
|
142
159
|
$("#edit_panel").slideUp("fast");
|
160
|
+
document.body.style.overflow = "initial";
|
143
161
|
}
|
144
162
|
|
145
|
-
function editContent(eltId, sectionId, entity, repeat, contentType, size) {
|
163
|
+
function editContent(eltId, sectionId, entity, repeat, contentType, size, children) {
|
146
164
|
$.ajax({
|
147
165
|
url: "<%= edit_element_site_page_path(@site.id, @page.id) %>",
|
148
166
|
method: "GET",
|
@@ -152,7 +170,8 @@
|
|
152
170
|
entity: entity,
|
153
171
|
repeat: repeat,
|
154
172
|
content_type: contentType,
|
155
|
-
size: size
|
173
|
+
size: size,
|
174
|
+
children: children
|
156
175
|
}
|
157
176
|
})
|
158
177
|
}
|
@@ -167,9 +186,10 @@
|
|
167
186
|
});
|
168
187
|
editables.click(function(evt) {
|
169
188
|
evt.preventDefault();
|
170
|
-
var elt = $(this), eltId = elt.data("id"), repeat = elt.data("repeat"), type = elt.data("type"),
|
189
|
+
var elt = $(this), eltId = elt.data("id"), repeat = elt.data("repeat"), type = elt.data("type"),
|
190
|
+
size = elt.data("size"), children = elt.data("children");
|
171
191
|
var sectionId = section.data("sb-id"), entity = section.data("sb-entity");
|
172
|
-
editContent(eltId, sectionId, entity, repeat, type, size);
|
192
|
+
editContent(eltId, sectionId, entity, repeat, type, size, children);
|
173
193
|
})
|
174
194
|
}
|
175
195
|
|
@@ -1,21 +1,21 @@
|
|
1
1
|
<% content_for :styles do %>
|
2
2
|
<style>
|
3
3
|
<% unless @site.primary_color.blank? %>
|
4
|
-
|
4
|
+
.sibu_site_content [class*='bg--primary'] {
|
5
5
|
background-color: <%= @site.primary_color %> !important;
|
6
6
|
}
|
7
7
|
|
8
|
-
|
8
|
+
.sibu_site_content [class *='txt--primary'] {
|
9
9
|
color: <%= @site.primary_color %> !important;
|
10
10
|
}
|
11
11
|
<% end %>
|
12
12
|
|
13
13
|
<% unless @site.secondary_color.blank? %>
|
14
|
-
|
14
|
+
.sibu_site_content [class*='bg--success'] {
|
15
15
|
background-color: <%= @site.secondary_color %> !important;
|
16
16
|
}
|
17
17
|
|
18
|
-
|
18
|
+
.sibu_site_content [class *='txt--success'] {
|
19
19
|
color: <%= @site.secondary_color %> !important;
|
20
20
|
}
|
21
21
|
<% end %>
|
@@ -1,4 +1,5 @@
|
|
1
1
|
<div id="element_actions">
|
2
|
-
<button onclick="cloneElement('<%= @entity_type %>', '<%= @section_id %>', '<%= @element_id %>')">Dupliquer</button>
|
3
|
-
<button onclick="deleteElement('<%= @entity_type %>', '<%= @section_id %>', '<%= @element_id %>')">Supprimer</button>
|
2
|
+
<button id="clone_elt" onclick="cloneElement('<%= @entity_type %>', '<%= @section_id %>', '<%= @element_id %>')">Dupliquer</button>
|
3
|
+
<button id="duplicate_elt" onclick="deleteElement('<%= @entity_type %>', '<%= @section_id %>', '<%= @element_id %>')">Supprimer</button>
|
4
|
+
<button id="child_elt" onclick="addChildElement('<%= @entity_type %>', '<%= @section_id %>', '<%= @element_id %>')">Ajouter un sous-menu</button>
|
4
5
|
</div>
|
@@ -6,13 +6,6 @@
|
|
6
6
|
<small>Libellé utilisé dans l'outil d'administration (non utilisé dans le site)</small>
|
7
7
|
</div>
|
8
8
|
</div>
|
9
|
-
<div class="sibu_field">
|
10
|
-
<%= f.label :template, 'Modèle' %>
|
11
|
-
<div>
|
12
|
-
<%= f.select(:template, page_templates, {prompt: 'Sélectionnez un modèle de page'}) %>
|
13
|
-
<small>Le gabarit utilisé pour créer la page</small>
|
14
|
-
</div>
|
15
|
-
</div>
|
16
9
|
<div class="sibu_field">
|
17
10
|
<%= f.label :path, "Chemin d'accès" %>
|
18
11
|
<div>
|
@@ -22,7 +22,7 @@
|
|
22
22
|
<%= hidden_field_tag :entity, @entity_type %>
|
23
23
|
<div class="sibu_actions">
|
24
24
|
<%= submit_tag 'Valider' %>
|
25
|
-
<%= link_to 'Annuler', '#', onclick: '
|
25
|
+
<%= link_to 'Annuler', '#', onclick: 'cancelEdit(); return false;' %>
|
26
26
|
</div>
|
27
27
|
<% end %>
|
28
28
|
</div>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<div class="sibu_panel sibu_view">
|
2
|
+
<h2>Choix du type de section</h2>
|
3
|
+
<div id="edit_msg"></div>
|
4
|
+
</div>
|
5
|
+
<div>
|
6
|
+
<div id="<%= "#{@site.site_template.reference}_sections" %>" class="sibu_sections sibu_site_content">
|
7
|
+
<% sections_templates.each do |st| %>
|
8
|
+
<div data-sb-template="<%= st["template"] %>">
|
9
|
+
<%= render "shared/#{@site.section_template(st)}", sec: st %>
|
10
|
+
</div>
|
11
|
+
<% end %>
|
12
|
+
</div>
|
13
|
+
<%= form_tag(create_section_site_page_path(@site.id, @page.id), method: :post, remote: true) do |f| %>
|
14
|
+
<%= hidden_field_tag 'section[template]', '' %>
|
15
|
+
<%= hidden_field_tag :section_id, @section_id %>
|
16
|
+
<%= hidden_field_tag :after, @after%>
|
17
|
+
<%= hidden_field_tag :entity, @entity_type %>
|
18
|
+
<div class="sibu_panel sibu_view">
|
19
|
+
<div class="sibu_actions">
|
20
|
+
<%= submit_tag 'Valider' %>
|
21
|
+
<%= link_to 'Annuler', '#', onclick: 'cancelEdit(); return false;' %>
|
22
|
+
</div>
|
23
|
+
</div>
|
24
|
+
<% end %>
|
25
|
+
</div>
|
@@ -40,8 +40,15 @@ editPanel.html("");
|
|
40
40
|
<% end %>
|
41
41
|
|
42
42
|
<% if @repeat %>
|
43
|
-
$("#
|
43
|
+
$("#clone_elt, #duplicate_elt").show();
|
44
44
|
<% else %>
|
45
|
-
$("#
|
45
|
+
$("#clone_elt, #duplicate_elt").remove();
|
46
|
+
<% end %>
|
47
|
+
|
48
|
+
<% if @children %>
|
49
|
+
$("#child_elt").show();
|
50
|
+
<% else %>
|
51
|
+
$("#child_elt").remove();
|
46
52
|
<% end %>
|
47
53
|
editPanel.slideDown("fast");
|
54
|
+
document.body.style.overflow = "hidden";
|
@@ -7,7 +7,6 @@
|
|
7
7
|
<thead>
|
8
8
|
<tr>
|
9
9
|
<th>Nom</th>
|
10
|
-
<th>Modèle</th>
|
11
10
|
<th>Chemin d'accès</th>
|
12
11
|
<th>Mise à jour</th>
|
13
12
|
<th colspan="2"></th>
|
@@ -17,7 +16,6 @@
|
|
17
16
|
<% @pages.each do |p| %>
|
18
17
|
<tr>
|
19
18
|
<td><%= p.name %></td>
|
20
|
-
<td><%= t "sibu.templates.#{p.template}" %></td>
|
21
19
|
<td><%= p.path %></td>
|
22
20
|
<td><%= l p.updated_at %></td>
|
23
21
|
<td colspan="2">
|
@@ -0,0 +1,17 @@
|
|
1
|
+
var sectionsPanel = $("#sections_panel");
|
2
|
+
sectionsPanel.html("");
|
3
|
+
sectionsPanel.html("<%= j(render 'new_section_panel') %>");
|
4
|
+
var sections = sectionsPanel.find(".sibu_sections > *");
|
5
|
+
sections.click(function() {
|
6
|
+
if(!$(this).hasClass('selected')) {
|
7
|
+
sections.removeClass('selected');
|
8
|
+
$(this).addClass('selected');
|
9
|
+
$("#section_template").val($(this).data("sb-template"));
|
10
|
+
}
|
11
|
+
});
|
12
|
+
sectionsPanel.slideDown("fast", function() {
|
13
|
+
if(typeof initSectionsForm === "function") {
|
14
|
+
initSectionsForm();
|
15
|
+
}
|
16
|
+
});
|
17
|
+
document.body.style.overflow = "hidden";
|
@@ -0,0 +1,3 @@
|
|
1
|
+
DEFAULT_TEXT = "Lorem ipsum"
|
2
|
+
DEFAULT_PARAGRAPH = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut."
|
3
|
+
DEFAULT_IMG = "/default.jpg"
|
data/config/routes.rb
CHANGED
@@ -12,8 +12,9 @@ Sibu::Engine.routes.draw do
|
|
12
12
|
patch 'update_element', on: :member
|
13
13
|
post 'clone_element', on: :member
|
14
14
|
delete 'delete_element', on: :member
|
15
|
-
|
16
|
-
|
15
|
+
post 'child_element', on: :member
|
16
|
+
get 'new_section', on: :member
|
17
|
+
post 'create_section', on: :member
|
17
18
|
delete 'delete_section', on: :member
|
18
19
|
end
|
19
20
|
|
data/lib/sibu/utils.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
module Sibu
|
2
|
+
class Utils
|
3
|
+
def self.convert_sections
|
4
|
+
Sibu::Site.all.each do |s|
|
5
|
+
sections = s.sections
|
6
|
+
s.update(sections: sections.keys.map {|k| {id: k, elements: sections[k]}})
|
7
|
+
end
|
8
|
+
|
9
|
+
Sibu::Page.all.each do |p|
|
10
|
+
sections = p.sections
|
11
|
+
p.update(sections: sections.keys.map {|k| {id: k, elements: sections[k]}})
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
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: 0.1.
|
4
|
+
version: 0.1.21
|
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: 2018-02-
|
11
|
+
date: 2018-02-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -141,10 +141,12 @@ files:
|
|
141
141
|
- app/views/sibu/pages/_form.html.erb
|
142
142
|
- app/views/sibu/pages/_link_edit_panel.html.erb
|
143
143
|
- app/views/sibu/pages/_media_edit_panel.html.erb
|
144
|
+
- app/views/sibu/pages/_new_section_panel.html.erb
|
144
145
|
- app/views/sibu/pages/_paragraph_edit_panel.html.erb
|
145
146
|
- app/views/sibu/pages/_text_edit_panel.html.erb
|
147
|
+
- app/views/sibu/pages/child_element.js.erb
|
146
148
|
- app/views/sibu/pages/clone_element.js.erb
|
147
|
-
- app/views/sibu/pages/
|
149
|
+
- app/views/sibu/pages/create_section.js.erb
|
148
150
|
- app/views/sibu/pages/delete_element.js.erb
|
149
151
|
- app/views/sibu/pages/delete_section.js.erb
|
150
152
|
- app/views/sibu/pages/destroy.html.erb
|
@@ -153,6 +155,7 @@ files:
|
|
153
155
|
- app/views/sibu/pages/edit_element.js.erb
|
154
156
|
- app/views/sibu/pages/index.html.erb
|
155
157
|
- app/views/sibu/pages/new.html.erb
|
158
|
+
- app/views/sibu/pages/new_section.js.erb
|
156
159
|
- app/views/sibu/pages/show.html.erb
|
157
160
|
- app/views/sibu/pages/update.html.erb
|
158
161
|
- app/views/sibu/pages/update_element.js.erb
|
@@ -163,6 +166,7 @@ files:
|
|
163
166
|
- app/views/sibu/sites/new.html.erb
|
164
167
|
- app/views/sibu/sites/show.html.erb
|
165
168
|
- app/views/sibu/sites/update.html.erb
|
169
|
+
- config/initializers/constants.rb
|
166
170
|
- config/initializers/shrine.rb
|
167
171
|
- config/routes.rb
|
168
172
|
- config/tinymce.yml
|
@@ -179,6 +183,7 @@ files:
|
|
179
183
|
- db/migrate/20180214134653_add_fields_to_sites.rb
|
180
184
|
- lib/sibu.rb
|
181
185
|
- lib/sibu/engine.rb
|
186
|
+
- lib/sibu/utils.rb
|
182
187
|
- lib/sibu/version.rb
|
183
188
|
- lib/tasks/sibu_tasks.rake
|
184
189
|
homepage: http://hotentic.com
|