agile_rails 0.0.0.1 → 0.0.0.2
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 +4 -4
- data/CHANGELOG.md +1 -2
- data/README.md +26 -19
- data/agile_rails.gemspec +4 -4
- data/app/renderers/ar_common_renderer.rb +12 -12
- data/lib/agile/version.rb +1 -1
- metadata +6 -9
- data/app/models/ar_json_ld.rb +0 -131
- data/app/models/concerns/ar_piece_concern.rb +0 -48
- data/app/models/concerns/ar_policy_rule_concern.rb +0 -87
- data/app/models/concerns/ar_seo_concern.rb +0 -66
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18dcbd28e6f1f0d840016fadd4a0ffc75da43233dac60f772b67d36de0a9f534
|
4
|
+
data.tar.gz: 19c2c9e047772cf7e26ad2073093803f9dd090cde50090931041ba94dfcd5a54
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3db8f8adb6b0e7c495cc43c2fe08e6f699ac69efda6371ff24cf9afe769b890637f4f962b3352501ab2d5fcdcaba147e6400411c27865af480df3582abb26a8c
|
7
|
+
data.tar.gz: 7824f2db93018f2f72f8247e76af3b3c83172be2a9a0b2ff9985199cc7ae219746af44cee0425261f263ae05dc3f4e5f8bc0ddc0e85a7795ed982c7e5a72d29e
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -3,23 +3,27 @@
|
|
3
3
|
[](https://rubygems.org/gems/agile_rails)
|
4
4
|
[](https://rubygems.org/gems/agile_rails)
|
5
5
|
|
6
|
-
|
6
|
+
Watch introduction videos on YouTube: https://www.youtube.com/playlist?list=PLM66pztpUC0DVAqZvIAqH3Khb_RzJdD3W
|
7
7
|
|
8
|
-
|
8
|
+
## What is AgileRails
|
9
|
+
|
10
|
+
AgileRails simplifies the programming of business Intranet applications with Ruby on Rails.
|
9
11
|
Minimal database experience and only basic programming skills are needed
|
10
12
|
to create a data entry program. You can do it in 6 simple steps.
|
11
13
|
|
12
14
|
Step 1: Know your data and create Rails migration and model<br>
|
13
|
-
Step 2: Generate
|
15
|
+
Step 2: Generate AgileRails form<br>
|
14
16
|
Step 3: Edit form to your requirements<br>
|
15
17
|
Step 4: Define Labels and Help Text<br>
|
16
18
|
Step 5: Create additional logic in Controls File (if required)<br>
|
17
19
|
Step 6: Include in application menu<br>
|
18
20
|
|
19
|
-
Most of the time, you will end up with
|
21
|
+
Most of the time, you will end up with 3 source files.
|
22
|
+
|
23
|
+
#### 1. Migration file
|
20
24
|
|
21
|
-
|
22
|
-
schema, such as creating tables or altering
|
25
|
+
Rails uses migrations to make changes to the database
|
26
|
+
schema, such as creating tables or altering table attributes.
|
23
27
|
|
24
28
|
An example of migration file.
|
25
29
|
```ruby
|
@@ -42,7 +46,10 @@ class Diary < ActiveRecord::Migration[7.0]
|
|
42
46
|
end
|
43
47
|
```
|
44
48
|
|
45
|
-
|
49
|
+
|
50
|
+
#### 2. Model file
|
51
|
+
|
52
|
+
Model's primary purposes is to represent the data and logic
|
46
53
|
of the application. It contains business logic, relations between data, validations
|
47
54
|
|
48
55
|
An example of a typical model file:
|
@@ -73,7 +80,10 @@ end
|
|
73
80
|
end
|
74
81
|
```
|
75
82
|
|
76
|
-
|
83
|
+
|
84
|
+
#### 3. Form file
|
85
|
+
|
86
|
+
AgileRails Form's purpose is to define data entry fields and actions which can be taken on data.
|
77
87
|
It contains two main sections.
|
78
88
|
|
79
89
|
<b>index:</b> Defines view on table data (data_set) and actions that can be performed on
|
@@ -229,31 +239,28 @@ On the first level administrator defines roles and roles rights as web site poli
|
|
229
239
|
if user can view content or not or if user can edit content. Roles are then assigned to users
|
230
240
|
and policies are assigned to documents (web content), parts of content, menus ...
|
231
241
|
<br>
|
232
|
-
Second level defines roles
|
233
|
-
user roles can read, edit, create or delete records
|
242
|
+
Second level defines roles to access database tables. Each table can have defined which
|
243
|
+
user roles can read, edit, create or delete records.
|
234
244
|
<br><br>
|
235
245
|
Integrates journal with options to undo single field
|
236
246
|
<br><br>
|
237
247
|
Integrates CK Editor as HTML editor and ElFinder file manager with with drag & drop support through
|
238
248
|
agile_rails_html_editor gem.
|
239
249
|
|
240
|
-
|
241
|
-
|
242
|
-
Go and [jumpstart](https://github.com/agile-rails/
|
243
|
-
|
250
|
+
Installation
|
251
|
+
------------
|
252
|
+
Go and [jumpstart](https://github.com/agile-rails/startup/README.md)
|
253
|
+
Intranet portal application with AgileRails in just few minutes.
|
244
254
|
|
245
255
|
Compatibility
|
246
256
|
-------------
|
247
|
-
|
248
257
|
Technology behind AgileRails is being actively developed since 2012 and has been live tested in production
|
249
|
-
since early days. It runs against latest technology Ruby (3.
|
258
|
+
since early days. It runs against latest technology Ruby (>= 3.2), Rails (>= 7.2)
|
250
259
|
and had so far little or no problems advancing to latest versions of Ruby or Ruby on Rails.
|
251
260
|
|
252
261
|
Documentation
|
253
262
|
-------------
|
254
|
-
|
255
|
-
Please see the agile-rails.com website for more information:
|
256
|
-
[agilerails.zop.si](http://agilerails.zop.si)
|
263
|
+
Visit the [agile-rails.com](https://agile-rails.com) website for more information:
|
257
264
|
|
258
265
|
License (MIT LICENCE)
|
259
266
|
---------------------
|
data/agile_rails.gemspec
CHANGED
@@ -12,15 +12,15 @@ Gem::Specification.new do |s|
|
|
12
12
|
s.authors = ['Damjan Rems']
|
13
13
|
s.email = ['damjan.rems@gmail.com']
|
14
14
|
s.homepage = 'https://agile-rails.com'
|
15
|
-
s.summary = '
|
16
|
-
s.description = '
|
15
|
+
s.summary = 'AgileRails: Agile business application development tool and CMS for Ruby on Rails'
|
16
|
+
s.description = 'AgileRails, development tool for agile development of in-house (Intranet, business, private cloud) applications as well as CMS for creating complex, data-entry intensive web sites.'
|
17
17
|
s.license = 'MIT'
|
18
18
|
s.files = Dir['{app,config,db,lib}/**/*'] + %w[MIT-LICENSE Rakefile README.md CHANGELOG.md agile_rails.gemspec]
|
19
19
|
#s.test_files = Dir['test/**/*']
|
20
20
|
|
21
21
|
s.metadata['homepage_uri'] = s.homepage
|
22
|
-
s.metadata['source_code_uri'] = 'https://github.com/agile-rails'
|
23
|
-
s.metadata['changelog_uri'] = 'https://github.com/agile-rails/
|
22
|
+
s.metadata['source_code_uri'] = 'https://github.com/agile-rails/agile-rails'
|
23
|
+
s.metadata['changelog_uri'] = 'https://github.com/agile-rails/agile-rails/CHANGELOG.md'
|
24
24
|
|
25
25
|
s.required_ruby_version = '> 3.1'
|
26
26
|
|
@@ -24,19 +24,19 @@
|
|
24
24
|
########################################################################
|
25
25
|
# Renderer methods which may be useful on any site.
|
26
26
|
########################################################################
|
27
|
-
class
|
27
|
+
class ArCommonRenderer < AgileRenderer
|
28
28
|
|
29
29
|
include AgileApplicationHelper
|
30
30
|
|
31
31
|
########################################################################
|
32
32
|
# Renderer for printer friendly layout. Will call another renderer which
|
33
33
|
# should provide html code for printer friendly output.
|
34
|
-
#
|
35
|
-
# Parameters are passed through link. There are currently two parameters,
|
34
|
+
#
|
35
|
+
# Parameters are passed through link. There are currently two parameters,
|
36
36
|
# which define renderer and method to be used for creating output.
|
37
|
-
#
|
37
|
+
#
|
38
38
|
# renderer::
|
39
|
-
# Defines renderer's class
|
39
|
+
# Defines renderer's class
|
40
40
|
# method::
|
41
41
|
# Defines renderer's class method
|
42
42
|
########################################################################
|
@@ -55,16 +55,16 @@ end
|
|
55
55
|
|
56
56
|
########################################################################
|
57
57
|
# Renderer for Google analytics code.
|
58
|
-
#
|
58
|
+
#
|
59
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
|
-
#
|
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
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
|
65
|
+
# called and if false is returned GA code will not be executed. This is in
|
66
66
|
# order with European cookie law.
|
67
|
-
#
|
67
|
+
#
|
68
68
|
# Example:
|
69
69
|
# agile_render(:agile_common_renderer, method: 'google_analytics', code4: 'UA-12345678-9')
|
70
70
|
########################################################################
|
data/lib/agile/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: agile_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.0.
|
4
|
+
version: 0.0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Damjan Rems
|
@@ -121,7 +121,7 @@ dependencies:
|
|
121
121
|
- - ">="
|
122
122
|
- !ruby/object:Gem::Version
|
123
123
|
version: '0'
|
124
|
-
description:
|
124
|
+
description: AgileRails, development tool for agile development of in-house (Intranet,
|
125
125
|
business, private cloud) applications as well as CMS for creating complex, data-entry
|
126
126
|
intensive web sites.
|
127
127
|
email:
|
@@ -274,7 +274,6 @@ files:
|
|
274
274
|
- app/models/ar_image.rb
|
275
275
|
- app/models/ar_internals.rb
|
276
276
|
- app/models/ar_journal.rb
|
277
|
-
- app/models/ar_json_ld.rb
|
278
277
|
- app/models/ar_key_value_store.rb
|
279
278
|
- app/models/ar_link.rb
|
280
279
|
- app/models/ar_memory.rb
|
@@ -300,9 +299,6 @@ files:
|
|
300
299
|
- app/models/ar_visit.rb
|
301
300
|
- app/models/concerns/ar_page_concern.rb
|
302
301
|
- app/models/concerns/ar_part_concern.rb
|
303
|
-
- app/models/concerns/ar_piece_concern.rb
|
304
|
-
- app/models/concerns/ar_policy_rule_concern.rb
|
305
|
-
- app/models/concerns/ar_seo_concern.rb
|
306
302
|
- app/models/concerns/ar_site_concern.rb
|
307
303
|
- app/models/concerns/ar_user_concern.rb
|
308
304
|
- app/renderers/agile_common_renderer.rb
|
@@ -392,8 +388,8 @@ licenses:
|
|
392
388
|
- MIT
|
393
389
|
metadata:
|
394
390
|
homepage_uri: https://agile-rails.com
|
395
|
-
source_code_uri: https://github.com/agile-rails
|
396
|
-
changelog_uri: https://github.com/agile-rails/
|
391
|
+
source_code_uri: https://github.com/agile-rails/agile-rails
|
392
|
+
changelog_uri: https://github.com/agile-rails/agile-rails/CHANGELOG.md
|
397
393
|
rdoc_options: []
|
398
394
|
require_paths:
|
399
395
|
- lib
|
@@ -410,5 +406,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
410
406
|
requirements: []
|
411
407
|
rubygems_version: 3.6.2
|
412
408
|
specification_version: 4
|
413
|
-
summary: '
|
409
|
+
summary: 'AgileRails: Agile business application development tool and CMS for Ruby
|
410
|
+
on Rails'
|
414
411
|
test_files: []
|
data/app/models/ar_json_ld.rb
DELETED
@@ -1,131 +0,0 @@
|
|
1
|
-
#--
|
2
|
-
# Copyright (c) 2024+ Damjan Rems
|
3
|
-
#
|
4
|
-
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
-
# a copy of this software and associated documentation files (the
|
6
|
-
# "Software"), to deal in the Software without restriction, including
|
7
|
-
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
-
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
-
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
-
# the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be
|
13
|
-
# included in all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
-
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
-
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
-
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
-
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
-
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
-
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
-
#+
|
23
|
-
|
24
|
-
########################################################################
|
25
|
-
# == Schema information
|
26
|
-
#
|
27
|
-
# name: ar_json_ld : JSON_LD data for site optimization
|
28
|
-
#
|
29
|
-
# id Integer id
|
30
|
-
# type String Type of structure
|
31
|
-
# data String Structure data in YAML
|
32
|
-
# ar_json_lds Object Can embed substructure
|
33
|
-
# created_at Time created_at
|
34
|
-
# updated_at Time Last updated at
|
35
|
-
# created_by Integer created_by
|
36
|
-
# updated_by Integer Last updated by
|
37
|
-
#
|
38
|
-
########################################################################
|
39
|
-
|
40
|
-
# Not implemented yet
|
41
|
-
class ArJsonLd
|
42
|
-
|
43
|
-
field :name, type: String
|
44
|
-
field :type, type: String
|
45
|
-
field :data, type: String
|
46
|
-
field :active, type: Boolean, default: true
|
47
|
-
|
48
|
-
embeds_many :ar_json_lds, cyclic: true
|
49
|
-
|
50
|
-
field :created_by, type: Integer
|
51
|
-
field :updated_by, type: Integer
|
52
|
-
|
53
|
-
validates :name, presence: true
|
54
|
-
validates :type, presence: true
|
55
|
-
|
56
|
-
##########################################################################
|
57
|
-
# Returns JSON LD data as YAML
|
58
|
-
##########################################################################
|
59
|
-
def get_json_ld(env_data)
|
60
|
-
yaml = (YAML.load(self.data) rescue nil) || {}
|
61
|
-
yaml['@type'] = self.type if yaml.size > 0
|
62
|
-
if ar_json_lds.size > 0
|
63
|
-
ar_json_lds.where(active: true).each do |element|
|
64
|
-
yml = element.get_json_ld(env_data)
|
65
|
-
if yml.size > 0
|
66
|
-
yaml[element.name] ||= []
|
67
|
-
yaml[element.name] << yml
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
yaml
|
72
|
-
end
|
73
|
-
|
74
|
-
########################################################################
|
75
|
-
# Find document by ids when document are embedded into main d even if embedded
|
76
|
-
#
|
77
|
-
# @param [tables] Tables parameter as send in url. Tables are separated by ;
|
78
|
-
# @param [ids] ids as send in url. ids are separated by ;
|
79
|
-
#
|
80
|
-
# @return [Document]
|
81
|
-
########################################################################
|
82
|
-
def self.find_document_by_ids(tables, ids)
|
83
|
-
collection = tables.split(';').first.classify.constantize
|
84
|
-
ar_ids = ids.split(';')
|
85
|
-
# Find top document
|
86
|
-
document = collection.find(ar_ids.shift)
|
87
|
-
# Search for embedded document
|
88
|
-
ar_ids.each { |id| document = document.ar_json_lds.find(id) }
|
89
|
-
document
|
90
|
-
end
|
91
|
-
|
92
|
-
#########################################################################
|
93
|
-
# Returns possible options for type select field on form.
|
94
|
-
#########################################################################
|
95
|
-
def self.choices_for_type
|
96
|
-
yaml = YAML.load_file(AgileHelper.form_file_find('json_ld_schema'))
|
97
|
-
|
98
|
-
yaml.map(&:first)
|
99
|
-
end
|
100
|
-
|
101
|
-
#########################################################################
|
102
|
-
# Create menu to add schema element. Called from Agile Form action.
|
103
|
-
#########################################################################
|
104
|
-
def self.add_schema_menu(env)
|
105
|
-
yaml = YAML.load_file(AgileHelper.form_file_find('json_ld_schema'))
|
106
|
-
if (level = env.params['ids'].split(';').size) == 1
|
107
|
-
# select only top level elements
|
108
|
-
yaml.delete_if { |schema_name, schema_data| schema_data['level'].nil? }
|
109
|
-
else
|
110
|
-
# select only elemets which are subelements of type
|
111
|
-
env_type = self.find_document_by_ids(env.params['table'],env.params['ids']).type
|
112
|
-
_yaml = []
|
113
|
-
yaml[env_type].each_value do |data|
|
114
|
-
next unless data.class == Hash
|
115
|
-
|
116
|
-
_yaml << [data['type'], yaml[data['type']]] if data['type'] && yaml[data['type']]
|
117
|
-
end
|
118
|
-
yaml = _yaml
|
119
|
-
end
|
120
|
-
# create menu code
|
121
|
-
html = '<ul>'
|
122
|
-
yaml.each do |schema_name, schema_data|
|
123
|
-
next if level == 1 && schema_data['level'].nil?
|
124
|
-
|
125
|
-
url = "/agile_common/add_json_ld_schema?table=#{env.params['table']}&ids=#{env.params['ids']}&schema=#{schema_name}&url=#{env.request.url}"
|
126
|
-
html += %(<li class="ar-link-ajax in-menu" data-url="#{url}">#{schema_name}</li>)
|
127
|
-
end
|
128
|
-
"#{html}</ul>"
|
129
|
-
end
|
130
|
-
|
131
|
-
end
|
@@ -1,48 +0,0 @@
|
|
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
|
@@ -1,87 +0,0 @@
|
|
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
|
@@ -1,66 +0,0 @@
|
|
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
|