sibu 1.0.0 → 1.0.5
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/stylesheets/sibu/defaults.scss +1 -2
- data/app/assets/stylesheets/sibu/sibu.css +12 -1
- data/app/controllers/sibu/pages_controller.rb +7 -1
- data/app/controllers/sibu/sites_controller.rb +5 -1
- data/app/helpers/sibu/application_helper.rb +1 -1
- data/app/helpers/sibu/pages_helper.rb +78 -37
- data/app/models/sibu/page.rb +4 -0
- data/app/views/layouts/sibu/edit_content.html.erb +50 -28
- data/app/views/sibu/pages/_code_edit_panel.html.erb +2 -1
- 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/edit.html.erb +1 -1
- data/app/views/sibu/pages/edit_element.js.erb +2 -2
- data/app/views/sibu/pages/index.html.erb +6 -3
- data/app/views/sibu/sites/_form.html.erb +2 -2
- data/app/views/sibu/sites/index.html.erb +1 -1
- data/app/views/sibu/sites/new.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: 83f747d2d0f30d44d8321ea252994eb72a246743
|
4
|
+
data.tar.gz: 4e422b2041a2e3b8ca5eb86810e5440873c7c85e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 22a3a04bb5835e8119274276106e99ab700cd85c55c47aecafd8111c7c7eaa633f1c57a5e35b088a3532de89d7250580e17965f411a974657df642ac3c6b8a3b
|
7
|
+
data.tar.gz: 284b06e15ef29a30528f605d4c7b003781f17cad85be9a5c42daf78fff8520818189128abe907976ace0930b34f5c05d1f80cf3e7d367c523267e45734e9b1b1
|
data/README.md
CHANGED
@@ -1,9 +1,13 @@
|
|
1
|
-
# Sibu
|
2
|
-
|
3
|
-
|
1
|
+
# Sibu
|
2
|
+
Sibu is an engine to build websites. It focuses on :
|
3
|
+
- Maintaining a simple data model, so it can be exported & imported in many formats
|
4
|
+
- Increasing the productivity of web developers by using a Domain Specific Language for page edition
|
5
|
+
- Providing non-technical users with a simple and accessible site administration interface
|
4
6
|
|
5
7
|
## Usage
|
6
|
-
|
8
|
+
Sibu is currently implemented as a Ruby on Rails engine. Therefore its setup requires a host Ruby on Rails application, that can be created via :
|
9
|
+
|
10
|
+
`rails new my_app`
|
7
11
|
|
8
12
|
## Installation
|
9
13
|
Add this line to your application's Gemfile:
|
@@ -22,6 +26,79 @@ Or install it yourself as:
|
|
22
26
|
$ gem install sibu
|
23
27
|
```
|
24
28
|
|
29
|
+
Once the installation is complete, make sure that you copy the database migrations to your application :
|
30
|
+
```bash
|
31
|
+
rake sibu:install:migrations
|
32
|
+
```
|
33
|
+
|
34
|
+
And finally run the migrations to update your database model :
|
35
|
+
```bash
|
36
|
+
rake db:migrate
|
37
|
+
```
|
38
|
+
|
39
|
+
## Configuration
|
40
|
+
Configuration is provided via the `sibu` key of the Rails application configuration. Typically, this would be done in a `sibu.rb` file in the `config/initializers` folder of your Rails application.
|
41
|
+
The example below lists the configuration options available :
|
42
|
+
```ruby
|
43
|
+
Rails.application.config.sibu = {
|
44
|
+
|
45
|
+
# Title metatag of the admin interface
|
46
|
+
title: 'My website administration',
|
47
|
+
|
48
|
+
# Stylesheet to use to style the admin interface
|
49
|
+
stylesheet: 'my_user_css',
|
50
|
+
|
51
|
+
# Javascript to include in the admin interface
|
52
|
+
javascript: 'my_user_js',
|
53
|
+
|
54
|
+
# Path to the admin interface header partial
|
55
|
+
top_panel: 'shared/user/top_panel',
|
56
|
+
|
57
|
+
# Path to the main content edition partial - must include a yield to delegate content display to the Sibu engine
|
58
|
+
content_panel: 'shared/user/content_panel',
|
59
|
+
|
60
|
+
# Path to the admin interface footer partial
|
61
|
+
bottom_panel: 'shared/user/bottom_panel',
|
62
|
+
|
63
|
+
# Name of the method that will be used to authenticate admin users - this method must be available to Sibu controllers
|
64
|
+
auth_filter: :authenticate_user!,
|
65
|
+
|
66
|
+
# Name of the method that will retrieve the current user - this method must be available to Sibu controllers
|
67
|
+
current_user: 'current_user',
|
68
|
+
|
69
|
+
# A flag to indicate that the Sibu instance should offer a separate environment for each user
|
70
|
+
multi_user: true,
|
71
|
+
|
72
|
+
# A proc to identify super-admin users in a multi-users setup (optional)
|
73
|
+
admin_filter: Proc.new {|usr| usr.is_admin},
|
74
|
+
|
75
|
+
# When active, users will be able to override the colors and fonts of the sites templates (optional)
|
76
|
+
custom_styles: true,
|
77
|
+
|
78
|
+
# Lists of colors and fonts available for sites templates customization - Only used when custom_styles is set to true (optional)
|
79
|
+
primary_colors: ['#23527c', '#00B1BF', '#BECD00'],
|
80
|
+
secondary_colors: ['#E2007A', '#aaaaa1', '#be6432'],
|
81
|
+
primary_fonts: ['Intro', 'Lato', 'SourceSansPro'],
|
82
|
+
secondary_fonts: ['Aleo', 'Bodoni', 'Cinzel'],
|
83
|
+
|
84
|
+
# The domain name that will host the admin interface (should be different from the website domain name)
|
85
|
+
host: 'localhost',
|
86
|
+
|
87
|
+
# A partial for 404 error pages
|
88
|
+
not_found: 'shared/templates/not_found',
|
89
|
+
|
90
|
+
# Dimensions of the images to use in the website - Uploaded images will be automatically resized in the provided formats
|
91
|
+
images: {large: 1600, medium: 800, small: 320},
|
92
|
+
|
93
|
+
# Versions available for the created websites
|
94
|
+
versions: [['Français', 'fr'], ['Anglais', 'en']],
|
95
|
+
|
96
|
+
# A proc to override the default ordering of the sections when editing content (optional)
|
97
|
+
sections_ordering: Proc.new {|sections| sections.sort_by {|s| SECTIONS_TABS.index(s['category'])}}
|
98
|
+
}
|
99
|
+
```
|
100
|
+
|
101
|
+
|
25
102
|
## Improvements
|
26
103
|
- Use a specific controller & helper for site display
|
27
104
|
- Move page templates to SiteTemplate model
|
@@ -3,10 +3,21 @@
|
|
3
3
|
*= require_self
|
4
4
|
*/
|
5
5
|
|
6
|
-
.sibu_content_panel {
|
6
|
+
body.sibu_edit_content, .sibu_content_panel {
|
7
7
|
position: relative
|
8
8
|
}
|
9
9
|
|
10
|
+
body.sibu_edit_content > .sibu_panel:first-child {
|
11
|
+
position: fixed;
|
12
|
+
width: 100%;
|
13
|
+
z-index: 999999;
|
14
|
+
top: 0;
|
15
|
+
}
|
16
|
+
|
17
|
+
body.sibu_edit_content > .sibu_content_panel {
|
18
|
+
padding-top: 60px;
|
19
|
+
}
|
20
|
+
|
10
21
|
.sb-editable {
|
11
22
|
cursor: pointer;
|
12
23
|
outline: dashed rgba(94, 219, 255, 0.8) 3px;
|
@@ -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
|
@@ -6,7 +6,11 @@ module Sibu
|
|
6
6
|
skip_before_action Rails.application.config.sibu[:auth_filter], only: [:show]
|
7
7
|
|
8
8
|
def index
|
9
|
-
|
9
|
+
if conf[:admin_filter].call(sibu_user)
|
10
|
+
@sites = Sibu::Site.all.order(:name, :version)
|
11
|
+
else
|
12
|
+
@sites = Sibu::Site.for_user(sibu_user).order(:name, :version)
|
13
|
+
end
|
10
14
|
end
|
11
15
|
|
12
16
|
def show
|
@@ -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,29 +39,53 @@ 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
|
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
|
43
57
|
if block
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
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
|
48
63
|
else
|
49
|
-
|
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
|
50
69
|
end
|
70
|
+
@sb_section -= [t_id]
|
71
|
+
html_output
|
51
72
|
end
|
52
73
|
end
|
53
74
|
|
54
|
-
[:div, :section, :article, :aside, :header, :footer, :nav, :main, :ul].each do |t|
|
55
|
-
define_method(t) do |elt,
|
75
|
+
[:div, :section, :article, :aside, :header, :footer, :nav, :main, :ul, :ol, :wrapper].each do |t|
|
76
|
+
define_method(t) do |elt, opts = {}, &block|
|
56
77
|
t_id = elt.is_a?(Hash) ? elt["id"] : elt
|
57
78
|
@sb_section = (@sb_section || []) + [t_id]
|
58
|
-
html_opts = {"id" => t_id}.merge(
|
59
|
-
|
60
|
-
|
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)
|
61
89
|
@sb_section -= [t_id]
|
62
90
|
html_output
|
63
91
|
end
|
@@ -71,8 +99,12 @@ module Sibu
|
|
71
99
|
(tokens + [suffix]).select {|t| !t.blank?}.join("|")
|
72
100
|
end
|
73
101
|
|
74
|
-
|
75
|
-
|
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)
|
76
108
|
element_id_tokens = (@sb_section + element_id.split("|")).uniq
|
77
109
|
nested_elts = @sb_entity.elements(*element_id_tokens)
|
78
110
|
nested_elts.blank? ? [{"id" => element_id.split("|").last, "data-id" => join_tokens(element_id_tokens[1..-1], "#{element_id}0")}] :
|
@@ -88,37 +120,37 @@ module Sibu
|
|
88
120
|
items.blank? ? [{"id" => "el#{Time.current.to_i}"}] : items
|
89
121
|
end
|
90
122
|
|
91
|
-
def p(elt, opts = {})
|
92
|
-
repeat = opts.delete(:repeat)
|
93
|
-
defaults = {"id" => elt.is_a?(Hash) ? elt["id"] : elt, "text" => Sibu::DEFAULT_PARAGRAPH}
|
94
|
-
content = defaults.merge(elt.is_a?(Hash) ? elt : (select_element(elt) || {}))
|
95
|
-
opts.merge!({data: {id: elt_id(elt), repeat: repeat, type: "paragraph"}}) if action_name != 'show'
|
96
|
-
content_tag(:div, content_tag(:p, raw(content["text"]).html_safe), opts)
|
97
|
-
end
|
98
|
-
|
99
123
|
def img(elt, opts = {})
|
100
124
|
wrapper = opts.delete(:wrapper)
|
101
125
|
repeat = opts.delete(:repeat)
|
102
126
|
size = opts.delete(:size)
|
103
|
-
|
127
|
+
t_id = elt.is_a?(Hash) ? elt["id"] : elt
|
128
|
+
defaults = {"id" => t_id, "src" => Sibu::DEFAULT_IMG}
|
104
129
|
content = defaults.merge(elt.is_a?(Hash) ? elt : (select_element(elt) || {}))
|
130
|
+
@sb_section = (@sb_section || []) + [t_id]
|
105
131
|
if action_name == 'show'
|
106
132
|
content["src"] = ("/#{conf[:deployment_path]}" + content["src"]) if @online && conf[:deployment_path]
|
107
133
|
else
|
108
|
-
opts.merge!({data: {id:
|
134
|
+
opts.merge!({data: {id: @sb_section[1..-1].join('|'), type: "media", repeat: repeat, size: size}})
|
109
135
|
end
|
110
|
-
wrapper ? content_tag(wrapper, content_tag(:img, nil, content.except("id")), opts)
|
136
|
+
html_output = wrapper ? content_tag(wrapper, content_tag(:img, nil, content.except("id")), opts)
|
111
137
|
: content_tag(:img, nil, content.except("id").merge(opts.stringify_keys) {|k, old, new| k == 'class' ? [old, new].join(' ') : new})
|
138
|
+
@sb_section -= [t_id]
|
139
|
+
html_output
|
112
140
|
end
|
113
141
|
|
114
142
|
def grp(elt, opts = {}, &block)
|
115
143
|
wrapper = opts.delete(:wrapper) || :div
|
116
144
|
repeat = opts.delete(:repeat)
|
117
145
|
children = opts.delete(:children)
|
118
|
-
|
146
|
+
t_id = elt.is_a?(Hash) ? elt["id"] : elt
|
147
|
+
@sb_section = (@sb_section || []) + [t_id]
|
148
|
+
defaults = {"id" => t_id}
|
119
149
|
opts = defaults.merge(opts)
|
120
|
-
opts.merge!({data: {id:
|
121
|
-
content_tag(wrapper, capture(*elts(elt), &block), opts)
|
150
|
+
opts.merge!({data: {id: @sb_section[1..-1].join('|'), type: "group", repeat: repeat, children: children}}) if action_name != 'show'
|
151
|
+
html_output = content_tag(wrapper, capture(*elts(elt), &block), opts)
|
152
|
+
@sb_section -= [t_id]
|
153
|
+
html_output
|
122
154
|
end
|
123
155
|
|
124
156
|
def empty_tag(elt, tag, type, opts = {})
|
@@ -171,10 +203,18 @@ module Sibu
|
|
171
203
|
locals: {sibu: self, sibu_section: s, sibu_attrs: sibu_attributes(s).html_safe}
|
172
204
|
end
|
173
205
|
|
206
|
+
# Page sections attrs
|
174
207
|
def sibu_attributes(section)
|
175
208
|
action_name != 'show' ? ('data-sb-id="' + section['id'] + '" data-sb-entity="page"') : ''
|
176
209
|
end
|
177
210
|
|
211
|
+
# Site sections attrs
|
212
|
+
def sibu_attrs(section_id)
|
213
|
+
@sb_section = [section_id]
|
214
|
+
@sb_entity = @site
|
215
|
+
action_name != 'show' ? ('data-sb-id="' + section_id + '" data-sb-entity="site"').html_safe : ''
|
216
|
+
end
|
217
|
+
|
178
218
|
def section(id, tag, html_opts = {}, &block)
|
179
219
|
@sb_section = [id]
|
180
220
|
opts = action_name != 'show' ? html_opts.merge({"data-sb-id" => id, "data-sb-entity" => @sb_entity == @site ? 'site' : 'page'}) : html_opts
|
@@ -197,12 +237,14 @@ module Sibu
|
|
197
237
|
def link(elt, html_opts = {}, &block)
|
198
238
|
repeat = html_opts.delete(:repeat)
|
199
239
|
children = html_opts.delete(:children)
|
200
|
-
|
240
|
+
t_id = elt.is_a?(Hash) ? elt["id"] : elt
|
241
|
+
defaults = {"id" => t_id, "value" => "", "text" => Sibu::DEFAULT_TEXT}
|
201
242
|
link_elt = current_elt(elt)
|
202
243
|
content = defaults.merge(link_elt)
|
203
244
|
val = content.delete("value") || ""
|
204
245
|
text = content.delete("text")
|
205
|
-
|
246
|
+
@sb_section = (@sb_section || []) + [t_id]
|
247
|
+
html_opts.merge!({data: {id: @sb_section[1..-1].join('|'), type: "link", repeat: repeat, children: children}}) if action_name != 'show'
|
206
248
|
if val.to_s.start_with?('http')
|
207
249
|
content["href"] = val
|
208
250
|
elsif val.to_s.start_with?('#')
|
@@ -216,17 +258,16 @@ module Sibu
|
|
216
258
|
content["href"] = @links.keys.include?(val.to_s) ? (action_name == 'show' ? link_path(val) : site_page_edit_content_path(@site.id, val)) : '#'
|
217
259
|
end
|
218
260
|
if block_given?
|
219
|
-
@sb_section = (@sb_section || []) + [elt_id(elt)]
|
220
261
|
html_output = content_tag(:a, capture(link_elt, elts(elt), &block), content.merge(html_opts).except("elements"))
|
221
|
-
@sb_section -= [elt_id(elt)]
|
222
|
-
html_output
|
223
262
|
else
|
224
|
-
content_tag(:a, raw(text), content.merge(html_opts).except("elements"))
|
263
|
+
html_output = content_tag(:a, raw(text), content.merge(html_opts).except("elements"))
|
225
264
|
end
|
265
|
+
@sb_section -= [t_id]
|
266
|
+
html_output
|
226
267
|
end
|
227
268
|
|
228
269
|
def interactive_map(elt, html_opts = {})
|
229
|
-
defaults = {"data-lat" => "
|
270
|
+
defaults = {"data-lat" => "46.1988027", "data-lng" => "5.1748288", "data-title" => Sibu::DEFAULT_TEXT}
|
230
271
|
content = defaults.merge(elt.is_a?(Hash) ? elt : (select_element(elt) || {"id" => elt}))
|
231
272
|
html_opts.merge!({data: {id: elt_id(elt), type: "map"}}) if action_name != 'show'
|
232
273
|
content_tag(:div, nil, content.merge(html_opts))
|
data/app/models/sibu/page.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
<head>
|
4
4
|
<title><%= conf[:title] %></title>
|
5
5
|
<%= stylesheet_link_tag 'sibu/sibu', media: 'all' %>
|
6
|
-
<%= stylesheet_link_tag conf[:stylesheet], media: 'all' %>
|
6
|
+
<%= stylesheet_link_tag "#{conf[:stylesheet]}-edit", media: 'all' %>
|
7
7
|
<%= javascript_include_tag "#{conf[:javascript]}-edit" %>
|
8
8
|
<% if @site %>
|
9
9
|
<%= stylesheet_link_tag (conf[:custom_styles] ? @site.style_url : @site.site_template.path), media: "all" %>
|
@@ -12,7 +12,7 @@
|
|
12
12
|
<%= csrf_meta_tags %>
|
13
13
|
<%= yield :styles %>
|
14
14
|
</head>
|
15
|
-
<body>
|
15
|
+
<body class="sibu_edit_content">
|
16
16
|
<% [:top_panel, :side_panel, :content_panel, :bottom_panel].each do |panel| %>
|
17
17
|
<% unless conf[panel].blank? %>
|
18
18
|
<div class="<%= panel == :content_panel ? 'sibu_content_panel' : 'sibu_panel' %>">
|
@@ -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) {
|
@@ -77,7 +74,8 @@
|
|
77
74
|
editMode.querySelector("#new_section_after").style.display = "block";
|
78
75
|
editMode.querySelector("#delete_section").style.display = "block";
|
79
76
|
}
|
80
|
-
|
77
|
+
var topPadding = top <= 120 ? 60 : 120;
|
78
|
+
window.scrollTo(0, top - topPadding);
|
81
79
|
section.classList.add('sb-editing');
|
82
80
|
initInnerOverlays(section);
|
83
81
|
document.querySelector("#edit_overlays").innerHTML = "";
|
@@ -212,7 +210,7 @@
|
|
212
210
|
function initInnerOverlays(section) {
|
213
211
|
var editables = section.querySelectorAll("[data-type]");
|
214
212
|
for (var i = 0; i < editables.length; i++) {
|
215
|
-
if (editables[i].getAttribute("data-type") !== 'group' || editables[i].getAttribute("data-repeat")
|
213
|
+
if (editables[i].getAttribute("data-type") !== 'group' || editables[i].getAttribute("data-repeat") === 'true' || editables[i].getAttribute("data-children") === 'true') {
|
216
214
|
editables[i].addEventListener("mouseenter", function(evt) {
|
217
215
|
evt.stopPropagation();
|
218
216
|
evt.currentTarget.classList.add("sb-editable");
|
@@ -232,28 +230,52 @@
|
|
232
230
|
}
|
233
231
|
}
|
234
232
|
|
235
|
-
function initOverlays() {
|
236
|
-
|
237
|
-
|
233
|
+
function initOverlays(activeSection = "") {
|
234
|
+
setTimeout(function() {
|
235
|
+
var container = document.querySelector("#edit_overlays"), sections = document.querySelectorAll("[data-sb-id]");
|
236
|
+
container.innerHTML = "";
|
237
|
+
|
238
|
+
for (var i = 0; i < sections.length; i++) {
|
239
|
+
var sectionBox = eltBox(sections[i]);
|
240
|
+
var yOffset = sectionBox.top;
|
241
|
+
var width = sections[i].offsetWidth, height = (sections[i].offsetHeight === 0 ? childrenHeight(sections[i]) : sections[i].offsetHeight);
|
242
|
+
var overlay = document.createElement("div");
|
243
|
+
overlay.setAttribute("data-sb-overlay", sections[i].getAttribute("data-sb-id"));
|
244
|
+
overlay.innerHTML = "Modifier";
|
245
|
+
container.appendChild(overlay);
|
246
|
+
overlay.style.top = yOffset + "px";
|
247
|
+
overlay.style.left = sectionBox.left + "px";
|
248
|
+
overlay.style.width = width + "px";
|
249
|
+
overlay.style.height = height + "px";
|
250
|
+
overlay.addEventListener("click", (function(section, offsetLeft, offsetTop, editWidth, editHeight) {
|
251
|
+
return function(evt) {
|
252
|
+
setEditMode(section, evt.currentTarget, offsetLeft, offsetTop, editWidth, editHeight);
|
253
|
+
};
|
254
|
+
})(sections[i], sectionBox.left, yOffset, width, height));
|
255
|
+
}
|
256
|
+
if (activeSection) {
|
257
|
+
document.querySelector("[data-sb-overlay='" + activeSection + "']").click();
|
258
|
+
}
|
259
|
+
}, 800);
|
260
|
+
}
|
238
261
|
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
overlay.style.top = yOffset + "px";
|
248
|
-
overlay.style.left = sectionBox.left + "px";
|
249
|
-
overlay.style.width = width + "px";
|
250
|
-
overlay.style.height = height + "px";
|
251
|
-
overlay.addEventListener("click", (function(section, offsetLeft, offsetTop, editWidth, editHeight) {
|
252
|
-
return function(evt) {
|
253
|
-
setEditMode(section, evt.currentTarget, offsetLeft, offsetTop, editWidth, editHeight);
|
254
|
-
};
|
255
|
-
})(sections[i], sectionBox.left, yOffset, width, height));
|
262
|
+
function eltBox(elt) {
|
263
|
+
var x, y, w, h, bbox = elt.getBoundingClientRect();
|
264
|
+
if (isIE()) {
|
265
|
+
x = bbox.left + window.scrollX;
|
266
|
+
y = bbox.top + window.scrollY;
|
267
|
+
} else {
|
268
|
+
x = bbox.x + window.scrollX;
|
269
|
+
y = bbox.y + window.scrollY;
|
256
270
|
}
|
271
|
+
w = bbox.width;
|
272
|
+
h = bbox.height;
|
273
|
+
return {top: y, left: x, width: w, height: h}
|
274
|
+
}
|
275
|
+
|
276
|
+
function isIE() {
|
277
|
+
let ua = navigator.userAgent;
|
278
|
+
return ua.indexOf("MSIE ") > -1 || ua.indexOf("Trident/") > -1;
|
257
279
|
}
|
258
280
|
|
259
281
|
function childrenHeight(parentElt) {
|
@@ -1,10 +1,11 @@
|
|
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">
|
6
7
|
<%= label_tag 'element[code]', "Code d'intégration du contenu" %>
|
7
|
-
<%= text_area_tag 'element[code]', @element["code"], placeholder: '
|
8
|
+
<%= text_area_tag 'element[code]', @element["code"], placeholder: 'ex: <iframe src="..."></iframe>' %>
|
8
9
|
</div>
|
9
10
|
<%= hidden_field_tag 'element[id]', @element["id"] %>
|
10
11
|
<%= hidden_field_tag :element_id, @element_id %>
|
@@ -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">
|
@@ -86,8 +86,8 @@ setTimeout(function() {
|
|
86
86
|
document.querySelector("#clone_elt").style.display = "inline-block";
|
87
87
|
document.querySelector("#duplicate_elt").style.display = "inline-block";
|
88
88
|
<% else %>
|
89
|
-
document.querySelector("#clone_elt").remove();
|
90
|
-
document.querySelector("#duplicate_elt").remove();
|
89
|
+
if (document.querySelector("#clone_elt")) document.querySelector("#clone_elt").remove();
|
90
|
+
if (document.querySelector("#duplicate_elt")) document.querySelector("#duplicate_elt").remove();
|
91
91
|
<% end %>
|
92
92
|
|
93
93
|
<% if @children %>
|
@@ -1,6 +1,9 @@
|
|
1
1
|
<div id="pages" class="sibu_view">
|
2
2
|
<div class="actions">
|
3
|
-
<%= link_to
|
3
|
+
<%= link_to "Bibliothèque d'images", images_path %>
|
4
|
+
<%= link_to "Documents", documents_path %>
|
5
|
+
<%= link_to 'Créer une page', new_site_page_path(@site.id) %>
|
6
|
+
<%= link_to 'Retour', :back %>
|
4
7
|
</div>
|
5
8
|
<h2>Pages du site "<%= @site.name %>"</h2>
|
6
9
|
<table>
|
@@ -8,7 +11,7 @@
|
|
8
11
|
<tr>
|
9
12
|
<th>Nom</th>
|
10
13
|
<th>Chemin d'accès</th>
|
11
|
-
<th>
|
14
|
+
<th>Référence</th>
|
12
15
|
<th>Mise à jour</th>
|
13
16
|
<th></th>
|
14
17
|
</tr>
|
@@ -24,7 +27,7 @@
|
|
24
27
|
<%= link_to 'Voir', site_page_path(@site.id, p), target: '_blank' %> |
|
25
28
|
<%= link_to 'Editer', site_page_edit_content_path(site_id: @site.id, page_id: p.id) %> |
|
26
29
|
<%= link_to 'Copier', duplicate_site_page_path(@site.id, p), method: :post, data: {confirm: "Copier la page \"#{p.name}\" ?"} %> |
|
27
|
-
<%= link_to 'Paramétrer', edit_site_page_path(@site.id, p) %> |
|
30
|
+
<%= link_to 'Paramétrer cette page', edit_site_page_path(@site.id, p) %> |
|
28
31
|
<%= link_to 'Supprimer', site_page_path(@site.id, p), method: :delete, data: {confirm: "Supprimer la page \"#{p.name}\" ?"} %>
|
29
32
|
</td>
|
30
33
|
</tr>
|
@@ -16,8 +16,8 @@
|
|
16
16
|
<div class="sibu_field">
|
17
17
|
<%= f.label :site_template_id, 'Modèle' %>
|
18
18
|
<div>
|
19
|
-
<%= f.collection_select(:site_template_id, Sibu::SiteTemplate.all, :id, :name, {prompt: 'Sélectionnez un modèle de site'}, disabled: @site.persisted?) %>
|
20
|
-
<small>Choisissez le gabarit qui servira de modèle pour votre site (non modifiable après création)</small>
|
19
|
+
<%= f.collection_select(:site_template_id, Sibu::SiteTemplate.all.order(:name), :id, :name, {prompt: 'Sélectionnez un modèle de site'}, disabled: @site.persisted?) %>
|
20
|
+
<small>Choisissez le gabarit qui servira de modèle pour votre site (voir exemples ci-dessous - non modifiable après création)</small>
|
21
21
|
</div>
|
22
22
|
</div>
|
23
23
|
<div class="sibu_field">
|
@@ -24,7 +24,7 @@
|
|
24
24
|
<td><%= l s.updated_at %></td>
|
25
25
|
<td colspan="2">
|
26
26
|
<%= link_to 'Pages', site_pages_path(s) %> |
|
27
|
-
<%= link_to '
|
27
|
+
<%= link_to 'Réglages du site', edit_site_path(s) %> |
|
28
28
|
<%= link_to 'Copier', duplicate_site_path(s), method: :post, data: {confirm: "Copier le site \"#{s.name}\" ?"} %> |
|
29
29
|
<%= link_to 'Supprimer', site_path(s), method: :delete, data: {confirm: "Supprimer le site \"#{s.name}\" ?"} %>
|
30
30
|
</td>
|
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.5
|
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-04
|
11
|
+
date: 2020-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|