radiant-archive_tabs-extension 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
- - if extracted?(model.parent)
1
+ - if archive_page?(model.parent)
2
2
  :javascript
3
3
  function redirect_cancel(event) {
4
- window.location = "#{url_for index_page_for_model_with_extract}"
4
+ window.location = "#{url_for index_page_for_model_with_archive}"
5
5
  event.stop()
6
6
  }
7
7
 
@@ -1,4 +1,5 @@
1
1
  require 'radiant-archive_tabs-extension/version'
2
+ require 'radiant-archive_tabs-extension/application_helper'
2
3
  require 'radiant-archive_tabs-extension/admin/node_helper'
3
4
  require 'radiant-archive_tabs-extension/admin/pages_controller'
4
5
 
@@ -8,6 +9,7 @@ class ArchiveTabsExtension < Radiant::Extension
8
9
  url "http://github.com/jsntv200/radiant-archive_tabs-extension"
9
10
 
10
11
  def activate
12
+ ApplicationHelper.send :include, RadiantArchiveTabsExtension::ApplicationHelper
11
13
  Admin::NodeHelper.send :include, RadiantArchiveTabsExtension::Admin::NodeHelper
12
14
  Admin::PagesController.send :include, RadiantArchiveTabsExtension::Admin::PagesController
13
15
 
@@ -3,36 +3,31 @@ module RadiantArchiveTabsExtension
3
3
  module NodeHelper
4
4
  def self.included(base)
5
5
  base.class_eval do
6
- # TODO: duplicated in pages_controller
7
- def extracted?(page)
8
- page.class == ArchivePage
9
- end
10
-
11
- alias_method_chain :expanded, :extract
12
- alias_method_chain :expander, :extract
13
- alias_method_chain :children_class, :extract
14
- alias_method_chain :children_for, :extract
6
+ alias_method_chain :expanded, :archive
7
+ alias_method_chain :expander, :archive
8
+ alias_method_chain :children_class, :archive
9
+ alias_method_chain :children_for, :archive
15
10
  end
16
11
  end
17
12
 
18
13
  # Never render the children on admin/pages
19
- def expanded_with_extract
20
- extracted?(@current_node) ? false : expanded_without_extract
14
+ def expanded_with_archive
15
+ archive_page?(@current_node) ? false : expanded_without_archive
21
16
  end
22
17
 
23
18
  # Don't display the expander arrow on admin/pages
24
- def expander_with_extract(level)
25
- extracted?(@current_node) ? '' : expander_without_extract(level)
19
+ def expander_with_archive(level)
20
+ archive_page?(@current_node) ? '' : expander_without_archive(level)
26
21
  end
27
22
 
28
23
  # Force the no_children class to diable the SiteMapBehavior js on admin/pages
29
- def children_class_with_extract
30
- extracted?(@current_node) ? ' no_children' : children_class_without_extract
24
+ def children_class_with_archive
25
+ archive_page?(@current_node) ? ' no_children' : children_class_without_archive
31
26
  end
32
27
 
33
28
  # Disable adding children on the index page, admin/pages/:page_id/children
34
- def children_for_with_extract(page)
35
- page.respond_to?(:parent) && extracted?(page.parent) ? [] : children_for_without_extract(page)
29
+ def children_for_with_archive(page)
30
+ page.respond_to?(:parent) && archive_page?(page.parent) ? [] : children_for_without_archive(page)
36
31
  end
37
32
  end
38
33
  end
@@ -3,41 +3,41 @@ module RadiantArchiveTabsExtension
3
3
  module PagesController
4
4
  def self.included(base)
5
5
  base.class_eval do
6
- # TODO: duplicated in node_helper
7
- def extracted?(page)
6
+ # TODO: duplicated in application_helper
7
+ def archive_page?(page)
8
8
  page.class == ArchivePage
9
9
  end
10
10
 
11
- helper_method :extracted?, :index_page_for_model_with_extract
12
- alias_method_chain :load_models, :extract
13
- alias_method_chain :index, :extract
14
- alias_method_chain :index_page_for_model, :extract
11
+ helper_method :archive_page?, :index_page_for_model_with_archive
12
+ alias_method_chain :load_models, :archive
13
+ alias_method_chain :index, :archive
14
+ alias_method_chain :index_page_for_model, :archive
15
15
  end
16
16
  end
17
17
 
18
- def load_models_with_extract
18
+ def load_models_with_archive
19
19
  if params[:page_id]
