alchemy-custom-model 2.2.0 → 3.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/stylesheets/alchemy-custom-model/custom_style.css.scss +95 -0
- data/app/controllers/alchemy/custom/model/admin/base_controller.rb +14 -15
- data/app/controllers/concerns/alchemy/admin/nodes_controller_dec.rb +2 -1
- data/app/helpers/alchemy/custom/model/admin/base_helper.rb +46 -1
- data/app/helpers/alchemy/custom/model/custom_model_helper.rb +26 -13
- data/app/views/alchemy/custom/model/admin/base/_search_panel.html.erb +16 -0
- data/app/views/alchemy/custom/model/admin/base/_show_object.html.erb +30 -0
- data/app/views/alchemy/custom/model/admin/base/_show_objects.html.erb +48 -0
- data/app/views/alchemy/custom/model/admin/base/index.html.erb +5 -4
- data/app/views/alchemy/custom/model/admin/base/show.html.erb +5 -48
- data/app/views/alchemy/pages/sitemap.xml.erb +16 -0
- data/lib/alchemy/custom/model.rb +7 -0
- data/lib/alchemy/custom/model/el_finder/paths/active_record_reference.rb +9 -0
- data/lib/alchemy/custom/model/globalize_model_decoration.rb +1 -0
- data/lib/alchemy/custom/model/model_decoration.rb +1 -0
- data/lib/alchemy/custom/model/pages_controller_dec.rb +38 -25
- data/lib/alchemy/custom/model/sitemap_methods.rb +18 -0
- data/lib/alchemy/custom/model/version.rb +1 -1
- metadata +16 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: caccdc8bd1c52308fba382b86a294ea2244c739f2088e5e508d82f81d4aadb20
|
4
|
+
data.tar.gz: 2856b5183c940815e58fcff9f0e691493e71efcc075659747194ad6ead20dfaf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b888fdfaab020a5e904236cb66943f7b51810fb2ac869561f622f8d326e27b1a396029eb9fefe039aa0a9f8ac3190b927ff29fae5acedf8666a5c1e4d846c2d3
|
7
|
+
data.tar.gz: d04b7ef5d81468442913b7420bec3f86e6606c6033416fa6a21d1537a36577dd42c7f2a5605e9f43856a0327ffc49702d61149e06deeede1338d5ee030708a40
|
@@ -276,3 +276,98 @@
|
|
276
276
|
|
277
277
|
}
|
278
278
|
|
279
|
+
|
280
|
+
.alchemy-dialog {
|
281
|
+
max-width: 1080px !important;
|
282
|
+
width: 100% !important;
|
283
|
+
|
284
|
+
.attribute_row {
|
285
|
+
margin: 10px 0px;
|
286
|
+
display: flex;
|
287
|
+
|
288
|
+
.labelfield {
|
289
|
+
font-size: 15px;
|
290
|
+
font-weight: bold;
|
291
|
+
text-transform: uppercase;
|
292
|
+
display: inline-block;
|
293
|
+
width: 200px;
|
294
|
+
overflow: hidden;
|
295
|
+
}
|
296
|
+
|
297
|
+
.valuefield {
|
298
|
+
font-size: 15px;
|
299
|
+
display: inline-block;
|
300
|
+
width: calc(100% - 200px);
|
301
|
+
overflow: hidden;
|
302
|
+
}
|
303
|
+
|
304
|
+
}
|
305
|
+
}
|
306
|
+
|
307
|
+
|
308
|
+
.search_panel {
|
309
|
+
background-color: #e9cfb7;
|
310
|
+
color:#000;
|
311
|
+
padding: 5px;
|
312
|
+
.row {
|
313
|
+
width: 100%;
|
314
|
+
height: auto;
|
315
|
+
display: flex;
|
316
|
+
}
|
317
|
+
.title {
|
318
|
+
color:#204166;
|
319
|
+
background-color: #eca96e;
|
320
|
+
font-weight: bolder;
|
321
|
+
width: 100;
|
322
|
+
display: block;
|
323
|
+
text-align: center;
|
324
|
+
height: 30px;
|
325
|
+
.title_label {
|
326
|
+
float:left;
|
327
|
+
margin-top:5px;
|
328
|
+
padding-left: 5px;
|
329
|
+
}
|
330
|
+
.button_toggle {
|
331
|
+
float:right;
|
332
|
+
margin-top:5px;
|
333
|
+
padding-right: 5px;
|
334
|
+
}
|
335
|
+
}
|
336
|
+
.search_fields_group div.input {
|
337
|
+
width: 30%;
|
338
|
+
float: left;
|
339
|
+
padding: 0 15px;
|
340
|
+
margin: 2px 0;
|
341
|
+
}
|
342
|
+
.action_buttons {
|
343
|
+
padding-top: 3px;
|
344
|
+
}
|
345
|
+
}
|
346
|
+
|
347
|
+
|
348
|
+
.show_page {
|
349
|
+
max-width: 1080px !important;
|
350
|
+
width: 100% !important;
|
351
|
+
|
352
|
+
.attribute_row {
|
353
|
+
margin: 10px 0px;
|
354
|
+
display: flex;
|
355
|
+
|
356
|
+
.labelfield {
|
357
|
+
font-size: 15px;
|
358
|
+
font-weight: bold;
|
359
|
+
text-transform: uppercase;
|
360
|
+
display: inline-block;
|
361
|
+
width: 200px;
|
362
|
+
overflow: hidden;
|
363
|
+
}
|
364
|
+
|
365
|
+
.valuefield {
|
366
|
+
font-size: 15px;
|
367
|
+
display: inline-block;
|
368
|
+
width: calc(100% - 200px);
|
369
|
+
overflow: hidden;
|
370
|
+
}
|
371
|
+
|
372
|
+
}
|
373
|
+
}
|
@@ -62,17 +62,19 @@ module Alchemy::Custom::Model
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def show
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
65
|
+
unless self.class.method_for_show.nil?
|
66
|
+
if @obj.respond_to? self.class.method_for_show
|
67
|
+
@objects = @obj.send(self.class.method_for_show.to_sym)
|
68
|
+
@objects = @objects.accessible_by(current_ability)
|
69
|
+
@total_objects = @objects
|
70
|
+
@objects = @objects.page(params[:page]).
|
71
|
+
per(params[:per_page] ||
|
72
|
+
(base_class::DEFAULT_PER_PAGE if base_class.const_defined? :DEFAULT_PER_PAGE) ||
|
73
|
+
25)
|
74
|
+
instance_variable_set "@#{self.class.method_for_show.to_s.underscore.downcase.pluralize}", @objects
|
75
|
+
else
|
76
|
+
@objects = base_class.none
|
77
|
+
end
|
76
78
|
end
|
77
79
|
end
|
78
80
|
|
@@ -82,10 +84,7 @@ module Alchemy::Custom::Model
|
|
82
84
|
@objects = @query.result(distinct: true)
|
83
85
|
@objects = @objects.accessible_by(current_ability)
|
84
86
|
@total_objects = @objects
|
85
|
-
|
86
|
-
per(params[:per_page] ||
|
87
|
-
(base_class::DEFAULT_PER_PAGE if base_class.const_defined? :DEFAULT_PER_PAGE) ||
|
88
|
-
25)
|
87
|
+
|
89
88
|
|
90
89
|
|
91
90
|
send_data generate_csv, filename: "export_member.csv", disposition: :attachment, type: "text/csv"
|
@@ -392,7 +392,7 @@ module Alchemy::Custom::Model::Admin::BaseHelper
|
|
392
392
|
|
393
393
|
def order_path(obj = nil, options = {})
|
394
394
|
if obj.nil?
|
395
|
-
new_polymorphic_path([:admin, base_class.to_s.pluralize.underscore, :order])
|
395
|
+
new_polymorphic_path([:admin, base_class.to_s.pluralize.underscore.to_sym, :order])
|
396
396
|
else
|
397
397
|
new_polymorphic_path([:admin, obj, :order])
|
398
398
|
end
|
@@ -437,4 +437,49 @@ module Alchemy::Custom::Model::Admin::BaseHelper
|
|
437
437
|
end
|
438
438
|
|
439
439
|
|
440
|
+
def search_panel(options = {}, &block)
|
441
|
+
submit_button = options.fetch(:enable_submit, true)
|
442
|
+
klass = options.delete(:class) || []
|
443
|
+
|
444
|
+
content_tag(:div, class: "search_panel #{klass.join(" ")}", ** options) do
|
445
|
+
sb = ActiveSupport::SafeBuffer.new
|
446
|
+
|
447
|
+
if @query
|
448
|
+
sb << content_tag(:div, class:"title") do
|
449
|
+
spt = ActiveSupport::SafeBuffer.new
|
450
|
+
spt << content_tag(:span, t("search_panel_title"), class:"title_label")
|
451
|
+
|
452
|
+
#TODO: toggle pannello
|
453
|
+
#spt << content_tag(:span, class:"button_toggle") do
|
454
|
+
# content_tag(:a,class:"icon_button") do
|
455
|
+
# content_tag(:i, nil, class:"icon fa-fw fa-bars fas")
|
456
|
+
# end
|
457
|
+
#end
|
458
|
+
spt
|
459
|
+
end
|
460
|
+
|
461
|
+
sb << simple_form_for(@query, url: polymorphic_path([:admin, @query.klass]), method: :get) do |f|
|
462
|
+
sff = ActiveSupport::SafeBuffer.new
|
463
|
+
|
464
|
+
sff << content_tag(:div, class: "search_fields_group") do
|
465
|
+
search_fields = ActiveSupport::SafeBuffer.new
|
466
|
+
|
467
|
+
search_fields << capture do
|
468
|
+
block.call(f)
|
469
|
+
end
|
470
|
+
|
471
|
+
search_fields
|
472
|
+
end
|
473
|
+
if submit_button
|
474
|
+
sff << content_tag(:div, class: "action_buttons") do
|
475
|
+
f.submit(::I18n.t('alchemy_ajax_form.submit_search'))
|
476
|
+
end
|
477
|
+
end
|
478
|
+
sff
|
479
|
+
end
|
480
|
+
end
|
481
|
+
sb
|
482
|
+
end
|
483
|
+
end
|
484
|
+
|
440
485
|
end
|
@@ -2,37 +2,46 @@ module Alchemy::Custom::Model
|
|
2
2
|
module CustomModelHelper
|
3
3
|
|
4
4
|
def self.included(mod)
|
5
|
-
if ::Rails.application.config.action_controller.include_all_helpers!=false
|
5
|
+
if ::Rails.application.config.action_controller.include_all_helpers != false
|
6
6
|
raise "Devi definire in config/application.rb config.action_controller.include_all_helpers=false
|
7
7
|
in modo da far funzionare correttamente l'override degli helper come per i controller"
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
|
-
def custom_model_page_urlname(obj)
|
12
|
-
|
11
|
+
def custom_model_page_urlname(obj, language: nil)
|
12
|
+
if language.blank?
|
13
|
+
language = Alchemy::Language.current
|
14
|
+
end
|
15
|
+
layout = Alchemy::PageLayout.get_all_by_attributes(custom_model: obj.class.to_s).select { |ly| ly["custom_model_action"] == "show" }.first
|
13
16
|
if not layout.blank?
|
14
|
-
|
17
|
+
language.pages.find_by(page_layout: layout["name"]).try(:parent).try(:urlname)
|
15
18
|
else
|
16
19
|
nil
|
17
20
|
end
|
18
21
|
end
|
19
22
|
|
20
|
-
def custom_model_path(obj)
|
21
|
-
|
22
|
-
|
23
|
+
def custom_model_path(obj, options = {})
|
24
|
+
language = options.delete(:language)
|
25
|
+
custom_model_url_builder(obj, language: language) do |url|
|
26
|
+
alchemy.show_page_path(language || Alchemy::Language.current.code, url, options)
|
23
27
|
end
|
24
28
|
end
|
25
29
|
|
26
|
-
def custom_model_url(obj)
|
27
|
-
|
28
|
-
|
30
|
+
def custom_model_url(obj, options = {})
|
31
|
+
language = options.delete(:language)
|
32
|
+
if language.is_a? String
|
33
|
+
language = Alchemy::Language.find_by_code(language)
|
34
|
+
end
|
35
|
+
custom_model_url_builder(obj, language: language) do |url|
|
36
|
+
alchemy.show_page_url(language.code || Alchemy::Language.current.code, url, options)
|
29
37
|
end
|
30
38
|
end
|
31
39
|
|
40
|
+
|
32
41
|
private
|
33
42
|
|
34
|
-
def custom_model_url_builder(obj)
|
35
|
-
to_url = custom_model_page_urlname obj
|
43
|
+
def custom_model_url_builder(obj, language: nil)
|
44
|
+
to_url = custom_model_page_urlname obj, language: language
|
36
45
|
if not to_url.blank?
|
37
46
|
|
38
47
|
# Url build with alchemy
|
@@ -49,11 +58,15 @@ module Alchemy::Custom::Model
|
|
49
58
|
url += '/'
|
50
59
|
|
51
60
|
if obj.class.respond_to?(:friendly_id_config)
|
52
|
-
|
61
|
+
language = Alchemy::Language.current if language.blank?
|
62
|
+
Globalize.with_locale(language.language_code.to_sym) do
|
63
|
+
url += "#{obj.send(obj.class.friendly_id_config.slug_column)}"
|
64
|
+
end
|
53
65
|
else
|
54
66
|
url += "#{obj.id}"
|
55
67
|
end
|
56
68
|
|
69
|
+
|
57
70
|
if block_given?
|
58
71
|
yield url
|
59
72
|
else
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<%= search_panel do |form| %>
|
2
|
+
|
3
|
+
<span>Ovverride with personalized ransack fields</span>
|
4
|
+
<div class="row">
|
5
|
+
form.input :field1_i_cont <br/>
|
6
|
+
form.input :field2_i_cont <br/>
|
7
|
+
form.input :field3_i_cont <br/>
|
8
|
+
</div>
|
9
|
+
|
10
|
+
<div class="row">
|
11
|
+
form.input :field4_i_cont <br/>
|
12
|
+
form.input :field5_i_cont <br/>
|
13
|
+
form.input :field6_i_cont <br/>
|
14
|
+
</div>
|
15
|
+
|
16
|
+
<% end %>
|
@@ -0,0 +1,30 @@
|
|
1
|
+
<%=toolbar(
|
2
|
+
buttons: [
|
3
|
+
{
|
4
|
+
icon: "angle-double-left ",
|
5
|
+
label: acm_t(:title_action, action: acm_t(:index, scope: :actions), model: base_class.model_name.human),
|
6
|
+
url: polymorphic_path(url_namespace),
|
7
|
+
title: acm_t(:title_action, action: acm_t(:index, scope: :actions), model: base_class.model_name.human),
|
8
|
+
hotkey: 'alt+b',
|
9
|
+
dialog: false,
|
10
|
+
if_permitted_to: [:index, @obj.class]
|
11
|
+
}
|
12
|
+
|
13
|
+
],
|
14
|
+
search: false
|
15
|
+
) %>
|
16
|
+
|
17
|
+
|
18
|
+
<div class="show_page">
|
19
|
+
<% @obj.attributes.each do |attribute| %>
|
20
|
+
<div class="attribute_row">
|
21
|
+
<div class="labelfield">
|
22
|
+
<%= @obj.class.human_attribute_name(attribute.first.to_sym) %>
|
23
|
+
</div>
|
24
|
+
<div class="valuefield">
|
25
|
+
<%= attribute[1] %>
|
26
|
+
</div>
|
27
|
+
</div>
|
28
|
+
<% end %>
|
29
|
+
|
30
|
+
</div>
|
@@ -0,0 +1,48 @@
|
|
1
|
+
<%
|
2
|
+
buttons = []
|
3
|
+
|
4
|
+
buttons << {
|
5
|
+
icon: "angle-double-left ",
|
6
|
+
label: acm_t(:title_action, action: acm_t(:index, scope: :actions), model: base_class.model_name.human),
|
7
|
+
url: polymorphic_path(url_namespace),
|
8
|
+
title: acm_t(:title_action, action: acm_t(:index, scope: :actions), model: base_class.model_name.human),
|
9
|
+
hotkey: 'alt+b',
|
10
|
+
dialog: false,
|
11
|
+
if_permitted_to: [:index, @obj.class]
|
12
|
+
}
|
13
|
+
|
14
|
+
if exist_order_path? @obj
|
15
|
+
buttons << {
|
16
|
+
icon: :random,
|
17
|
+
label: acm_t(:title_action, action: acm_t(:order, scope: :actions), model: base_class.model_name.human),
|
18
|
+
url: order_path(@obj),
|
19
|
+
title: acm_t(:title_action, action: acm_t(:order, scope: :actions), model: base_class.model_name.human),
|
20
|
+
hotkey: 'alt+n',
|
21
|
+
dialog: false,
|
22
|
+
if_permitted_to: [:order, base_class]
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
%>
|
27
|
+
|
28
|
+
|
29
|
+
<% toolbar(
|
30
|
+
buttons: buttons,
|
31
|
+
search: false
|
32
|
+
) %>
|
33
|
+
|
34
|
+
|
35
|
+
<%= base_container do %>
|
36
|
+
|
37
|
+
<div id="archive_all" class="resources-table-wrapper">
|
38
|
+
|
39
|
+
<%= content_tag :h1, "#{@objects.count} #{base_class.model_name.human(count: @objects.count)}", class: 'resources-header' %>
|
40
|
+
|
41
|
+
|
42
|
+
<%= render partial: "table" %>
|
43
|
+
|
44
|
+
<%= paginate @objects, theme: 'alchemy', hide_per_page_select: true %>
|
45
|
+
|
46
|
+
</div>
|
47
|
+
|
48
|
+
<% end %>
|
@@ -31,22 +31,22 @@
|
|
31
31
|
}
|
32
32
|
end
|
33
33
|
|
34
|
-
if can?(:export_csv, base_class) and check_presence_polymorphic_path([:export_csv, :admin,
|
34
|
+
if can?(:export_csv, base_class) and check_presence_polymorphic_path([:export_csv, :admin, base_class.to_s.demodulize.pluralize.underscore.to_sym ], :get, format: :csv)
|
35
35
|
buttons << {
|
36
36
|
icon: "download",
|
37
37
|
label: t(:export_selected_data),
|
38
|
-
url: polymorphic_path([:export_csv, :admin,
|
38
|
+
url: polymorphic_path([:export_csv, :admin, base_class.to_s.demodulize.pluralize.underscore.to_sym], {format: :csv}.merge(request.query_parameters) ),
|
39
39
|
title: t(:export_selected_data),
|
40
40
|
dialog: false,
|
41
41
|
if_permitted_to: [:export_csv, base_class]
|
42
42
|
}
|
43
43
|
end
|
44
44
|
|
45
|
-
if can?(:export_csv_full, base_class) and check_presence_polymorphic_path([:export_csv_full, :admin,
|
45
|
+
if can?(:export_csv_full, base_class) and check_presence_polymorphic_path([:export_csv_full, :admin, base_class.to_s.demodulize.pluralize.underscore.to_sym ], :get, format: :csv)
|
46
46
|
buttons << {
|
47
47
|
icon: "file-archive",
|
48
48
|
label: t(:export_all_data),
|
49
|
-
url: polymorphic_path([:export_csv_full, :admin,
|
49
|
+
url: polymorphic_path([:export_csv_full, :admin, base_class.to_s.demodulize.pluralize.underscore.to_sym],format: :csv),
|
50
50
|
title: t(:export_all_data),
|
51
51
|
dialog: false,
|
52
52
|
if_permitted_to: [:export_csv_full, base_class]
|
@@ -67,6 +67,7 @@
|
|
67
67
|
|
68
68
|
<%= content_tag :h1, "#{@total_objects.count} #{base_class.model_name.human(count: @objects.count)}", class: 'resources-header' %>
|
69
69
|
|
70
|
+
<%= render partial: "search_panel" %>
|
70
71
|
|
71
72
|
<%= render partial: "table" %>
|
72
73
|
|
@@ -1,48 +1,5 @@
|
|
1
|
-
<%
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
label: acm_t(:title_action, action: acm_t(:index, scope: :actions), model: base_class.model_name.human),
|
7
|
-
url: polymorphic_path(url_namespace),
|
8
|
-
title: acm_t(:title_action, action: acm_t(:index, scope: :actions), model: base_class.model_name.human),
|
9
|
-
hotkey: 'alt+b',
|
10
|
-
dialog: false,
|
11
|
-
if_permitted_to: [:index, @obj.class]
|
12
|
-
}
|
13
|
-
|
14
|
-
if exist_order_path? @obj
|
15
|
-
buttons << {
|
16
|
-
icon: :random,
|
17
|
-
label: acm_t(:title_action, action: acm_t(:order, scope: :actions), model: base_class.model_name.human),
|
18
|
-
url: order_path(@obj),
|
19
|
-
title: acm_t(:title_action, action: acm_t(:order, scope: :actions), model: base_class.model_name.human),
|
20
|
-
hotkey: 'alt+n',
|
21
|
-
dialog: false,
|
22
|
-
if_permitted_to: [:order, base_class]
|
23
|
-
}
|
24
|
-
end
|
25
|
-
|
26
|
-
%>
|
27
|
-
|
28
|
-
|
29
|
-
<% toolbar(
|
30
|
-
buttons: buttons,
|
31
|
-
search: false
|
32
|
-
) %>
|
33
|
-
|
34
|
-
|
35
|
-
<%= base_container do %>
|
36
|
-
|
37
|
-
<div id="archive_all" class="resources-table-wrapper">
|
38
|
-
|
39
|
-
<%= content_tag :h1, "#{@objects.count} #{base_class.model_name.human(count: @objects.count)}", class: 'resources-header' %>
|
40
|
-
|
41
|
-
|
42
|
-
<%= render partial: "table" %>
|
43
|
-
|
44
|
-
<%= paginate @objects, theme: 'alchemy', hide_per_page_select: true %>
|
45
|
-
|
46
|
-
</div>
|
47
|
-
|
48
|
-
<% end %>
|
1
|
+
<% if @objects.nil? %>
|
2
|
+
<%= render partial: "show_object" %>
|
3
|
+
<% else %>
|
4
|
+
<%= render partial: "show_objects" %>
|
5
|
+
<% end %>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<%- @pages.each do |page| -%>
|
2
|
+
<url>
|
3
|
+
<loc><%= show_alchemy_page_url(page) %></loc>
|
4
|
+
<lastmod><%= page.updated_at.utc.iso8601 %></lastmod>
|
5
|
+
<changefreq><%= Alchemy::Custom::Model.sitemap_change_freq %></changefreq>
|
6
|
+
</url>
|
7
|
+
<%- end -%>
|
8
|
+
<% Alchemy::Language.published.each do |language| %>
|
9
|
+
<% @custom_elements.each do |ce| %>
|
10
|
+
<url>
|
11
|
+
<loc><%= custom_model_url(ce, language: language) %></loc>
|
12
|
+
<lastmod><%= ce.updated_at.utc.iso8601 %></lastmod>
|
13
|
+
<changefreq><%= Alchemy::Custom::Model.sitemap_change_freq %></changefreq>
|
14
|
+
</url>
|
15
|
+
<% end %>
|
16
|
+
<% end%>
|
data/lib/alchemy/custom/model.rb
CHANGED
@@ -31,9 +31,16 @@ module Alchemy
|
|
31
31
|
autoload :PagesControllerDec
|
32
32
|
autoload :PictureUsedBy
|
33
33
|
autoload :ModelUtilsMethod
|
34
|
+
autoload :SitemapMethods
|
34
35
|
autoload :GlobalizeModelDecoration
|
35
36
|
|
36
37
|
|
38
|
+
mattr_accessor :sitemap_change_freq
|
39
|
+
@@sitemap_change_freq = "weekly"
|
40
|
+
|
41
|
+
mattr_accessor :sitemaps_models
|
42
|
+
@@sitemaps_models = []
|
43
|
+
|
37
44
|
|
38
45
|
mattr_accessor :base_admin_controller_class
|
39
46
|
|
@@ -35,6 +35,15 @@ module Alchemy::Custom::Model::ElFinder
|
|
35
35
|
"#{p.id}#{URI_SPACER}"
|
36
36
|
end
|
37
37
|
|
38
|
+
##
|
39
|
+
# Identifichiamo la data di modifica del file con la data di modifica del record, in questo modo la cache
|
40
|
+
# che viene generata attraverso l'inserimento di un parametro nella query con il valore t=orario non andrà ad essere
|
41
|
+
# aggiornato ad ogni refresh, anche solo a livello di browser
|
42
|
+
# nel caso abbiamo problemi usiamo lo standard
|
43
|
+
def mtime
|
44
|
+
active_record_instance.updated_at rescue super
|
45
|
+
end
|
46
|
+
|
38
47
|
def file
|
39
48
|
active_record_instance.file
|
40
49
|
end
|
@@ -7,12 +7,28 @@ module Alchemy::Custom::Model
|
|
7
7
|
|
8
8
|
skip_before_action :page_not_found!, only: [:index, :show]
|
9
9
|
before_action :load_custom_model_page, only: [:show]
|
10
|
-
before_action :page_not_found_after_custom_model!, if: -> {@page.blank?}, only: [:index, :show]
|
10
|
+
before_action :page_not_found_after_custom_model!, if: -> { @page.blank? }, only: [:index, :show]
|
11
11
|
before_action :perform_search, only: :show
|
12
|
-
after_action :set_404_after
|
12
|
+
after_action :set_404_after, except: :sitemap
|
13
13
|
|
14
14
|
helper CustomModelHelper
|
15
15
|
|
16
|
+
def sitemap
|
17
|
+
@pages = Alchemy::Page.sitemap.reject do |page|
|
18
|
+
page.definition["custom_model_action"].to_s == "show"
|
19
|
+
end
|
20
|
+
@custom_elements = []
|
21
|
+
Alchemy::Custom::Model.sitemaps_models.each do |model|
|
22
|
+
if model.respond_to? :to_sitemap
|
23
|
+
@custom_elements << model.to_sitemap
|
24
|
+
end
|
25
|
+
end
|
26
|
+
@custom_elements = @custom_elements.flatten
|
27
|
+
respond_to do |format|
|
28
|
+
format.xml { render layout: 'alchemy/sitemap' }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
16
32
|
private
|
17
33
|
|
18
34
|
def load_custom_model_page
|
@@ -30,6 +46,8 @@ module Alchemy::Custom::Model
|
|
30
46
|
instance_variable_set("@#{custom_model_string.demodulize.downcase.pluralize}", @custom_elements)
|
31
47
|
end
|
32
48
|
|
49
|
+
elsif action_name == "sitemap"
|
50
|
+
super
|
33
51
|
else
|
34
52
|
|
35
53
|
url = params[:urlname]
|
@@ -38,37 +56,35 @@ module Alchemy::Custom::Model
|
|
38
56
|
|
39
57
|
unless url_params.nil?
|
40
58
|
|
41
|
-
|
42
59
|
parent_page = Alchemy::Language.current.pages.contentpages.find_by(
|
43
60
|
urlname: url_params[:page_name],
|
44
61
|
language_code: params[:locale] || Alchemy::Language.current.code
|
45
62
|
)
|
46
63
|
|
47
64
|
if parent_page.nil?
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
#TODO magari implementare ricerca children in base a una action es. edit new chow ecc
|
52
|
-
|
53
|
-
@page = parent_page.children.first
|
54
|
-
|
55
|
-
if @page.nil?
|
56
|
-
raise ActionController::RoutingError, "You have to define a subpage for custom model"
|
57
|
-
end
|
58
|
-
|
59
|
-
custom_model_string = get_custom_model_string
|
60
|
-
|
61
|
-
if custom_model_string.blank?
|
62
|
-
raise ActionController::RoutingError, "You have to specify custom_model in page_layouts config file"
|
65
|
+
Rails.logger.warn "Parent Page not Found [#{url_params[:page_name]}]"
|
66
|
+
#TODO magari implementare ricerca children in base a una action es. edit new chow ecc
|
63
67
|
else
|
64
|
-
|
65
|
-
@
|
66
|
-
|
68
|
+
@page = parent_page.children.first
|
69
|
+
if @page.nil?
|
70
|
+
Rails.logger.warn "You have to define a subpage for custom model"
|
71
|
+
else
|
72
|
+
custom_model_string = get_custom_model_string
|
73
|
+
|
74
|
+
if custom_model_string.blank?
|
75
|
+
Rails.logger.warn "You have to specify custom_model in page_layouts config file"
|
76
|
+
else
|
77
|
+
custom_model = custom_model_string.classify.constantize
|
78
|
+
@custom_element = custom_model.only_current_language.friendly.find(url_params[:custom_model_id])
|
79
|
+
instance_variable_set("@#{custom_model_string.demodulize.underscore}", @custom_element)
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
|
67
84
|
end
|
68
85
|
|
69
86
|
end
|
70
87
|
|
71
|
-
|
72
88
|
end
|
73
89
|
end
|
74
90
|
|
@@ -95,7 +111,6 @@ module Alchemy::Custom::Model
|
|
95
111
|
end
|
96
112
|
end
|
97
113
|
|
98
|
-
|
99
114
|
def get_custom_model_string
|
100
115
|
|
101
116
|
children_page_layout = Alchemy::PageLayout.get(@page.page_layout)
|
@@ -104,7 +119,6 @@ module Alchemy::Custom::Model
|
|
104
119
|
|
105
120
|
end
|
106
121
|
|
107
|
-
|
108
122
|
def page_not_found_after_custom_model!
|
109
123
|
not_found_error!("Alchemy::Page not found \"#{request.fullpath}\"")
|
110
124
|
end
|
@@ -113,7 +127,6 @@ module Alchemy::Custom::Model
|
|
113
127
|
ArchimediaPgsearch::SEARCH_RESULTS_PAGINATION_NUMBER
|
114
128
|
end
|
115
129
|
|
116
|
-
|
117
130
|
def not_found_error!(msg = "Not found \"#{request.fullpath}\"")
|
118
131
|
not_found_page = Alchemy::Language.current.pages.published.find_by(page_layout: "not_found")
|
119
132
|
if !not_found_page.nil?
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alchemy-custom-model
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alessandro Baccanelli
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2021-07-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: alchemy_cms
|
@@ -17,14 +17,20 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: '
|
20
|
+
version: '5.1'
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 5.1.2
|
21
24
|
type: :runtime
|
22
25
|
prerelease: false
|
23
26
|
version_requirements: !ruby/object:Gem::Requirement
|
24
27
|
requirements:
|
25
28
|
- - "~>"
|
26
29
|
- !ruby/object:Gem::Version
|
27
|
-
version: '
|
30
|
+
version: '5.1'
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 5.1.2
|
28
34
|
- !ruby/object:Gem::Dependency
|
29
35
|
name: jquery-ui-rails
|
30
36
|
requirement: !ruby/object:Gem::Requirement
|
@@ -179,7 +185,10 @@ files:
|
|
179
185
|
- app/views/alchemy/custom/model/admin/base/_gallery_item.html.erb
|
180
186
|
- app/views/alchemy/custom/model/admin/base/_language_tree_select.html.erb
|
181
187
|
- app/views/alchemy/custom/model/admin/base/_search_box.html.erb
|
188
|
+
- app/views/alchemy/custom/model/admin/base/_search_panel.html.erb
|
182
189
|
- app/views/alchemy/custom/model/admin/base/_seo.html.erb
|
190
|
+
- app/views/alchemy/custom/model/admin/base/_show_object.html.erb
|
191
|
+
- app/views/alchemy/custom/model/admin/base/_show_objects.html.erb
|
183
192
|
- app/views/alchemy/custom/model/admin/base/_table.html.erb
|
184
193
|
- app/views/alchemy/custom/model/admin/base/_title.html.erb
|
185
194
|
- app/views/alchemy/custom/model/admin/base/edit.html.erb
|
@@ -190,6 +199,7 @@ files:
|
|
190
199
|
- app/views/alchemy/custom/model/admin/files/error_notice.json.jbuilder
|
191
200
|
- app/views/alchemy/custom/model/admin/files/ui.html.erb
|
192
201
|
- app/views/alchemy/custom/model/admin/orders/new.html.erb
|
202
|
+
- app/views/alchemy/pages/sitemap.xml.erb
|
193
203
|
- config/initializers/elfinder_abilities.rb
|
194
204
|
- config/locales/en.yml
|
195
205
|
- config/locales/it.yml
|
@@ -228,6 +238,7 @@ files:
|
|
228
238
|
- lib/alchemy/custom/model/order.rb
|
229
239
|
- lib/alchemy/custom/model/pages_controller_dec.rb
|
230
240
|
- lib/alchemy/custom/model/picture_used_by.rb
|
241
|
+
- lib/alchemy/custom/model/sitemap_methods.rb
|
231
242
|
- lib/alchemy/custom/model/slug_optimizer.rb
|
232
243
|
- lib/alchemy/custom/model/translation_scope.rb
|
233
244
|
- lib/alchemy/custom/model/version.rb
|
@@ -313,7 +324,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
313
324
|
- !ruby/object:Gem::Version
|
314
325
|
version: '0'
|
315
326
|
requirements: []
|
316
|
-
rubygems_version: 3.0.
|
327
|
+
rubygems_version: 3.0.8
|
317
328
|
signing_key:
|
318
329
|
specification_version: 4
|
319
330
|
summary: A gem for semplify model implementation with Alchemy CMS
|