sibu 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 23580168267b70a604f22863c33d73268eed7967
4
- data.tar.gz: 0cac86156e41ebd512473aa887fab6fd02fb5b1b
3
+ metadata.gz: 3ab0e87dab04c591e1072ba7606a327ab09c39b2
4
+ data.tar.gz: 55ad274ae00c536177c6b1b558a7c39bfc23b205
5
5
  SHA512:
6
- metadata.gz: a48297363054e2ec96bcc07821a45395ef9a3e56e72f2c3edcaa4c28cf05612ec1d6b3b7dd046f67f5ccfd1e564f2c6564467383f2c8ea5e9a417fe17e551ac7
7
- data.tar.gz: abd171b04e211b2b22d3d2136ee35101bb48f7e0d40b93377c377e6ab3e5c47372ddfdf0578594eb8d7591814ce93923b4659f3846f868c0529df465cc068fd6
6
+ metadata.gz: 6630c445f0902e0be6e6e0256b954a5815afa031c3fa3b5b3c7fc0dffa3dd39d18c64e44b5ac3e64e3edbf80a5bf035e499245c79b6625db356b0e8227d74ab3
7
+ data.tar.gz: 4b8dc78d1031281490e6c6c2a43a9c75586783617358c3f323a37e6c8b1fa719656b35e3cb376a410ec053ef943ca991c8c4d78bb058fc24d7be25a175abe1cb
@@ -0,0 +1,272 @@
1
+ $sibu-color1 : #acb3c2 !default;
2
+ $sibu-color2 : #727e96 !default;
3
+ $sibu-color3 : #333 !default;
4
+
5
+ .sibu_view {
6
+ padding: 2rem;
7
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
8
+
9
+ h2 {
10
+ padding-bottom: 1rem;
11
+ border-bottom: 2px solid $sibu-color1;
12
+ }
13
+
14
+ > .actions {
15
+ float: right;
16
+
17
+ a {
18
+ text-decoration: none;
19
+ }
20
+ }
21
+
22
+ .sibu_images {
23
+ width: 70%;
24
+ float: left;
25
+ max-height: calc(100vh - 160px);
26
+ overflow: auto;
27
+ }
28
+
29
+ .sibu_edit_image {
30
+ margin-top: 1rem;
31
+ padding: 1rem;
32
+ text-align: center;
33
+ height: calc(100vh - 160px);
34
+ float: right;
35
+ width: 30%;
36
+ background-color: $sibu-color2;
37
+
38
+ .sibu_field {
39
+ margin-top: 1rem;
40
+ label {
41
+ font-weight: bold;
42
+ }
43
+ }
44
+ }
45
+
46
+ .sibu_image {
47
+ display: inline-block;
48
+ margin-right: 1rem;
49
+ margin-top: 1rem;
50
+
51
+ img {
52
+ padding: 5px;
53
+ border: 1px solid $sibu-color3;
54
+ height: 100px;
55
+ width: auto;
56
+ }
57
+
58
+ &.selected {
59
+ background-color: $sibu-color3;
60
+ }
61
+ }
62
+
63
+ .sibu_form {
64
+ padding: 2rem;
65
+ text-align: center;
66
+
67
+ .sibu_field {
68
+ width: 90%;
69
+ margin: 0 auto 2rem auto;
70
+
71
+ label {
72
+ display: inline-block;
73
+ width: 20%;
74
+ text-align: right;
75
+ padding-right: 1rem;
76
+ vertical-align: top;
77
+ font-weight: bold;
78
+ margin-top: 0.5rem;
79
+ line-height: 1;
80
+
81
+ & + * {
82
+ display: inline-block;
83
+ width: 75%;
84
+ > * {
85
+ display: inline-block;
86
+ width: 100%;
87
+ }
88
+ small {
89
+ text-align: left;
90
+ font-style: italic;
91
+ }
92
+ }
93
+ }
94
+ }
95
+
96
+ .sibu_colors {
97
+ label {
98
+ vertical-align: top;
99
+ }
100
+
101
+ label + div {
102
+ text-align: left;
103
+ }
104
+
105
+ .sibu_color {
106
+ display: inline-block;
107
+ width: 4rem;
108
+ height: 4rem;
109
+ margin-right: 0.5rem;
110
+
111
+ &.selected {
112
+ border: 2px solid $sibu-color3;
113
+ outline: solid white 2px;
114
+ outline-offset: -3px;
115
+ }
116
+
117
+ &:hover {
118
+ cursor: pointer;
119
+ }
120
+ }
121
+ }
122
+ }
123
+
124
+ .sibu_edit_form {
125
+ padding: 2rem 0;
126
+ text-align: left;
127
+
128
+ .sibu_actions {
129
+ text-align: center;
130
+ }
131
+
132
+ .sibu_field {
133
+ width: 100%;
134
+ margin: 0 auto 2rem auto;
135
+
136
+ p {
137
+ font-weight: bold;
138
+ }
139
+
140
+ label {
141
+ text-align: left;
142
+ font-weight: bold;
143
+
144
+ & + * {
145
+ display: block;
146
+ width: 100%;
147
+ }
148
+
149
+ & + input[type='checkbox'] {
150
+ display: inline-block;
151
+ width: 2rem;
152
+ margin-right: 2rem;
153
+ }
154
+ }
155
+ }
156
+
157
+ .sibu_image_selection {
158
+ display: flex;
159
+ flex-direction: row;
160
+ }
161
+
162
+ .sibu_select_images {
163
+ width: 70%;
164
+ max-height: calc(100vh - 300px);
165
+ overflow: auto;
166
+
167
+ .sibu_image {
168
+ position: relative;
169
+ span {
170
+ position: absolute;
171
+ z-index: -1;
172
+ line-height: 1;
173
+ width: 100%;
174
+ text-align: center;
175
+ top: 30px;
176
+
177
+ & + .selected {
178
+ background-color: transparentize($sibu-color3, 0.5);
179
+ }
180
+ }
181
+ }
182
+
183
+ img {
184
+ padding: 5px;
185
+ border: 1px solid $sibu-color3;
186
+
187
+ &.selected {
188
+ background-color: $sibu-color3;
189
+ }
190
+
191
+ &:hover {
192
+ cursor: pointer;
193
+ }
194
+ }
195
+ }
196
+
197
+ .sibu_selected_image {
198
+ background-color: $sibu-color2;
199
+ width: 30%;
200
+ margin-bottom: 2rem;
201
+ text-align: center;
202
+ padding: 1rem;
203
+
204
+ .sibu_field {
205
+ margin-top: 1rem;
206
+ label {
207
+ font-weight: bold;
208
+ }
209
+ }
210
+ }
211
+
212
+ #editor-container .ql-editor {
213
+ color: $sibu-color2;
214
+ }
215
+ }
216
+
217
+ .sibu_actions {
218
+ margin-top: 2rem;
219
+ margin-bottom: 2rem;
220
+
221
+ input, a {
222
+ font-size: 18px;
223
+ padding: 0.5em 1em;
224
+ }
225
+ }
226
+
227
+ .sibu_template {
228
+ display: inline-block;
229
+ width: 33%;
230
+ vertical-align: top;
231
+ padding: 2rem;
232
+
233
+ img {
234
+ padding-top: 2rem;
235
+ padding-bottom: 2rem;
236
+ border-top: 2px solid $sibu-color1;
237
+ box-shadow: 0 0 5px #ccc;
238
+ }
239
+ }
240
+ }
241
+
242
+ #sections_panel {
243
+ .sibu_sections {
244
+ padding: 2rem;
245
+
246
+ > div {
247
+ > * {
248
+ padding: 2rem;
249
+ border-bottom: 2px solid $sibu-color1;
250
+ &:hover {
251
+ cursor: pointer;
252
+ outline: dashed $sibu-color2 4px;
253
+ outline-offset: -5px;
254
+ }
255
+
256
+ &.selected {
257
+ outline: solid $sibu-color2 5px;
258
+ outline-offset: -5px;
259
+ }
260
+
261
+ > * {
262
+ margin-top: 0 !important;
263
+ margin-bottom: 0 !important;
264
+ }
265
+ }
266
+ }
267
+ }
268
+
269
+ .sibu_actions {
270
+ text-align: center;
271
+ }
272
+ }
@@ -3,8 +3,12 @@ module Sibu
3
3
  protect_from_forgery with: :exception
