sibu 0.8.3 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (28) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/sibu/sibu.js.erb +1 -0
  3. data/app/assets/javascripts/tarteaucitron/advertising.js +1 -0
  4. data/app/assets/javascripts/tarteaucitron/lang/tarteaucitron.cs.js +75 -0
  5. data/app/assets/javascripts/tarteaucitron/lang/tarteaucitron.de.js +75 -0
  6. data/app/assets/javascripts/tarteaucitron/lang/tarteaucitron.el.js +75 -0
  7. data/app/assets/javascripts/tarteaucitron/lang/tarteaucitron.en.js +75 -0
  8. data/app/assets/javascripts/tarteaucitron/lang/tarteaucitron.es.js +75 -0
  9. data/app/assets/javascripts/tarteaucitron/lang/tarteaucitron.fr.js +75 -0
  10. data/app/assets/javascripts/tarteaucitron/lang/tarteaucitron.it.js +75 -0
  11. data/app/assets/javascripts/tarteaucitron/lang/tarteaucitron.nl.js +75 -0
  12. data/app/assets/javascripts/tarteaucitron/lang/tarteaucitron.pl.js +76 -0
  13. data/app/assets/javascripts/tarteaucitron/lang/tarteaucitron.pt.js +73 -0
  14. data/app/assets/javascripts/tarteaucitron/lang/tarteaucitron.ru.js +75 -0
  15. data/app/assets/javascripts/tarteaucitron/tarteaucitron.js.erb +1480 -0
  16. data/app/assets/javascripts/tarteaucitron/tarteaucitron.services.js +2627 -0
  17. data/app/assets/stylesheets/sibu/defaults.scss +71 -29
  18. data/app/assets/stylesheets/tarteaucitron/tarteaucitron.css +749 -0
  19. data/app/helpers/sibu/pages_helper.rb +23 -8
  20. data/app/models/sibu/site_template.rb +3 -0
  21. data/app/views/layouts/sibu/edit_content.html.erb +2 -2
  22. data/app/views/layouts/sibu/site.html.erb +42 -6
  23. data/app/views/sibu/pages/_media_edit_panel.html.erb +24 -7
  24. data/app/views/sibu/pages/edit_element.js.erb +10 -5
  25. data/config/initializers/assets.rb +1 -0
  26. data/config/routes.rb +3 -0
  27. data/lib/sibu/version.rb +1 -1
  28. metadata +22 -6
@@ -90,6 +90,14 @@ module Sibu
90
90
  content_tag(wrapper, capture(*elts(elt), &block), opts)
91
91
  end
92
92
 
93
+ def empty_tag(elt, tag, type, opts = {})
94
+ repeat = opts.delete(:repeat)
95
+ defaults = {"id" => elt.is_a?(Hash) ? elt["id"] : elt}.merge!(default_content(type))
96
+ opts = defaults.merge(opts)
97
+ opts.merge!({data: {id: elt_id(elt), type: type, repeat: repeat}}) if action_name != 'show'
98
+ content_tag(tag, nil, opts)
99
+ end
100
+
93
101
  def form_label(elt, html_opts = {}, &block)
94
102
  defaults = {"id" => elt.is_a?(Hash) ? elt["id"] : elt, "text" => DEFAULT_TEXT}
95
103
  content = defaults.merge(elt.is_a?(Hash) ? elt : (select_element(elt) || {}))
@@ -131,14 +139,6 @@ module Sibu
131
139
  content_tag(tag, capture(self, &block), opts)
132
140
  end
133
141
 
134
- def sections(id, tag, html_opts = {}, &block)
135
- (@sb_entity.find_or_init(id)["elements"].map.with_index do |elt, i|
136
- @sb_section = [id, elt["id"]]
137
- 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
138
- content_tag(tag, capture(self, i, &block), opts)
139
- end).join('').html_safe
140
- end
141
-
142
142
  def elts(id)
143
143
  items = []
144
144
  element_id = elt_id(id)
@@ -190,5 +190,20 @@ module Sibu
190
190
  def elt_id(elt)
191
191
  elt.is_a?(Hash) ? (elt["data-id"] || elt["id"]) : elt
192
192
  end
193
+
194
+ def default_content(type)
195
+ case type
196
+ when "text"
197
+ {"text" => DEFAULT_TEXT}
198
+ when "link"
199
+ {"value" => "", "text" => DEFAULT_TEXT}
200
+ when "paragraph"
201
+ {"text" => DEFAULT_PARAGRAPH}
202
+ when "media"
203
+ {"src" => DEFAULT_IMG}
204
+ when "embed"
205
+ {"code" => '<p>Contenu HTML personnalisé (iframe, etc...)</p>'}
206
+ end
207
+ end
193
208
  end
