radiant-dashboard-extension 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/HELP.md +5 -0
- data/HELP_developer.md +83 -0
- data/README +6 -0
- data/Rakefile +136 -0
- data/VERSION +1 -0
- data/app/controllers/admin/dashboard_controller.rb +14 -0
- data/app/helpers/admin/dashboard_helper.rb +19 -0
- data/app/views/admin/dashboard/index.html.haml +92 -0
- data/cucumber.yml +1 -0
- data/dashboard_extension.rb +57 -0
- data/features/support/env.rb +16 -0
- data/features/support/paths.rb +14 -0
- data/lib/tasks/dashboard_extension_tasks.rake +39 -0
- data/public/stylesheets/admin/dashboard.css +46 -0
- data/spec/controllers/dashboard_controller_spec.rb +32 -0
- data/spec/datasets/dashboard_dataset.rb +21 -0
- data/spec/helpers/dashboard_helper_spec.rb +5 -0
- data/spec/models/page_spec.rb +15 -0
- data/spec/spec.opts +6 -0
- data/spec/spec_helper.rb +36 -0
- data/spec/views/admin/dashboard/index_view_spec.rb +26 -0
- metadata +88 -0
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
.svn
|
data/HELP.md
ADDED
@@ -0,0 +1,5 @@
|
|
1
|
+
Your Dashboard shows you the latest activity in your system. It is not a place
|
2
|
+
to find everything, but a place to see what's been happening recently.
|
3
|
+
|
4
|
+
Other installed extensions may also provide information in addition to the recent
|
5
|
+
activity with your site's pages.
|
data/HELP_developer.md
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
You can provide details about recent activity for other areas of your site,
|
2
|
+
or for other extensions in your system.
|
3
|
+
|
4
|
+
Dashboard comes with regions that you may edit just like any other area of
|
5
|
+
the Radiant interface.
|
6
|
+
|
7
|
+
## For Extension Developers
|
8
|
+
|
9
|
+
First, be sure to load Dashboard first if you are adding regions to the view.
|
10
|
+
Set up your `config/environment.rb` like
|
11
|
+
|
12
|
+
config.extensions = [:dashboard, :all]
|
13
|
+
|
14
|
+
Because extensions are loaded alphabetically (the order of their names in `vendor/extensions`)
|
15
|
+
An extension such as the [Blog](http://ext.radiantcms.org/extensions/30-blog) extension may
|
16
|
+
add a region but due to the alphabetical loading (blog comes before dashboard) the Dashboard
|
17
|
+
regions have not yet been initialized, and the Blog regions will not appear. To avoid this,
|
18
|
+
setup your extensions to load in the proper order.
|
19
|
+
|
20
|
+
### Dashboard Regions
|
21
|
+
|
22
|
+
If you would like to provide some information about your extension to users
|
23
|
+
but the information doesn't present the need for another tab in the main
|
24
|
+
navigation of the admin area, you can easily add your information to the
|
25
|
+
Dashboard instead.
|
26
|
+
|
27
|
+
Here's an example used by [Site Watcher](http://ext.radiantcms.org/extensions/41-site-watcher)
|
28
|
+
|
29
|
+
|
30
|
+
def activate
|
31
|
+
if admin.respond_to?(:dashboard)
|
32
|
+
admin.dashboard.index.add :extensions, 'popular_pages'
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
Site Watcher adds Radius tags to the system to list popular pages on your
|
37
|
+
public website. It's not necessary for the extension to list these pages
|
38
|
+
for site editors, but it would be convenient. So Dashboard fills the gap of
|
39
|
+
providing a small area to display information for Site Watcher when a main
|
40
|
+
navigation tab would be unnecessary.
|
41
|
+
|
42
|
+
For another example of its use, see [Featured Pages](http://ext.radiantcms.org/extensions/42-featured-pages)
|
43
|
+
|
44
|
+
### Dashboard Helper
|
45
|
+
|
46
|
+
Dashboard comes with a simple helper to display the name of the user who
|
47
|
+
most recently update a particular object. You may use `updater_name_for(your_object)`
|
48
|
+
|
49
|
+
By default the `updater_name_for` helper will find the name of the user
|
50
|
+
listed as the `updated_by_id`. If that field is empty, it will find the user
|
51
|
+
listed as the `created_by_id`. If that field is empty, it will display
|
52
|
+
"Radiant System" as the updaters name.
|
53
|
+
|
54
|
+
If you need a more complex result, or if you would like to provide some
|
55
|
+
other default result, you may user the `associations`, `attribute`, and
|
56
|
+
`not_found` arguments:
|
57
|
+
|
58
|
+
updater_name_for(page, :associations => [:reviewed_by_id, :approved_by_id], :attribute => :login, :not_found => 'Nobody')
|
59
|
+
|
60
|
+
The `updater_name_for` method will loop through the `:associations` in the
|
61
|
+
order that they are provided, if the association exists it will ask for the
|
62
|
+
provided `:attribute` and if none of these are found it will display the
|
63
|
+
`:not_found` argument.
|
64
|
+
|
65
|
+
The above example assumes a theoretical extension that adds the fields
|
66
|
+
`reviewed_by_id` and `approved_by_id` to the pages table. If those fields
|
67
|
+
are empty (or NULL) in the database, the result would be "Nobody"
|
68
|
+
|
69
|
+
If none of these are provided the default values will be `[:updated_by, :created_by]`,
|
70
|
+
`:name` and `Radiant System`.
|
71
|
+
|
72
|
+
### CSS
|
73
|
+
|
74
|
+
Each default Dashboard module is defined in HTML as:
|
75
|
+
|
76
|
+
<div id="..." class="dashboard_module">
|
77
|
+
<h2>...Title...</h2>
|
78
|
+
<p>...optional message...</p>
|
79
|
+
... your details...
|
80
|
+
</div>
|
81
|
+
|
82
|
+
If you would like to keep your modules up to date with the default CSS, be sure
|
83
|
+
to use this structure and to include the class `dashboard_module`.
|
data/README
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,136 @@
|
|
1
|
+
begin
|
2
|
+
require 'jeweler'
|
3
|
+
Jeweler::Tasks.new do |gem|
|
4
|
+
gem.name = "radiant-dashboard-extension"
|
5
|
+
gem.summary = %Q{Dashboard Extension for Radiant CMS}
|
6
|
+
gem.description = %Q{Describe your extension here}
|
7
|
+
gem.email = "jim@saturnflyer.com"
|
8
|
+
gem.homepage = "http://github.com/saturnflyer/radiant-dashboard-extension"
|
9
|
+
gem.authors = ["Jim Gay"]
|
10
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
11
|
+
end
|
12
|
+
rescue LoadError
|
13
|
+
puts "Jeweler (or a dependency) not available. This is only required if you plan to package dashboard as a gem."
|
14
|
+
end
|
15
|
+
|
16
|
+
# In rails 1.2, plugins aren't available in the path until they're loaded.
|
17
|
+
# Check to see if the rspec plugin is installed first and require
|
18
|
+
# it if it is. If not, use the gem version.
|
19
|
+
|
20
|
+
# Determine where the RSpec plugin is by loading the boot
|
21
|
+
unless defined? RADIANT_ROOT
|
22
|
+
ENV["RAILS_ENV"] = "test"
|
23
|
+
case
|
24
|
+
when ENV["RADIANT_ENV_FILE"]
|
25
|
+
require File.dirname(ENV["RADIANT_ENV_FILE"]) + "/boot"
|
26
|
+
when File.dirname(__FILE__) =~ %r{vendor/radiant/vendor/extensions}
|
27
|
+
require "#{File.expand_path(File.dirname(__FILE__) + "/../../../../../")}/config/boot"
|
28
|
+
else
|
29
|
+
require "#{File.expand_path(File.dirname(__FILE__) + "/../../../")}/config/boot"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
require 'rake'
|
34
|
+
require 'rake/rdoctask'
|
35
|
+
require 'rake/testtask'
|
36
|
+
|
37
|
+
rspec_base = File.expand_path(RADIANT_ROOT + '/vendor/plugins/rspec/lib')
|
38
|
+
$LOAD_PATH.unshift(rspec_base) if File.exist?(rspec_base)
|
39
|
+
require 'spec/rake/spectask'
|
40
|
+
require 'cucumber'
|
41
|
+
require 'cucumber/rake/task'
|
42
|
+
|
43
|
+
# Cleanup the RADIANT_ROOT constant so specs will load the environment
|
44
|
+
Object.send(:remove_const, :RADIANT_ROOT)
|
45
|
+
|
46
|
+
extension_root = File.expand_path(File.dirname(__FILE__))
|
47
|
+
|
48
|
+
task :default => :spec
|
49
|
+
task :stats => "spec:statsetup"
|
50
|
+
|
51
|
+
desc "Run all specs in spec directory"
|
52
|
+
Spec::Rake::SpecTask.new(:spec) do |t|
|
53
|
+
t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
|
54
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
55
|
+
end
|
56
|
+
|
57
|
+
task :features => 'spec:integration'
|
58
|
+
|
59
|
+
namespace :spec do
|
60
|
+
desc "Run all specs in spec directory with RCov"
|
61
|
+
Spec::Rake::SpecTask.new(:rcov) do |t|
|
62
|
+
t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
|
63
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
64
|
+
t.rcov = true
|
65
|
+
t.rcov_opts = ['--exclude', 'spec', '--rails']
|
66
|
+
end
|
67
|
+
|
68
|
+
desc "Print Specdoc for all specs"
|
69
|
+
Spec::Rake::SpecTask.new(:doc) do |t|
|
70
|
+
t.spec_opts = ["--format", "specdoc", "--dry-run"]
|
71
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
72
|
+
end
|
73
|
+
|
74
|
+
[:models, :controllers, :views, :helpers].each do |sub|
|
75
|
+
desc "Run the specs under spec/#{sub}"
|
76
|
+
Spec::Rake::SpecTask.new(sub) do |t|
|
77
|
+
t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
|
78
|
+
t.spec_files = FileList["spec/#{sub}/**/*_spec.rb"]
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
desc "Run the Cucumber features"
|
83
|
+
Cucumber::Rake::Task.new(:integration) do |t|
|
84
|
+
t.fork = true
|
85
|
+
t.cucumber_opts = ['--format', (ENV['CUCUMBER_FORMAT'] || 'pretty')]
|
86
|
+
# t.feature_pattern = "#{extension_root}/features/**/*.feature"
|
87
|
+
t.profile = "default"
|
88
|
+
end
|
89
|
+
|
90
|
+
# Setup specs for stats
|
91
|
+
task :statsetup do
|
92
|
+
require 'code_statistics'
|
93
|
+
::STATS_DIRECTORIES << %w(Model\ specs spec/models)
|
94
|
+
::STATS_DIRECTORIES << %w(View\ specs spec/views)
|
95
|
+
::STATS_DIRECTORIES << %w(Controller\ specs spec/controllers)
|
96
|
+
::STATS_DIRECTORIES << %w(Helper\ specs spec/views)
|
97
|
+
::CodeStatistics::TEST_TYPES << "Model specs"
|
98
|
+
::CodeStatistics::TEST_TYPES << "View specs"
|
99
|
+
::CodeStatistics::TEST_TYPES << "Controller specs"
|
100
|
+
::CodeStatistics::TEST_TYPES << "Helper specs"
|
101
|
+
::STATS_DIRECTORIES.delete_if {|a| a[0] =~ /test/}
|
102
|
+
end
|
103
|
+
|
104
|
+
namespace :db do
|
105
|
+
namespace :fixtures do
|
106
|
+
desc "Load fixtures (from spec/fixtures) into the current environment's database. Load specific fixtures using FIXTURES=x,y"
|
107
|
+
task :load => :environment do
|
108
|
+
require 'active_record/fixtures'
|
109
|
+
ActiveRecord::Base.establish_connection(RAILS_ENV.to_sym)
|
110
|
+
(ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/) : Dir.glob(File.join(RAILS_ROOT, 'spec', 'fixtures', '*.{yml,csv}'))).each do |fixture_file|
|
111
|
+
Fixtures.create_fixtures('spec/fixtures', File.basename(fixture_file, '.*'))
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
desc 'Generate documentation for the dashboard extension.'
|
119
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
120
|
+
rdoc.rdoc_dir = 'rdoc'
|
121
|
+
rdoc.title = 'DashboardExtension'
|
122
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
123
|
+
rdoc.rdoc_files.include('README')
|
124
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
125
|
+
end
|
126
|
+
|
127
|
+
# For extensions that are in transition
|
128
|
+
desc 'Test the dashboard extension.'
|
129
|
+
Rake::TestTask.new(:test) do |t|
|
130
|
+
t.libs << 'lib'
|
131
|
+
t.pattern = 'test/**/*_test.rb'
|
132
|
+
t.verbose = true
|
133
|
+
end
|
134
|
+
|
135
|
+
# Load any custom rakefiles for extension
|
136
|
+
Dir[File.dirname(__FILE__) + '/tasks/*.rake'].sort.each { |f| require f }
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.2.0
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class Admin::DashboardController < ApplicationController
|
2
|
+
def index
|
3
|
+
@template_name = 'index'
|
4
|
+
@current_user_published_pages = current_user.pages.published.recently_updated.find(:all, :limit => 10)
|
5
|
+
@current_user_draft_pages = current_user.pages.drafts.by_updated.find(:all, :limit => 10)
|
6
|
+
|
7
|
+
@updated_pages = Page.recently_updated.find(:all, :limit => 10)
|
8
|
+
@draft_pages = Page.drafts.by_updated.find(:all, :limit => 10)
|
9
|
+
@reviewed_pages = Page.reviewed.by_updated.find(:all, :limit => 10)
|
10
|
+
|
11
|
+
@updated_snippets = Snippet.recently_updated.find(:all, :limit => 10, :order => 'updated_at DESC') # default_order override
|
12
|
+
@updated_layouts = Layout.recently_updated.find(:all, :limit => 10, :order => 'updated_at DESC') # default_order override
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Admin::DashboardHelper
|
2
|
+
def updater_name_for(obj, options={})
|
3
|
+
associations = *options[:associations] || [:updated_by, :created_by]
|
4
|
+
attribute = options[:attribute] || :name
|
5
|
+
not_found = options[:not_found] || 'Radiant System'
|
6
|
+
answer = ""
|
7
|
+
for association in associations
|
8
|
+
if obj.respond_to?(association.to_sym)
|
9
|
+
if obj.send(association.to_sym).nil?
|
10
|
+
answer = not_found
|
11
|
+
else
|
12
|
+
answer = obj.send(association.to_sym).send(attribute.to_sym)
|
13
|
+
break
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
answer
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
- render_region :main do |main|
|
2
|
+
- main.header
|
3
|
+
- main.current_user_draft_pages do
|
4
|
+
- unless @current_user_draft_pages.blank?
|
5
|
+
#current_user_draft_pages.dashboard_module
|
6
|
+
%h2 Your Draft Pages
|
7
|
+
= render_region :current_user_draft_pages_top
|
8
|
+
%ul
|
9
|
+
- @current_user_draft_pages.each do |page|
|
10
|
+
%li
|
11
|
+
%span.title= page.title
|
12
|
+
%span.details
|
13
|
+
= "Updated by #{updater_name_for(page)} #{time_ago_in_words page.updated_at.to_time} ago."
|
14
|
+
= link_to "Edit", edit_admin_page_path(page)
|
15
|
+
= render_region :current_user_draft_pages_bottom
|
16
|
+
- main.current_user_published_pages do
|
17
|
+
- unless @current_user_published_pages.blank?
|
18
|
+
#current_user_published_pages_top.dashboard_module
|
19
|
+
%h2 Your Recently Published Pages
|
20
|
+
= render_region :current_user_published_pages_top
|
21
|
+
%ul
|
22
|
+
- @current_user_published_pages.each do |page|
|
23
|
+
%li
|
24
|
+
- if page.virtual? or !page.published?
|
25
|
+
%span.virtual.title= page.title
|
26
|
+
- else
|
27
|
+
%span.title= link_to page.title, page.url
|
28
|
+
%span.details
|
29
|
+
= "Updated by #{updater_name_for(page)} #{time_ago_in_words page.updated_at.to_time} ago."
|
30
|
+
= link_to "Edit", edit_admin_page_path(page)
|
31
|
+
= render_region :current_user_published_pages_bottom
|
32
|
+
- main.draft_pages do
|
33
|
+
- unless @draft_pages.blank?
|
34
|
+
#draft_pages.dashboard_module
|
35
|
+
%h2 Draft Pages
|
36
|
+
%ul
|
37
|
+
- @draft_pages.each do |page|
|
38
|
+
%li
|
39
|
+
%span.title= page.title
|
40
|
+
%span.details
|
41
|
+
= "Updated by #{updater_name_for(page)} #{time_ago_in_words page.updated_at.to_time} ago."
|
42
|
+
= link_to "Edit", edit_admin_page_path(page)
|
43
|
+
- main.reviewed_pages do
|
44
|
+
- unless @reviewed_pages.blank?
|
45
|
+
#reviewed_pages.dashboard_module
|
46
|
+
%h2 Recently Reviewed Pages
|
47
|
+
%ul
|
48
|
+
- @reviewed_pages.each do |page|
|
49
|
+
%li
|
50
|
+
%span.title= page.title
|
51
|
+
%span.details
|
52
|
+
= "Updated by #{updater_name_for(page)} #{time_ago_in_words page.updated_at.to_time} ago."
|
53
|
+
= link_to "Edit", page_edit_path(page)
|
54
|
+
- main.updated_pages do
|
55
|
+
- unless @updated_pages.blank?
|
56
|
+
#updated_pages.dashboard_module
|
57
|
+
%h2 Recently Updated Pages
|
58
|
+
%ul
|
59
|
+
- @updated_pages.each do |page|
|
60
|
+
%li
|
61
|
+
- if page.virtual? or !page.published?
|
62
|
+
%span.virtual.title= page.title
|
63
|
+
- else
|
64
|
+
%span.title= link_to page.title, page.url
|
65
|
+
%span.details
|
66
|
+
= "Updated by #{updater_name_for(page)} #{time_ago_in_words page.updated_at.to_time} ago."
|
67
|
+
= link_to "Edit", edit_admin_page_path(page)
|
68
|
+
- main.updated_snippets do
|
69
|
+
- unless @updated_snippets.blank?
|
70
|
+
#updated_snippets.dashboard_module
|
71
|
+
%h2 Recently Updated Snippets
|
72
|
+
%ul
|
73
|
+
- @updated_snippets.each do |snippet|
|
74
|
+
%li
|
75
|
+
%span.title= snippet.name
|
76
|
+
%span.details
|
77
|
+
= "Updated by #{updater_name_for(snippet)} #{time_ago_in_words snippet.updated_at.to_time} ago."
|
78
|
+
= link_to "Edit", edit_admin_snippet_path(snippet)
|
79
|
+
- main.updated_layouts do
|
80
|
+
- if (designer? or admin?) and !@updated_layouts.blank?
|
81
|
+
#updated_layouts.dashboard_module
|
82
|
+
%h2 Recently Updated Layouts
|
83
|
+
%ul
|
84
|
+
- @updated_layouts.each do |layout|
|
85
|
+
%li
|
86
|
+
%span.title= layout.name
|
87
|
+
%span.details
|
88
|
+
= "Updated by #{updater_name_for(layout)} #{time_ago_in_words layout.updated_at.to_time} ago."
|
89
|
+
= link_to "Edit", edit_admin_layout_path(layout)
|
90
|
+
= render_region :extensions
|
91
|
+
|
92
|
+
- include_stylesheet 'admin/dashboard'
|
data/cucumber.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
default: --format progress features --tags ~@proposed,~@in_progress
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# Uncomment this if you reference any of your controllers in activate
|
2
|
+
# require_dependency 'application'
|
3
|
+
|
4
|
+
class DashboardExtension < Radiant::Extension
|
5
|
+
version "#{File.read(File.expand_path(File.dirname(__FILE__)) + '/VERSION')}"
|
6
|
+
description "Dashboard provides a way to view recent activity in Radiant and gives small extensions a place to grow."
|
7
|
+
url "http://saturnflyer.com/"
|
8
|
+
|
9
|
+
define_routes do |map|
|
10
|
+
map.dashboard 'admin/dashboard/:action', :controller => 'admin/dashboard'
|
11
|
+
end
|
12
|
+
|
13
|
+
def activate
|
14
|
+
tab "Content" do
|
15
|
+
add_item 'Dashboard', "/admin/dashboard", :before => 'Pages'
|
16
|
+
end
|
17
|
+
Radiant::AdminUI.class_eval do
|
18
|
+
attr_accessor :dashboard
|
19
|
+
end
|
20
|
+
admin.dashboard = load_default_dashboard_regions
|
21
|
+
User.class_eval {
|
22
|
+
has_many :pages, :foreign_key => :created_by_id unless self.respond_to?(:pages)
|
23
|
+
}
|
24
|
+
Page.class_eval {
|
25
|
+
named_scope :drafts, :conditions => ['status_id = ?',Status['Draft'].id]
|
26
|
+
named_scope :reviewed, :conditions => ["status_id = ?", Status['Reviewed'].id ]
|
27
|
+
named_scope :published, :conditions => ["status_id = ?", Status['Published'].id ]
|
28
|
+
named_scope :recently_updated, lambda{{:conditions => ['updated_at > ?', 1.week.ago ], :order => 'updated_at DESC'}}
|
29
|
+
named_scope :by_updated, :order => 'updated_at DESC'
|
30
|
+
}
|
31
|
+
Snippet.class_eval {
|
32
|
+
named_scope :recently_updated, lambda{{:conditions => ['updated_at > ?', 1.week.ago ], :order => 'updated_at DESC, name'}}
|
33
|
+
}
|
34
|
+
Layout.class_eval {
|
35
|
+
named_scope :recently_updated, lambda{{:conditions => ['updated_at > ?', 1.week.ago ], :order => 'updated_at DESC'}}
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
def deactivate
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def load_default_dashboard_regions
|
45
|
+
returning OpenStruct.new do |dashboard|
|
46
|
+
dashboard.index = Radiant::AdminUI::RegionSet.new do |index|
|
47
|
+
index.main.concat %w{current_user_draft_pages current_user_published_pages draft_pages reviewed_pages updated_pages updated_snippets updated_layouts}
|
48
|
+
index.current_user_draft_pages_top.concat %w{}
|
49
|
+
index.current_user_draft_pages_bottom.concat %w{}
|
50
|
+
index.current_user_published_pages_top.concat %w{}
|
51
|
+
index.current_user_published_pages_bottom.concat %w{}
|
52
|
+
index.extensions.concat %w{}
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# Sets up the Rails environment for Cucumber
|
2
|
+
ENV["RAILS_ENV"] = "test"
|
3
|
+
# Extension root
|
4
|
+
extension_env = File.expand_path(File.dirname(__FILE__) + '/../../../../../config/environment')
|
5
|
+
require extension_env+'.rb'
|
6
|
+
|
7
|
+
Dir.glob(File.join(RADIANT_ROOT, "features", "**", "*.rb")).each {|step| require step}
|
8
|
+
|
9
|
+
Cucumber::Rails::World.class_eval do
|
10
|
+
include Dataset
|
11
|
+
datasets_directory "#{RADIANT_ROOT}/spec/datasets"
|
12
|
+
Dataset::Resolver.default = Dataset::DirectoryResolver.new("#{RADIANT_ROOT}/spec/datasets", File.dirname(__FILE__) + '/../../spec/datasets', File.dirname(__FILE__) + '/../datasets')
|
13
|
+
self.datasets_database_dump_path = "#{Rails.root}/tmp/dataset"
|
14
|
+
|
15
|
+
# dataset :dashboardx
|
16
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
namespace :radiant do
|
2
|
+
namespace :extensions do
|
3
|
+
namespace :dashboard do
|
4
|
+
|
5
|
+
desc "Runs the migration and update tasks of the Dashboard extension"
|
6
|
+
task :install => [:environment, :migrate, :update]
|
7
|
+
|
8
|
+
desc "Runs the migration of the Dashboard extension"
|
9
|
+
task :migrate => :environment do
|
10
|
+
require 'radiant/extension_migrator'
|
11
|
+
if ENV["VERSION"]
|
12
|
+
DashboardExtension.migrator.migrate(ENV["VERSION"].to_i)
|
13
|
+
else
|
14
|
+
DashboardExtension.migrator.migrate
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
desc "Copies public assets of the Dashboard to the instance public/ directory."
|
19
|
+
task :update => :environment do
|
20
|
+
is_svn_or_dir = proc {|path| path =~ /\.svn/ || File.directory?(path) }
|
21
|
+
puts "Copying assets from DashboardExtension"
|
22
|
+
Dir[DashboardExtension.root + "/public/**/*"].reject(&is_svn_or_dir).each do |file|
|
23
|
+
path = file.sub(DashboardExtension.root, '')
|
24
|
+
directory = File.dirname(path)
|
25
|
+
mkdir_p RAILS_ROOT + directory, :verbose => false
|
26
|
+
cp file, RAILS_ROOT + path, :verbose => false
|
27
|
+
end
|
28
|
+
unless DashboardExtension.root.starts_with? RAILS_ROOT # don't need to copy vendored tasks
|
29
|
+
puts "Copying rake tasks from DashboardExtension"
|
30
|
+
local_tasks_path = File.join(RAILS_ROOT, %w(lib tasks))
|
31
|
+
mkdir_p local_tasks_path, :verbose => false
|
32
|
+
Dir[File.join DashboardExtension.root, %w(lib tasks *.rake)].each do |file|
|
33
|
+
cp file, local_tasks_path, :verbose => false
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
.dashboard_module {
|
2
|
+
background: #efefef;
|
3
|
+
float: left;
|
4
|
+
margin: 0 20px 20px 0;
|
5
|
+
width: 450px;
|
6
|
+
}
|
7
|
+
.dashboard_module h2 {
|
8
|
+
background: #fff;
|
9
|
+
border-bottom: 3px solid #666;
|
10
|
+
color: #000;
|
11
|
+
font-size: 1.2em;
|
12
|
+
font-weight: normal;
|
13
|
+
margin: 0;
|
14
|
+
padding: 5px 5px 0 0;
|
15
|
+
}
|
16
|
+
.dashboard_module p {
|
17
|
+
margin: 5px;
|
18
|
+
}
|
19
|
+
.dashboard_module ul, .dashboard_module ul li {
|
20
|
+
padding: 0;
|
21
|
+
margin: 0;
|
22
|
+
list-style: none;
|
23
|
+
}
|
24
|
+
.dashboard_module ul li {
|
25
|
+
padding: 5px;
|
26
|
+
border-bottom: 1px solid #ddd;
|
27
|
+
}
|
28
|
+
.dashboard_module li:hover { background: #ffc; }
|
29
|
+
.dashboard_module ul li.alternate {
|
30
|
+
color: #666;
|
31
|
+
}
|
32
|
+
.dashboard_module ul li.alternate a {
|
33
|
+
color: #555;
|
34
|
+
}
|
35
|
+
.dashboard_module ul li span {
|
36
|
+
display: block;
|
37
|
+
}
|
38
|
+
.dashboard_module ul li span.virtual {
|
39
|
+
font-style: italic;
|
40
|
+
}
|
41
|
+
.dashboard_module ul li span.details {
|
42
|
+
color: #999;
|
43
|
+
font-size: 0.8em;
|
44
|
+
}
|
45
|
+
.dashboard_module a.addition { color: #393; }
|
46
|
+
.dashboard_module a.subtraction { color: #933; }
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe Admin::DashboardController do
|
4
|
+
dataset :users, :dashboard, :snippets
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
@date_time = DateTime.strptime("12 October 2008", "%d %B %Y")
|
8
|
+
Time.stub!(:now).and_return(@date_time.to_time)
|
9
|
+
assigns[:updated_pages] = Page.recently_updated
|
10
|
+
login_as :admin
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "/index with GET" do
|
14
|
+
before(:each) do
|
15
|
+
get 'index'
|
16
|
+
end
|
17
|
+
it "should collect updated_pages" do
|
18
|
+
assigns[:updated_pages].should == Page.recently_updated.find(:all, :limit => 10)
|
19
|
+
end
|
20
|
+
it "should find pages no earlier than 7 days ago" do
|
21
|
+
assigns[:updated_pages].each do |page|
|
22
|
+
page.updated_at.should >= @date_time.to_time - 7.days
|
23
|
+
end
|
24
|
+
end
|
25
|
+
it "should limit the collected pages to 10" do
|
26
|
+
assigns[:updated_pages].size.should <= 10
|
27
|
+
end
|
28
|
+
it "should collect updated_snippets" do
|
29
|
+
assigns[:updated_snippets].should == Snippet.recently_updated
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class DashboardDataset < Dataset::Base
|
2
|
+
uses :home_page, :users
|
3
|
+
|
4
|
+
def load
|
5
|
+
create_page "Recent" do
|
6
|
+
create_page "Taylor", :created_by_id => users(:admin), :created_at => DateTime.parse('1849-03-04 12:12:12'), :updated_at => DateTime.parse('2008-10-07 12:12:23')
|
7
|
+
create_page "Polk", :created_by_id => users(:admin), :created_at => DateTime.parse('1845-03-04 12:12:12'), :updated_at => DateTime.parse('2008-10-07 12:12:22')
|
8
|
+
create_page "Tyler", :created_by_id => users(:admin), :created_at => DateTime.parse('1841-04-04 12:12:12'), :updated_at => DateTime.parse('2008-10-07 12:12:21')
|
9
|
+
create_page "Harrison", :created_by_id => users(:admin), :created_at => DateTime.parse('1841-03-04 12:12:12'), :updated_at => DateTime.parse('2008-10-06 12:12:20')
|
10
|
+
create_page "Van Buren", :created_by_id => users(:admin), :created_at => DateTime.parse('1837-03-04 12:12:12'), :updated_at => DateTime.parse('2008-10-06 12:12:19')
|
11
|
+
create_page "Jackson", :created_by_id => users(:admin), :created_at => DateTime.parse('1829-03-04 12:12:12'), :updated_at => DateTime.parse('2008-10-06 12:12:18')
|
12
|
+
create_page "Quincy Adams", :created_by_id => users(:admin), :created_at => DateTime.parse('1825-03-04 12:12:12'), :updated_at => DateTime.parse('2008-10-05 12:12:17')
|
13
|
+
create_page "Monroe", :created_by_id => users(:admin), :created_at => DateTime.parse('1817-03-04 12:12:12'), :updated_at => DateTime.parse('2008-10-05 12:12:16')
|
14
|
+
create_page "Madison", :created_by_id => users(:admin), :created_at => DateTime.parse('1809-03-04 12:12:12'), :updated_at => DateTime.parse('2008-10-05 12:12:15')
|
15
|
+
create_page "Jefferson", :created_by_id => users(:admin), :created_at => DateTime.parse('1801-03-04 12:12:12'), :updated_at => DateTime.parse('2008-10-04 12:12:14')
|
16
|
+
create_page "Adams", :created_by_id => users(:admin), :created_at => DateTime.parse('1797-03-04 12:12:12'), :updated_at => DateTime.parse('2008-10-01 12:12:13')
|
17
|
+
create_page "Washington", :created_by_id => users(:admin), :created_at => DateTime.parse('1789-04-30 12:12:12'), :updated_at => DateTime.parse('2008-10-01 12:12:12')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe Page do
|
4
|
+
before do
|
5
|
+
@date_time = DateTime.strptime("12 October 2008", "%d %B %Y")
|
6
|
+
Time.stub!(:now).and_return(@date_time.to_time)
|
7
|
+
end
|
8
|
+
describe "recently_updated" do
|
9
|
+
it 'should return pages updated less than one week ago' do
|
10
|
+
Page.recently_updated.each do |page|
|
11
|
+
page.updated_at.should > @date_time - 1.week
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
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
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
|
3
|
+
describe "/admin/dashboard/index" do
|
4
|
+
dataset :dashboard
|
5
|
+
before do
|
6
|
+
template.stub!(:include_stylesheet).and_return(true)
|
7
|
+
@updated_pages = pages(:recent).children
|
8
|
+
assigns[:updated_pages] = @updated_pages
|
9
|
+
render '/admin/dashboard/index'
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should have a list of recent pages" do
|
13
|
+
response.should have_tag('ul') do
|
14
|
+
with_tag('li',/Taylor/)
|
15
|
+
with_tag('li',/Polk/)
|
16
|
+
with_tag('li',/Tyler/)
|
17
|
+
with_tag('li',/Harrison/)
|
18
|
+
with_tag('li',/Van Buren/)
|
19
|
+
with_tag('li',/Jackson/)
|
20
|
+
with_tag('li',/Quincy Adams/)
|
21
|
+
with_tag('li',/Monroe/)
|
22
|
+
with_tag('li',/Madison/)
|
23
|
+
with_tag('li',/Jefferson/)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: radiant-dashboard-extension
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 1
|
7
|
+
- 2
|
8
|
+
- 0
|
9
|
+
version: 1.2.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Jim Gay
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-03-05 00:00:00 -05:00
|
18
|
+
default_executable:
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description: Describe your extension here
|
22
|
+
email: jim@saturnflyer.com
|
23
|
+
executables: []
|
24
|
+
|
25
|
+
extensions: []
|
26
|
+
|
27
|
+
extra_rdoc_files:
|
28
|
+
- README
|
29
|
+
files:
|
30
|
+
- .gitignore
|
31
|
+
- HELP.md
|
32
|
+
- HELP_developer.md
|
33
|
+
- README
|
34
|
+
- Rakefile
|
35
|
+
- VERSION
|
36
|
+
- app/controllers/admin/dashboard_controller.rb
|
37
|
+
- app/helpers/admin/dashboard_helper.rb
|
38
|
+
- app/views/admin/dashboard/index.html.haml
|
39
|
+
- cucumber.yml
|
40
|
+
- dashboard_extension.rb
|
41
|
+
- features/support/env.rb
|
42
|
+
- features/support/paths.rb
|
43
|
+
- lib/tasks/dashboard_extension_tasks.rake
|
44
|
+
- public/stylesheets/admin/dashboard.css
|
45
|
+
- spec/controllers/dashboard_controller_spec.rb
|
46
|
+
- spec/datasets/dashboard_dataset.rb
|
47
|
+
- spec/helpers/dashboard_helper_spec.rb
|
48
|
+
- spec/models/page_spec.rb
|
49
|
+
- spec/spec.opts
|
50
|
+
- spec/spec_helper.rb
|
51
|
+
- spec/views/admin/dashboard/index_view_spec.rb
|
52
|
+
has_rdoc: true
|
53
|
+
homepage: http://github.com/saturnflyer/radiant-dashboard-extension
|
54
|
+
licenses: []
|
55
|
+
|
56
|
+
post_install_message:
|
57
|
+
rdoc_options:
|
58
|
+
- --charset=UTF-8
|
59
|
+
require_paths:
|
60
|
+
- lib
|
61
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
segments:
|
66
|
+
- 0
|
67
|
+
version: "0"
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
segments:
|
73
|
+
- 0
|
74
|
+
version: "0"
|
75
|
+
requirements: []
|
76
|
+
|
77
|
+
rubyforge_project:
|
78
|
+
rubygems_version: 1.3.6
|
79
|
+
signing_key:
|
80
|
+
specification_version: 3
|
81
|
+
summary: Dashboard Extension for Radiant CMS
|
82
|
+
test_files:
|
83
|
+
- spec/controllers/dashboard_controller_spec.rb
|
84
|
+
- spec/datasets/dashboard_dataset.rb
|
85
|
+
- spec/helpers/dashboard_helper_spec.rb
|
86
|
+
- spec/models/page_spec.rb
|
87
|
+
- spec/spec_helper.rb
|
88
|
+
- spec/views/admin/dashboard/index_view_spec.rb
|