4
4
  before_action Rails.application.config.sibu[:auth_filter]
5
5
 
6
+ def conf
7
+ Rails.application.config.sibu
8
+ end
9
+
6
10
  def sibu_user
7
- send(Rails.application.config.sibu[:current_user])
11
+ send(conf[:current_user])
8
12
  end
9
13
  end
10
14
  end
@@ -7,6 +7,7 @@ module Sibu
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
+ before_action :set_online, only: [:show, :edit]
10
11
  skip_before_action Rails.application.config.sibu[:auth_filter], only: [:show]
11
12
 
12
13
  def index
@@ -14,23 +15,28 @@ module Sibu
14
15
  end
15
16
 
16
17
  def show
18
+ return_code = :ok
17
19
  if params[:site_id].blank?
18
- @page = Page.lookup(request.domain, params[:path])
20
+ @page = Sibu::Page.lookup(request.host, params[:path])
19
21
  if @page
22
+ @query_path = params[:path][@page.path.length + 1..-1] unless @page.path.blank?
23
+ @query_params = show_params.except(:controller, :action, :path).to_h
20
24
  @site = @page.site
21
25
  @links = @site.pages_path_by_id
22
- view_template = @page ? 'show' : @site.not_found
26
+ view_template = 'show'
23
27
  else