194
209
  end
@@ -16,6 +16,9 @@ module Sibu
16
16
  sections_list += Dir.glob(dir + "*.erb").map {|f| f.split('/').last}.
17
17
  map {|f| f[1..-1].gsub('.html.erb', '')}.map {|f| {"id" => "sibu_template_#{f}", "category" => cat, "template" => f}}
18
18
  end
19
+ if Rails.application.config.sibu[:sections_ordering]
20
+ sections_list = Rails.application.config.sibu[:sections_ordering].call(sections_list)
21
+ end
19
22
  sections_list
20
23
  end
21
24
  end
@@ -2,10 +2,10 @@
2
2
  <html>
3
3
  <head>
4
4
  <title><%= conf[:title] %></title>
5
- <%= stylesheet_link_tag "#{conf[:stylesheet]}-edit", media: 'all' %>
6
5
  <%= stylesheet_link_tag 'sibu/sibu', media: 'all' %>
7
- <%= javascript_include_tag "#{conf[:javascript]}-edit" %>
6
+ <%= stylesheet_link_tag "#{conf[:stylesheet]}-edit", media: 'all' %>
8
7
  <%= javascript_include_tag 'sibu/sibu' %>
8
+ <%= javascript_include_tag "#{conf[:javascript]}-edit" %>
9
9
  <% if @site %>
10
10
  <%= stylesheet_link_tag (conf[:custom_styles] ? @site.style_url : @site.site_template.path), media: "all" %>
11
11
  <%= javascript_include_tag "#{@site.site_template.path}-core" %>
@@ -10,12 +10,48 @@
10
10
  <%= stylesheet_link_tag (conf[:custom_styles] ? @site.style_url : @site.site_template.path), media: "all" %>
11
11
  <%= javascript_include_tag @site.site_template.path %>
12
12
  <% unless @site.analytics_id.blank? %>
13
- <script async src="https://www.googletagmanager.com/gtag/js?id=<%= @site.analytics_id %>"></script>
14
- <script>
15
- window.dataLayer = window.dataLayer || [];
16
- function gtag(){dataLayer.push(arguments);}
17
- gtag('js', new Date());
18
- gtag('config', '<%= @site.analytics_id %>');
13
+ <%= stylesheet_link_tag 'tarteaucitron/tarteaucitron' %>
14
+ <%= javascript_include_tag 'tarteaucitron/tarteaucitron' %>
15
+ <script type="text/javascript">
16
+ var defaultOpts = {
17
+ "privacyUrl": "", /* Privacy policy url */
18
+ "hashtag": "#tarteaucitron", /* Open the panel with this hashtag */
19
+ "cookieName": "tarteaucitron", /* Cookie name */
20
+ "orientation": "bottom", /* Banner position (top - bottom) */
21
+ "showAlertSmall": false, /* Show the small banner on bottom right */
22
+ "cookieslist": true, /* Show the cookie list */
23
+ "adblocker": false, /* Show a Warning if an adblocker is detected */
24
+ "AcceptAllCta": true, /* Show the accept all button when highPrivacy on */
25
+ "highPrivacy": false, /* Disable auto consent */
26
+ "handleBrowserDNTRequest": false, /* If Do Not Track == 1, disallow all */
27
+ "removeCredit": false, /* Remove credit link */
28
+ "moreInfoLink": true, /* Show more info link */
29
+ "useExternalCss": true, /* If false, the tarteaucitron.css file will be loaded */
30
+ "readmoreLink": "/cookiespolicy" /* Change the default readmore link */
31
+ };
32
+ if (typeof tarteaucitronOpts === 'undefined') {
33
+ var tarteaucitronOpts = defaultOpts;
34
+ } else {
35
+ tarteaucitronOpts["hashtag"] = "#tarteaucitron";
36
+ tarteaucitronOpts["cookieName"] = "tarteaucitron";
37
+ tarteaucitronOpts["orientation"] = tarteaucitronOpts["orientation"] || "top";
38
+ tarteaucitronOpts["showAlertSmall"] = !(tarteaucitronOpts["showAlertSmall"] === false);
39
+ tarteaucitronOpts["cookieslist"] = !(tarteaucitronOpts["cookieslist"] === false);
40
+ tarteaucitronOpts["adblocker"] = tarteaucitronOpts["adblocker"] === true;
41
+ tarteaucitronOpts["AcceptAllCta"] = tarteaucitronOpts["AcceptAllCta"] === true;
42
+ tarteaucitronOpts["highPrivacy"] = !(tarteaucitronOpts["AcceptAllCta"] === false);
43
+ tarteaucitronOpts["handleBrowserDNTRequest"] = !(tarteaucitronOpts["handleBrowserDNTRequest"] === false);
44
+ tarteaucitronOpts["removeCredit"] = !(tarteaucitronOpts["removeCredit"] === false);
45
+ tarteaucitronOpts["moreInfoLink"] = tarteaucitronOpts["moreInfoLink"] === true;
46
+ tarteaucitronOpts["useExternalCss"] = !(tarteaucitronOpts["useExternalCss"] === false);
47
+ tarteaucitronOpts["cookieDomain"] = "<%= @site.domain %>";
48
+ }
49
+ tarteaucitron.init(tarteaucitronOpts);
50
+ </script>
51
+ <script type="text/javascript">
52
+ tarteaucitron.user.analyticsUa = '<%= @site.analytics_id %>';
53
+ tarteaucitron.user.analyticsMore = function () { };
54
+ (tarteaucitron.job = tarteaucitron.job || []).push('analytics');
19
55
  </script>
