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,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
|
+
# ActiveSupport::Concern definition for ArPart model.
|
26
|
+
#########################################################################
|
27
|
+
module ArPartConcern
|
28
|
+
extend ActiveSupport::Concern
|
29
|
+
included do
|
30
|
+
|
31
|
+
validates :name, presence: true
|
32
|
+
|
33
|
+
before_save do
|
34
|
+
self.link = name.strip.downcase.gsub(' ', '-') if link.blank?
|
35
|
+
end
|
36
|
+
|
37
|
+
after_save :cache_clear
|
38
|
+
after_destroy :cache_clear
|
39
|
+
|
40
|
+
####################################################################
|
41
|
+
# Clear parent's record from cache if cache is configured
|
42
|
+
####################################################################
|
43
|
+
def cache_clear
|
44
|
+
Agile.cache_clear(self.class.to_s.underscore)
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
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
|
+
# ActiveSupport::Concern definition for ArPart model.
|
26
|
+
#########################################################################
|
27
|
+
module ArPartConcern
|
28
|
+
extend ActiveSupport::Concern
|
29
|
+
included do
|
30
|
+
|
31
|
+
validates :name, presence: true
|
32
|
+
|
33
|
+
before_save do
|
34
|
+
self.link = name.strip.downcase.gsub(' ', '-') if link.blank?
|
35
|
+
end
|
36
|
+
|
37
|
+
after_save :cache_clear
|
38
|
+
after_destroy :cache_clear
|
39
|
+
|
40
|
+
####################################################################
|
41
|
+
# Clear parent's record from cache if cache is configured
|
42
|
+
####################################################################
|
43
|
+
def cache_clear
|
44
|
+
Agile.cache_clear(self.class.to_s.underscore)
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,87 @@
|
|
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
|
+
# ActiveSupport::Concern definition for ArPolicyRule class.
|
26
|
+
#########################################################################
|
27
|
+
module ArPolicyRuleConcern
|
28
|
+
extend ActiveSupport::Concern
|
29
|
+
included do
|
30
|
+
|
31
|
+
belongs_to :ar_policy_role
|
32
|
+
|
33
|
+
field :permission, type: Integer, default: 0
|
34
|
+
|
35
|
+
embedded_in :policy_rules, polymorphic: true
|
36
|
+
|
37
|
+
#after_save :cache_clear
|
38
|
+
#after_destroy :cache_clear
|
39
|
+
|
40
|
+
#########################################################################
|
41
|
+
# Returns values for permissions ready to be used in select field.
|
42
|
+
#
|
43
|
+
# Example (as used in AgileRails form):
|
44
|
+
# 20:
|
45
|
+
# name: permission
|
46
|
+
# type: select
|
47
|
+
# eval: ArPolicyRule.values_for_permissions
|
48
|
+
#########################################################################
|
49
|
+
def self.values_for_permissions
|
50
|
+
key = 'helpers.label.ar_policy_rule.choices_for_permission'
|
51
|
+
c = I18n.t(key)
|
52
|
+
c = I18n.t(key, locale: 'en') if c.class == Hash || c.match(/translation missing/i)
|
53
|
+
c.split(',').map { |e| (ar = e.split(':'); [ar.first, ar.last.to_i]) }
|
54
|
+
end
|
55
|
+
|
56
|
+
#########################################################################
|
57
|
+
# Will return translated permission name for value.
|
58
|
+
#
|
59
|
+
# Parameters:
|
60
|
+
# [value] Integer. Permission value
|
61
|
+
#
|
62
|
+
# Example (as used in AgileRails form):
|
63
|
+
# data_set:
|
64
|
+
# columns:
|
65
|
+
# 2:
|
66
|
+
# name: permission
|
67
|
+
# eval: ArPolicyRule.permission_name_for_value
|
68
|
+
#
|
69
|
+
# Returns:
|
70
|
+
# String. Name (description) for value
|
71
|
+
#########################################################################
|
72
|
+
def self.permission_name_for_value(value)
|
73
|
+
values_for_permissions.reduce('error') { |r, v| break v.first if v.last.to_i == value.to_i }
|
74
|
+
end
|
75
|
+
|
76
|
+
private
|
77
|
+
|
78
|
+
####################################################################
|
79
|
+
# Clear cache if cache is configured
|
80
|
+
####################################################################
|
81
|
+
#def cache_clear
|
82
|
+
# _parent.send(:cache_clear) if _parent.respond_to?(:cache_clear)
|
83
|
+
#end
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
@@ -0,0 +1,66 @@
|
|
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
|
+
# ar_seo_concern, ads SEO optimization fields to any model.
|
26
|
+
#
|
27
|
+
# title String Browser title. Optimization for SEO.
|
28
|
+
# meta_description String SEO optimised page description
|
29
|
+
# meta_additional String Additional meta page data. Enter as meta_name=meta data
|
30
|
+
# ar_json_lds Embedded: ArJsonLd Page structure data
|
31
|
+
#
|
32
|
+
# If you want to add SEO optimization data to your document add:
|
33
|
+
#
|
34
|
+
# "include ArSeoConcern" to your model definition
|
35
|
+
#
|
36
|
+
# and
|
37
|
+
#
|
38
|
+
# "include: ar_seo" option to top of AgileRails edit form for your document.
|
39
|
+
##########################################################################
|
40
|
+
module ArSeoConcern
|
41
|
+
extend ActiveSupport::Concern
|
42
|
+
|
43
|
+
included do
|
44
|
+
field :title, type: String
|
45
|
+
field :meta_description, type: String
|
46
|
+
field :canonical_link, type: String
|
47
|
+
embeds_many :ar_json_lds # JSON-LD structure
|
48
|
+
|
49
|
+
######################################################################
|
50
|
+
# Will return JSON LD data if defined for the page
|
51
|
+
######################################################################
|
52
|
+
def get_json_ld()
|
53
|
+
parent_data = {'datePublished' => self.created_at, 'dateModified' => self.updated_at}
|
54
|
+
data = []
|
55
|
+
if ar_json_lds.size > 0
|
56
|
+
ar_json_lds.where(active: true).each do |element|
|
57
|
+
dta = element.get_json_ld(parent_data)
|
58
|
+
data << dta if dta.size > 0
|
59
|
+
end
|
60
|
+
end
|
61
|
+
data
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
end
|
@@ -0,0 +1,103 @@
|
|
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
|
+
# ActiveSupport::Concern definition for ArSite class.
|
26
|
+
#########################################################################
|
27
|
+
module ArSiteConcern
|
28
|
+
extend ActiveSupport::Concern
|
29
|
+
include ActiveModel::Validations
|
30
|
+
|
31
|
+
included do
|
32
|
+
|
33
|
+
has_many :ar_policies
|
34
|
+
validates :name, presence: true
|
35
|
+
|
36
|
+
after_save :cache_clear
|
37
|
+
after_destroy :cache_clear
|
38
|
+
|
39
|
+
####################################################################
|
40
|
+
# Clear cache if cache is configured
|
41
|
+
####################################################################
|
42
|
+
def cache_clear
|
43
|
+
Agile.cache_clear(:ar_site)
|
44
|
+
end
|
45
|
+
|
46
|
+
########################################################################
|
47
|
+
# Returns value of site setting. If no value is send as parameter it returns
|
48
|
+
# all settings hash object.
|
49
|
+
########################################################################
|
50
|
+
def params(what = nil)
|
51
|
+
@params ||= self.settings.to_s.size > 5 ? YAML.load(self.settings) : {}
|
52
|
+
what.nil? ? @params : @params[what.to_s]
|
53
|
+
end
|
54
|
+
alias :options :params
|
55
|
+
|
56
|
+
########################################################################
|
57
|
+
# Returns class object of page table
|
58
|
+
########################################################################
|
59
|
+
def page_klass
|
60
|
+
page_class.classify.constantize
|
61
|
+
end
|
62
|
+
|
63
|
+
########################################################################
|
64
|
+
# Returns class object of site's menu table name
|
65
|
+
########################################################################
|
66
|
+
def menu_klass
|
67
|
+
(menu_class.blank? ? 'ArMenu' : menu_class).classify.constantize
|
68
|
+
end
|
69
|
+
|
70
|
+
########################################################################
|
71
|
+
# Returns this site policies
|
72
|
+
########################################################################
|
73
|
+
def site_policies
|
74
|
+
ArPolicy.where(ar_site_id: id, active: true).order(name: :asc)
|
75
|
+
end
|
76
|
+
|
77
|
+
########################################################################
|
78
|
+
# Return default site policy rules
|
79
|
+
########################################################################
|
80
|
+
def default_policy
|
81
|
+
ArPolicyRule.where('ar_policy.ar_site_id' => id, 'ar_policy.is_default' => true).joins(:ar_policy)
|
82
|
+
end
|
83
|
+
|
84
|
+
########################################################################
|
85
|
+
# Return choices for select for site_id
|
86
|
+
########################################################################
|
87
|
+
def self.choices_for_sites
|
88
|
+
all.map { |site| [(site.active ? '' : I18n.t('agile.disabled') ) + site.name, site.id] }
|
89
|
+
.sort { |a, b| a[0] <=> b[0] }
|
90
|
+
end
|
91
|
+
|
92
|
+
########################################################################
|
93
|
+
# Return choices for selecting policies for the site
|
94
|
+
########################################################################
|
95
|
+
def self.choices_for_menu(menu_class)
|
96
|
+
return [] if menu_class.blank?
|
97
|
+
|
98
|
+
menu = menu_class.classify.constantize
|
99
|
+
menu.where(active: true).map { [_1.description, _1.id] }
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
103
|
+
end
|
@@ -0,0 +1,195 @@
|
|
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
|
+
# ActiveSupport::Concern definition for ArUser class.
|
26
|
+
#########################################################################
|
27
|
+
module ArUserConcern
|
28
|
+
extend ActiveSupport::Concern
|
29
|
+
#include ActiveModel::Validations
|
30
|
+
included do
|
31
|
+
@@countries = nil
|
32
|
+
|
33
|
+
include ActiveModel::SecurePassword
|
34
|
+
|
35
|
+
has_many :ar_user_roles
|
36
|
+
has_many :ar_roles, through: :ar_user_roles
|
37
|
+
|
38
|
+
has_secure_password
|
39
|
+
|
40
|
+
validates_length_of :username, minimum: 4
|
41
|
+
validates :username, uniqueness: true
|
42
|
+
validates :email, uniqueness: true
|
43
|
+
validate :do_validate
|
44
|
+
|
45
|
+
before_save :do_before_save
|
46
|
+
before_validation :do_before_validation
|
47
|
+
|
48
|
+
attr_reader :cached_roles
|
49
|
+
|
50
|
+
##########################################################################
|
51
|
+
# Checks if user has role 'role_id' defined in his roles.
|
52
|
+
#
|
53
|
+
# Role may be passed as id or as String like role name.
|
54
|
+
##########################################################################
|
55
|
+
def has_role?(role_id)
|
56
|
+
return false if role_id.nil?
|
57
|
+
|
58
|
+
if role_id.class == String
|
59
|
+
role = ArRole.get_role(role_id)
|
60
|
+
role_id = role.id if role
|
61
|
+
end
|
62
|
+
roles().include?(role_id)
|
63
|
+
end
|
64
|
+
|
65
|
+
##########################################################################
|
66
|
+
# Returns all active roles for user
|
67
|
+
#
|
68
|
+
# @return [Array] : Array of user roles ids
|
69
|
+
##########################################################################
|
70
|
+
def roles
|
71
|
+
return @cached_roles if @cached_roles
|
72
|
+
|
73
|
+
user_and_groups = [id] + ArUserGroup.where(ar_user_id: id).map(&:group_id)
|
74
|
+
@cached_roles = ArUserRole.where(ar_user_id: user_and_groups, active: true).select(&:active?).map(&:ar_role_id).uniq
|
75
|
+
end
|
76
|
+
|
77
|
+
##########################################################################
|
78
|
+
# Helper for updating group membership
|
79
|
+
##########################################################################
|
80
|
+
def member_a=(value)
|
81
|
+
return if id.nil?
|
82
|
+
|
83
|
+
old = member_a
|
84
|
+
new = (value.is_a?(String) ? [value] : value).map(&:to_i)
|
85
|
+
remove = old - new
|
86
|
+
create = new - old
|
87
|
+
ArUserGroup.where(ar_user_id: id, :group_id => remove).delete_all if remove.present?
|
88
|
+
create.each { |e| ArUserGroup.create(ar_user_id: id, group_id: e) }
|
89
|
+
end
|
90
|
+
|
91
|
+
##########################################################################
|
92
|
+
# Helper for updating group membership
|
93
|
+
##########################################################################
|
94
|
+
def member_a
|
95
|
+
ArUserGroup.where(ar_user_id: id).map(&:group_id)
|
96
|
+
end
|
97
|
+
|
98
|
+
##########################################################################
|
99
|
+
# Will return all possible values for country field ready for input in select field.
|
100
|
+
# Values are loaded from github when method is first called.
|
101
|
+
##########################################################################
|
102
|
+
def self.choices_for_country
|
103
|
+
countries.map(&:reverse)
|
104
|
+
end
|
105
|
+
|
106
|
+
##########################################################################
|
107
|
+
# Will return @@countries class variable
|
108
|
+
##########################################################################
|
109
|
+
def self.countries
|
110
|
+
return @@countries if @@countries
|
111
|
+
|
112
|
+
uri = URI.parse("https://raw.githubusercontent.com/umpirsky/country-list/master/data/en/country.json")
|
113
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
114
|
+
http.use_ssl = true
|
115
|
+
|
116
|
+
request = Net::HTTP::Get.new(uri.request_uri)
|
117
|
+
response = http.request(request)
|
118
|
+
@@countries = JSON.parse(response.body)
|
119
|
+
end
|
120
|
+
|
121
|
+
##########################################################################
|
122
|
+
# Performs logically test on passed email parameter.
|
123
|
+
#
|
124
|
+
# Parameters:
|
125
|
+
# [email] String: e-mail address
|
126
|
+
#
|
127
|
+
# Returns:
|
128
|
+
# Boolean: True if parameter is logically valid email address.
|
129
|
+
#
|
130
|
+
# Example:
|
131
|
+
# if ! ArUser.is_email?(params[:email])
|
132
|
+
# flash[:error] = 'e-Mail address is not valid!'
|
133
|
+
# end
|
134
|
+
#
|
135
|
+
##########################################################################
|
136
|
+
def self.is_email?(email)
|
137
|
+
email.to_s =~ /^[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/
|
138
|
+
end
|
139
|
+
|
140
|
+
##########################################################################
|
141
|
+
# Will return list of available groups
|
142
|
+
##########################################################################
|
143
|
+
def self.groups_for_select
|
144
|
+
where(group: true, active: true).order(name: :asc).map { [_1.name, _1.id] }
|
145
|
+
end
|
146
|
+
|
147
|
+
##########################################################################
|
148
|
+
# Will return list of available users without groups
|
149
|
+
##########################################################################
|
150
|
+
def self.users_for_select
|
151
|
+
where(group: false, active: true).order(name: :asc).map { [_1.name, _1.id] }
|
152
|
+
end
|
153
|
+
|
154
|
+
private
|
155
|
+
|
156
|
+
##########################################################################
|
157
|
+
# before_save callback takes care of name field and ensures that e-mail is unique
|
158
|
+
# when entry is left empty.
|
159
|
+
##########################################################################
|
160
|
+
def do_before_save
|
161
|
+
self.name = "#{title} #{first_name} #{middle_name if middle_name.present?} #{last_name}".squish
|
162
|
+
# to ensure unique e-mail
|
163
|
+
self.email = "unknown@#{id}" if email.blank?
|
164
|
+
end
|
165
|
+
|
166
|
+
##########################################################################
|
167
|
+
# Create random password for groups. Must be done before validation
|
168
|
+
##########################################################################
|
169
|
+
def do_before_validation
|
170
|
+
if new_record? && group
|
171
|
+
self.password = ArUser.random_password(30)
|
172
|
+
self.password_confirmation = password
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
##########################################################################
|
177
|
+
# Perform some additional validations
|
178
|
+
##########################################################################
|
179
|
+
def do_validate
|
180
|
+
if group && ArUserGroup.where(ar_user_id: id).present?
|
181
|
+
errors.add('member', I18n.t('errors.messages.present'))
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
##########################################################################
|
186
|
+
# Will create random password
|
187
|
+
##########################################################################
|
188
|
+
def self.random_password(number)
|
189
|
+
charset = Array('A'..'Z') + Array('0'..'9') + Array('a'..'z')
|
190
|
+
Array.new(number) { charset.sample }.join
|
191
|
+
end
|
192
|
+
|
193
|
+
end
|
194
|
+
|
195
|
+
end
|
@@ -0,0 +1,93 @@
|
|
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
|
+
# Renderer methods which may be useful on any site.
|
26
|
+
########################################################################
|
27
|
+
class AgileCommonRenderer < AgileRenderer
|
28
|
+
|
29
|
+
include AgileApplicationHelper
|
30
|
+
|
31
|
+
########################################################################
|
32
|
+
# Renderer for printer friendly layout. Will call another renderer which
|
33
|
+
# should provide html code for printer friendly output.
|
34
|
+
#
|
35
|
+
# Parameters are passed through link. There are currently two parameters,
|
36
|
+
# which define renderer and method to be used for creating output.
|
37
|
+
#
|
38
|
+
# renderer::
|
39
|
+
# Defines renderer's class
|
40
|
+
# method::
|
41
|
+
# Defines renderer's class method
|
42
|
+
########################################################################
|
43
|
+
def layout_4print
|
44
|
+
return '' if @env.params[:renderer].blank?
|
45
|
+
|
46
|
+
opts = @opts.dup
|
47
|
+
opts[:method] = @env.params[:method]
|
48
|
+
klass = (@env.params[:renderer] + '_renderer').classify
|
49
|
+
obj = Kernel.const_get(klass, Class.new).new(@env, opts)
|
50
|
+
|
51
|
+
html = obj.render_html
|
52
|
+
@css += obj.render_css.to_s
|
53
|
+
html
|
54
|
+
end
|
55
|
+
|
56
|
+
########################################################################
|
57
|
+
# Renderer for Google analytics code.
|
58
|
+
#
|
59
|
+
# Parameters:
|
60
|
+
# Are passed through @opts hash and can therefore be set on site
|
61
|
+
# or page document parameters field as ga_acc key.
|
62
|
+
#
|
63
|
+
# Example:
|
64
|
+
# agile_render(:agile_common, method: 'google_analytics', code4: 'UA-12345678-9')
|
65
|
+
########################################################################
|
66
|
+
def google_analytics
|
67
|
+
html = ''
|
68
|
+
ga4_acc = @opts[:code4] || @opts[:ga4_acc]
|
69
|
+
if ga4_acc && ga4_acc != '/'
|
70
|
+
html << %(
|
71
|
+
<!-- Global site tag (gtag.js) - Google Analytics -->
|
72
|
+
<script async src="https://www.googletagmanager.com/gtag/js?id=#{ga4_acc}"></script>
|
73
|
+
<script>
|
74
|
+
window.dataLayer = window.dataLayer || [];
|
75
|
+
function gtag(){dataLayer.push(arguments);}
|
76
|
+
gtag('js', new Date());
|
77
|
+
|
78
|
+
gtag('config', '#{ga4_acc}');
|
79
|
+
</script>)
|
80
|
+
end
|
81
|
+
|
82
|
+
html.html_safe
|
83
|
+
end
|
84
|
+
|
85
|
+
########################################################################
|
86
|
+
# Return HTML part of code.
|
87
|
+
########################################################################
|
88
|
+
def render_html
|
89
|
+
method = @opts[:method] || 'default'
|
90
|
+
respond_to?(method) ? send(method) : "Error ArCommonRenderer: Method #{method} doesn't exist!"
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|