24
28
  view_template = Rails.application.config.sibu[:not_found]
29
+ return_code = :not_found
25
30
  end
26
31
  else
27
32
  @site = Sibu::Site.find(params[:site_id])
28
33
  @page = Sibu::Page.find(params[:id])
29
34
  @links = @site.pages_path_by_id
35
+ @query_path = params[:path]
30
36
  view_template = 'show'
31
37
  end
32
38
 
33
- render view_template, layout: 'sibu/site'
39
+ render view_template, layout: 'sibu/site', status: return_code
34
40
  end
35
41
 
36
42
  def new
@@ -153,6 +159,10 @@ module Sibu
153
159
  @entity = @entity_type == 'site' ? @site : @page
154
160
  end
155
161
 
162
+ def set_online
163
+ @online = request.host != conf[:host]
164
+ end
165
+
156
166
  def page_params
157
167
  params.require(:page).permit!
158
168
  end
@@ -164,5 +174,9 @@ module Sibu
164
174
  def section_params
165
175
  params.require(:section).permit!
166
176
  end
177
+
178
+ def show_params
179
+ params.permit!
180
+ end
167
181
  end
168
182
  end
@@ -21,7 +21,7 @@ module Sibu
21
21
  def create
22
22
  @site = Sibu::Site.new(site_params)
23
23
  if @site.save_and_init
24
- generate_styles(@site)
24
+ generate_styles(@site) if conf[:custom_styles]
25
25
  redirect_to sites_url, notice: "Le site a bien été créé."
26
26
  else
27
27
  flash.now[:alert] = "Une erreur s'est produite lors de la création du site."
@@ -30,15 +30,14 @@ module Sibu
30
30
  end
31
31
 
32
32
  def edit
33
- @next_page = params[:next_page]
34
33
  end
35
34
 
36
35
  def update
37
36
  if @site.update(site_params)
38
- if @site.previous_changes.has_key?(:custom_data)
37
+ if conf[:custom_styles] && @site.previous_changes.has_key?(:custom_data)
39
38
  generate_styles(@site)
40
39
  end
41
- redirect_to (params[:next_page].blank? ? sites_url : params[:next_page]), notice: "Le site a bien été mis à jour."
40
+ redirect_to sites_url, notice: "Le site a bien été mis à jour."
42
41
  else
43
42
  flash.now[:alert] = "Une erreur s'est produite lors de l'enregistrement du site."
44
43
  render :edit
@@ -53,8 +52,10 @@ module Sibu
53
52
  def duplicate
54
53
  new_site = @site.deep_copy
55
54
  if new_site.save
56
- generate_styles(@site)
57
- generate_styles(new_site)
55
+ if conf[:custom_styles]
56
+ generate_styles(@site)
57
+ generate_styles(new_site)
58
+ end
58
59
  redirect_to sites_url, notice: "Le site a bien été copié."
59
60
  else
60
61
  flash.now[:alert] = "Une erreur s'est produite lors de la copie du site."