20
56
  <% end %>
21
57
  <% end %>
@@ -7,13 +7,29 @@
7
7
  <div class="sibu_select_images sibu_field">
8
8
  <p>Sélectionnez ou <%= link_to 'téléchargez', new_image_path(page_id: @page.id, section_id: @section_id, entity_type: @entity_type,
9
9
  element_id: @element_id, img_id: @element["id"], size: @size) %> une image</p>
10
- <% site_images.each_with_index do |image, i| %>
11
- <div class="sibu_image" data-img-id="<%= image.id %>">
12
- <% if i == 0 %><span>Aucune image</span><% end %>
13
- <%= image_tag image.file_url(:small), class: (@element["src"] == image.file_url(@size) ? 'selected' : ''),
14
- data: {src: image.file_url(@size), alt: image.alt} %>
15
- </div>
16
- <% end %>
10
+ <table class="sibu_images">
11
+ <thead>
12
+ <tr>
13
+ <th>Aperçu</th>
14
+ <th>Descriptif</th>
15
+ <th>Crédits</th>
16
+ </tr>
17
+ </thead>
18
+ <tbody>
19
+ <% site_images.each do |image| %>
20
+ <tr>
21
+ <td>
22
+ <span class="sibu_image" data-img-id="<%= image.id %>">
23
+ <%= image_tag image.file_url(:small), class: (@element["src"] == image.file_url(@size) ? 'selected' : ''),
24
+ data: {src: image.file_url(@size), alt: image.alt} %>
25
+ </span>
26
+ </td>
27
+ <td><%= image.alt %></td>
28
+ <td><%= image.credits %></td>
29
+ </tr>
30
+ <% end %>
31
+ </tbody>
32
+ </table>
17
33
  </div>
18
34
  <div class="sibu_selected_image">
19
35
  <% if @element["src"] == DEFAULT_IMG || @element["src"].blank? %>
@@ -26,6 +42,7 @@
26
42
  <div class="sibu_center">
27
43
  <%= image_tag(@element["src"]) unless @element["src"] == DEFAULT_IMG || @element["src"].blank? %>
28
44
  <div id="sibu_center_pos" style="display: none;">✕</div>
45
+ <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>
29
46
  </div>
30
47
  <div class="sibu_field" style="display: <%= (@element["src"] == DEFAULT_IMG || @element["src"].blank?) ? 'none' : 'block' %>">
31
48
  <%= label_tag 'element[alt]', 'Légende / texte alternatif' %>
@@ -38,15 +38,19 @@ editPanel.slideDown("fast", function() {
38
38
  "text-align": wrapper.css("text-align")
39
39
  });
40
40
  <% when 'media' %>
