radiant-relations-extension 1.2.5 → 1.2.6

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.
@@ -1,3 +1,3 @@
1
1
  class RadiantRelationsExtension
2
- VERSION = '1.2.5'
2
+ VERSION = '1.2.6'
3
3
  end
@@ -24,12 +24,22 @@ module RelationsExtension::RelationsTags
24
24
 
25
25
  desc %{ Expands only if there are related pages. }
26
26
  tag 'if_related_pages' do |tag|
27
- tag.expand if tag.locals.page.related_pages.any?
27
+ tag.locals.related_pages = tag.locals.page.related_pages.dup
28
+ if tag.attr['from_ancestor']
29
+ ancestor_path = Page.find(tag.attr['from_ancestor']).path
30
+ tag.locals.related_pages.delete_if{|p| not p.path =~ /^#{ancestor_path}/ }
31
+ end
32
+ tag.expand unless tag.locals.related_pages.empty?
28
33
  end
29
34
 
30
35
  desc %{ Expands only if there are no related pages. }
31
36
  tag 'unless_related_pages' do |tag|
32
- tag.expand unless tag.locals.page.related_pages.any?
37
+ tag.locals.related_pages = tag.locals.page.related_pages.dup
38
+ if tag.attr['from_ancestor']
39
+ ancestor_path = Page.find(tag.attr['from_ancestor']).path
40
+ tag.locals.related_pages.delete_if{|p| not p.path =~ /^#{ancestor_path}/ }
41
+ end
42
+ tag.expand if tag.locals.related_pages.empty?
33
43
  end
34
44
 
35
45
  desc %{ Sets the scope to the first related page. }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: radiant-relations-extension
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.5
4
+ version: 1.2.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2019-06-06 00:00:00.000000000 Z
13
+ date: 2019-06-24 00:00:00.000000000 Z
14
14
  dependencies: []
15
15
  description: Allows you to define relations between pages
16
16
  email:
@@ -43,11 +43,12 @@ files:
43
43
  - app/views/admin/pages/_relations_header_load.html.haml
44
44
  - app/models/relation_page_part.rb
45
45
  - app/helpers/relations_helper.rb
46
+ - radiant-relations-extension-1.2.5.gem
46
47
  - radiant-relations-extension-1.2.3.gem
47
48
  homepage: http://github.com/jomz/radiant-relations-extension
48
49
  licenses: []
49
50
  post_install_message: ! "\n Add this to your radiant project by putting this line
50
- in your Gemfile:\n gem \"radiant-relations-extension\", \"~> 1.2.5\"\n "
51
+ in your Gemfile:\n gem \"radiant-relations-extension\", \"~> 1.2.6\"\n "
51
52
  rdoc_options: []
52
53
  require_paths:
53
54
  - lib