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,115 @@
|
|
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
|
+
# ArSetup table is for settings, that are specific to the application,
|
26
|
+
# or part of application (gem). It consists of data definitions and form for editing the data.
|
27
|
+
# Data is saved internally in YAML format.
|
28
|
+
#
|
29
|
+
# When editing, admin can see and edit form definition (adding new fields to application setup), while user
|
30
|
+
# sees only data entry form.
|
31
|
+
#
|
32
|
+
# Usage:
|
33
|
+
# my_app_settings = ArSetup.find_by(name: 'my_app')
|
34
|
+
# my_app_settings = ArSetup.get('my_app')
|
35
|
+
# company = my_app_settings.company_name
|
36
|
+
# company, ceo = my_app_settings[:company_name, 'ceo_name']
|
37
|
+
#
|
38
|
+
##############################################################################
|
39
|
+
class ArSetup < ApplicationRecord
|
40
|
+
|
41
|
+
attr_reader :my_data
|
42
|
+
attr_reader :my_fields
|
43
|
+
|
44
|
+
validates_length_of :name, minimum: 3
|
45
|
+
|
46
|
+
before_save do
|
47
|
+
self.data = my_data.to_yaml
|
48
|
+
end
|
49
|
+
|
50
|
+
##############################################################################
|
51
|
+
# Will return editors var as array to the application. Editors are internaly saved
|
52
|
+
# as string separated by comma.
|
53
|
+
##############################################################################
|
54
|
+
def editors
|
55
|
+
edit_ids.to_s.split(',').map(&:to_i)
|
56
|
+
end
|
57
|
+
|
58
|
+
##############################################################################
|
59
|
+
# Will return editors var as array to the application. Editors are internaly saved
|
60
|
+
# as string separated by comma.
|
61
|
+
##############################################################################
|
62
|
+
def editors=(value)
|
63
|
+
self.edit_ids = value.join(',')
|
64
|
+
end
|
65
|
+
|
66
|
+
##############################################################################
|
67
|
+
# Will return settings record for specified application.
|
68
|
+
#
|
69
|
+
# @param [String] app_name The name of the application
|
70
|
+
# @return [Object, nil] The settings record if found, nil otherwise
|
71
|
+
##############################################################################
|
72
|
+
def self.get(app_name)
|
73
|
+
ArSetup.find_by(name: app_name.to_s)
|
74
|
+
end
|
75
|
+
|
76
|
+
##############################################################################
|
77
|
+
# Will return value for single setting if called as method.
|
78
|
+
##############################################################################
|
79
|
+
def method_missing(m, *args, &block)
|
80
|
+
m = m.to_s
|
81
|
+
if m.match('=')
|
82
|
+
m.chomp!('=')
|
83
|
+
my_data[m] = args.first
|
84
|
+
else
|
85
|
+
my_data[m]
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
##############################################################################
|
90
|
+
# Will return value for single setting. Called as parameter in square brackets.
|
91
|
+
# If more then one parameter is passed it will return them as array.
|
92
|
+
##############################################################################
|
93
|
+
def [](*keys)
|
94
|
+
return my_data[keys.first.to_s] if keys.size == 1
|
95
|
+
|
96
|
+
keys.map { |k| my_data[k.to_s] }
|
97
|
+
end
|
98
|
+
|
99
|
+
##############################################################################
|
100
|
+
# Will return true if setting is defined on the form
|
101
|
+
##############################################################################
|
102
|
+
def respond_to?(field_name)
|
103
|
+
return true #if my_fields[field_name.to_s]
|
104
|
+
|
105
|
+
super.respond_to?(field_name)
|
106
|
+
end
|
107
|
+
|
108
|
+
##############################################################################
|
109
|
+
#
|
110
|
+
##############################################################################
|
111
|
+
def my_data
|
112
|
+
@my_data ||= (YAML.unsafe_load(data)) rescue {}
|
113
|
+
end
|
114
|
+
|
115
|
+
end
|
@@ -0,0 +1,68 @@
|
|
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_site : Sites
|
28
|
+
#
|
29
|
+
# id Integer id
|
30
|
+
# created_at Time created_at
|
31
|
+
# updated_at Time updated_at
|
32
|
+
# name String Name of the site eg. www.mysite.com
|
33
|
+
# description String Short description of site
|
34
|
+
# homepage_link String Shortcut link when just site name is in the url
|
35
|
+
# error_link String Link to error page
|
36
|
+
# header String Additional data used in page html header
|
37
|
+
# css String Site wide CSS
|
38
|
+
# route_name String Default route name for creating page link. ex. page. Leave blank if not used.
|
39
|
+
# page_title String Default page title displayed in browser's top menu when title can not be extracted from document
|
40
|
+
# document_extension String Default document extension eg. html
|
41
|
+
# page_class String Rails model class name which defines table holding pages data usually ArPage
|
42
|
+
# site_layout String Rails layout used to draw response. This is by default content layout.
|
43
|
+
# menu_class String Rails model class name which defines table holding menu data usually ArMenu
|
44
|
+
# files_directory String Directory name where uploaded files are located
|
45
|
+
# logo String Logotype picture for the site
|
46
|
+
# active Boolean Is the site active
|
47
|
+
# created_by Integer created_by
|
48
|
+
# updated_by Integer updated_by
|
49
|
+
# menu_name String Menu name for this site
|
50
|
+
# menu_id Integer Menu id. Menu name will be deprecated.
|
51
|
+
# settings String Various site settings
|
52
|
+
# alias_for String Is alias name for entered site name
|
53
|
+
# rails_view String Rails view filename used as standard design
|
54
|
+
# design String Standard design can also be defined at the site level
|
55
|
+
# inherit_policy Integer Use policy from other site
|
56
|
+
# ar_policies Embedded: ArPolicy Access policies defined for the site
|
57
|
+
# ar_parts Embedded: ArPart Parts contained in site
|
58
|
+
#
|
59
|
+
# ar_Since AgileRails can handle multiple sites on single ROR instance, every document
|
60
|
+
# in ar_sites table defines data which defines a site.
|
61
|
+
#
|
62
|
+
# Sites can be aliased which is very usefull in development and test environment.
|
63
|
+
# If 'site.name' document is not found application will search for 'test' document and
|
64
|
+
# continue searching with value found in alias_for field.
|
65
|
+
######################################################################
|
66
|
+
class ArSite < ApplicationRecord
|
67
|
+
include ArSiteConcern
|
68
|
+
end
|
@@ -0,0 +1,150 @@
|
|
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_temp : Table used for temporary data saving.
|
28
|
+
#
|
29
|
+
# ar_temp table has three important fields:
|
30
|
+
# key: String
|
31
|
+
# data: String containing data set saved as yaml
|
32
|
+
# order: String holding value to be osed for sorting selected refords
|
33
|
+
########################################################################
|
34
|
+
class ArTemp < ApplicationRecord
|
35
|
+
|
36
|
+
after_initialize do |record|
|
37
|
+
@internals = YAML.unsafe_load(record.data.to_s) rescue {}
|
38
|
+
end
|
39
|
+
|
40
|
+
before_save do
|
41
|
+
self.data = @internals.to_yaml
|
42
|
+
end
|
43
|
+
|
44
|
+
########################################################################
|
45
|
+
# Initilize object
|
46
|
+
########################################################################
|
47
|
+
def initialize(attributes = nil)
|
48
|
+
super()
|
49
|
+
@internals = {}
|
50
|
+
attributes = attributes.nil? ? {} : attributes.stringify_keys
|
51
|
+
self.key = attributes.delete('key') if attributes['key']
|
52
|
+
self.active = attributes.delete('active') if attributes['active']
|
53
|
+
self.order = attributes.delete('order') if attributes['order']
|
54
|
+
attributes.each { |k, v| @internals[k.to_s] = v }
|
55
|
+
end
|
56
|
+
|
57
|
+
########################################################################
|
58
|
+
# Respond_to should always return true.
|
59
|
+
########################################################################
|
60
|
+
def respond_to?(a = nil, b = nil)
|
61
|
+
true
|
62
|
+
end
|
63
|
+
|
64
|
+
########################################################################
|
65
|
+
# Redefine send method. Send is used to assign or access value
|
66
|
+
########################################################################
|
67
|
+
def send(field, value = nil)
|
68
|
+
return super(field) if field.is_a? Symbol
|
69
|
+
|
70
|
+
field = field.to_s
|
71
|
+
if field.match('=')
|
72
|
+
field.chomp!('=')
|
73
|
+
@internals[field] = value
|
74
|
+
else
|
75
|
+
@internals[field]
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
########################################################################
|
80
|
+
# Redefine [] method to act similar as send method
|
81
|
+
########################################################################
|
82
|
+
def [](field)
|
83
|
+
@internals[field.to_s]
|
84
|
+
end
|
85
|
+
|
86
|
+
########################################################################
|
87
|
+
# Redefine [] method to act similar as send method
|
88
|
+
########################################################################
|
89
|
+
def []=(field, value)
|
90
|
+
@internals[field.to_s] = value
|
91
|
+
end
|
92
|
+
|
93
|
+
########################################################################
|
94
|
+
# Convert internal data to yaml
|
95
|
+
########################################################################
|
96
|
+
def to_yaml
|
97
|
+
@internals.to_yaml
|
98
|
+
end
|
99
|
+
|
100
|
+
########################################################################
|
101
|
+
# For debugging
|
102
|
+
########################################################################
|
103
|
+
def to_s
|
104
|
+
"ArTemp: @key=#{key} @data=#{data}"
|
105
|
+
end
|
106
|
+
|
107
|
+
########################################################################
|
108
|
+
# Method missing will return value if value defined by m parameter is saved to
|
109
|
+
# @internals array or will save field value to @internals hash if m matches '='.
|
110
|
+
########################################################################
|
111
|
+
def method_missing(m, *args, &block) #:nodoc:
|
112
|
+
m = m.to_s
|
113
|
+
return @internals[m] unless m.match('=')
|
114
|
+
|
115
|
+
m.chomp!('=')
|
116
|
+
@internals[m] = args.first
|
117
|
+
end
|
118
|
+
|
119
|
+
########################################################################
|
120
|
+
# Remove all documents with specified key from ar_temp table
|
121
|
+
########################################################################
|
122
|
+
def self.clear(key)
|
123
|
+
where(key: key).delete_all
|
124
|
+
end
|
125
|
+
|
126
|
+
########################################################################
|
127
|
+
# Prepare ar_temp for data. It first checks if data associated with the key is to
|
128
|
+
# be deleted and then yields block code.
|
129
|
+
#
|
130
|
+
# Returns: Query for the data associated with the key
|
131
|
+
########################################################################
|
132
|
+
def self.prepare(key:, clear: nil)
|
133
|
+
unless %w(no false 0).include?(clear.to_s.strip.downcase)
|
134
|
+
clear(key)
|
135
|
+
yield
|
136
|
+
end
|
137
|
+
where(key: key)
|
138
|
+
end
|
139
|
+
|
140
|
+
########################################################################
|
141
|
+
# Order data by new key. Will update order field with values from new field
|
142
|
+
########################################################################
|
143
|
+
def self.reorder_by(key, *new_order)
|
144
|
+
where(key: key).each do |record|
|
145
|
+
record.order = new_order.map(&:to_s).join('')
|
146
|
+
record.save
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
end
|
@@ -0,0 +1,72 @@
|
|
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_user : Users
|
28
|
+
#
|
29
|
+
# id Integer id
|
30
|
+
# created_at Time created_at
|
31
|
+
# updated_at Time updated_at
|
32
|
+
# username String Username
|
33
|
+
# title String Title (dr, mag)
|
34
|
+
# first_name String Users first name
|
35
|
+
# middle_name String Middle name
|
36
|
+
# last_name String Users last name
|
37
|
+
# name String Name colected from firstname, title and lastname
|
38
|
+
# company String company
|
39
|
+
# address String Home address
|
40
|
+
# post String Post and post city
|
41
|
+
# country String Country
|
42
|
+
# phone String Phone number
|
43
|
+
# email String e-Mail address
|
44
|
+
# www String www
|
45
|
+
# picture String Picture file name
|
46
|
+
# birthdate Date Date of birth
|
47
|
+
# about String Short description of user
|
48
|
+
# last_visit Time Users last visit
|
49
|
+
# active Boolean Account is active
|
50
|
+
# valid_from Date Account is valid from
|
51
|
+
# valid_to Date Account is valid until
|
52
|
+
# created_by Integer created_by
|
53
|
+
# updated_by Integer Account last updated by
|
54
|
+
# type Integer Type of user account
|
55
|
+
# signature String signature
|
56
|
+
# interests String interests
|
57
|
+
# job_occup String job_occup
|
58
|
+
# description String description
|
59
|
+
# reg_date Date reg_date
|
60
|
+
# password_digest String password_digest
|
61
|
+
# ar_user_roles Embedded: ArUserRole Roles for this user
|
62
|
+
#
|
63
|
+
# ar_users table holds data about regitered users. Passwords are encrypted
|
64
|
+
# with bcrypt gem.
|
65
|
+
#
|
66
|
+
# This model defines basic fields required for evidence of
|
67
|
+
# registerred users. Since it is implemented as ActiveSupport::Concern you are
|
68
|
+
# encouraged to further expand model with your own data structures.
|
69
|
+
########################################################################
|
70
|
+
class ArUser < ApplicationRecord
|
71
|
+
include ArUserConcern
|
72
|
+
end
|
@@ -0,0 +1,38 @@
|
|
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_user_group: When user is a member of group of users
|
28
|
+
#
|
29
|
+
# id Integer id
|
30
|
+
# ar_user_id Integer User id
|
31
|
+
# group_id Integer Group id
|
32
|
+
#
|
33
|
+
# ArUserGroup record holds relation of which group specific user is a member.
|
34
|
+
# Groups are like users defined in ArUser table and have group flag set to true.
|
35
|
+
########################################################################
|
36
|
+
class ArUserGroup < ApplicationRecord
|
37
|
+
belongs_to :ar_user
|
38
|
+
end
|
@@ -0,0 +1,54 @@
|
|
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_user_role : User roles
|
28
|
+
#
|
29
|
+
# id Integer id
|
30
|
+
# created_at Time created_at
|
31
|
+
# updated_at Time updated_at
|
32
|
+
# ar_role_id Object User role
|
33
|
+
# valid_from Date Role is valid from
|
34
|
+
# valid_to Date Role is valid to
|
35
|
+
# active Boolean Role is active
|
36
|
+
# created_by Integer created_by
|
37
|
+
# updated_by Integer Role last updated
|
38
|
+
#
|
39
|
+
# ArUserRole documents are embedded in ArUser model and define user roles which
|
40
|
+
# belong to user.
|
41
|
+
########################################################################
|
42
|
+
class ArUserRole < ApplicationRecord
|
43
|
+
belongs_to :ar_user
|
44
|
+
belongs_to :ar_role
|
45
|
+
|
46
|
+
###############################################################################
|
47
|
+
# Determine of role is still active
|
48
|
+
###############################################################################
|
49
|
+
def active?
|
50
|
+
now = Time.current
|
51
|
+
active && (valid_from.nil? || now > valid_from) && (valid_to.nil? || now < valid_to)
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
@@ -0,0 +1,41 @@
|
|
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_visit : Visits
|
28
|
+
#
|
29
|
+
# id Integer id
|
30
|
+
# page_id Integer page_id
|
31
|
+
# user_id Integer user_id
|
32
|
+
# site_id Integer site_id
|
33
|
+
# session_id String session_id
|
34
|
+
# ip String ip
|
35
|
+
# time DateTime time
|
36
|
+
#
|
37
|
+
# ArVisit documents are used to record visits to web site.
|
38
|
+
######################################################################
|
39
|
+
class ArVisit < ApplicationRecord
|
40
|
+
|
41
|
+
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
|
+
# ActiveSupport::Concern definition for ArPage class.
|
26
|
+
#########################################################################
|
27
|
+
module ArPageConcern
|
28
|
+
extend ActiveSupport::Concern
|
29
|
+
included do
|
30
|
+
|
31
|
+
# SEO
|
32
|
+
#include ArSeoConcern
|
33
|
+
|
34
|
+
belongs_to :ar_site, optional: true
|
35
|
+
belongs_to :ar_design, optional: true
|
36
|
+
|
37
|
+
before_save :do_before_save
|
38
|
+
|
39
|
+
validates :publish_date, presence: true
|
40
|
+
validate :validate_images_alt_present
|
41
|
+
|
42
|
+
after_save :cache_clear
|
43
|
+
after_destroy :cache_clear
|
44
|
+
|
45
|
+
scope :ar_parts, -> { ArParts.where("parent_type = 'ArPage'") }
|
46
|
+
|
47
|
+
####################################################################
|
48
|
+
# Clear cache if cache is configured
|
49
|
+
####################################################################
|
50
|
+
def cache_clear
|
51
|
+
Agile.cache_clear(:ar_page)
|
52
|
+
end
|
53
|
+
|
54
|
+
######################################################################
|
55
|
+
# Will return validation error if all images in body field do not have
|
56
|
+
# alt attribute present.
|
57
|
+
######################################################################
|
58
|
+
def validate_images_alt_present
|
59
|
+
errors.add('body', I18n.t('agile.img_alt_not_present')) unless ArPage.images_alt_present?(body)
|
60
|
+
end
|
61
|
+
|
62
|
+
protected
|
63
|
+
|
64
|
+
######################################################################
|
65
|
+
# Implementation of before_save callback.
|
66
|
+
######################################################################
|
67
|
+
def do_before_save
|
68
|
+
self.link = ArPage.clear_link(subject.downcase.strip) if link.blank?
|
69
|
+
# menu_id is returned as string Array class if entered on form as tree_select object.
|
70
|
+
self.menu_id = menu_id.scan(/"([^"]*)"/)[0][0] if menu_id.to_s.match('"')
|
71
|
+
end
|
72
|
+
|
73
|
+
######################################################################
|
74
|
+
# Clears subject link of chars that shouldn't be there and also takes care
|
75
|
+
# than link size is not larger than 100 chars.
|
76
|
+
######################################################################
|
77
|
+
def self.clear_link(link)
|
78
|
+
link.gsub!(/\.|\?|\!\&|\||»|«|\,|\"|\'|\:/, '')
|
79
|
+
link.gsub!('<br>','')
|
80
|
+
link.gsub!('–','-')
|
81
|
+
link.gsub!(' ','-')
|
82
|
+
link.gsub!('---', '-')
|
83
|
+
link.gsub!('--', '-')
|
84
|
+
# it shall not be greater than 100 chars. Don't break in the middle of words
|
85
|
+
if link.size > 100
|
86
|
+
link = link[0, 100]
|
87
|
+
link.chop! until link[-1, 1] == '-' || link.size < 10 # delete until -
|
88
|
+
end
|
89
|
+
link.chop! if link[-1, 1] == '-' # remove - at the end
|
90
|
+
link
|
91
|
+
end
|
92
|
+
|
93
|
+
######################################################################
|
94
|
+
# Return all pages belonging to site ready for select input field. Used
|
95
|
+
# by ar_menu* forms, for selecting page which will be linked by menu option.
|
96
|
+
#
|
97
|
+
# Parameters:
|
98
|
+
# [site] Site document.
|
99
|
+
######################################################################
|
100
|
+
def self.all_pages_for_site(site)
|
101
|
+
only(:subject, :link).where(ar_site_id: site.id, active: true).order(subject: 1)
|
102
|
+
.map { [ _1.subject, _1.link] }
|
103
|
+
end
|
104
|
+
|
105
|
+
########################################################################
|
106
|
+
# Return filter options
|
107
|
+
########################################################################
|
108
|
+
def self.agile_filters
|
109
|
+
{ title: I18n.t('agile.filters.this_site_only'), operation: 'eq', field: 'ar_site_id', value: '@current_site' }
|
110
|
+
end
|
111
|
+
|
112
|
+
######################################################################
|
113
|
+
# Clears subject link of chars that shouldn't be there and also takes care
|
114
|
+
# than link size is not larger than 100 chars.
|
115
|
+
######################################################################
|
116
|
+
def self.images_alt_present?(text)
|
117
|
+
return true if text.blank?
|
118
|
+
|
119
|
+
document = Nokogiri::HTML.parse(text)
|
120
|
+
document.xpath('//img').each do |image|
|
121
|
+
return false if !image.attributes['alt'] || image.attributes['alt'].text.blank?
|
122
|
+
end
|
123
|
+
true
|
124
|
+
end
|
125
|
+
|
126
|
+
end
|
127
|
+
|
128
|
+
end
|