41
- var images = editPanel.find(".sibu_image img");
42
- var customCenter = $("#custom_center"), customCtr;
41
+ var images = editPanel.find(".sibu_image");
42
+ var customCenter = $("#custom_center");
43
43
  images.click(function() {
44
44
  if(!$(this).hasClass('selected')) {
45
45
  images.removeClass('selected');
46
46
  $(this).addClass('selected');
47
- $("#element_src").val($(this).data("src"));
48
- $("#element_alt").val($(this).data("alt"));
49
- editPanel.find(".sibu_center").html('<img src="' + $("#element_src").val() + '"/><div id="sibu_center_pos" style="display: none;">✕</div>');
47
+ var imgElt = $(this).find("img");
48
+ $("#element_src").val(imgElt.data("src"));
49
+ $("#element_alt").val(imgElt.data("alt"));
50
+ editPanel.find(".sibu_center").html(
51
+ '<img src="' + $("#element_src").val() + '"/>' +
52
+ '<div id="sibu_center_pos" style="display: none;">✕</div>' +
53
+ '<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>');
50
54
  editPanel.find(".sibu_selected_image > p:first-child").hide();
51
55
  editPanel.find(".sibu_selected_image").find(".sibu_custom_center").show();
52
56
  editPanel.find(".sibu_selected_image").find(".sibu_field").show();
@@ -69,6 +73,7 @@ editPanel.slideDown("fast", function() {
69
73
  $("#element_class").val("");
70
74
  $(".sibu_center").attr("style", "");
71
75
  $(".sibu_center > #sibu_center_pos").hide();
76
+ $(".sibu_center > #sibu_center_desc").hide();
72
77
  }
73
78
  });
74
79
  <% when 'link' %>
@@ -0,0 +1 @@
1
+ Rails.application.config.assets.precompile += %w( tarteaucitron/tarteaucitron.css tarteaucitron/tarteaucitron.js )
@@ -1,5 +1,8 @@
1
1
  Sibu::Engine.routes.draw do
2
2
 
3
+ scope format: true, constraints: { format: /jpg|png|gif|svg/ } do
4
+ get '/*missed', to: proc { [404, {}, ['']] }
5
+ end
3
6
  get '/', to: 'pages#show', constraints: lambda {|req| req.host != Rails.application.config.sibu[:host]}
4
7
  get '*path', to: 'pages#show', constraints: lambda {|req| req.host != Rails.application.config.sibu[:host]}
5
8
 
@@ -1,3 +1,3 @@
1
1
  module Sibu
2
- VERSION = '0.8.3'
2
+ VERSION = '0.9.3'
3
3
  end
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.8.3
4
+ version: 0.9.3
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: 2019-07-18 00:00:00.000000000 Z
11
+ date: 2019-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 5.1.6
19
+ version: '5.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 5.1.6
26
+ version: '5.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: pg
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.2'
33
+ version: '1.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0.2'
40
+ version: '1.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: shrine
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -130,11 +130,26 @@ files:
130
130
  - app/assets/javascripts/sibu/common.js
131
131
  - app/assets/javascripts/sibu/sibu.js.erb
132
132
  - app/assets/javascripts/tabs/van11y-accessible-tab-panel-aria.js
133
+ - app/assets/javascripts/tarteaucitron/advertising.js
134
+ - app/assets/javascripts/tarteaucitron/lang/tarteaucitron.cs.js
135
+ - app/assets/javascripts/tarteaucitron/lang/tarteaucitron.de.js
136
+ - app/assets/javascripts/tarteaucitron/lang/tarteaucitron.el.js
137
+ - app/assets/javascripts/tarteaucitron/lang/tarteaucitron.en.js
138
+ - app/assets/javascripts/tarteaucitron/lang/tarteaucitron.es.js
139
+ - app/assets/javascripts/tarteaucitron/lang/tarteaucitron.fr.js
140
+ - app/assets/javascripts/tarteaucitron/lang/tarteaucitron.it.js
141
+ - app/assets/javascripts/tarteaucitron/lang/tarteaucitron.nl.js
142
+ - app/assets/javascripts/tarteaucitron/lang/tarteaucitron.pl.js
143
+ - app/assets/javascripts/tarteaucitron/lang/tarteaucitron.pt.js
144
+ - app/assets/javascripts/tarteaucitron/lang/tarteaucitron.ru.js
145
+ - app/assets/javascripts/tarteaucitron/tarteaucitron.js.erb
146
+ - app/assets/javascripts/tarteaucitron/tarteaucitron.services.js
133
147
  - app/assets/stylesheets/cropper/cropper.css
134
148
  - app/assets/stylesheets/quill/quill.snow.css
135
149
  - app/assets/stylesheets/sibu/defaults.scss
136
150
  - app/assets/stylesheets/sibu/icons.scss
137
151
  - app/assets/stylesheets/sibu/sibu.css
152
+ - app/assets/stylesheets/tarteaucitron/tarteaucitron.css
138
153
  - app/controllers/sibu/application_controller.rb
139
154
  - app/controllers/sibu/documents_controller.rb
140
155
  - app/controllers/sibu/images_controller.rb
@@ -207,6 +222,7 @@ files:
207
222
  - app/views/sibu/sites/new.html.erb
208
223
  - app/views/sibu/sites/show.html.erb
209
224
  - app/views/sibu/sites/update.html.erb
225
+ - config/initializers/assets.rb
210
226
  - config/initializers/constants.rb
211
227
  - config/initializers/shrine.rb
212
228
  - config/routes.rb