sibu 0.1.8 → 0.1.9
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/pages_controller.rb +2 -2
- data/app/helpers/sibu/pages_helper.rb +6 -6
- data/app/models/concerns/sibu/sections_concern.rb +12 -18
- data/app/views/layouts/sibu/edit_content.html.erb +22 -18
- data/app/views/sibu/pages/_media_edit_panel.html.erb +3 -2
- data/app/views/sibu/pages/edit_element.js.erb +1 -0
- data/app/views/sibu/pages/index.html.erb +2 -2
- data/app/views/sibu/sites/index.html.erb +3 -3
- data/lib/sibu/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee29b0c95ac6340e5d0a42975ba4c699b19a413d
|
4
|
+
data.tar.gz: d25ad5770ab28ddd5dea0424506449a70ac74d12
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8fe798120905a4ce03a06b170ac5568cc86aab93056d7e04578b3aa9171492a1da52340b98384318c107f20724655250f0144dc5ffef5833776fd4eba0772c77
|
7
|
+
data.tar.gz: 16c4d3f1f5048fa095813055ea968b9fccab205cd0333a12ccda5fb6a49645df26372305a4fdf989ea808f77f95e5c7a09d5b0627d2cb97ad11cf0bbfa824d3f
|
@@ -70,11 +70,11 @@ module Sibu
|
|
70
70
|
def edit_element
|
71
71
|
@content_type = params[:content_type]
|
72
72
|
@links = @site.pages_path_by_id if @site
|
73
|
-
@element = @entity.element(
|
73
|
+
@element = @entity.element(*@section_id.split('|'), @element_id)
|
74
74
|
end
|
75
75
|
|
76
76
|
def update_element
|
77
|
-
@updated = @entity.update_element(
|
77
|
+
@updated = @entity.update_element(*@section_id.split('|'), element_params)
|
78
78
|
end
|
79
79
|
|
80
80
|
def edit_section
|
@@ -36,9 +36,9 @@ module Sibu
|
|
36
36
|
|
37
37
|
def site_section(id, sub_id = nil, &block)
|
38
38
|
@sb_entity = @site
|
39
|
-
@sb_section = sub_id ? [id, sub_id] : id
|
39
|
+
@sb_section = sub_id ? [id, sub_id] : [id]
|
40
40
|
if block_given?
|
41
|
-
"<sb-edit data-id='#{
|
41
|
+
"<sb-edit data-id='#{@sb_section.join('|')}' data-entity='site'>#{capture(self, &block)}</sb-edit>".html_safe
|
42
42
|
else
|
43
43
|
self
|
44
44
|
end
|
@@ -46,8 +46,8 @@ module Sibu
|
|
46
46
|
|
47
47
|
def section(id, sub_id = nil, &block)
|
48
48
|
@sb_entity = @page
|
49
|
-
@sb_section = sub_id ? [id, sub_id] : id
|
50
|
-
"<sb-edit data-id='#{
|
49
|
+
@sb_section = sub_id ? [id, sub_id] : [id]
|
50
|
+
"<sb-edit data-id='#{@sb_section.join('|')}' data-entity='page'>#{capture(self, &block)}</sb-edit>".html_safe
|
51
51
|
end
|
52
52
|
|
53
53
|
def site_sections(id)
|
@@ -64,13 +64,13 @@ module Sibu
|
|
64
64
|
|
65
65
|
def each
|
66
66
|
# Todo : init array when empty
|
67
|
-
@sb_entity.section(
|
67
|
+
@sb_entity.section(*@sb_section).each do |elt|
|
68
68
|
yield(elt.except("elements"), elt["elements"])
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
72
|
def each_elements
|
73
|
-
@sb_entity.section(
|
73
|
+
@sb_entity.section(*@sb_section).each do |elt|
|
74
74
|
yield(*elt["elements"])
|
75
75
|
end
|
76
76
|
end
|
@@ -20,22 +20,14 @@ module Sibu
|
|
20
20
|
elsif ids.length == 2
|
21
21
|
subsection(*ids)
|
22
22
|
end
|
23
|
-
# s = section(ids[0])
|
24
|
-
# sub = s.select {|elt| elt["id"] == ids[1]}
|
25
|
-
# unless sub
|
26
|
-
# sub = {"id" => ids[1], "elements" => []}
|
27
|
-
# self.sections[ids[0]] << sub
|
28
|
-
# save
|
29
|
-
# end
|
30
|
-
# elts = sub
|
31
|
-
# end
|
32
|
-
# elts.blank? ? {"default" => {}} : Hash[elts.map {|e| [e["id"], e.except("id")]}]
|
33
23
|
end
|
34
24
|
|
35
25
|
def subsection(id, subid)
|
36
26
|
s = section(id)
|
37
|
-
|
38
|
-
|
27
|
+
sub_idx = s.index {|elt| elt["id"] == subid}
|
28
|
+
if sub_idx
|
29
|
+
sub = s[sub_idx]
|
30
|
+
else
|
39
31
|
sub = {"id" => subid, "elements" => []}
|
40
32
|
self.sections[id] << sub
|
41
33
|
save
|
@@ -43,21 +35,23 @@ module Sibu
|
|
43
35
|
sub["elements"]
|
44
36
|
end
|
45
37
|
|
46
|
-
def element(
|
47
|
-
elt = section(
|
38
|
+
def element(*ids, element_id)
|
39
|
+
elt = section(*ids).select {|e| e["id"] == element_id}.first
|
48
40
|
elt || {}
|
49
41
|
end
|
50
42
|
|
51
43
|
def update_section(*ids, value)
|
52
44
|
end
|
53
45
|
|
54
|
-
def update_element(
|
46
|
+
def update_element(*ids, value)
|
55
47
|
sanitize_value(value)
|
56
|
-
|
57
|
-
|
48
|
+
parent_section = section(*ids)
|
49
|
+
if parent_section.any? {|elt| elt["id"] == value["id"]}
|
50
|
+
parent_section.map! {|elt| elt["id"] == value["id"] ? value : elt}
|
58
51
|
else
|
59
|
-
|
52
|
+
parent_section << value
|
60
53
|
end
|
54
|
+
|
61
55
|
value if save
|
62
56
|
end
|
63
57
|
|
@@ -2,9 +2,9 @@
|
|
2
2
|
<html>
|
3
3
|
<head>
|
4
4
|
<title><%= conf[:title] %></title>
|
5
|
-
<%= stylesheet_link_tag conf[:stylesheet], media: 'all' %>
|
5
|
+
<%= stylesheet_link_tag "#{conf[:stylesheet]}-edit", media: 'all' %>
|
6
6
|
<%= stylesheet_link_tag 'sibu/sibu', media: 'all' %>
|
7
|
-
<%= javascript_include_tag conf[:javascript] %>
|
7
|
+
<%= javascript_include_tag "#{conf[:javascript]}-edit" %>
|
8
8
|
<%= javascript_include_tag 'sibu/sibu' %>
|
9
9
|
<% if @site %>
|
10
10
|
<%= stylesheet_link_tag @site.site_template.path, media: "all" %>
|
@@ -17,20 +17,22 @@
|
|
17
17
|
<% unless conf[panel].blank? %>
|
18
18
|
<div class="<%= panel == :content_panel ? 'sibu_content_panel' : 'sibu_panel' %>">
|
19
19
|
<%= render conf[panel] %>
|
20
|
+
<% if panel == :content_panel %>
|
21
|
+
<div id="edit_panel" class="sibu_panel sibu_view"></div>
|
22
|
+
<div id="edit_mode_overlay" class="sibu_panel sibu_view">
|
23
|
+
<div class="overlay_top"></div>
|
24
|
+
<div class="overlay_right"></div>
|
25
|
+
<div class="overlay_left"></div>
|
26
|
+
<div class="overlay_bottom"></div>
|
27
|
+
<div class="edit_mode_actions">
|
28
|
+
<p>Modifier la section</p>
|
29
|
+
<button onclick="cancelEditMode()">Fermer</button>
|
30
|
+
</div>
|
31
|
+
</div>
|
32
|
+
<% end %>
|
20
33
|
</div>
|
21
34
|
<% end %>
|
22
35
|
<% end %>
|
23
|
-
<div id="edit_panel" class="sibu_view"></div>
|
24
|
-
<div id="edit_mode_overlay">
|
25
|
-
<div class="overlay_top"></div>
|
26
|
-
<div class="overlay_right"></div>
|
27
|
-
<div class="overlay_left"></div>
|
28
|
-
<div class="overlay_bottom"></div>
|
29
|
-
<div class="edit_mode_actions">
|
30
|
-
<button onclick="cancelEditMode()">Fermer</button>
|
31
|
-
</div>
|
32
|
-
</div>
|
33
|
-
|
34
36
|
<script>
|
35
37
|
const TEXT_TAGS = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'span'];
|
36
38
|
const IMG_TAGS = ['img'];
|
@@ -44,12 +46,14 @@
|
|
44
46
|
var offset = elt.offset();
|
45
47
|
var width = elt.width(), height = elt.height();
|
46
48
|
var overlay = $("#edit_mode_overlay");
|
47
|
-
|
48
|
-
overlay.find(".
|
49
|
-
overlay.find(".
|
50
|
-
overlay.find(".
|
51
|
-
overlay.find(".
|
49
|
+
var yPosition = offset.top - $(".sibu_content_panel").offset().top;
|
50
|
+
overlay.find(".overlay_top").css("height", yPosition);
|
51
|
+
overlay.find(".overlay_bottom").css("top", yPosition + height);
|
52
|
+
overlay.find(".overlay_left").css({"height": height, "width": offset.left, "top": yPosition});
|
53
|
+
overlay.find(".overlay_right").css({"height": height, "left": offset.left + width, "top": yPosition});
|
54
|
+
overlay.find(".edit_mode_actions").css({"top": (yPosition <= 40 ? (yPosition + height) : (yPosition - 40)), left: offset.left, width: width});
|
52
55
|
overlay.show();
|
56
|
+
window.scrollTo(0, yPosition);
|
53
57
|
initInnerOverlays(elt);
|
54
58
|
elt.remove();
|
55
59
|
}
|
@@ -1,8 +1,9 @@
|
|
1
1
|
<h2>Modifier l'image</h2>
|
2
2
|
<div id="edit_msg"></div>
|
3
|
-
<div class="
|
3
|
+
<div class="sibu_edit_form">
|
4
4
|
<%= form_tag(update_element_site_page_path(@site.id, @page.id), method: :patch, remote: true) do |f| %>
|
5
|
-
<div class="sibu_select_images">
|
5
|
+
<div class="sibu_select_images sibu_field">
|
6
|
+
<p>Sélectionnez ou <%= link_to 'téléchargez', new_site_image_path(@site.id) %> une image</p>
|
6
7
|
<% @site.images.each do |image| %>
|
7
8
|
<div class="sibu_image">
|
8
9
|
<%= image_tag image.file_url(:small) %>
|
@@ -8,6 +8,7 @@ editPanel.html("");
|
|
8
8
|
<% elsif @content_type == 'media' %>
|
9
9
|
editPanel.html("<%= j(render 'media_edit_panel') %>");
|
10
10
|
editPanel.find(".sibu_image img").click(function() {
|
11
|
+
$(this).toggleClass('selected');
|
11
12
|
$("#element_src").val($(this).attr("src"));
|
12
13
|
});
|
13
14
|
<% elsif @content_type == 'link' %>
|
@@ -10,7 +10,7 @@
|
|
10
10
|
<th>Modèle</th>
|
11
11
|
<th>Chemin d'accès</th>
|
12
12
|
<th>Mise à jour</th>
|
13
|
-
<th></th>
|
13
|
+
<th colspan="2"></th>
|
14
14
|
</tr>
|
15
15
|
</thead>
|
16
16
|
<tbody>
|
@@ -20,7 +20,7 @@
|
|
20
20
|
<td><%= p.template %></td>
|
21
21
|
<td><%= p.path %></td>
|
22
22
|
<td><%= l p.updated_at %></td>
|
23
|
-
<td>
|
23
|
+
<td colspan="2">
|
24
24
|
<%= link_to 'Voir', site_page_path(@site.id, p), target: '_blank' %> |
|
25
25
|
<%= link_to 'Editer', site_page_edit_content_path(site_id: @site.id, page_id: p.id) %> |
|
26
26
|
<%= link_to 'Modifier', edit_site_page_path(@site.id, p) %> |
|
@@ -9,7 +9,7 @@
|
|
9
9
|
<th>Nom</th>
|
10
10
|
<th>Modèle</th>
|
11
11
|
<th>Mise à jour</th>
|
12
|
-
<th></th>
|
12
|
+
<th colspan="2"></th>
|
13
13
|
</tr>
|
14
14
|
</thead>
|
15
15
|
<tbody>
|
@@ -18,9 +18,9 @@
|
|
18
18
|
<td><%= s.name %></td>
|
19
19
|
<td><%= s.site_template.name if s.site_template %></td>
|
20
20
|
<td><%= l s.updated_at %></td>
|
21
|
-
<td>
|
22
|
-
<%= link_to 'Voir', site_path(s), target: '_blank' %> |
|
21
|
+
<td colspan="2">
|
23
22
|
<%= link_to 'Pages', site_pages_path(s) %> |
|
23
|
+
<%= link_to 'Images', site_images_path(s) %> |
|
24
24
|
<%= link_to 'Modifier', edit_site_path(s) %> |
|
25
25
|
<%= link_to 'Supprimer', site_path(s), method: :delete, data: {confirm: "Supprimer le site \"#{s.name}\" ?"} %>
|
26
26
|
</td>
|
data/lib/sibu/version.rb
CHANGED