radiant-relations-extension 1.2.6 → 1.2.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  class RadiantRelationsExtension
2
- VERSION = '1.2.6'
2
+ VERSION = '1.2.7'
3
3
  end
@@ -1,12 +1,23 @@
1
1
  module RelationsExtension::RelationsTags
2
2
  include Radiant::Taggable
3
3
 
4
+ class TagError < StandardError; end
5
+
4
6
  tag 'related_pages' do |tag|
5
7
  tag.locals.related_pages = tag.locals.page.related_pages.dup
6
8
  if tag.attr['from_ancestor']
7
9
  ancestor_path = Page.find(tag.attr['from_ancestor']).path
8
10
  tag.locals.related_pages.delete_if{|p| not p.path =~ /^#{ancestor_path}/ }
9
11
  end
12
+ if tag.attr['order']
13
+ attr = tag.attr['order']
14
+ by, order = attr.strip.split(" ")
15
+ raise TagError, "Can not order related pages by #{by}: not a valid attribute." unless Page.column_names.include?(by)
16
+ tag.locals.related_pages.sort_by(&by.to_sym)
17
+ if(order && order.downcase == 'desc')
18
+ tag.locals.related_pages.reverse!
19
+ end
20
+ end
10
21
  tag.expand unless tag.locals.related_pages.empty?
11
22
  end
12
23
  desc %{
@@ -14,6 +25,10 @@ module RelationsExtension::RelationsTags
14
25
  You can limit the results by use of a @from_ancestor@ attribute.
15
26
  For example: &lt;r:related_pages from_ancestor="8"&gt;&lt;r:each:link/&gt;&lt;/r:related_pages&gt; where 8 is a page id
16
27
  The from_ancestor attribute accepts only one page id.
28
+
29
+ You can change the order of the results by use of a @order@ attribute.
30
+ For example: &lt;r:related_pages order="title"&gt;&lt;r:each:link/&gt;&lt;/r:related_pages&gt;
31
+ By default the order will be ascending, you can reverse it 'SQL style' by adding " desc" to the order attribute.
17
32
  }
18
33
  tag 'related_pages:each' do |tag|
19
34
  tag.locals.related_pages.inject('') do |result, 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.6
4
+ version: 1.2.7
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-24 00:00:00.000000000 Z
13
+ date: 2019-10-07 00:00:00.000000000 Z
14
14
  dependencies: []
15
15
  description: Allows you to define relations between pages
16
16
  email:
@@ -20,6 +20,7 @@ extensions: []
20
20
  extra_rdoc_files: []
21
21
  files:
22
22
  - db/migrate/20110623112105_add_related_pages.rb
23
+ - radiant-relations-extension-1.2.6.gem
23
24
  - radiant-relations-extension.gemspec
24
25
  - config/initializers/radiant_config.rb
25
26
  - config/routes.rb
@@ -48,7 +49,7 @@ files:
48
49
  homepage: http://github.com/jomz/radiant-relations-extension
49
50
  licenses: []
50
51
  post_install_message: ! "\n Add this to your radiant project by putting this line
51
- in your Gemfile:\n gem \"radiant-relations-extension\", \"~> 1.2.6\"\n "
52
+ in your Gemfile:\n gem \"radiant-relations-extension\", \"~> 1.2.7\"\n "
52
53
  rdoc_options: []
53
54
  require_paths:
54
55
  - lib
@@ -66,7 +67,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
66
67
  version: '0'
67
68
  requirements: []
68
69
  rubyforge_project:
69
- rubygems_version: 1.8.23.2
70
+ rubygems_version: 1.8.29
70
71
  signing_key:
71
72
  specification_version: 3
72
73
  summary: Relations extension for Radiant CMS