radiant-help-extension 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/HELP_developer.rdoc +92 -0
- data/README.md +35 -0
- data/Rakefile +109 -0
- data/TODO +6 -0
- data/app/controllers/admin/help_controller.rb +59 -0
- data/app/helpers/admin/help_helper.rb +36 -0
- data/app/models/help_doc.rb +42 -0
- data/app/views/admin/help/_admin_index.html.haml +11 -0
- data/app/views/admin/help/_designer_index.html.haml +20 -0
- data/app/views/admin/help/_docs_introduction.html.haml +2 -0
- data/app/views/admin/help/_editing.html.haml +64 -0
- data/app/views/admin/help/_extension_docs_list.html.haml +9 -0
- data/app/views/admin/help/_organizing.html.haml +7 -0
- data/app/views/admin/help/_other_index.html.haml +2 -0
- data/app/views/admin/help/_regions.html.haml +34 -0
- data/app/views/admin/help/_scripts.js.erb +14 -0
- data/app/views/admin/help/_styles.html.haml +128 -0
- data/app/views/admin/help/_tag_reference.html.haml +6 -0
- data/app/views/admin/help/developing.html.haml +19 -0
- data/app/views/admin/help/extension_doc.html.haml +16 -0
- data/app/views/admin/help/index.html.haml +16 -0
- data/app/views/admin/help/role.html.haml +12 -0
- data/config/initializers/radiant_config.rb +3 -0
- data/config/locales/en.yml +3 -0
- data/config/routes.rb +8 -0
- data/cucumber.yml +1 -0
- data/features/support/env.rb +11 -0
- data/features/support/paths.rb +22 -0
- data/help_extension.rb +86 -0
- data/lib/radiant-help-extension.rb +8 -0
- data/lib/tasks/help_extension_tasks.rake +29 -0
- data/radiant-help-extension.gemspec +29 -0
- data/spec/controllers/admin/help_controller_spec.rb +110 -0
- data/spec/models/help_doc_spec.rb +111 -0
- data/spec/spec.opts +6 -0
- data/spec/spec_helper.rb +36 -0
- metadata +87 -0
@@ -0,0 +1,29 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "radiant-help-extension"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "radiant-help-extension"
|
7
|
+
s.version = RadiantHelpExtension::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = RadiantHelpExtension::AUTHORS
|
10
|
+
s.email = RadiantHelpExtension::EMAIL
|
11
|
+
s.homepage = RadiantHelpExtension::URL
|
12
|
+
s.summary = RadiantHelpExtension::SUMMARY
|
13
|
+
s.description = RadiantHelpExtension::DESCRIPTION
|
14
|
+
|
15
|
+
# Define gem dependencies here.
|
16
|
+
# Don't include a dependency on radiant itself: it causes problems when radiant is in vendor/radiant.
|
17
|
+
# s.add_dependency "something", "~> 1.0.0"
|
18
|
+
# s.add_dependency "radiant-some-extension", "~> 1.0.0"
|
19
|
+
|
20
|
+
ignores = if File.exist?('.gitignore')
|
21
|
+
File.read('.gitignore').split("\n").inject([]) {|a,p| a + Dir[p] }
|
22
|
+
else
|
23
|
+
[]
|
24
|
+
end
|
25
|
+
s.files = Dir['**/*'] - ignores
|
26
|
+
s.test_files = Dir['test/**/*','spec/**/*','features/**/*'] - ignores
|
27
|
+
# s.executables = Dir['bin/*'] - ignores
|
28
|
+
s.require_paths = ["lib"]
|
29
|
+
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
describe Admin::HelpController do
|
4
|
+
# use Radiant datasets
|
5
|
+
dataset :users
|
6
|
+
|
7
|
+
before(:each) do
|
8
|
+
login_as :existing
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "calling index with GET" do
|
12
|
+
it "should render the index template" do
|
13
|
+
get :index
|
14
|
+
response.should render_template('admin/help/index')
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should assign HelpDocs for all users" do
|
18
|
+
@doc = "/path/to/doc/HELP.rdoc"
|
19
|
+
HelpDoc.stub!(:find_for).with(:all).and_return([@doc])
|
20
|
+
get :index
|
21
|
+
assigns[:docs].should == [@doc]
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should set the role to 'all' and assign it to the view" do
|
25
|
+
get :index
|
26
|
+
assigns[:role].should == 'all'
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should get the cms_name from Radiant::Config and assign it to the view" do
|
30
|
+
Radiant::Config.stub!(:[],'admin.title').and_return('Test CMS')
|
31
|
+
get :index
|
32
|
+
assigns[:cms_name].should == 'Test CMS'
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should find all TextFilters and assign them to the view" do
|
36
|
+
TextFilter.stub!(:descendants).and_return([MarkdownFilter, TextileFilter])
|
37
|
+
get :index
|
38
|
+
assigns[:filters].should == [MarkdownFilter, TextileFilter]
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should find all Layouts and assign them to the view" do
|
42
|
+
@layout1 = mock_model(Layout)
|
43
|
+
Layout.stub!(:find).with(:all).and_return([@layout1])
|
44
|
+
get :index
|
45
|
+
assigns[:layouts].should == [@layout1]
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should find the first FileNotFoundPage and assign it to the view" do
|
49
|
+
@page404 = mock_model(Page, :class_name => 'FileNotFoundPage')
|
50
|
+
Page.should_receive(:find).with(:first,{:conditions => {:class_name => 'FileNotFoundPage'}}).and_return(@page404)
|
51
|
+
get :index
|
52
|
+
assigns[:file_not_found_page].should == @page404
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe "calling extension_doc with GET" do
|
57
|
+
it "should load the role from the params and assign it to the view" do
|
58
|
+
get :extension_doc, :extension_name => 'help', :role => 'developer'
|
59
|
+
assigns[:role].should == 'developer'
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should set the role to 'all' if none is present in the params and assign it to the view" do
|
63
|
+
@test_path = '/path'
|
64
|
+
HelpDoc.stub!(:find_for).and_return([@test_path])
|
65
|
+
File.stub!(:read).and_return('') # can't read a non-existant path
|
66
|
+
get :extension_doc, :extension_name => 'help'
|
67
|
+
assigns[:role].should == 'all'
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should find all HelpDocs for the given role and assign them to the view" do
|
71
|
+
@doc1 = "/path/to/test1/HELP_admin.rdoc"
|
72
|
+
@doc2 = "/path/to/test2/HELP_admin.rdoc"
|
73
|
+
File.stub!(:read).and_return('') # can't read a non-existant path
|
74
|
+
HelpDoc.should_receive(:find_for).with("admin").and_return([@doc1,@doc2])
|
75
|
+
HelpDoc.stub!(:find_for).with("admin","test1").and_return([@doc1])
|
76
|
+
get :extension_doc, :extension_name => 'test1', :role => 'admin'
|
77
|
+
assigns[:docs].should == [@doc1,@doc2]
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should get the doc_name from the URL extension_name and assign it to the view" do
|
81
|
+
get :extension_doc, :extension_name => 'help', :role => 'developer'
|
82
|
+
assigns[:doc_name].should == 'Help'
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should find the HelpDoc for the given role and extension_name" do
|
86
|
+
@doc1 = "/path/to/test1/HELP_developer.rdoc"
|
87
|
+
@doc2 = "/path/to/test2/HELP_developer.rdoc"
|
88
|
+
File.stub!(:read).and_return('') # can't read a non-existant path
|
89
|
+
HelpDoc.stub!(:find_for).with("developer").and_return([@doc1,@doc2])
|
90
|
+
HelpDoc.should_receive(:find_for).with("developer","test1").and_return([@doc1])
|
91
|
+
get :extension_doc, :extension_name => 'test1', :role => 'developer'
|
92
|
+
assigns[:doc_path].should == @doc1
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
describe "calling role with GET" do
|
97
|
+
it "should find the HelpDocs for the given role and assign them to the view" do
|
98
|
+
@doc1 = "/path/to/test1/HELP_admin.rdoc"
|
99
|
+
@doc2 = "/path/to/test2/HELP_admin.rdoc"
|
100
|
+
HelpDoc.should_receive(:find_for).with("admin").and_return([@doc1,@doc2])
|
101
|
+
get :role, :role => 'admin'
|
102
|
+
assigns[:docs].should == [@doc1,@doc2]
|
103
|
+
end
|
104
|
+
|
105
|
+
it "should redirect to the help index if given no role" do
|
106
|
+
get :role
|
107
|
+
response.should redirect_to(:action => 'index')
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe HelpDoc, "given existing extension docs" do
|
4
|
+
|
5
|
+
before(:all) do
|
6
|
+
@test_ext_name = "help_rspec_test#{rand(1000)}"
|
7
|
+
@test_dir = "#{RAILS_ROOT}/vendor/extensions/#{@test_ext_name}"
|
8
|
+
FileUtils.mkdir(@test_dir)
|
9
|
+
File.open("#{@test_dir}/HELP", 'wb') {|f| f.write('help for all') }
|
10
|
+
File.open("#{@test_dir}/HELP_developer.rdoc", 'wb') {|f| f.write('== Testing
|
11
|
+
help for developers in rdoc
|
12
|
+
') }
|
13
|
+
File.open("#{@test_dir}/HELP_admin.markdown", 'wb') {|f| f.write('Test
|
14
|
+
----
|
15
|
+
help for admins in **markdown**
|
16
|
+
') }
|
17
|
+
File.open("#{@test_dir}/HELP_imaginary.md", 'wb') {|f| f.write('## Test
|
18
|
+
help for non-existent role in **markdown**
|
19
|
+
') }
|
20
|
+
File.open("#{@test_dir}/HELP_other.textile", 'wb') {|f| f.write('help for _another_ non-existent role in *textile*
|
21
|
+
') }
|
22
|
+
end
|
23
|
+
|
24
|
+
after(:all) do
|
25
|
+
FileUtils.remove_dir(@test_dir)
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "calling find_for" do
|
29
|
+
|
30
|
+
it "should fail to find extension docs with no given role type" do
|
31
|
+
lambda { HelpDoc.find_for() }.should raise_error(ArgumentError)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should find for all users extension docs named 'HELP' with an optional file extension" do
|
35
|
+
lambda do
|
36
|
+
HelpDoc.find_for(:all).each do |doc|
|
37
|
+
raise Exception unless /HELP(\.[\w]+)?$/.match(doc)
|
38
|
+
end
|
39
|
+
end.should_not raise_error(Exception)
|
40
|
+
HelpDoc.find_for(:all).size.should > 0
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should find extension docs for developers named 'HELP_developer' and end with an optional file extension" do
|
44
|
+
lambda do
|
45
|
+
HelpDoc.find_for(:developer).each do |doc|
|
46
|
+
raise Exception unless /HELP_developer/.match(doc)
|
47
|
+
end
|
48
|
+
end.should_not raise_error(Exception)
|
49
|
+
HelpDoc.find_for(:developer).size.should > 0
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should find extension docs for admins named 'HELP_admin' and end with an optional file extension" do
|
53
|
+
lambda do
|
54
|
+
HelpDoc.find_for(:admin).each do |doc|
|
55
|
+
raise Exception unless /HELP_admin(\.[\w]+)?$/.match(doc)
|
56
|
+
end
|
57
|
+
end.should_not raise_error(Exception)
|
58
|
+
HelpDoc.find_for(:admin).size.should > 0
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should find only the given extension's docs when given an extension name" do
|
62
|
+
HelpDoc.find_for(:all, @test_ext_name).size.should == 1
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
describe "calling formatted_contents_from" do
|
68
|
+
|
69
|
+
it "should return formatted contents of a given extension doc in RDoc formatting by default" do
|
70
|
+
test_doc = HelpDoc.find_for(:all, @test_ext_name).first
|
71
|
+
HelpDoc.formatted_contents_from(test_doc).should == "<p>\nhelp for all\n</p>\n"
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should return RDoc formatted contents of a given extension doc ending in '.rdoc'" do
|
75
|
+
test_doc = HelpDoc.find_for(:developer, @test_ext_name).first
|
76
|
+
HelpDoc.formatted_contents_from(test_doc).should == "<h2>Testing</h2>\n<p>\nhelp for developers in rdoc\n</p>\n"
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should return Markdown formatted contents of a given extension doc ending in '.markdown'" do
|
80
|
+
test_doc = HelpDoc.find_for(:admin, @test_ext_name).first
|
81
|
+
HelpDoc.formatted_contents_from(test_doc).should == "<h2>Test</h2>\n<p>help for admins in <strong>markdown</strong></p>\n"
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should return Markdown formatted contents of a given extension doc ending in '.md'" do
|
85
|
+
test_doc = HelpDoc.find_for(:imaginary, @test_ext_name).first
|
86
|
+
HelpDoc.formatted_contents_from(test_doc).should == "<h2>Test</h2>\n<p>help for non-existent role in <strong>markdown</strong></p>\n"
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should return Textile formatted contents of a given extension doc ending in '.textile'" do
|
90
|
+
test_doc = HelpDoc.find_for(:other, @test_ext_name).first
|
91
|
+
HelpDoc.formatted_contents_from(test_doc).should == "<p>help for <em>another</em> non-existent role in <strong>textile</strong></p>"
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
|
96
|
+
it "should call parsed_rdoc and return HTML from RDoc formatted text" do
|
97
|
+
test_doc = HelpDoc.find_for(:developer, @test_ext_name).first
|
98
|
+
HelpDoc.parsed_rdoc(test_doc).should == "<h2>Testing</h2>\n<p>\nhelp for developers in rdoc\n</p>\n"
|
99
|
+
end
|
100
|
+
|
101
|
+
it "should call parsed_markdown and return HTML from Markdown formatted text" do
|
102
|
+
test_doc = HelpDoc.find_for(:admin, @test_ext_name).first
|
103
|
+
HelpDoc.parsed_markdown(test_doc).should == "<h2>Test</h2>\n<p>help for admins in <strong>markdown</strong></p>\n"
|
104
|
+
end
|
105
|
+
|
106
|
+
it "should call parsed_textile and return HTML from Textile formatted text" do
|
107
|
+
test_doc = HelpDoc.find_for(:other, @test_ext_name).first
|
108
|
+
HelpDoc.parsed_textile(test_doc).should == "<p>help for <em>another</em> non-existent role in <strong>textile</strong></p>"
|
109
|
+
end
|
110
|
+
|
111
|
+
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,87 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: radiant-help-extension
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jim Gay
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-03-02 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Help Documentation for Radiant CMS!
|
15
|
+
email:
|
16
|
+
- jim@saturnflyer.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- app/controllers/admin/help_controller.rb
|
22
|
+
- app/helpers/admin/help_helper.rb
|
23
|
+
- app/models/help_doc.rb
|
24
|
+
- app/views/admin/help/_admin_index.html.haml
|
25
|
+
- app/views/admin/help/_designer_index.html.haml
|
26
|
+
- app/views/admin/help/_docs_introduction.html.haml
|
27
|
+
- app/views/admin/help/_editing.html.haml
|
28
|
+
- app/views/admin/help/_extension_docs_list.html.haml
|
29
|
+
- app/views/admin/help/_organizing.html.haml
|
30
|
+
- app/views/admin/help/_other_index.html.haml
|
31
|
+
- app/views/admin/help/_regions.html.haml
|
32
|
+
- app/views/admin/help/_scripts.js.erb
|
33
|
+
- app/views/admin/help/_styles.html.haml
|
34
|
+
- app/views/admin/help/_tag_reference.html.haml
|
35
|
+
- app/views/admin/help/developing.html.haml
|
36
|
+
- app/views/admin/help/extension_doc.html.haml
|
37
|
+
- app/views/admin/help/index.html.haml
|
38
|
+
- app/views/admin/help/role.html.haml
|
39
|
+
- config/initializers/radiant_config.rb
|
40
|
+
- config/locales/en.yml
|
41
|
+
- config/routes.rb
|
42
|
+
- cucumber.yml
|
43
|
+
- features/support/env.rb
|
44
|
+
- features/support/paths.rb
|
45
|
+
- HELP_developer.rdoc
|
46
|
+
- help_extension.rb
|
47
|
+
- lib/radiant-help-extension.rb
|
48
|
+
- lib/tasks/help_extension_tasks.rake
|
49
|
+
- radiant-help-extension.gemspec
|
50
|
+
- Rakefile
|
51
|
+
- README.md
|
52
|
+
- spec/controllers/admin/help_controller_spec.rb
|
53
|
+
- spec/models/help_doc_spec.rb
|
54
|
+
- spec/spec.opts
|
55
|
+
- spec/spec_helper.rb
|
56
|
+
- TODO
|
57
|
+
homepage: https://github.com/saturnflyer/radiant-help-extension
|
58
|
+
licenses: []
|
59
|
+
post_install_message:
|
60
|
+
rdoc_options: []
|
61
|
+
require_paths:
|
62
|
+
- lib
|
63
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
65
|
+
requirements:
|
66
|
+
- - ! '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
71
|
+
requirements:
|
72
|
+
- - ! '>='
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
requirements: []
|
76
|
+
rubyforge_project:
|
77
|
+
rubygems_version: 1.8.11
|
78
|
+
signing_key:
|
79
|
+
specification_version: 3
|
80
|
+
summary: Help for Radiant CMS
|
81
|
+
test_files:
|
82
|
+
- spec/controllers/admin/help_controller_spec.rb
|
83
|
+
- spec/models/help_doc_spec.rb
|
84
|
+
- spec/spec.opts
|
85
|
+
- spec/spec_helper.rb
|
86
|
+
- features/support/env.rb
|
87
|
+
- features/support/paths.rb
|