@@ -4,7 +4,7 @@ module Sibu
4
4
 
5
5
  def link_path(page_id)
6
6
  p = @site.page_by_id(page_id)
7
- p ? (request.host == conf[:domain] ? site_page_path(@site.id, p.id) : "/#{p.path}") : "#"
7
+ p ? (request.host == conf[:host] ? site_page_path(@site.id, p.id) : "/#{p.path}") : "#"
8
8
  end
9
9
 
10
10
  def sections_templates
@@ -24,7 +24,7 @@ module Sibu
24
24
  end
25
25
 
26
26
  def link_type(val)
27
- if val.blank? || val == '#' || /^\d{1,3}$/.match(val.to_s)
27
+ if val.blank? || val == '#' || /^\d+$/.match(val.to_s)
28
28
  'internal'
29
29
  elsif Sibu::Document.for_user(sibu_user).map {|d| d.file_url}.include?(val)
30
30
  'document'
@@ -92,7 +92,7 @@ module Sibu
92
92
 
93
93
  def widget(elt, widget_type, opts = {}, &block)
94
94
  content = elt.is_a?(Hash) ? elt : (select_element(elt) || {})
95
- opts.merge!({data: {id: elt_id(elt), type: "widget_#{widget_type.to_s.underscore}"}}) if action_name != 'show'
95
+ opts.merge!({data: {id: elt_id(elt), type: "widget_#{widget_type.to_s.split('::').last.underscore}"}}) if action_name != 'show'
96
96
  content_tag(:div, capture(widget_type.new(content), &block), opts)
97
97
  end
98
98
 
@@ -9,9 +9,16 @@ module Sibu
9
9
  before_save :update_path
10
10
  validates_presence_of :name, :site
11
11
 
12
- def self.lookup(domain_name, page_path)
13
- joins(:site).where("sibu_sites.domain = ? AND ((sibu_sites.version = ? AND COALESCE(sibu_pages.path, '') = ?) OR sibu_pages.path = LTRIM(REPLACE(?, sibu_sites.version, ''), '/'))",
14
- domain_name, Sibu::Site::DEFAULT_VERSION, page_path.nil? ? '' : page_path.strip, page_path.nil? ? '' : page_path.strip).first
12
+ def self.lookup(domain_name, page_query)
13
+ page_path = (page_query || '').strip.split('?')[0]
14
+ if page_path.blank?
15
+ joins(:site).where("sibu_sites.domain = ? AND COALESCE(sibu_pages.path, '') = ''", domain_name).first
16
+ else
17
+ paths = page_path.split('/').inject([]) {|p, s| p << (p.length == 0 ? s : "#{p[-1]}/#{s}")}
18
+ joins(:site).where("sibu_sites.domain = ? AND COALESCE(sibu_pages.path, '') IN (?)", domain_name, paths)
19
+ .order(path: :desc)
20
+ .first
21
+ end
15
22
  end
16
23
 
17
24
  def save_and_init
@@ -7,7 +7,7 @@
7
7
  <%= javascript_include_tag "#{conf[:javascript]}-edit" %>
8
8
  <%= javascript_include_tag 'sibu/sibu' %>
9
9
  <% if @site %>
10
- <%= stylesheet_link_tag @site.style_url, media: "all" %>
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" %>
12
12
  <% end %>
13
13
  <%= csrf_meta_tags %>
@@ -7,7 +7,7 @@
7
7
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
8
8
 
9
9
  <% if @site %>
10
- <%= stylesheet_link_tag @site.style_url, media: "all" %>
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
13
  <script async src="https://www.googletagmanager.com/gtag/js?id=<%= @site.analytics_id %>"></script>
@@ -9,7 +9,7 @@
9
9
  <th>Nom</th>
10
10
  <th>Chemin d'accès</th>
11
11
  <th>Mise à jour</th>
12
- <th colspan="2"></th>
12
+ <th></th>
13
13
  </tr>
14
14
  </thead>
15
15
  <tbody>
@@ -18,7 +18,7 @@
18
18
  <td><%= p.name %></td>
19
19
  <td><%= p.path %></td>
20
20
  <td><%= l p.updated_at %></td>
21
- <td colspan="2">
21
+ <td>
22
22
  <%= link_to 'Voir', site_page_path(@site.id, p), target: '_blank' %> |
