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,59 @@
|
|
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
|
+
# This is default AgileRails renderer class definition which can be reused by other
|
26
|
+
# renderers.
|
27
|
+
########################################################################
|
28
|
+
class AgileRenderer
|
29
|
+
|
30
|
+
########################################################################
|
31
|
+
# Object initialization.
|
32
|
+
########################################################################
|
33
|
+
def initialize( env, opts = {} )
|
34
|
+
@env = env
|
35
|
+
@page = env.page
|
36
|
+
@opts = opts
|
37
|
+
@css = ''
|
38
|
+
self
|
39
|
+
end
|
40
|
+
|
41
|
+
########################################################################
|
42
|
+
# Renderer dispatcher. Method returns HTML part of code.
|
43
|
+
########################################################################
|
44
|
+
def render_html
|
45
|
+
can_view, msg = @env.agile_user_can_view(@env, @env.page)
|
46
|
+
return msg unless can_view
|
47
|
+
|
48
|
+
method = @opts[:method] || 'default'
|
49
|
+
respond_to?(method) ? send(method) : "Error #{self.class}: Method (#{method}) not defined!"
|
50
|
+
end
|
51
|
+
|
52
|
+
########################################################################
|
53
|
+
# Return CSS part of code.
|
54
|
+
########################################################################
|
55
|
+
def render_css
|
56
|
+
@css
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
@@ -0,0 +1,219 @@
|
|
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 BUTe 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
|
+
# Ads renderer. Typically ads renderer is defined in design like this.
|
26
|
+
# <div id="ads-on-top">
|
27
|
+
# <%= agile_render(:ar_ad, position: 'top') %>
|
28
|
+
# </div>
|
29
|
+
#
|
30
|
+
# There can be more than one ad shown on the same position. Therefore Ads can be grouped by position
|
31
|
+
# they are displayed at. Position name can be any string. I suggest using top, right ...
|
32
|
+
#
|
33
|
+
# Ads may be prioritized. Higher priority means higher probability that ad will be selected for display.
|
34
|
+
#
|
35
|
+
# Clicks on picture and flash can be intercepted and are saved into ar_ad_stat table.
|
36
|
+
# It is also possible to limit number of times ad will be displayed or clicked.
|
37
|
+
########################################################################
|
38
|
+
class ArAdRenderer
|
39
|
+
|
40
|
+
include AgileApplicationHelper
|
41
|
+
|
42
|
+
########################################################################
|
43
|
+
#
|
44
|
+
########################################################################
|
45
|
+
def initialize( env, opts={} ) #:nodoc:
|
46
|
+
@env = env
|
47
|
+
@opts = opts
|
48
|
+
@css = ''
|
49
|
+
self
|
50
|
+
end
|
51
|
+
|
52
|
+
########################################################################
|
53
|
+
# Finds ads that will be rendered. Subroutine of multi method.
|
54
|
+
########################################################################
|
55
|
+
def find_ads_multi() #:nodoc:
|
56
|
+
ads = ArAd.where( position: @opts[:position], active: true).to_a#, :valid_to.gt => Time.now, :valid_from.lt => Time.now).to_a
|
57
|
+
#p @opts, ads.size, '*-*-*-*'
|
58
|
+
ads.delete_if { |ad| (ad.valid_to and ad.valid_to < Time.now) or
|
59
|
+
(ad.valid_from and ad.valid_from > Time.now) or
|
60
|
+
(ad.displays > 0 and ad.displayed >= ad.displays) or
|
61
|
+
(ad.clicks > 0 and ad.clicked >= ad.clicks) }
|
62
|
+
|
63
|
+
ads
|
64
|
+
end
|
65
|
+
|
66
|
+
########################################################################
|
67
|
+
# This is an experiment of how to render multiple ads on same location simultaneously by
|
68
|
+
# fade in and out div on which ad resides.
|
69
|
+
########################################################################
|
70
|
+
def multi
|
71
|
+
return '' if @env.session[:is_robot] # don't bother if robot
|
72
|
+
html = "<div id='ad-#{@opts[:position]}-div'>"
|
73
|
+
n = 0
|
74
|
+
find_ads_multi.each do |ad|
|
75
|
+
div = "ad-#{@opts[:position]}-#{n+=1}"
|
76
|
+
html += "<div id='#{div}' style='position: absolute; display: none;'>"
|
77
|
+
# all except first are hidden
|
78
|
+
# html += n == 1 ? '>' : 'style="display: none;">'
|
79
|
+
html += case ad.type
|
80
|
+
when 1 then # picture
|
81
|
+
picture_link ad
|
82
|
+
when 2 then # flash
|
83
|
+
flash_link ad
|
84
|
+
when 3 then # script
|
85
|
+
ad.script
|
86
|
+
else
|
87
|
+
'Error. Wrong ad type!'
|
88
|
+
end
|
89
|
+
html += '</div>'
|
90
|
+
end
|
91
|
+
#
|
92
|
+
html += '</div>'
|
93
|
+
if n > 0
|
94
|
+
js = <<EOJS
|
95
|
+
ar_ad_next_slide = function(div, index, max, timeout) {
|
96
|
+
index = index + 1;
|
97
|
+
div_show = div + index.toString();
|
98
|
+
index_h = index - 1;
|
99
|
+
if (index_h == 0) index_h = max;
|
100
|
+
div_hide = div + index_h.toString();
|
101
|
+
$('#' + div_show).fadeIn(1500);
|
102
|
+
$('#' + div_hide).fadeOut(1500);
|
103
|
+
|
104
|
+
if (index == max) index = 0;
|
105
|
+
setTimeout( function () { ar_ad_next_slide(div, index, max, timeout); }, timeout);
|
106
|
+
}
|
107
|
+
|
108
|
+
$(document).ready(function () {
|
109
|
+
ar_ad_next_slide("ad-#{@opts[:position]}-", 0, #{n}, 5000)
|
110
|
+
});
|
111
|
+
EOJS
|
112
|
+
html += @env.javascript_tag(js)
|
113
|
+
end
|
114
|
+
html
|
115
|
+
end
|
116
|
+
|
117
|
+
########################################################################
|
118
|
+
# Determines which add will be displayed next. Subroutine of default method.
|
119
|
+
########################################################################
|
120
|
+
def find_ad_to_display()
|
121
|
+
ads = ArAd.where(ar_site_id: @env.site.id, position: @opts[:position], active: true).to_a#, :valid_to.gt => Time.now, :valid_from.lt => Time.now).to_a
|
122
|
+
|
123
|
+
ads.delete_if { |ad| (ad.valid_to and ad.valid_to < Time.now) or
|
124
|
+
(ad.valid_from and ad.valid_from > Time.now) or
|
125
|
+
(ad.displays > 0 and ad.displayed >= ad.displays) or
|
126
|
+
(ad.clicks > 0 and ad.clicked >= ad.clicks) }
|
127
|
+
return nil if ads.size == 0
|
128
|
+
# Determine ad to display, based on priority. This is of course not totally accurate,
|
129
|
+
# but it will have to do.
|
130
|
+
sum = ads.sum(&:priority)
|
131
|
+
rnd = Random.rand(sum)
|
132
|
+
r = 0
|
133
|
+
ads.each do |e|
|
134
|
+
return e if rnd >= r && rnd < r + e.priority
|
135
|
+
|
136
|
+
r += e.priority
|
137
|
+
end
|
138
|
+
ads.last # we really shouldn't be here
|
139
|
+
end
|
140
|
+
|
141
|
+
########################################################################
|
142
|
+
# Code for flash ad.
|
143
|
+
########################################################################
|
144
|
+
def flash_ad(ad)
|
145
|
+
click_tag = ad.link.to_s.size > 5 ? "flashvars=\"clickTag=#{ad.link}\"" : ''
|
146
|
+
<<EOT
|
147
|
+
<div class="link_to_track" id="#{ad.id}">
|
148
|
+
<object>
|
149
|
+
<param name="wmode" value="transenv" />
|
150
|
+
<embed width="#{ad.width}" height="#{ad.height}" src="#{ad.file}" #{click_tag}
|
151
|
+
wmode=transenv allowfullscreen='true' allowscriptaccess='always' type="application/x-shockwave-flash"></embed>
|
152
|
+
</object>
|
153
|
+
</div>
|
154
|
+
|
155
|
+
<script type='text/javascript'>
|
156
|
+
$('##{ad.id}').mousedown(function (e){
|
157
|
+
$.post('/ar_common/ad_click', { id: this.id });
|
158
|
+
return true;
|
159
|
+
});
|
160
|
+
</script>
|
161
|
+
EOT
|
162
|
+
end
|
163
|
+
|
164
|
+
########################################################################
|
165
|
+
# Code for picture ad.
|
166
|
+
########################################################################
|
167
|
+
def picture_ad(ad)
|
168
|
+
@env.link_to @env.image_tag(ad.file), ad.link, id: ad.id, class: 'link_to_track', target: ad.link_target
|
169
|
+
end
|
170
|
+
|
171
|
+
########################################################################
|
172
|
+
# Default method for rendering ads.
|
173
|
+
########################################################################
|
174
|
+
def default
|
175
|
+
return '' if @env.session[:is_robot] # don't bother if robot
|
176
|
+
html = ''
|
177
|
+
if (ad = find_ad_to_display)
|
178
|
+
# save to statistics, if not in cms
|
179
|
+
if @opts[:edit_mode] < 1
|
180
|
+
ArAdStat.create!(ar_ad_id: ad.id, ip: @env.request.ip, type: 1 )
|
181
|
+
# save display counter
|
182
|
+
ad.displayed += 1
|
183
|
+
ad.save
|
184
|
+
end
|
185
|
+
html += case ad.type
|
186
|
+
when 1 then # picture
|
187
|
+
picture_ad ad
|
188
|
+
when 2 then # flash
|
189
|
+
flash_ad ad
|
190
|
+
when 3 then # script
|
191
|
+
ad.script
|
192
|
+
else
|
193
|
+
'Error. Wrong ad type!'
|
194
|
+
end
|
195
|
+
end
|
196
|
+
html
|
197
|
+
end
|
198
|
+
|
199
|
+
########################################################################
|
200
|
+
# Renderer dispatcher. Method returns HTML part of code.
|
201
|
+
########################################################################
|
202
|
+
def render_html
|
203
|
+
method = @opts[:method] || 'default'
|
204
|
+
html = if method and self.respond_to?(method)
|
205
|
+
send(method)
|
206
|
+
else
|
207
|
+
" ArAdRenderer: method #{method} not defined!"
|
208
|
+
end
|
209
|
+
html
|
210
|
+
end
|
211
|
+
|
212
|
+
########################################################################
|
213
|
+
# Render CSS. This method returns css part of code.
|
214
|
+
########################################################################
|
215
|
+
def render_css
|
216
|
+
@css
|
217
|
+
end
|
218
|
+
|
219
|
+
end
|
@@ -0,0 +1,113 @@
|
|
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
|
+
# This is renderer to return captcha code field when required on data entry. It currently
|
26
|
+
# implements only very basic captcha logic and only in Slovenian language.
|
27
|
+
########################################################################
|
28
|
+
class ArCaptchaRenderer < AgileRenderer
|
29
|
+
|
30
|
+
########################################################################
|
31
|
+
# Check if result of captcha is OK.
|
32
|
+
########################################################################
|
33
|
+
def is_ok?
|
34
|
+
return false unless self.respond_to?(@opts[:type])
|
35
|
+
|
36
|
+
send(@opts[:type], true)
|
37
|
+
end
|
38
|
+
|
39
|
+
########################################################################
|
40
|
+
# Very simple captcha type. This is Slovenian only version.
|
41
|
+
########################################################################
|
42
|
+
def simpl(check = false) #:nodoc:
|
43
|
+
a1 = [['enajst', 11], ['dvanajst',12],['petindvajset',25],['triintridest',33],['devetnajst',19]]
|
44
|
+
a2 = [['šest', 6], ['sedem',7],['osem',8],['devet',9],['deset',10]]
|
45
|
+
op = [['seštejte','+'],['odštejte','-']]
|
46
|
+
|
47
|
+
if check
|
48
|
+
# Prosimo sestejte dvanajst in sedem
|
49
|
+
ha1, hop, ha2 = Hash[a1], Hash[op], Hash[a2]
|
50
|
+
n1, operacija, prvi, n2, drugi = @opts['vprasanje'].split(' ')
|
51
|
+
rezultat = eval("#{ha1[prvi]}#{hop[operacija]}#{ha2[drugi]}")
|
52
|
+
return rezultat == @opts['record']['rezultat'].to_i
|
53
|
+
else
|
54
|
+
txt = "Prosimo #{op[Random.rand(1)][0]} #{a1[Arndom.rand(4)][0]} in #{a2[Arndom.rand(4)][0]}"
|
55
|
+
y = {}
|
56
|
+
y['name'] = 'rezultat'
|
57
|
+
y['html'] = {}
|
58
|
+
y['html']['size'] = 5
|
59
|
+
|
60
|
+
<<eot
|
61
|
+
<div style="background-color: #fafafa; border: 1px solid #eee; padding: 6px; margin: 5px 5px 25px 5px; font-size: 1.2em; border-radius: 2px;">
|
62
|
+
#{txt} <span style="color: red;">*</span> #{@env.text_field('record','rezultat', size: 5)} #{@env.hidden_field_tag('vprasanje', txt )}
|
63
|
+
</div>
|
64
|
+
eot
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
########################################################################
|
69
|
+
# Very simple captcha. Will ask for name of month in a year and check if entered value is valid when
|
70
|
+
# asked to check.
|
71
|
+
#
|
72
|
+
# Parameters:
|
73
|
+
# [check] Boolean. Send true if you are checking if entered value is OK. Default is false.
|
74
|
+
# Method will return HTML code required to render capcha field on form.
|
75
|
+
#
|
76
|
+
# Returns:
|
77
|
+
# HTML code for displaying captcha field on page.
|
78
|
+
# If parameters check is true then method checks if written data is correct and returns true/false.
|
79
|
+
########################################################################
|
80
|
+
def simple(check=false)
|
81
|
+
if check
|
82
|
+
number = @opts['question'].split(' ').last.chomp('?').to_i
|
83
|
+
month = I18n.t('date.month_names')[number].downcase
|
84
|
+
return month == @opts['record']['captcha_result'].to_i
|
85
|
+
else
|
86
|
+
number = Random.rand(11) + 1
|
87
|
+
txt = I18n.t(' gile.ar_captcha.simple_message', number)
|
88
|
+
|
89
|
+
<<eot
|
90
|
+
<div style="background-color: #fafafa; border: 1px solid #eee; padding: 6px; margin: 5px 5px 25px 5px; font-size: 1.2em; border-radius: 2px;">
|
91
|
+
#{txt} <span style="color: red;">*</span> #{@env.text_field('record','captcha_result', size: 5)} #{@env.hidden_field_tag('question', txt )}
|
92
|
+
</div>
|
93
|
+
eot
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
########################################################################
|
98
|
+
# Return HTML part of code.
|
99
|
+
########################################################################
|
100
|
+
def render_html
|
101
|
+
captcha_type = @opts[:captcha_type] || @env.params[:captcha_type]
|
102
|
+
return ' ArCaptchaRenderer: Error captcha_type parameter not set!' unless captcha_type
|
103
|
+
|
104
|
+
html = if self.respond_to?(captcha_type)
|
105
|
+
send(captcha_type)
|
106
|
+
else
|
107
|
+
" ArCaptchaRenderer: Error method #{captcha_type} not defined!"
|
108
|
+
end
|
109
|
+
|
110
|
+
html
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
@@ -0,0 +1,90 @@
|
|
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. You may also disable sending
|
62
|
+
#
|
63
|
+
#
|
64
|
+
# If eu_cookies_allowed function is defined in javascript libraries it will be
|
65
|
+
# called and if false is returned GA code will not be executed. This is in
|
66
|
+
# order with European cookie law.
|
67
|
+
#
|
68
|
+
# Example:
|
69
|
+
# agile_render(:agile_common_renderer, method: 'google_analytics', code4: 'UA-12345678-9')
|
70
|
+
########################################################################
|
71
|
+
def google_analytics
|
72
|
+
html = ''
|
73
|
+
ga4_acc = @opts[:code4] || @opts[:ga4_acc]
|
74
|
+
if ga4_acc && ga4_acc != '/'
|
75
|
+
html += %(
|
76
|
+
<!-- Global site tag (gtag.js) - Google Analytics -->
|
77
|
+
<script async src="https://www.googletagmanager.com/gtag/js?id=#{ga4_acc}"></script>
|
78
|
+
<script>
|
79
|
+
window.dataLayer = window.dataLayer || [];
|
80
|
+
function gtag(){dataLayer.push(arguments);}
|
81
|
+
gtag('js', new Date());
|
82
|
+
|
83
|
+
gtag('config', '#{ga4_acc}');
|
84
|
+
</script>)
|
85
|
+
end
|
86
|
+
|
87
|
+
html.html_safe
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
@@ -0,0 +1,107 @@
|
|
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
|
+
# ArGalleryRenderer renders data for displaying picture gallery on the web page.
|
26
|
+
#
|
27
|
+
# Example:
|
28
|
+
# <div id="page">
|
29
|
+
# <%= agile_render(:ar_gallery) if document.gallery %>
|
30
|
+
# </div>
|
31
|
+
#
|
32
|
+
########################################################################
|
33
|
+
class ArGalleryRenderer
|
34
|
+
|
35
|
+
include AgileApplicationHelper
|
36
|
+
include AgileCommonHelper
|
37
|
+
|
38
|
+
########################################################################
|
39
|
+
# Object initialization.
|
40
|
+
########################################################################
|
41
|
+
def initialize( env, opts = {} ) #:nodoc:
|
42
|
+
@env = env
|
43
|
+
@opts = opts
|
44
|
+
@css = ''
|
45
|
+
end
|
46
|
+
|
47
|
+
#########################################################################
|
48
|
+
# Default ArGallery render method. It will simply put thumbnail pictures side by side and
|
49
|
+
# open big picture when clicked on thumbnail.
|
50
|
+
#########################################################################
|
51
|
+
def default
|
52
|
+
html = '<div class="picture-gallery"><ul>' + new_menu()
|
53
|
+
ArGallery.where(doc_id: @opts[:doc_id], doc_type: @opts[:doc_type], active: true).order(:order).each do |picture|
|
54
|
+
html += "<li>" + edit_menu(picture)
|
55
|
+
html += @env.link_to(@env.image_tag(picture.thumbnail, title: picture.title), picture.picture)
|
56
|
+
html += '</li>'
|
57
|
+
end
|
58
|
+
html += '</ul></div>'
|
59
|
+
end
|
60
|
+
|
61
|
+
#########################################################################
|
62
|
+
# Renderer dispatcher. Method returns HTML part of code.
|
63
|
+
########################################################################
|
64
|
+
def render_html
|
65
|
+
method = @opts[:method] || 'default'
|
66
|
+
respond_to?(method) ? send(method) : "Error ArGalleryRenderer: Method #{method} doesn't exist!"
|
67
|
+
end
|
68
|
+
|
69
|
+
########################################################################
|
70
|
+
# Return CSS part of code.
|
71
|
+
########################################################################
|
72
|
+
def render_css
|
73
|
+
@css
|
74
|
+
end
|
75
|
+
|
76
|
+
private
|
77
|
+
|
78
|
+
########################################################################
|
79
|
+
#
|
80
|
+
########################################################################
|
81
|
+
def edit_menu(picture)
|
82
|
+
return '' if @opts[:edit_mode] < 2
|
83
|
+
|
84
|
+
opts = { action: :edit,
|
85
|
+
title: "#{t('agile.edit')}: #{picture.title}",
|
86
|
+
id: picture.id,
|
87
|
+
table: 'ar_gallery'
|
88
|
+
}
|
89
|
+
"<li>#{@env.agile_link_for_edit(opts)}</li>\n"
|
90
|
+
end
|
91
|
+
|
92
|
+
########################################################################
|
93
|
+
#
|
94
|
+
########################################################################
|
95
|
+
def new_menu
|
96
|
+
return '' if @opts[:edit_mode] < 2
|
97
|
+
|
98
|
+
opts = { action: :new,
|
99
|
+
title: "#{t('agile.new')}: Picture",
|
100
|
+
p_doc_id: @opts[:doc_id],
|
101
|
+
p_doc_type: @opts[:doc_type],
|
102
|
+
table: 'ar_gallery'
|
103
|
+
}
|
104
|
+
"<li>#{@env.agile_link_for_create(opts)}</li>\n"
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|