20
20
  self.model = Page.find(params[:page_id])
21
21
 
22
- if extracted?(self.model)
22
+ if archive_page?(self.model)
23
23
  acts_as_tree_options
24
24
  self.class.paginate_models :per_page => Radiant.config['admin.pagination.per_page']
25
25
  end
26
26
  end
27
27
 
28
- load_models_without_extract
28
+ load_models_without_archive
29
29
  end
30
30
 
31
- def index_with_extract
32
- if extracted?(self.model)
31
+ def index_with_archive
32
+ if archive_page?(self.model)
33
33
  render :action => 'archive_index'
34
34
  else
35
- index_without_extract
35
+ index_without_archive
36
36
  end
37
37
  end
38
38
 
39
- def index_page_for_model_with_extract
40
- if model && extracted?(model.parent)
39
+ def index_page_for_model_with_archive
40
+ if model && archive_page?(model.parent)
41
41
  acts_as_tree_options
42
42
  parts = {:action => "index", :page_id => model.parent_id}
43
43
 
@@ -48,7 +48,7 @@ module RadiantArchiveTabsExtension
48
48
 
49
49
  parts
50
50
  else
51
- index_page_for_model_without_extract
51
+ index_page_for_model_without_archive
52
52
  end
53
53
  end
54
54
 
@@ -0,0 +1,31 @@
1
+ module RadiantArchiveTabsExtension
2
+ module ApplicationHelper
3
+ def self.included(base)
4
+ base.class_eval do
5
+ # TODO: duplicated in pages_controller
6
+ def archive_page?(page)
7
+ page.class == ArchivePage
8
+ end
9
+
10
+ alias_method_chain :current_url?, :archive
11
+ end
12
+ end
13
+
14
+ def current_url_with_archive?(options)
15
+ if current_object.respond_to?(:parent) && archive_page?(current_object.parent)
16
+ parent_url = url_for index_page_for_model_with_archive
17
+
18
+ url = case options
19
+ when Hash
20
+ url_for options
21
+ else
22
+ options.to_s
23
+ end
24
+
25
+ parent_url == clean(url)
26
+ else
27
+ current_url_without_archive?(options)
28
+ end
29
+ end
30
+ end
31
+ end
@@ -1,3 +1,3 @@
1
1
  module RadiantArchiveTabsExtension
2
- VERSION = '1.0.0'
2
+ VERSION = '1.0.1'
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: radiant-archive_tabs-extension
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 0
10
- version: 1.0.0
9
+ - 1
10
+ version: 1.0.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jason Taylor
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-05-23 00:00:00 +10:00
18
+ date: 2011-05-26 00:00:00 +10:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -39,6 +39,7 @@ files:
39
39
  - lib/radiant-archive_tabs-extension.rb
40
40
  - lib/radiant-archive_tabs-extension/admin/node_helper.rb
41
41
  - lib/radiant-archive_tabs-extension/admin/pages_controller.rb
42
+ - lib/radiant-archive_tabs-extension/application_helper.rb
42
43
  - lib/radiant-archive_tabs-extension/version.rb
43
44
  - lib/tasks/archive_tabs_extension_tasks.rake
44
45
  - radiant-archive_tabs-extension.gemspec
@@ -51,7 +52,7 @@ has_rdoc: true
51
52
  homepage: http://github.com/jsntv200/radiant-archive_tabs-extension
52
53
  licenses: []
53
54
 
54
- post_install_message: "\n Edit your Radiant environment.rb file and add the following :\n\n 1. Ensure Archive Tabs is loaded last\n\n config.extensions = [ :all, :archive_tabs ]\n\n 2. Load Archive Tabs by adding the gem\n\n config.gem 'radiant-archive_tabs-extension', :version => '1.0.0'\n "
55
+ post_install_message: "\n Edit your Radiant environment.rb file and add the following :\n\n 1. Ensure Archive Tabs is loaded last\n\n config.extensions = [ :all, :archive_tabs ]\n\n 2. Load Archive Tabs by adding the gem\n\n config.gem 'radiant-archive_tabs-extension', :version => '1.0.1'\n "
55
56
  rdoc_options: []
56
57
 
57
58
  require_paths:
@@ -77,7 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
77
78
  requirements: []
78
79
 
79
80
  rubyforge_project:
80
- rubygems_version: 1.5.0
81
+ rubygems_version: 1.6.2
81
82
  signing_key:
82
83
  specification_version: 3
83
84
  summary: Archive tabs extension for Radiant CMS