23
23
  <%= link_to 'Modifier', site_page_edit_content_path(site_id: @site.id, page_id: p.id) %> |
24
24
  <%= link_to 'Copier', duplicate_site_page_path(@site.id, p), method: :post, data: {confirm: "Copier la page \"#{p.name}\" ?"} %> |
@@ -34,7 +34,7 @@
34
34
  <small>Renseignez l'identifiant Google Analytics pour suivre les statistiques d'audience du site</small>
35
35
  </div>
36
36
  </div>
37
- <% if @site.persisted? && @next_page %>
37
+ <% if conf[:custom_styles] && @site.persisted? %>
38
38
  <div class="sibu_field sibu_colors">
39
39
  <%= f.label :primary_color, 'Couleur principale' %>
40
40
  <div>
@@ -70,7 +70,6 @@
70
70
  </div>
71
71
  </div>
72
72
  <% end %>
73
- <%= hidden_field_tag :next_page, @next_page %>
74
73
  <%= f.hidden_field :user_id %>
75
74
  <div class="sibu_actions">
76
75
  <%= f.submit 'Valider', data: {disable_with: 'Enregistrement en cours...'} %>
@@ -1,6 +1,6 @@
1
1
  <div class="sibu_view">
2
2
  <div class="actions">
3
- <% if @site.persisted? && @next_page %><%= link_to 'Rétablir les paramètres par défaut', '#', onclick: 'resetValues()' %><% end %>
3
+ <% if conf[:custom_styles] && @site.persisted? %><%= link_to 'Rétablir les paramètres par défaut', '#', onclick: 'resetValues()' %><% end %>
4
4
  <%= link_to 'Retour', :back %>
5
5
  </div>
6
6
  <h2>Modifier un site</h2>
data/config/routes.rb CHANGED
@@ -1,8 +1,7 @@
1
1
  Sibu::Engine.routes.draw do
2
2
 
3
- # Note : fix the issue with domain & subdomain & internal links
4
- get '/', to: 'pages#show', constraints: lambda {|req| req.domain != Rails.application.config.sibu[:domain]}
5
- get '*path', to: 'pages#show', constraints: lambda {|req| req.domain != Rails.application.config.sibu[:domain]}
3
+ get '/', to: 'pages#show', constraints: lambda {|req| req.host != Rails.application.config.sibu[:host]}
4
+ get '*path', to: 'pages#show', constraints: lambda {|req| req.host != Rails.application.config.sibu[:host]}
6
5
 
7
6
  scope path_names: {new: 'creer', edit: 'modifier'} do
8
7
  resources :sites do
@@ -19,6 +18,7 @@ Sibu::Engine.routes.draw do
19
18
  get 'new_section', on: :member
20
19
  post 'create_section', on: :member
21
20
  delete 'delete_section', on: :member
21
+ get '*path', to: 'pages#show', on: :member
22
22
  end
23
23
  end
24
24
  resources :images, :documents
data/lib/sibu/engine.rb CHANGED
@@ -11,6 +11,9 @@ module Sibu
11
11
  rescue
12
12
  Rails.logger.info("Sibu custom helper is not available - skipping")
13
13
  end
14
+ Dir.glob(Rails.root + "app/decorators/**/*_decorator*.rb").each do |c|
15
+ require_dependency(c)
16
+ end
14
17
  end
15
18
  end
16
19
  end
data/lib/sibu/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Sibu
2
- VERSION = '0.4.0'
2
+ VERSION = '0.5.0'
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.4.0
4
+ version: 0.5.0
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-08-07 00:00:00.000000000 Z
11
+ date: 2018-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '5.1'
19
+ version: 5.1.6
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'
26
+ version: 5.1.6
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: pg
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -131,6 +131,7 @@ files:
131
131
  - app/assets/javascripts/sibu/sibu.js.erb
132
132
  - app/assets/stylesheets/cropper/cropper.css
133
133
  - app/assets/stylesheets/quill/quill.snow.css
134
+ - app/assets/stylesheets/sibu/defaults.scss
134
135
  - app/assets/stylesheets/sibu/icons.scss
135
136
  - app/assets/stylesheets/sibu/sibu.css
136
137
  - app/controllers/sibu/application_controller.rb