agile_rails 0.0.0.1
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 +7 -0
- data/CHANGELOG.md +5 -0
- data/MIT-LICENSE +20 -0
- data/README.md +285 -0
- data/Rakefile +39 -0
- data/agile_rails.gemspec +36 -0
- data/app/assets/fonts/ibm-plex-sans-300.woff2 +0 -0
- data/app/assets/fonts/ibm-plex-sans-400.woff2 +0 -0
- data/app/assets/fonts/ibm-plex-sans-500.woff2 +0 -0
- data/app/assets/fonts/ibm-plex-sans-600.woff2 +0 -0
- data/app/assets/fonts/ibm-plex-sans-700.woff2 +0 -0
- data/app/assets/fonts/ibm-plex-sans-italic.woff2 +0 -0
- data/app/assets/images/32px.png +0 -0
- data/app/assets/images/throbber.gif +0 -0
- data/app/assets/javascripts/agile/agile.js +1489 -0
- data/app/assets/javascripts/agile/jquery-migrate.js +702 -0
- data/app/assets/javascripts/agile/jquery.bpopup.js +372 -0
- data/app/assets/javascripts/agile/jquery.datetimepicker.js +1353 -0
- data/app/assets/javascripts/agile/jstree.min.js +6 -0
- data/app/assets/javascripts/agile/select-multiple.js +459 -0
- data/app/assets/javascripts/agile/some_scripts.js +33 -0
- data/app/assets/javascripts/agile.js +22 -0
- data/app/assets/javascripts/agile_application.js +22 -0
- data/app/assets/javascripts/agile_editor.js +22 -0
- data/app/assets/stylesheets/agile/agile.css +1882 -0
- data/app/assets/stylesheets/agile/agile_apps.css +149 -0
- data/app/assets/stylesheets/agile/jquery.datetimepicker.css +304 -0
- data/app/assets/stylesheets/agile/jstree.css +1107 -0
- data/app/assets/stylesheets/agile/select-multiple.css +110 -0
- data/app/assets/stylesheets/agile/th-bg.png +0 -0
- data/app/assets/stylesheets/agile/theme.css +49 -0
- data/app/assets/stylesheets/agile.css +21 -0
- data/app/assets/stylesheets/agile_application.css +20 -0
- data/app/assets/stylesheets/agile_editor.css +19 -0
- data/app/controllers/agile_application_controller.rb +735 -0
- data/app/controllers/agile_common_controller.rb +345 -0
- data/app/controllers/agile_controller.rb +977 -0
- data/app/controllers/agile_main_controller.rb +36 -0
- data/app/controls/agile_control.rb +120 -0
- data/app/controls/agile_report.rb +364 -0
- data/app/controls/ar_category_control.rb +39 -0
- data/app/controls/ar_help_control.rb +139 -0
- data/app/controls/ar_image_control.rb +180 -0
- data/app/controls/ar_journal_control.rb +47 -0
- data/app/controls/ar_menu_item_control.rb +55 -0
- data/app/controls/ar_page_control.rb +64 -0
- data/app/controls/ar_poll_result_control.rb +84 -0
- data/app/controls/ar_setup_control.rb +62 -0
- data/app/controls/belongs_to_control.rb +61 -0
- data/app/controls/browse_models_control.rb +98 -0
- data/app/controls/settings_form_control.rb +137 -0
- data/app/forms/agile_help.yml +112 -0
- data/app/forms/agile_menu.yml +140 -0
- data/app/forms/agile_report_defaults.yml +39 -0
- data/app/forms/all_options.yml +810 -0
- data/app/forms/ar_ad.yml +121 -0
- data/app/forms/ar_big_table.yml +60 -0
- data/app/forms/ar_big_table_value.yml +52 -0
- data/app/forms/ar_browse_fields.yml +35 -0
- data/app/forms/ar_browse_models.yml +48 -0
- data/app/forms/ar_category.yml +73 -0
- data/app/forms/ar_category_as_tree.yml +31 -0
- data/app/forms/ar_design.yml +75 -0
- data/app/forms/ar_filter.yml +52 -0
- data/app/forms/ar_folder_permission.yml +56 -0
- data/app/forms/ar_folder_rule.yml +48 -0
- data/app/forms/ar_gallery.yml +55 -0
- data/app/forms/ar_image.yml +126 -0
- data/app/forms/ar_image_search.yml +83 -0
- data/app/forms/ar_journal.yml +76 -0
- data/app/forms/ar_json_ld.yml +56 -0
- data/app/forms/ar_key_value.yml +33 -0
- data/app/forms/ar_key_value_store.yml +33 -0
- data/app/forms/ar_link.yml +60 -0
- data/app/forms/ar_menu.yml +67 -0
- data/app/forms/ar_menu_item.yml +141 -0
- data/app/forms/ar_page.yml +187 -0
- data/app/forms/ar_part.yml +91 -0
- data/app/forms/ar_permission.yml +52 -0
- data/app/forms/ar_permission_rule.yml +40 -0
- data/app/forms/ar_piece.yml +106 -0
- data/app/forms/ar_policy.yml +64 -0
- data/app/forms/ar_policy_rule.yml +42 -0
- data/app/forms/ar_policy_rule_nocms.yml +40 -0
- data/app/forms/ar_poll.yml +118 -0
- data/app/forms/ar_poll_item.yml +78 -0
- data/app/forms/ar_poll_result.yml +88 -0
- data/app/forms/ar_poll_result_export.yml +35 -0
- data/app/forms/ar_removed_url.yml +41 -0
- data/app/forms/ar_role.yml +43 -0
- data/app/forms/ar_seo.yml +32 -0
- data/app/forms/ar_setup.yml +45 -0
- data/app/forms/ar_site.yml +149 -0
- data/app/forms/ar_steps_template.yml +51 -0
- data/app/forms/ar_user.yml +140 -0
- data/app/forms/ar_user_role.yml +57 -0
- data/app/forms/help/dc_category_as_tree.en +4 -0
- data/app/forms/help/dc_category_as_tree.sl +5 -0
- data/app/forms/json_ld_schema.yml +168 -0
- data/app/helpers/agile_application_helper.rb +1162 -0
- data/app/helpers/agile_category_helper.rb +128 -0
- data/app/helpers/agile_common_helper.rb +308 -0
- data/app/helpers/agile_edit_helper.rb +645 -0
- data/app/helpers/agile_helper.rb +509 -0
- data/app/helpers/agile_index_helper.rb +677 -0
- data/app/helpers/ar_image_helper.rb +128 -0
- data/app/models/agile_form_fields/action.rb +61 -0
- data/app/models/agile_form_fields/agile_form_field.rb +322 -0
- data/app/models/agile_form_fields/belongs_to.rb +112 -0
- data/app/models/agile_form_fields/check_box.rb +73 -0
- data/app/models/agile_form_fields/comment.rb +62 -0
- data/app/models/agile_form_fields/date_picker.rb +104 -0
- data/app/models/agile_form_fields/date_select.rb +68 -0
- data/app/models/agile_form_fields/datetime_picker.rb +88 -0
- data/app/models/agile_form_fields/datetime_select.rb +73 -0
- data/app/models/agile_form_fields/file_field.rb +52 -0
- data/app/models/agile_form_fields/file_select.rb +69 -0
- data/app/models/agile_form_fields/hidden_field.rb +51 -0
- data/app/models/agile_form_fields/html_field.rb +69 -0
- data/app/models/agile_form_fields/journal_diff.rb +62 -0
- data/app/models/agile_form_fields/link_to.rb +69 -0
- data/app/models/agile_form_fields/method.rb +66 -0
- data/app/models/agile_form_fields/multitext_autocomplete.rb +215 -0
- data/app/models/agile_form_fields/number_field.rb +92 -0
- data/app/models/agile_form_fields/password_field.rb +63 -0
- data/app/models/agile_form_fields/radio_button.rb +95 -0
- data/app/models/agile_form_fields/readonly.rb +77 -0
- data/app/models/agile_form_fields/select.rb +281 -0
- data/app/models/agile_form_fields/submit_tag.rb +58 -0
- data/app/models/agile_form_fields/text_area.rb +61 -0
- data/app/models/agile_form_fields/text_autocomplete.rb +171 -0
- data/app/models/agile_form_fields/text_field.rb +55 -0
- data/app/models/agile_form_fields/text_with_select.rb +94 -0
- data/app/models/agile_form_fields/tree_select.rb +170 -0
- data/app/models/ar_big_table.rb +82 -0
- data/app/models/ar_big_table_value.rb +53 -0
- data/app/models/ar_category.rb +109 -0
- data/app/models/ar_design.rb +116 -0
- data/app/models/ar_filter.rb +200 -0
- data/app/models/ar_folder_permission.rb +50 -0
- data/app/models/ar_folder_rule.rb +47 -0
- data/app/models/ar_gallery.rb +53 -0
- data/app/models/ar_image.rb +198 -0
- data/app/models/ar_internals.rb +60 -0
- data/app/models/ar_journal.rb +46 -0
- data/app/models/ar_json_ld.rb +131 -0
- data/app/models/ar_key_value_store.rb +128 -0
- data/app/models/ar_link.rb +48 -0
- data/app/models/ar_memory.rb +172 -0
- data/app/models/ar_menu.rb +144 -0
- data/app/models/ar_menu_item.rb +106 -0
- data/app/models/ar_page.rb +74 -0
- data/app/models/ar_part.rb +66 -0
- data/app/models/ar_permission.rb +180 -0
- data/app/models/ar_permission_rule.rb +65 -0
- data/app/models/ar_policy.rb +78 -0
- data/app/models/ar_policy_rule.rb +65 -0
- data/app/models/ar_poll.rb +74 -0
- data/app/models/ar_poll_item.rb +47 -0
- data/app/models/ar_poll_result.rb +38 -0
- data/app/models/ar_removed_url.rb +42 -0
- data/app/models/ar_role.rb +84 -0
- data/app/models/ar_setup.rb +115 -0
- data/app/models/ar_site.rb +68 -0
- data/app/models/ar_temp.rb +150 -0
- data/app/models/ar_user.rb +72 -0
- data/app/models/ar_user_group.rb +38 -0
- data/app/models/ar_user_role.rb +54 -0
- data/app/models/ar_visit.rb +41 -0
- data/app/models/concerns/ar_page_concern.rb +128 -0
- data/app/models/concerns/ar_part_concern.rb +48 -0
- data/app/models/concerns/ar_piece_concern.rb +48 -0
- data/app/models/concerns/ar_policy_rule_concern.rb +87 -0
- data/app/models/concerns/ar_seo_concern.rb +66 -0
- data/app/models/concerns/ar_site_concern.rb +103 -0
- data/app/models/concerns/ar_user_concern.rb +195 -0
- data/app/renderers/agile_common_renderer.rb +93 -0
- data/app/renderers/agile_renderer.rb +59 -0
- data/app/renderers/ar_ad_renderer.rb +219 -0
- data/app/renderers/ar_captcha_renderer.rb +113 -0
- data/app/renderers/ar_common_renderer.rb +90 -0
- data/app/renderers/ar_gallery_renderer.rb +107 -0
- data/app/renderers/ar_menu_renderer.rb +195 -0
- data/app/renderers/ar_page_renderer.rb +147 -0
- data/app/renderers/ar_part_renderer.rb +235 -0
- data/app/renderers/ar_piece_renderer.rb +119 -0
- data/app/renderers/ar_poll_renderer.rb +272 -0
- data/app/views/agile/_edit_stuff.html.erb +57 -0
- data/app/views/agile/_form.html.erb +24 -0
- data/app/views/agile/_result.html.erb +28 -0
- data/app/views/agile/edit.html.erb +13 -0
- data/app/views/agile/error.html.erb +2 -0
- data/app/views/agile/index.html.erb +14 -0
- data/app/views/agile/login.html.erb +19 -0
- data/app/views/agile/new.html.erb +12 -0
- data/app/views/agile_common/_help.html.erb +18 -0
- data/app/views/agile_common/_iframe_edit.html.erb +2 -0
- data/app/views/agile_common/paste_clipboard.html.erb +17 -0
- data/app/views/layouts/agile.html.erb +17 -0
- data/app/views/layouts/content.html.erb +20 -0
- data/app/views/models/dump_models.html.erb +47 -0
- data/config/initializers/kaminari_patch.rb +56 -0
- data/config/locales/agile_de.yml +138 -0
- data/config/locales/agile_en.yml +162 -0
- data/config/locales/agile_sl.yml +163 -0
- data/config/locales/datetimepicker.yml +19 -0
- data/config/locales/de.yml +231 -0
- data/config/locales/en.yml +13 -0
- data/config/locales/kaminari.yml +26 -0
- data/config/locales/models_en.yml +1032 -0
- data/config/locales/models_sl.yml +1065 -0
- data/config/locales/sl.yml +211 -0
- data/db/migrate/20240120160001_add_sessions_table.rb +12 -0
- data/db/migrate/20240120160002_ar_big_table.rb +17 -0
- data/db/migrate/20240120160003_ar_big_table_value.rb +18 -0
- data/db/migrate/20240120160004_ar_category.rb +22 -0
- data/db/migrate/20240120160005_ar_design.rb +20 -0
- data/db/migrate/20240120160006_ar_filter.rb +17 -0
- data/db/migrate/20240120160007_ar_gallery.rb +21 -0
- data/db/migrate/20240120160008_ar_journal.rb +19 -0
- data/db/migrate/20240120160009_ar_key_value_store.rb +11 -0
- data/db/migrate/20240120160010_ar_link.rb +19 -0
- data/db/migrate/20240120160011_ar_memory.rb +8 -0
- data/db/migrate/20240120160012_ar_menu.rb +21 -0
- data/db/migrate/20240120160013_ar_menu_item.rb +28 -0
- data/db/migrate/20240120160014_ar_page.rb +50 -0
- data/db/migrate/20240120160015_ar_part.rb +33 -0
- data/db/migrate/20240120160016_ar_permission.rb +16 -0
- data/db/migrate/20240120160017_ar_permission_rule.rb +17 -0
- data/db/migrate/20240120160018_ar_piece.rb +28 -0
- data/db/migrate/20240120160019_ar_policy.rb +21 -0
- data/db/migrate/20240120160020_ar_policy_rule.rb +18 -0
- data/db/migrate/20240120160021_ar_poll.rb +27 -0
- data/db/migrate/20240120160022_ar_poll_item.rb +23 -0
- data/db/migrate/20240120160023_ar_poll_result.rb +14 -0
- data/db/migrate/20240120160024_ar_removed_url.rb +16 -0
- data/db/migrate/20240120160025_ar_role.rb +17 -0
- data/db/migrate/20240120160026_ar_site.rb +37 -0
- data/db/migrate/20240120160027_ar_temp.rb +11 -0
- data/db/migrate/20240120160028_ar_user.rb +42 -0
- data/db/migrate/20240120160029_ar_user_group.rb +12 -0
- data/db/migrate/20240120160030_ar_user_role.rb +18 -0
- data/db/migrate/20240120160031_ar_visit.rb +15 -0
- data/db/migrate/20240703016001_ar_setup.rb +16 -0
- data/db/migrate/20240703016002_ar_folder_permission.rb +15 -0
- data/db/migrate/20240703016003_ar_folder_rule.rb +14 -0
- data/db/migrate/20250115000001_ar_image.rb +25 -0
- data/lib/agile/configuration.rb +43 -0
- data/lib/agile/engine.rb +29 -0
- data/lib/agile/version.rb +27 -0
- data/lib/agile.rb +282 -0
- data/lib/agile_rails.rb +1 -0
- data/lib/generators/agile/USAGE +11 -0
- data/lib/generators/agile/new_form_generator.rb +369 -0
- data/lib/generators/convert_to_ar/convert_to_ar_generator.rb +158 -0
- data/lib/tasks/agile_db_clone.rake +132 -0
- data/lib/tasks/agile_db_export_to_yaml.rake +37 -0
- data/lib/tasks/agile_db_migrate.rake +35 -0
- metadata +414 -0
@@ -0,0 +1,198 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2024+ Damjan Rems
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#++
|
23
|
+
|
24
|
+
##########################################################################
|
25
|
+
# == Schema information
|
26
|
+
#
|
27
|
+
# Collection name: ar_images : Images
|
28
|
+
#
|
29
|
+
# _id BSON::ObjectId _id
|
30
|
+
# created_at Time created_at
|
31
|
+
# updated_at Time updated_at
|
32
|
+
# ar_site_id BSON::ObjectId Site id
|
33
|
+
# ar_user_id BSON::ObjectId User's id
|
34
|
+
# name String ip
|
35
|
+
# short String short name
|
36
|
+
# text String text
|
37
|
+
# size_o String Original image size
|
38
|
+
# size_l String Large image size
|
39
|
+
# size_m String Medium image size
|
40
|
+
# size_s String Small image size
|
41
|
+
#
|
42
|
+
# AgileRails module for saving and manipulating images. Images can be saved to local
|
43
|
+
# directory only. Settings for output images must be set in settings in site record.
|
44
|
+
# Example:
|
45
|
+
# ar_image:
|
46
|
+
# sizes: 900x600,500x400,300x200
|
47
|
+
# location: images
|
48
|
+
# quality: '80'
|
49
|
+
# img_type: webp
|
50
|
+
#
|
51
|
+
# To use this module imagemagick tools and mini_magick ruby gem must be installed.
|
52
|
+
##########################################################################
|
53
|
+
class ArImage < ApplicationRecord
|
54
|
+
|
55
|
+
before_validation :set_original
|
56
|
+
validate :validate_image_values
|
57
|
+
|
58
|
+
#########################################################################
|
59
|
+
# checks that image size values are in correct format. Must be hsize[x]vsize (ex. 300x200)
|
60
|
+
#########################################################################
|
61
|
+
def set_original
|
62
|
+
if keep_original
|
63
|
+
if size_o.blank?
|
64
|
+
image = MiniMagick::Image.open(name)
|
65
|
+
self.size_o = "#{image.width}x#{image.height}"
|
66
|
+
end
|
67
|
+
else
|
68
|
+
self.size_o = ''
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
#########################################################################
|
73
|
+
# checks that image size values are in correct format. Must be hsize[x]vsize (ex. 300x200)
|
74
|
+
#########################################################################
|
75
|
+
def validate_image_values
|
76
|
+
%w[l m s o].each do |size|
|
77
|
+
field = "size_#{size}"
|
78
|
+
value = send(field)
|
79
|
+
next if value.blank?
|
80
|
+
|
81
|
+
a = value.strip.split(/x|\+/)
|
82
|
+
a[0, 2].each { |e| errors.add(field, I18n.t('agile.not_valid')) unless e.to_i > 0 }
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
#########################################################################
|
87
|
+
# Will return first available image starting from small up
|
88
|
+
#########################################################################
|
89
|
+
def first_available_image
|
90
|
+
image = %w[o s m l].each do |size|
|
91
|
+
field = "size_#{size}"
|
92
|
+
value = send(field)
|
93
|
+
return "#{id}-#{size}.#{img_type}" if value.present?
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
#########################################################################
|
98
|
+
# Will return size for large image
|
99
|
+
#########################################################################
|
100
|
+
def size_ls
|
101
|
+
size_l.blank? ? '' : size_l.split(/x|\+/)[0, 2].join('x')
|
102
|
+
end
|
103
|
+
|
104
|
+
#########################################################################
|
105
|
+
# Will set new size for large image
|
106
|
+
#########################################################################
|
107
|
+
def size_ls=(value)
|
108
|
+
self.size_l = value.blank? ? '' : value
|
109
|
+
end
|
110
|
+
|
111
|
+
#########################################################################
|
112
|
+
# Will return x offset for cropping large image
|
113
|
+
#########################################################################
|
114
|
+
def offset_lx
|
115
|
+
size_l.blank? ? '' : size_l.split(/x|\+/)[2].to_i
|
116
|
+
end
|
117
|
+
|
118
|
+
#########################################################################
|
119
|
+
# Will set x offset for cropping large image
|
120
|
+
#########################################################################
|
121
|
+
def offset_lx=(value)
|
122
|
+
self.size_l += (size_l.blank? ? '' : "+#{value}")
|
123
|
+
end
|
124
|
+
|
125
|
+
#########################################################################
|
126
|
+
# Will return y offset for cropping large image
|
127
|
+
#########################################################################
|
128
|
+
def offset_ly
|
129
|
+
size_l.blank? ? '' : size_l.split(/x|\+/)[3].to_i
|
130
|
+
end
|
131
|
+
|
132
|
+
#########################################################################
|
133
|
+
# Will set y offset for cropping large image
|
134
|
+
#########################################################################
|
135
|
+
def offset_ly=(value)
|
136
|
+
self.size_l += (size_l.blank? ? '' : "+#{value}")
|
137
|
+
end
|
138
|
+
|
139
|
+
def size_ms
|
140
|
+
size_m.blank? ? '' : size_m.split(/x|\+/)[0, 2].join('x')
|
141
|
+
end
|
142
|
+
|
143
|
+
def size_ms=(value)
|
144
|
+
self.size_m = value.blank? ? '' : value
|
145
|
+
end
|
146
|
+
|
147
|
+
def offset_mx
|
148
|
+
size_m.blank? ? '' : size_m.split(/x|\+/)[2].to_i
|
149
|
+
end
|
150
|
+
|
151
|
+
def offset_mx=(value)
|
152
|
+
self.size_m += (size_m.blank? ? '' : "+#{value}")
|
153
|
+
end
|
154
|
+
|
155
|
+
def offset_my
|
156
|
+
size_m.blank? ? '' : size_m.split(/x|\+/)[3].to_i
|
157
|
+
end
|
158
|
+
|
159
|
+
def offset_my=(value)
|
160
|
+
self.size_m += (size_m.blank? ? '' : "+#{value}")
|
161
|
+
end
|
162
|
+
|
163
|
+
def size_ss
|
164
|
+
size_s.blank? ? '' : size_s.split(/x|\+/)[0, 2].join('x')
|
165
|
+
end
|
166
|
+
|
167
|
+
def size_ss=(value)
|
168
|
+
self.size_s = value.blank? ? '' : value
|
169
|
+
end
|
170
|
+
|
171
|
+
def offset_sx
|
172
|
+
size_s.blank? ? '' : size_s.split(/x|\+/)[2].to_i
|
173
|
+
end
|
174
|
+
|
175
|
+
def offset_sx=(value)
|
176
|
+
self.size_s += (size_s.blank? ? '' : "+#{value}")
|
177
|
+
end
|
178
|
+
|
179
|
+
def offset_sy
|
180
|
+
size_s.blank? ? '' : size_s.split(/x|\+/)[3].to_i
|
181
|
+
end
|
182
|
+
|
183
|
+
def offset_sy=(value)
|
184
|
+
self.size_s += (size_s.blank? ? '' : "+#{value}")
|
185
|
+
end
|
186
|
+
|
187
|
+
#########################################################################
|
188
|
+
# Return all users that have contributed images
|
189
|
+
#########################################################################
|
190
|
+
def self.all_users
|
191
|
+
ArUser.where(:id.in => distinct(:created_by)).order(name: 'asc').map { [_1.name, _1.id] }
|
192
|
+
end
|
193
|
+
|
194
|
+
def self.html_code
|
195
|
+
'code'
|
196
|
+
end
|
197
|
+
|
198
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2024+ Damjan Rems
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#+
|
23
|
+
|
24
|
+
##########################################################################
|
25
|
+
# Internals model returns some Rails environment variables like session, params, record ...
|
26
|
+
# with more user friendly names. These names can be used for interacting with
|
27
|
+
# users and hide complexity behind the scene.
|
28
|
+
#
|
29
|
+
# eg: ArInternals.get('current_user_name') will return session[:user_name]
|
30
|
+
#
|
31
|
+
# Predefined internal values are:
|
32
|
+
# current_user
|
33
|
+
# current_user_name
|
34
|
+
# current_site
|
35
|
+
##########################################################################
|
36
|
+
module ArInternals
|
37
|
+
INTERNALS = {
|
38
|
+
'current_user' => 'session[:user_id]',
|
39
|
+
'current_user_name' => 'session[:user_name]',
|
40
|
+
'current_site' => 'agile_get_site.id'
|
41
|
+
}
|
42
|
+
@additions = {}
|
43
|
+
|
44
|
+
##########################################################################
|
45
|
+
# Add additional internal. This method allows application specific internals
|
46
|
+
# to be added to structure and be used together with predefined values.
|
47
|
+
##########################################################################
|
48
|
+
def self.add(hash)
|
49
|
+
hash.each { |key, value| @additions[key] = value }
|
50
|
+
end
|
51
|
+
|
52
|
+
##########################################################################
|
53
|
+
#
|
54
|
+
##########################################################################
|
55
|
+
def self.get(key)
|
56
|
+
key.delete_prefix!('@')
|
57
|
+
INTERNALS[key] || @additions[key]
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2024+ Damjan Rems
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#+
|
23
|
+
|
24
|
+
#########################################################################
|
25
|
+
# == Schema information
|
26
|
+
#
|
27
|
+
# Table name: ar_journal : Update journal
|
28
|
+
#
|
29
|
+
# id Integer id
|
30
|
+
# user_id Integer User
|
31
|
+
# site_id Integer Site
|
32
|
+
# doc_id Integer doc_id
|
33
|
+
# operation String Operation
|
34
|
+
# tables String Table name
|
35
|
+
# ids String Parent ids
|
36
|
+
# ip String ip address from where operation was performed
|
37
|
+
# time DateTime Time of operation
|
38
|
+
# diff String Differences
|
39
|
+
#
|
40
|
+
# ar_journals collections saves all data that has been updated through agile controller.
|
41
|
+
# It saves old and new values of changed fields and can be used for
|
42
|
+
# instant restore of single document field or tracking who and when updated
|
43
|
+
# particular document.
|
44
|
+
#########################################################################
|
45
|
+
class ArJournal < ApplicationRecord
|
46
|
+
end
|
@@ -0,0 +1,131 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2024+ Damjan Rems
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#+
|
23
|
+
|
24
|
+
########################################################################
|
25
|
+
# == Schema information
|
26
|
+
#
|
27
|
+
# name: ar_json_ld : JSON_LD data for site optimization
|
28
|
+
#
|
29
|
+
# id Integer id
|
30
|
+
# type String Type of structure
|
31
|
+
# data String Structure data in YAML
|
32
|
+
# ar_json_lds Object Can embed substructure
|
33
|
+
# created_at Time created_at
|
34
|
+
# updated_at Time Last updated at
|
35
|
+
# created_by Integer created_by
|
36
|
+
# updated_by Integer Last updated by
|
37
|
+
#
|
38
|
+
########################################################################
|
39
|
+
|
40
|
+
# Not implemented yet
|
41
|
+
class ArJsonLd
|
42
|
+
|
43
|
+
field :name, type: String
|
44
|
+
field :type, type: String
|
45
|
+
field :data, type: String
|
46
|
+
field :active, type: Boolean, default: true
|
47
|
+
|
48
|
+
embeds_many :ar_json_lds, cyclic: true
|
49
|
+
|
50
|
+
field :created_by, type: Integer
|
51
|
+
field :updated_by, type: Integer
|
52
|
+
|
53
|
+
validates :name, presence: true
|
54
|
+
validates :type, presence: true
|
55
|
+
|
56
|
+
##########################################################################
|
57
|
+
# Returns JSON LD data as YAML
|
58
|
+
##########################################################################
|
59
|
+
def get_json_ld(env_data)
|
60
|
+
yaml = (YAML.load(self.data) rescue nil) || {}
|
61
|
+
yaml['@type'] = self.type if yaml.size > 0
|
62
|
+
if ar_json_lds.size > 0
|
63
|
+
ar_json_lds.where(active: true).each do |element|
|
64
|
+
yml = element.get_json_ld(env_data)
|
65
|
+
if yml.size > 0
|
66
|
+
yaml[element.name] ||= []
|
67
|
+
yaml[element.name] << yml
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
yaml
|
72
|
+
end
|
73
|
+
|
74
|
+
########################################################################
|
75
|
+
# Find document by ids when document are embedded into main d even if embedded
|
76
|
+
#
|
77
|
+
# @param [tables] Tables parameter as send in url. Tables are separated by ;
|
78
|
+
# @param [ids] ids as send in url. ids are separated by ;
|
79
|
+
#
|
80
|
+
# @return [Document]
|
81
|
+
########################################################################
|
82
|
+
def self.find_document_by_ids(tables, ids)
|
83
|
+
collection = tables.split(';').first.classify.constantize
|
84
|
+
ar_ids = ids.split(';')
|
85
|
+
# Find top document
|
86
|
+
document = collection.find(ar_ids.shift)
|
87
|
+
# Search for embedded document
|
88
|
+
ar_ids.each { |id| document = document.ar_json_lds.find(id) }
|
89
|
+
document
|
90
|
+
end
|
91
|
+
|
92
|
+
#########################################################################
|
93
|
+
# Returns possible options for type select field on form.
|
94
|
+
#########################################################################
|
95
|
+
def self.choices_for_type
|
96
|
+
yaml = YAML.load_file(AgileHelper.form_file_find('json_ld_schema'))
|
97
|
+
|
98
|
+
yaml.map(&:first)
|
99
|
+
end
|
100
|
+
|
101
|
+
#########################################################################
|
102
|
+
# Create menu to add schema element. Called from Agile Form action.
|
103
|
+
#########################################################################
|
104
|
+
def self.add_schema_menu(env)
|
105
|
+
yaml = YAML.load_file(AgileHelper.form_file_find('json_ld_schema'))
|
106
|
+
if (level = env.params['ids'].split(';').size) == 1
|
107
|
+
# select only top level elements
|
108
|
+
yaml.delete_if { |schema_name, schema_data| schema_data['level'].nil? }
|
109
|
+
else
|
110
|
+
# select only elemets which are subelements of type
|
111
|
+
env_type = self.find_document_by_ids(env.params['table'],env.params['ids']).type
|
112
|
+
_yaml = []
|
113
|
+
yaml[env_type].each_value do |data|
|
114
|
+
next unless data.class == Hash
|
115
|
+
|
116
|
+
_yaml << [data['type'], yaml[data['type']]] if data['type'] && yaml[data['type']]
|
117
|
+
end
|
118
|
+
yaml = _yaml
|
119
|
+
end
|
120
|
+
# create menu code
|
121
|
+
html = '<ul>'
|
122
|
+
yaml.each do |schema_name, schema_data|
|
123
|
+
next if level == 1 && schema_data['level'].nil?
|
124
|
+
|
125
|
+
url = "/agile_common/add_json_ld_schema?table=#{env.params['table']}&ids=#{env.params['ids']}&schema=#{schema_name}&url=#{env.request.url}"
|
126
|
+
html += %(<li class="ar-link-ajax in-menu" data-url="#{url}">#{schema_name}</li>)
|
127
|
+
end
|
128
|
+
"#{html}</ul>"
|
129
|
+
end
|
130
|
+
|
131
|
+
end
|
@@ -0,0 +1,128 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2024+ Damjan Rems
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#+
|
23
|
+
|
24
|
+
#########################################################################
|
25
|
+
# == Schema information
|
26
|
+
#
|
27
|
+
# Table name: ar_key_value_store : Table used for storing all kind of values
|
28
|
+
#
|
29
|
+
# id Integer id
|
30
|
+
# key String Identification key
|
31
|
+
# value String Stored value
|
32
|
+
#
|
33
|
+
# This model represents key/value store. Typical usage is for saving last
|
34
|
+
# used document number on internal document numbering schema.
|
35
|
+
#
|
36
|
+
# Example:
|
37
|
+
# invoice_number = ArKeyValueStore.get_next_value('invoices', invoice.year)
|
38
|
+
#########################################################################
|
39
|
+
class ArKeyValueStore < ApplicationRecord
|
40
|
+
|
41
|
+
###########################################################################
|
42
|
+
# Will return value incremented by 1 and update document with new value.
|
43
|
+
#
|
44
|
+
# Parameters:
|
45
|
+
# [keys] Array. Any number of parameters from which key will be generated.
|
46
|
+
#
|
47
|
+
# Returns:
|
48
|
+
# String. Last saved value incremented by 1.
|
49
|
+
###########################################################################
|
50
|
+
def self.get_next_value(*keys)
|
51
|
+
doc = find_by(key: keys.join('-'))
|
52
|
+
value = (doc ? doc.value : '0').next
|
53
|
+
if doc
|
54
|
+
doc.value = value
|
55
|
+
doc.save!
|
56
|
+
else
|
57
|
+
create(key: keys.join('-'), value: value)
|
58
|
+
end
|
59
|
+
value
|
60
|
+
end
|
61
|
+
|
62
|
+
###########################################################################
|
63
|
+
# Will try to restore to previous value if value matches current value.
|
64
|
+
#
|
65
|
+
# Parameters:
|
66
|
+
# [value] String. Last value obtained by get_next_value method.
|
67
|
+
# [keys] Array. Any number of parameters from which key will be generated.
|
68
|
+
###########################################################################
|
69
|
+
def self.restore_value(value, *keys)
|
70
|
+
doc = find_by(key: keys.join('-'))
|
71
|
+
if value == doc.value
|
72
|
+
value = value.prev
|
73
|
+
doc.value = value
|
74
|
+
doc.save!
|
75
|
+
return value
|
76
|
+
end
|
77
|
+
nil
|
78
|
+
end
|
79
|
+
|
80
|
+
###########################################################################
|
81
|
+
# Will return value incremented by 1 but will not update document with new value.
|
82
|
+
# Used for presenting user with most possible document number. Real document number must
|
83
|
+
# of course be obtained by get_next_value before document is saved to collection.
|
84
|
+
#
|
85
|
+
# Parameters:
|
86
|
+
# [keys] Array. Any number of parameters from which key will be generated.
|
87
|
+
#
|
88
|
+
# Returns:
|
89
|
+
# String. Last saved value incremented by 1.
|
90
|
+
###########################################################################
|
91
|
+
def self.peep_next_value(*keys)
|
92
|
+
doc = find_by(key: keys.join('-'))
|
93
|
+
(doc ? doc.value : '0').next
|
94
|
+
end
|
95
|
+
|
96
|
+
###########################################################################
|
97
|
+
# Will return current value for the key.
|
98
|
+
#
|
99
|
+
# Parameters:
|
100
|
+
# [keys] Array. Any number of parameters from which key will be generated.
|
101
|
+
#
|
102
|
+
# Returns:
|
103
|
+
# String. Current value for specified key or nil if key is not found.
|
104
|
+
###########################################################################
|
105
|
+
def self.get_value(*keys)
|
106
|
+
doc = find_by(key: keys.join('-'))
|
107
|
+
doc ? doc.value : nil
|
108
|
+
end
|
109
|
+
|
110
|
+
###########################################################################
|
111
|
+
# Will set value for the key. If document is not found new document will be created.
|
112
|
+
#
|
113
|
+
# Parameters:
|
114
|
+
# [value] String. New value to be set.
|
115
|
+
# [keys] Array. Any number of parameters from which key will be generated.
|
116
|
+
###########################################################################
|
117
|
+
def self.set_value(value, *keys)
|
118
|
+
doc = find_by(key: keys.join('-'))
|
119
|
+
if doc
|
120
|
+
doc.value = value
|
121
|
+
doc.save!
|
122
|
+
else
|
123
|
+
create(key: keys.join('-'), value: value.to_s)
|
124
|
+
end
|
125
|
+
value
|
126
|
+
end
|
127
|
+
|
128
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2024+ Damjan Rems
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#+
|
23
|
+
|
24
|
+
#########################################################################
|
25
|
+
# == Schema information
|
26
|
+
#
|
27
|
+
# Table name: ar_link : Alternative links
|
28
|
+
#
|
29
|
+
# id Integer id
|
30
|
+
# created_at Time created_at
|
31
|
+
# updated_at Time updated_at
|
32
|
+
# name String Link name ex. homepage
|
33
|
+
# params String Aditional parameters passed to document renderer
|
34
|
+
# active Boolean Link is active
|
35
|
+
# page_id Integer Page redirected to by this shortcut link
|
36
|
+
# redirect String Link to redirect to
|
37
|
+
# created_by Integer created_by
|
38
|
+
# updated_by Integer updated_by
|
39
|
+
# ar_site_id Object Link is valid for site
|
40
|
+
#
|
41
|
+
# ArLink documents is used for creating alternative url links or redirections. page_id field must
|
42
|
+
# point to valid ArPage document which will be used for further processing.
|
43
|
+
#########################################################################
|
44
|
+
class ArLink < ApplicationRecord
|
45
|
+
belongs_to :ar_site, optional: true
|
46
|
+
|
47
|
+
validates :link, presence: true
|
48
|
+
end
|