sibu 1.0.1 → 1.0.2
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/controllers/sibu/pages_controller.rb +7 -1
- data/app/helpers/sibu/application_helper.rb +1 -1
- data/app/helpers/sibu/pages_helper.rb +20 -4
- data/app/views/layouts/sibu/edit_content.html.erb +8 -8
- data/app/views/sibu/pages/_code_edit_panel.html.erb +1 -0
- data/app/views/sibu/pages/_form.html.erb +8 -0
- data/app/views/sibu/pages/_map_edit_panel.html.erb +1 -0
- data/app/views/sibu/pages/index.html.erb +1 -1
- data/lib/sibu/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b274fec919e722e48ba571e1ee3379f037af6372
|
4
|
+
data.tar.gz: 4da5793bc66501214bbb5c9a5a38b00890b4754e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '085bf4d2059a0f51494b062332fa6c9e9ada4313d6be6c4ee4799c8f0418d0fc4967d1c2ac967e7f750651866abb1fb249997e6f10e71d067c912fb5ecb5081e'
|
7
|
+
data.tar.gz: f26e18f34db37e935cdf4f891fa7033bc585a78421f32b950974460f1a777e97174cf8b728b9f95c452c6d2ffdd7fff2e82e2fbe6163e235fd5633cd0b250f88
|
@@ -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
|
@@ -194,5 +196,9 @@ module Sibu
|
|
194
196
|
def show_params
|
195
197
|
params.permit!
|
196
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
|
197
203
|
end
|
198
204
|
end
|
@@ -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
|
@@ -58,7 +62,7 @@ module Sibu
|
|
58
62
|
end
|
59
63
|
else
|
60
64
|
if t == :p
|
61
|
-
html_output = content_tag(:div, content_tag(t, raw(content["text"]).html_safe
|
65
|
+
html_output = content_tag(:div, content_tag(t, raw(content["text"]).html_safe), html_opts)
|
62
66
|
else
|
63
67
|
html_output = content_tag(t, raw(content["text"]).html_safe, html_opts)
|
64
68
|
end
|
@@ -95,8 +99,12 @@ module Sibu
|
|
95
99
|
(tokens + [suffix]).select {|t| !t.blank?}.join("|")
|
96
100
|
end
|
97
101
|
|
98
|
-
|
99
|
-
|
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)
|
100
108
|
element_id_tokens = (@sb_section + element_id.split("|")).uniq
|
101
109
|
nested_elts = @sb_entity.elements(*element_id_tokens)
|
102
110
|
nested_elts.blank? ? [{"id" => element_id.split("|").last, "data-id" => join_tokens(element_id_tokens[1..-1], "#{element_id}0")}] :
|
@@ -187,10 +195,18 @@ module Sibu
|
|
187
195
|
locals: {sibu: self, sibu_section: s, sibu_attrs: sibu_attributes(s).html_safe}
|
188
196
|
end
|
189
197
|
|
198
|
+
# Page sections attrs
|
190
199
|
def sibu_attributes(section)
|
191
200
|
action_name != 'show' ? ('data-sb-id="' + section['id'] + '" data-sb-entity="page"') : ''
|
192
201
|
end
|
193
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
|
+
|
194
210
|
def section(id, tag, html_opts = {}, &block)
|
195
211
|
@sb_section = [id]
|
196
212
|
opts = action_name != 'show' ? html_opts.merge({"data-sb-id" => id, "data-sb-entity" => @sb_entity == @site ? 'site' : 'page'}) : html_opts
|
@@ -242,7 +258,7 @@ module Sibu
|
|
242
258
|
end
|
243
259
|
|
244
260
|
def interactive_map(elt, html_opts = {})
|
245
|
-
defaults = {"data-lat" => "
|
261
|
+
defaults = {"data-lat" => "46.1988027", "data-lng" => "5.1748288", "data-title" => Sibu::DEFAULT_TEXT}
|
246
262
|
content = defaults.merge(elt.is_a?(Hash) ? elt : (select_element(elt) || {"id" => elt}))
|
247
263
|
html_opts.merge!({data: {id: elt_id(elt), type: "map"}}) if action_name != 'show'
|
248
264
|
content_tag(:div, nil, content.merge(html_opts))
|
@@ -2,13 +2,13 @@
|
|
2
2
|
<html>
|
3
3
|
<head>
|
4
4
|
<title><%= conf[:title] %></title>
|
5
|
-
<%= stylesheet_link_tag 'sibu/sibu', media: 'all' %>
|
6
|
-
<%= stylesheet_link_tag conf[:stylesheet], media: 'all' %>
|
7
|
-
<%= javascript_include_tag "#{conf[:javascript]}-edit" %>
|
8
5
|
<% if @site %>
|
9
6
|
<%= stylesheet_link_tag (conf[:custom_styles] ? @site.style_url : @site.site_template.path), media: "all" %>
|
10
7
|
<%= javascript_include_tag @site.site_template.path %>
|
11
8
|
<% end %>
|
9
|
+
<%= stylesheet_link_tag 'sibu/sibu', media: 'all' %>
|
10
|
+
<%= stylesheet_link_tag "#{conf[:stylesheet]}-edit", media: 'all' %>
|
11
|
+
<%= javascript_include_tag "#{conf[:javascript]}-edit" %>
|
12
12
|
<%= csrf_meta_tags %>
|
13
13
|
<%= yield :styles %>
|
14
14
|
</head>
|
@@ -44,11 +44,8 @@
|
|
44
44
|
<%= javascript_include_tag 'sibu/sibu' %>
|
45
45
|
<script>
|
46
46
|
document.addEventListener("DOMContentLoaded", function() {
|
47
|
-
initOverlays();
|
47
|
+
initOverlays("<%= @edit_section || '' %>");
|
48
48
|
sibuCallback("editContent");
|
49
|
-
<% unless @edit_section.blank? %>
|
50
|
-
document.querySelector("[data-sb-overlay='<%= @edit_section %>']").click();
|
51
|
-
<% end %>
|
52
49
|
});
|
53
50
|
|
54
51
|
function setEditMode(section, overlay, left, top, width, height) {
|
@@ -232,7 +229,7 @@
|
|
232
229
|
}
|
233
230
|
}
|
234
231
|
|
235
|
-
function initOverlays() {
|
232
|
+
function initOverlays(activeSection = "") {
|
236
233
|
setTimeout(function() {
|
237
234
|
var container = document.querySelector("#edit_overlays"), sections = document.querySelectorAll("[data-sb-id]");
|
238
235
|
container.innerHTML = "";
|
@@ -255,6 +252,9 @@
|
|
255
252
|
};
|
256
253
|
})(sections[i], sectionBox.left, yOffset, width, height));
|
257
254
|
}
|
255
|
+
if (activeSection) {
|
256
|
+
document.querySelector("[data-sb-overlay='" + activeSection + "']").click();
|
257
|
+
}
|
258
258
|
}, 800);
|
259
259
|
}
|
260
260
|
|
@@ -1,5 +1,6 @@
|
|
1
1
|
<h2>Modifier le contenu</h2>
|
2
2
|
<div id="edit_msg"></div>
|
3
|
+
<%= render 'element_actions' %>
|
3
4
|
<div class="sibu_edit_form">
|
4
5
|
<form class="edit_element_form" action="<%= update_element_site_page_path(@site.id, @page.id, format: :js) %>" accept-charset="UTF-8" method="patch">
|
5
6
|
<div class="sibu_field">
|
@@ -13,6 +13,13 @@
|
|
13
13
|
<small>L'adresse (ou URL) de la page, utilisée par les navigateurs web pour y accéder</small>
|
14
14
|
</div>
|
15
15
|
</div>
|
16
|
+
<div class="sibu_field">
|
17
|
+
<%= f.label :source, "Référence" %>
|
18
|
+
<div>
|
19
|
+
<%= f.text_field :source, placeholder: "Référence interne optionnelle (Ex: test mise en page 2) " %>
|
20
|
+
<small>Un bref descriptif de la page, à usage interne uniquement</small>
|
21
|
+
</div>
|
22
|
+
</div>
|
16
23
|
<div class="sibu_field">
|
17
24
|
<%= f.label :is_home, "Page d'accueil" %>
|
18
25
|
<div>
|
@@ -56,6 +63,7 @@
|
|
56
63
|
</div>
|
57
64
|
</div>
|
58
65
|
<%= f.hidden_field :site_id %>
|
66
|
+
<%= f.hidden_field :site_id %>
|
59
67
|
<div class="sibu_actions">
|
60
68
|
<%= f.submit 'Valider' %>
|
61
69
|
<%= link_to 'Annuler', :back %>
|
@@ -1,5 +1,6 @@
|
|
1
1
|
<h2>Modifier la carte</h2>
|
2
2
|
<div id="edit_msg"></div>
|
3
|
+
<%= render 'element_actions' %>
|
3
4
|
<div class="sibu_edit_form">
|
4
5
|
<form class="edit_element_form" action="<%= update_element_site_page_path(@site.id, @page.id, format: :js) %>" accept-charset="UTF-8" method="patch">
|
5
6
|
<div class="sibu_field">
|
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.2
|
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-06-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|