radiant-archive_tabs-extension 1.0.0
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.
- data/.gitignore +3 -0
- data/README.md +38 -0
- data/Rakefile +109 -0
- data/app/views/admin/pages/_redirect_cancel.html.haml +8 -0
- data/app/views/admin/pages/archive_index.html.haml +36 -0
- data/archive_tabs_extension.rb +24 -0
- data/config/locales/en.yml +4 -0
- data/lib/radiant-archive_tabs-extension/admin/node_helper.rb +39 -0
- data/lib/radiant-archive_tabs-extension/admin/pages_controller.rb +61 -0
- data/lib/radiant-archive_tabs-extension/version.rb +3 -0
- data/lib/radiant-archive_tabs-extension.rb +2 -0
- data/lib/tasks/archive_tabs_extension_tasks.rake +55 -0
- data/radiant-archive_tabs-extension.gemspec +31 -0
- data/spec/controllers/admin/pages_controller_spec.rb +70 -0
- data/spec/datasets/archive_pages.rb +12 -0
- data/spec/helpers/admin/node_helper_spec.rb +31 -0
- data/spec/spec.opts +6 -0
- data/spec/spec_helper.rb +36 -0
- metadata +89 -0
data/.gitignore
ADDED
data/README.md
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# Archive Tabs
|
2
|
+
|
3
|
+
Display Archive pages in their own paginated tab.
|
4
|
+
|
5
|
+
Archive page types often contain the most child pages, with Radiant's tree based navigation this can often lead to very long lists. Archive tabs creates a tab for each Archive Page Type which contains a paginated list of it's children.
|
6
|
+
|
7
|
+
Archive pages will no longer display their children on the main Pages index page.
|
8
|
+
|
9
|
+
Tested against Radiant v1.0.0 and probably won't be back ported to older versions
|
10
|
+
|
11
|
+
It's a monkey patch so use at your own risk.
|
12
|
+
|
13
|
+
|
14
|
+
## Installation
|
15
|
+
|
16
|
+
Install as a gem :
|
17
|
+
|
18
|
+
```
|
19
|
+
gem install radiant-archive_tabs-extension
|
20
|
+
```
|
21
|
+
|
22
|
+
Ensure Archive Tabs is loaded last :
|
23
|
+
|
24
|
+
```
|
25
|
+
config.extensions = [ :all, :archive_tabs ]
|
26
|
+
```
|
27
|
+
|
28
|
+
Load Archive Tabs by adding the gem :
|
29
|
+
|
30
|
+
```
|
31
|
+
config.gem 'radiant-archive_tabs-extension', :version => '1.0.0'
|
32
|
+
```
|
33
|
+
|
34
|
+
|
35
|
+
## To Do
|
36
|
+
|
37
|
+
- Add search filter ?
|
38
|
+
- Look into why will_paginate isn't creating the correct urls, currently using a js hack to fix this
|
data/Rakefile
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
# Determine where the RSpec plugin is by loading the boot
|
2
|
+
unless defined? RADIANT_ROOT
|
3
|
+
ENV["RAILS_ENV"] = "test"
|
4
|
+
case
|
5
|
+
when ENV["RADIANT_ENV_FILE"]
|
6
|
+
require File.dirname(ENV["RADIANT_ENV_FILE"]) + "/boot"
|
7
|
+
when File.dirname(__FILE__) =~ %r{vendor/radiant/vendor/extensions}
|
8
|
+
require "#{File.expand_path(File.dirname(__FILE__) + "/../../../../../")}/config/boot"
|
9
|
+
else
|
10
|
+
require "#{File.expand_path(File.dirname(__FILE__) + "/../../../")}/config/boot"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
require 'rake'
|
15
|
+
require 'rake/rdoctask'
|
16
|
+
require 'rake/testtask'
|
17
|
+
|
18
|
+
rspec_base = File.expand_path(RADIANT_ROOT + '/vendor/plugins/rspec/lib')
|
19
|
+
$LOAD_PATH.unshift(rspec_base) if File.exist?(rspec_base)
|
20
|
+
require 'spec/rake/spectask'
|
21
|
+
require 'cucumber'
|
22
|
+
require 'cucumber/rake/task'
|
23
|
+
|
24
|
+
# Cleanup the RADIANT_ROOT constant so specs will load the environment
|
25
|
+
Object.send(:remove_const, :RADIANT_ROOT)
|
26
|
+
|
27
|
+
extension_root = File.expand_path(File.dirname(__FILE__))
|
28
|
+
|
29
|
+
task :default => [:spec, :features]
|
30
|
+
task :stats => "spec:statsetup"
|
31
|
+
|
32
|
+
desc "Run all specs in spec directory"
|
33
|
+
Spec::Rake::SpecTask.new(:spec) do |t|
|
34
|
+
t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
|
35
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
36
|
+
end
|
37
|
+
|
38
|
+
task :features => 'spec:integration'
|
39
|
+
|
40
|
+
namespace :spec do
|
41
|
+
desc "Run all specs in spec directory with RCov"
|
42
|
+
Spec::Rake::SpecTask.new(:rcov) do |t|
|
43
|
+
t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
|
44
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
45
|
+
t.rcov = true
|
46
|
+
t.rcov_opts = ['--exclude', 'spec', '--rails']
|
47
|
+
end
|
48
|
+
|
49
|
+
desc "Print Specdoc for all specs"
|
50
|
+
Spec::Rake::SpecTask.new(:doc) do |t|
|
51
|
+
t.spec_opts = ["--format", "specdoc", "--dry-run"]
|
52
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
53
|
+
end
|
54
|
+
|
55
|
+
[:models, :controllers, :views, :helpers].each do |sub|
|
56
|
+
desc "Run the specs under spec/#{sub}"
|
57
|
+
Spec::Rake::SpecTask.new(sub) do |t|
|
58
|
+
t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
|
59
|
+
t.spec_files = FileList["spec/#{sub}/**/*_spec.rb"]
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
desc "Run the Cucumber features"
|
64
|
+
Cucumber::Rake::Task.new(:integration) do |t|
|
65
|
+
t.fork = true
|
66
|
+
t.cucumber_opts = ['--format', (ENV['CUCUMBER_FORMAT'] || 'pretty')]
|
67
|
+
# t.feature_pattern = "#{extension_root}/features/**/*.feature"
|
68
|
+
t.profile = "default"
|
69
|
+
end
|
70
|
+
|
71
|
+
# Setup specs for stats
|
72
|
+
task :statsetup do
|
73
|
+
require 'code_statistics'
|
74
|
+
::STATS_DIRECTORIES << %w(Model\ specs spec/models)
|
75
|
+
::STATS_DIRECTORIES << %w(View\ specs spec/views)
|
76
|
+
::STATS_DIRECTORIES << %w(Controller\ specs spec/controllers)
|
77
|
+
::STATS_DIRECTORIES << %w(Helper\ specs spec/views)
|
78
|
+
::CodeStatistics::TEST_TYPES << "Model specs"
|
79
|
+
::CodeStatistics::TEST_TYPES << "View specs"
|
80
|
+
::CodeStatistics::TEST_TYPES << "Controller specs"
|
81
|
+
::CodeStatistics::TEST_TYPES << "Helper specs"
|
82
|
+
::STATS_DIRECTORIES.delete_if {|a| a[0] =~ /test/}
|
83
|
+
end
|
84
|
+
|
85
|
+
namespace :db do
|
86
|
+
namespace :fixtures do
|
87
|
+
desc "Load fixtures (from spec/fixtures) into the current environment's database. Load specific fixtures using FIXTURES=x,y"
|
88
|
+
task :load => :environment do
|
89
|
+
require 'active_record/fixtures'
|
90
|
+
ActiveRecord::Base.establish_connection(RAILS_ENV.to_sym)
|
91
|
+
(ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/) : Dir.glob(File.join(RAILS_ROOT, 'spec', 'fixtures', '*.{yml,csv}'))).each do |fixture_file|
|
92
|
+
Fixtures.create_fixtures('spec/fixtures', File.basename(fixture_file, '.*'))
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
desc 'Generate documentation for the Archive Tabs extension.'
|
100
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
101
|
+
rdoc.rdoc_dir = 'rdoc'
|
102
|
+
rdoc.title = 'ArchiveTabsExtension'
|
103
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
104
|
+
rdoc.rdoc_files.include('README')
|
105
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
106
|
+
end
|
107
|
+
|
108
|
+
# Load any custom rakefiles for extension
|
109
|
+
Dir[File.dirname(__FILE__) + '/tasks/*.rake'].sort.each { |f| require f }
|
@@ -0,0 +1,36 @@
|
|
1
|
+
- @page_title = t('pages') + ' - ' + default_page_title
|
2
|
+
|
3
|
+
.outset
|
4
|
+
= render_region :top
|
5
|
+
%table.index#pages{:summary=>t('page_hierarchy')}
|
6
|
+
%thead
|
7
|
+
%tr
|
8
|
+
- render_region :sitemap_head do |sitemap_head|
|
9
|
+
- sitemap_head.title_column_header do
|
10
|
+
%th.name= t('page')
|
11
|
+
- sitemap_head.status_column_header do
|
12
|
+
%th.status= t('status')
|
13
|
+
- sitemap_head.actions_column_header do
|
14
|
+
%th.actions= t('modify')
|
15
|
+
%tbody
|
16
|
+
- if models
|
17
|
+
- models.each do |child|
|
18
|
+
= render_node child
|
19
|
+
- else
|
20
|
+
%tr
|
21
|
+
%td.empty{:colspan => admin.page.index.node.length}= t('no_pages')
|
22
|
+
= render_region :bottom
|
23
|
+
|
24
|
+
#actions
|
25
|
+
= pagination_for(models, :depaginate => false)
|
26
|
+
|
27
|
+
%ul
|
28
|
+
%li= link_to image('plus') + ' ' + t('add') + ' ' + model.title.singularize, new_admin_page_child_path, :class => 'action_button'
|
29
|
+
|
30
|
+
:javascript
|
31
|
+
function redirect_pagination(element) {
|
32
|
+
window.location = Event.element(event).readAttribute('href').replace('.html', '')
|
33
|
+
event.stop()
|
34
|
+
}
|
35
|
+
|
36
|
+
$$('.pagination a').invoke('observe', 'click', redirect_pagination)
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'radiant-archive_tabs-extension/version'
|
2
|
+
require 'radiant-archive_tabs-extension/admin/node_helper'
|
3
|
+
require 'radiant-archive_tabs-extension/admin/pages_controller'
|
4
|
+
|
5
|
+
class ArchiveTabsExtension < Radiant::Extension
|
6
|
+
version RadiantArchiveTabsExtension::VERSION
|
7
|
+
description "Display Archive pages in their own paginated tab"
|
8
|
+
url "http://github.com/jsntv200/radiant-archive_tabs-extension"
|
9
|
+
|
10
|
+
def activate
|
11
|
+
Admin::NodeHelper.send :include, RadiantArchiveTabsExtension::Admin::NodeHelper
|
12
|
+
Admin::PagesController.send :include, RadiantArchiveTabsExtension::Admin::PagesController
|
13
|
+
|
14
|
+
admin.page.edit.add :main, 'redirect_cancel', :after => 'form_bottom'
|
15
|
+
|
16
|
+
if Page.table_exists?
|
17
|
+
tab 'Content' do
|
18
|
+
ArchivePage.all(:order => 'slug ASC').each do |page|
|
19
|
+
add_item page.title, "/admin/pages/#{page.id}/children"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module RadiantArchiveTabsExtension
|
2
|
+
module Admin
|
3
|
+
module NodeHelper
|
4
|
+
def self.included(base)
|
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
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
# Never render the children on admin/pages
|
19
|
+
def expanded_with_extract
|
20
|
+
extracted?(@current_node) ? false : expanded_without_extract
|
21
|
+
end
|
22
|
+
|
23
|
+
# Don't display the expander arrow on admin/pages
|
24
|
+
def expander_with_extract(level)
|
25
|
+
extracted?(@current_node) ? '' : expander_without_extract(level)
|
26
|
+
end
|
27
|
+
|
28
|
+
# 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
|
31
|
+
end
|
32
|
+
|
33
|
+
# 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)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module RadiantArchiveTabsExtension
|
2
|
+
module Admin
|
3
|
+
module PagesController
|
4
|
+
def self.included(base)
|
5
|
+
base.class_eval do
|
6
|
+
# TODO: duplicated in node_helper
|
7
|
+
def extracted?(page)
|
8
|
+
page.class == ArchivePage
|
9
|
+
end
|
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
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def load_models_with_extract
|
19
|
+
if params[:page_id]
|
20
|
+
self.model = Page.find(params[:page_id])
|
21
|
+
|
22
|
+
if extracted?(self.model)
|
23
|
+
acts_as_tree_options
|
24
|
+
self.class.paginate_models :per_page => Radiant.config['admin.pagination.per_page']
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
load_models_without_extract
|
29
|
+
end
|
30
|
+
|
31
|
+
def index_with_extract
|
32
|
+
if extracted?(self.model)
|
33
|
+
render :action => 'archive_index'
|
34
|
+
else
|
35
|
+
index_without_extract
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def index_page_for_model_with_extract
|
40
|
+
if model && extracted?(model.parent)
|
41
|
+
acts_as_tree_options
|
42
|
+
parts = {:action => "index", :page_id => model.parent_id}
|
43
|
+
|
44
|
+
if i = model.self_and_siblings.index(model)
|
45
|
+
p = (i / Radiant.config['admin.pagination.per_page'].to_i) + 1
|
46
|
+
parts[:p] = p if p && p > 1
|
47
|
+
end
|
48
|
+
|
49
|
+
parts
|
50
|
+
else
|
51
|
+
index_page_for_model_without_extract
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
# TODO: Probably a better way to do this but it works
|
56
|
+
def acts_as_tree_options
|
57
|
+
Page.acts_as_tree :order => 'virtual ASC, published_at DESC'
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
namespace :radiant do
|
2
|
+
namespace :extensions do
|
3
|
+
namespace :archive_tabs do
|
4
|
+
|
5
|
+
desc "Runs the migration of the Archive Tabs extension"
|
6
|
+
task :migrate => :environment do
|
7
|
+
require 'radiant/extension_migrator'
|
8
|
+
if ENV["VERSION"]
|
9
|
+
ArchiveTabsExtension.migrator.migrate(ENV["VERSION"].to_i)
|
10
|
+
Rake::Task['db:schema:dump'].invoke
|
11
|
+
else
|
12
|
+
ArchiveTabsExtension.migrator.migrate
|
13
|
+
Rake::Task['db:schema:dump'].invoke
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "Copies public assets of the Extract to the instance public/ directory."
|
18
|
+
task :update => :environment do
|
19
|
+
is_svn_or_dir = proc {|path| path =~ /\.svn/ || File.directory?(path) }
|
20
|
+
puts "Copying assets from Archive Tabs extension"
|
21
|
+
Dir[ArchiveTabsExtension.root + "/public/**/*"].reject(&is_svn_or_dir).each do |file|
|
22
|
+
path = file.sub(ArchiveTabsExtension.root, '')
|
23
|
+
directory = File.dirname(path)
|
24
|
+
mkdir_p RAILS_ROOT + directory, :verbose => false
|
25
|
+
cp file, RAILS_ROOT + path, :verbose => false
|
26
|
+
end
|
27
|
+
unless ArchiveTabsExtension.root.starts_with? RAILS_ROOT # don't need to copy vendored tasks
|
28
|
+
puts "Copying rake tasks from Archive Tabs extension"
|
29
|
+
local_tasks_path = File.join(RAILS_ROOT, %w(lib tasks))
|
30
|
+
mkdir_p local_tasks_path, :verbose => false
|
31
|
+
Dir[File.join ArchiveTabsExtension.root, %w(lib tasks *.rake)].each do |file|
|
32
|
+
cp file, local_tasks_path, :verbose => false
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
desc "Syncs all available translations for this ext to the English ext master"
|
38
|
+
task :sync => :environment do
|
39
|
+
# The main translation root, basically where English is kept
|
40
|
+
language_root = ArchiveTabsExtension.root + "/config/locales"
|
41
|
+
words = TranslationSupport.get_translation_keys(language_root)
|
42
|
+
|
43
|
+
Dir["#{language_root}/*.yml"].each do |filename|
|
44
|
+
next if filename.match('_available_tags')
|
45
|
+
basename = File.basename(filename, '.yml')
|
46
|
+
puts "Syncing #{basename}"
|
47
|
+
(comments, other) = TranslationSupport.read_file(filename, basename)
|
48
|
+
words.each { |k,v| other[k] ||= words[k] } # Initializing hash variable as empty if it does not exist
|
49
|
+
other.delete_if { |k,v| !words[k] } # Remove if not defined in en.yml
|
50
|
+
TranslationSupport.write_file(filename, basename, comments, other)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "radiant-archive_tabs-extension/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "radiant-archive_tabs-extension"
|
7
|
+
s.version = RadiantArchiveTabsExtension::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Jason Taylor"]
|
10
|
+
s.email = ["jsntv200@gmail.com"]
|
11
|
+
s.homepage = "http://github.com/jsntv200/radiant-archive_tabs-extension"
|
12
|
+
s.summary = %q{Archive tabs extension for Radiant CMS}
|
13
|
+
s.description = %q{Display Archive pages in their own paginated tab}
|
14
|
+
|
15
|
+
s.files = `git ls-files`.split("\n")
|
16
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
18
|
+
s.require_paths = ["lib"]
|
19
|
+
|
20
|
+
s.post_install_message = %{
|
21
|
+
Edit your Radiant environment.rb file and add the following :
|
22
|
+
|
23
|
+
1. Ensure Archive Tabs is loaded last
|
24
|
+
|
25
|
+
config.extensions = [ :all, :archive_tabs ]
|
26
|
+
|
27
|
+
2. Load Archive Tabs by adding the gem
|
28
|
+
|
29
|
+
config.gem 'radiant-archive_tabs-extension', :version => '#{RadiantArchiveTabsExtension::VERSION}'
|
30
|
+
}
|
31
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
describe Admin::PagesController do
|
4
|
+
dataset :users, :archive_pages
|
5
|
+
|
6
|
+
before :each do
|
7
|
+
login_as :existing
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "viewing the admin index" do
|
11
|
+
integrate_views
|
12
|
+
|
13
|
+
before :each do
|
14
|
+
get :index
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should have a secondary navigation" do
|
18
|
+
response.should be_success
|
19
|
+
response.should have_tag('ul#secondary_navigation')
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should have a Pages link" do
|
23
|
+
response.should be_success
|
24
|
+
response.should have_tag('a', :text => 'Pages')
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should have a News link" do
|
28
|
+
response.should be_success
|
29
|
+
response.should have_tag('a', :text => 'News')
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "viewing the admin extract index" do
|
34
|
+
before :each do
|
35
|
+
get :index, :page_id => ArchivePage.first.id
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should be an ArchivePage" do
|
39
|
+
response.should be_success
|
40
|
+
assigns(:page).should be_kind_of(ArchivePage)
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should render the archive_index template" do
|
44
|
+
response.should be_success
|
45
|
+
response.should render_template('archive_index')
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should be paginated" do
|
49
|
+
response.should be_success
|
50
|
+
controller.paginated?.should be_true
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe "#new" do
|
55
|
+
it "should redirect to the archive parent" do
|
56
|
+
get :new, :page_id => page_id(:news)
|
57
|
+
response.should be_success
|
58
|
+
controller.index_page_for_model_with_extract.should == {:action => 'index', :page_id => page_id(:news)}
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe "#edit" do
|
63
|
+
it "should redirect to paginated archive parent" do
|
64
|
+
Admin::PagesController.send :paginate_models, {:per_page => 2}
|
65
|
+
get :edit, :id => pages(:news).children.first.id
|
66
|
+
response.should be_success
|
67
|
+
controller.index_page_for_model_with_extract.should == {:action => 'index', :page_id => page_id(:news), :p => 2}
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class ArchivePagesDataset < Dataset::Base
|
2
|
+
uses :home_page
|
3
|
+
|
4
|
+
def load
|
5
|
+
create_page 'News', :class_name => 'ArchivePage' do
|
6
|
+
create_page 'Article 1', :published_at => DateTime.parse('2000-12-01 08:41:07')
|
7
|
+
create_page 'Article 2', :published_at => DateTime.parse('2001-02-09 08:42:04')
|
8
|
+
create_page 'Article 3', :published_at => DateTime.parse('2001-02-24 12:02:43')
|
9
|
+
create_page 'Article 4', :published_at => DateTime.parse('2001-03-06 03:32:31')
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../../spec_helper"
|
2
|
+
|
3
|
+
describe Admin::NodeHelper do
|
4
|
+
before :each do
|
5
|
+
@archive = mock_model(ArchivePage)
|
6
|
+
@archive.stub!(:extracted?).and_return(true)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should not expand the current node" do
|
10
|
+
assigns[:current_node] = @archive
|
11
|
+
helper.expanded.should be_false
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should have a no_children class for the current node" do
|
15
|
+
assigns[:current_node] = @archive
|
16
|
+
helper.children_class.should == " no_children"
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should not render an arrow for the current node" do
|
20
|
+
assigns[:current_node] = @archive
|
21
|
+
helper.expander(0).should == ""
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should return no children if the parent is an ArchivePage" do
|
25
|
+
@page = mock_model(Page)
|
26
|
+
@page.stub!(:extracted?).and_return(false)
|
27
|
+
@page.stub!(:parent).and_return(@archive)
|
28
|
+
assigns[:current_node] = @page
|
29
|
+
helper.children_for(@page).should == []
|
30
|
+
end
|
31
|
+
end
|
data/spec/spec.opts
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
unless defined? RADIANT_ROOT
|
2
|
+
ENV["RAILS_ENV"] = "test"
|
3
|
+
case
|
4
|
+
when ENV["RADIANT_ENV_FILE"]
|
5
|
+
require ENV["RADIANT_ENV_FILE"]
|
6
|
+
when File.dirname(__FILE__) =~ %r{vendor/radiant/vendor/extensions}
|
7
|
+
require "#{File.expand_path(File.dirname(__FILE__) + "/../../../../../../")}/config/environment"
|
8
|
+
else
|
9
|
+
require "#{File.expand_path(File.dirname(__FILE__) + "/../../../../")}/config/environment"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
require "#{RADIANT_ROOT}/spec/spec_helper"
|
13
|
+
|
14
|
+
Dataset::Resolver.default << (File.dirname(__FILE__) + "/datasets")
|
15
|
+
|
16
|
+
if File.directory?(File.dirname(__FILE__) + "/matchers")
|
17
|
+
Dir[File.dirname(__FILE__) + "/matchers/*.rb"].each {|file| require file }
|
18
|
+
end
|
19
|
+
|
20
|
+
Spec::Runner.configure do |config|
|
21
|
+
# config.use_transactional_fixtures = true
|
22
|
+
# config.use_instantiated_fixtures = false
|
23
|
+
# config.fixture_path = RAILS_ROOT + '/spec/fixtures'
|
24
|
+
|
25
|
+
# You can declare fixtures for each behaviour like this:
|
26
|
+
# describe "...." do
|
27
|
+
# fixtures :table_a, :table_b
|
28
|
+
#
|
29
|
+
# Alternatively, if you prefer to declare them only once, you can
|
30
|
+
# do so here, like so ...
|
31
|
+
#
|
32
|
+
# config.global_fixtures = :table_a, :table_b
|
33
|
+
#
|
34
|
+
# If you declare global fixtures, be aware that they will be declared
|
35
|
+
# for all of your examples, even those that don't use them.
|
36
|
+
end
|
metadata
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: radiant-archive_tabs-extension
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 23
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
- 0
|
10
|
+
version: 1.0.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Jason Taylor
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-05-23 00:00:00 +10:00
|
19
|
+
default_executable:
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description: Display Archive pages in their own paginated tab
|
23
|
+
email:
|
24
|
+
- jsntv200@gmail.com
|
25
|
+
executables: []
|
26
|
+
|
27
|
+
extensions: []
|
28
|
+
|
29
|
+
extra_rdoc_files: []
|
30
|
+
|
31
|
+
files:
|
32
|
+
- .gitignore
|
33
|
+
- README.md
|
34
|
+
- Rakefile
|
35
|
+
- app/views/admin/pages/_redirect_cancel.html.haml
|
36
|
+
- app/views/admin/pages/archive_index.html.haml
|
37
|
+
- archive_tabs_extension.rb
|
38
|
+
- config/locales/en.yml
|
39
|
+
- lib/radiant-archive_tabs-extension.rb
|
40
|
+
- lib/radiant-archive_tabs-extension/admin/node_helper.rb
|
41
|
+
- lib/radiant-archive_tabs-extension/admin/pages_controller.rb
|
42
|
+
- lib/radiant-archive_tabs-extension/version.rb
|
43
|
+
- lib/tasks/archive_tabs_extension_tasks.rake
|
44
|
+
- radiant-archive_tabs-extension.gemspec
|
45
|
+
- spec/controllers/admin/pages_controller_spec.rb
|
46
|
+
- spec/datasets/archive_pages.rb
|
47
|
+
- spec/helpers/admin/node_helper_spec.rb
|
48
|
+
- spec/spec.opts
|
49
|
+
- spec/spec_helper.rb
|
50
|
+
has_rdoc: true
|
51
|
+
homepage: http://github.com/jsntv200/radiant-archive_tabs-extension
|
52
|
+
licenses: []
|
53
|
+
|
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
|
+
rdoc_options: []
|
56
|
+
|
57
|
+
require_paths:
|
58
|
+
- lib
|
59
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
60
|
+
none: false
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
hash: 3
|
65
|
+
segments:
|
66
|
+
- 0
|
67
|
+
version: "0"
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
hash: 3
|
74
|
+
segments:
|
75
|
+
- 0
|
76
|
+
version: "0"
|
77
|
+
requirements: []
|
78
|
+
|
79
|
+
rubyforge_project:
|
80
|
+
rubygems_version: 1.5.0
|
81
|
+
signing_key:
|
82
|
+
specification_version: 3
|
83
|
+
summary: Archive tabs extension for Radiant CMS
|
84
|
+
test_files:
|
85
|
+
- spec/controllers/admin/pages_controller_spec.rb
|
86
|
+
- spec/datasets/archive_pages.rb
|
87
|
+
- spec/helpers/admin/node_helper_spec.rb
|
88
|
+
- spec/spec.opts
|
89
|
+
- spec/spec_helper.rb
|