radiant-help-extension 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. data/HELP_developer.rdoc +92 -0
  2. data/README.md +35 -0
  3. data/Rakefile +109 -0
  4. data/TODO +6 -0
  5. data/app/controllers/admin/help_controller.rb +59 -0
  6. data/app/helpers/admin/help_helper.rb +36 -0
  7. data/app/models/help_doc.rb +42 -0
  8. data/app/views/admin/help/_admin_index.html.haml +11 -0
  9. data/app/views/admin/help/_designer_index.html.haml +20 -0
  10. data/app/views/admin/help/_docs_introduction.html.haml +2 -0
  11. data/app/views/admin/help/_editing.html.haml +64 -0
  12. data/app/views/admin/help/_extension_docs_list.html.haml +9 -0
  13. data/app/views/admin/help/_organizing.html.haml +7 -0
  14. data/app/views/admin/help/_other_index.html.haml +2 -0
  15. data/app/views/admin/help/_regions.html.haml +34 -0
  16. data/app/views/admin/help/_scripts.js.erb +14 -0
  17. data/app/views/admin/help/_styles.html.haml +128 -0
  18. data/app/views/admin/help/_tag_reference.html.haml +6 -0
  19. data/app/views/admin/help/developing.html.haml +19 -0
  20. data/app/views/admin/help/extension_doc.html.haml +16 -0
  21. data/app/views/admin/help/index.html.haml +16 -0
  22. data/app/views/admin/help/role.html.haml +12 -0
  23. data/config/initializers/radiant_config.rb +3 -0
  24. data/config/locales/en.yml +3 -0
  25. data/config/routes.rb +8 -0
  26. data/cucumber.yml +1 -0
  27. data/features/support/env.rb +11 -0
  28. data/features/support/paths.rb +22 -0
  29. data/help_extension.rb +86 -0
  30. data/lib/radiant-help-extension.rb +8 -0
  31. data/lib/tasks/help_extension_tasks.rake +29 -0
  32. data/radiant-help-extension.gemspec +29 -0
  33. data/spec/controllers/admin/help_controller_spec.rb +110 -0
  34. data/spec/models/help_doc_spec.rb +111 -0
  35. data/spec/spec.opts +6 -0
  36. data/spec/spec_helper.rb +36 -0
  37. metadata +87 -0
@@ -0,0 +1,9 @@
1
+ - unless @docs.blank?
2
+ .Docs
3
+ %h2= "#{(@role.titleize + ' ') unless @role == 'all'}Help Documents"
4
+ = render :partial => 'docs_introduction'
5
+ %ul
6
+ - @docs.each do |doc|
7
+ %li
8
+ - doc_name = doc_extension_dir(doc)
9
+ = link_to doc_name.titleize, help_extension_doc_url(doc_name, @role)
@@ -0,0 +1,7 @@
1
+ %h2 Organizing and Creating Pages
2
+ %p Pages are organized in a parent/child relationship.
3
+ %p That means that if you want an "About Us" section on your website and you want to have a page for each member of your staff, each staff page would be a 'child' of the "About Us" page.
4
+ %h3 Creating
5
+ %p To create a page, you add a child to another page. Your home page, for example, is the root of your website: all pages stem from your home page and it lives at yoursite.com/
6
+ %p A child of the home page lives at yoursite.com/about and a child of that child lives at yoursite.com/about/management-team.
7
+ %p If you think of your pages in terms of a family, you'll see that yoursite.com/about and yoursite.com/services are siblings. That is, they are both children of the home page.
@@ -0,0 +1,2 @@
1
+ %h2 Standard Information wasn't found
2
+ %p= "We could not find any information for the role '#{@custom_role}'."
@@ -0,0 +1,34 @@
1
+ .Regions
2
+ %h2 Current Regions
3
+ %p Below is a list of editable regions from your installation of the application interface
4
+ - admin.instance_variables.sort.each do |reg|
5
+ .ui_region
6
+ %h3{:class => 'region_header'}= reg.to_s.gsub(/^@/,'').camelize
7
+ - region_instance = admin.send(:instance_variable_get, reg)
8
+ - if region_instance.respond_to?(:marshal_dump)
9
+ - unless region_instance.marshal_dump.blank?
10
+ %ul
11
+ - region_instance.marshal_dump.each do |key, value|
12
+ %li
13
+ %h4= key
14
+ - value_regions = value.send(:instance_variable_get, "@regions")
15
+ - unless value_regions.blank?
16
+ %ul
17
+ - value_regions.each do |vr_key, vr_value|
18
+ %li
19
+ = vr_key
20
+ - unless vr_value.blank?
21
+ %ul
22
+ - vr_value.each do |endpoint|
23
+ %li= endpoint
24
+ - else
25
+ - unless region_instance.blank?
26
+ %ul
27
+ - region_instance.each do |reg|
28
+ %li
29
+ %h4
30
+ = reg.name
31
+ - reg.each do |r|
32
+ %p
33
+ = link_to r.name, r.url
34
+ = "(#{r.url})"
@@ -0,0 +1,14 @@
1
+ document.observe('dom:loaded', function(){
2
+ $$('div.ui_region').each(function(element){
3
+ element.down('ul').hide();
4
+ element.observe('click',function(e){
5
+ this.down('ul').toggle();
6
+ });
7
+ element.observe('mouseover',function(e){
8
+ e.target.up('div.ui_region').addClassName('over');
9
+ });
10
+ element.observe('mouseout',function(e){
11
+ e.target.up('div.ui_region').removeClassName('over');
12
+ });
13
+ });
14
+ })
@@ -0,0 +1,128 @@
1
+ :sass
2
+ .region_header
3
+ padding: 3px
4
+ .ui_region
5
+ background: rgb(245, 241, 226)
6
+ padding: 0 0 10px
7
+ margin: 0 10px
8
+ .over
9
+ background: rgb(234, 227, 197)
10
+ cursor: hand
11
+ cursor: pointer
12
+ .Help
13
+ color: #222
14
+ font-size: 16px
15
+ overflow: hidden
16
+ min-width: 900px
17
+ .HelpNav
18
+ background: rgb(245, 241, 226)
19
+ border: 1px solid rgb(234, 227, 197)
20
+ margin: 0 0 12px 0
21
+ padding: 5px 0
22
+ p
23
+ margin: 0
24
+ padding: 0
25
+ a
26
+ color: #000
27
+ line-height: 1.8
28
+ margin: 0 -4px 0 1px
29
+ padding: 9px 10px
30
+ text-decoration: none
31
+ a:hover
32
+ color: #000
33
+ background: #fff
34
+ .Extras
35
+ float: right
36
+ margin-top: 40px
37
+ padding-bottom: 10px
38
+ width: 38%
39
+ .Docs, .Regions
40
+ background: rgb(245, 241, 226)
41
+ border-bottom: 2px solid rgb(234, 227, 197)
42
+ margin: 0
43
+ *
44
+ margin: 0 10px 4px 10px
45
+ * *
46
+ margin: 0
47
+ h2
48
+ background: rgb(234, 227, 197)
49
+ color: #000
50
+ font-weight: normal
51
+ margin: 0 0 5px 0
52
+ padding: 2px 5px
53
+ .over
54
+ background: rgb(234, 227, 197)
55
+ p, li
56
+ color: #333
57
+ line-height: 1.3
58
+ margin: 0 10px 10px 0
59
+ .MainTopics
60
+ float: left
61
+ margin: 0 0 0 8px
62
+ width: 60%
63
+ min-height: 300px
64
+ h1
65
+ margin-bottom: 12px
66
+ h2
67
+ border-bottom: 4px solid #444
68
+ font-weight: normal
69
+ font-size: 1.4em
70
+ margin: 24px 0 6px 0
71
+ padding: 2px 2px 6px 0
72
+ h3
73
+ color: #222
74
+ font-size: 1.1em
75
+ margin: 6px 0 6px 0
76
+ h4
77
+ color: #222
78
+ font-size: 0.95em
79
+ margin: 3px 0 3px 0
80
+ padding: 3px 0
81
+ p, li
82
+ color: #444
83
+ line-height: 1.4
84
+ margin: 0 0 6px 10px
85
+ ul, ol
86
+ margin: 0 0 0 20px
87
+ ul
88
+ margin: 0 0 0 20px
89
+ list-style: square
90
+ ol
91
+ margin: 0 0 0 28px
92
+ list-style-type: decimal
93
+ code
94
+ background: #eee
95
+ color: #222
96
+ line-height: inherit
97
+ padding: 4px 2px
98
+ pre
99
+ background: #eee
100
+ color: #222
101
+ line-height: 1.4
102
+ margin: 16px 0 16px 0
103
+ padding: 12px 0 12px 12px
104
+ width: 99%
105
+ white-space: pre-wrap
106
+ word-wrap: break-word
107
+ @media print
108
+ #header, #footer, .HelpNav, .Extras, hr
109
+ display: none
110
+ #footer
111
+ display: none
112
+ .MainTopics
113
+ min-width: 90%
114
+ body
115
+ background:-color white
116
+ font-family: "Cambria", "Hoefler Text", "Georgia", "Times New Roman", times, serif
117
+ font-size: 12pt
118
+ a:link:after, a:visited:after
119
+ color: #222
120
+ content: " : " attr(href) ""
121
+ font-size: 9pt
122
+ font-weight: normal
123
+ div.popup
124
+ border: none
125
+ .reference
126
+ border: none
127
+ width: 50em
128
+ height: 100%
@@ -0,0 +1,6 @@
1
+ .reference
2
+ .tag_description
3
+ %h4= "<r:#{tag_name} />"
4
+ %div= description
5
+ %p= "Available on #{classes.map{|c| c.titleize.gsub(/ Page$/, '')}.sort.to_sentence}."
6
+ .Additions= render_region tag_name
@@ -0,0 +1,19 @@
1
+ - content_for :page_css do
2
+ = render :partial => 'styles.html.haml'
3
+ - content_for :page_scripts do
4
+ = render :partial => 'scripts.js.erb'
5
+
6
+ .Help
7
+ .MainTopics
8
+ - render_region :regions do |shard|
9
+ - shard.regions_introduction do
10
+ %h2 Altering Regions
11
+ %p Listed below are the main regions that may be altered with 'partial' injection. You may inject partials into the interface by adding code such this into your extension's activate method:
12
+ %pre admin.help.index.add :main, "client_welcome", :before => "introduction"
13
+ %ul
14
+ %li "admin.help.index" refers to the main help page (the help index) and ".add" is called to add information to the section provided in the next argument.
15
+ %li ":main" is the argument that specifies which section will receive your partial.
16
+ %li "client_welcome" is the partial that you want to add and should be located in your extension directory app/views/admin/help/_client_welcome.html.haml
17
+ %li :before => "introduction" will place your partial before the introduction region (or you could do :after). This is optional, and if left out, your partial will be appended to the ":main" section.
18
+ - shard.regions_map do
19
+ = render 'regions'
@@ -0,0 +1,16 @@
1
+ - content_for :page_css do
2
+ = render :partial => 'styles.html.haml'
3
+ - content_for :page_scripts do
4
+ = render :partial => 'scripts.js.erb'
5
+
6
+ .Help
7
+ .MainTopics
8
+ - unless @doc.blank?
9
+ %h1= "#{@doc_name} Extension"
10
+ - if @doc_path
11
+ = @doc
12
+ - else
13
+ %p= "Sorry. We couldn't find information about the #{@doc_name} Extension#{' for the role: ' + @role unless @role.to_s == 'all'}."
14
+ .Extras
15
+ - render_region :extras do |extras|
16
+ - extras.render_region :extension_docs_list
@@ -0,0 +1,16 @@
1
+ - content_for :page_css do
2
+ = render :partial => 'styles.html.haml'
3
+ - content_for :page_scripts do
4
+ = render :partial => 'scripts.js.erb'
5
+
6
+ .Help
7
+ .MainTopics
8
+ %h1= @cms_name + " Help"
9
+ - render_region :main do |main|
10
+ - main.introduction do
11
+ %p Use this reference to help guide your way through editing your website.
12
+ - main.render_region :organizing
13
+ - main.render_region :editing
14
+ .Extras
15
+ - render_region :extras do |extras|
16
+ - extras.render_region :extension_docs_list
@@ -0,0 +1,12 @@
1
+ - content_for :page_css do
2
+ = render :partial => 'styles.html.haml'
3
+ - content_for :page_scripts do
4
+ = render :partial => 'scripts.js.erb'
5
+
6
+ .Help
7
+ .MainTopics
8
+ %h1= "#{(@custom_role || @role).titleize} Help"
9
+ = render :partial => "#{@role}_index"
10
+ .Extras
11
+ - render_region :extras do |extras|
12
+ - extras.render_region :extension_docs_list
@@ -0,0 +1,3 @@
1
+ Radiant.config do |config|
2
+ # config.define "setting.name", :default => 'value', :select_from => ['foo', 'bar']
3
+ end
@@ -0,0 +1,3 @@
1
+ ---
2
+ en:
3
+ help: Help
data/config/routes.rb ADDED
@@ -0,0 +1,8 @@
1
+ ActionController::Routing::Routes.draw do |map|
2
+ map.with_options :controller => 'admin/help', :conditions => {:method => :get} do |help|
3
+ help.developing 'admin/help/developing', :action => 'developing'
4
+ help.help_role 'admin/help/role/:role', :action => 'role', :role => nil
5
+ help.help_extension_doc 'admin/help/extension/:extension_name/:role', :action => 'extension_doc', :extension_name => 'all', :role => 'all'
6
+ help.help 'admin/help', :action => 'index'
7
+ end
8
+ end
data/cucumber.yml ADDED
@@ -0,0 +1 @@
1
+ default: --format progress features --tags ~@proposed,~@in_progress
@@ -0,0 +1,11 @@
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 unless step =~ /datasets_loader\.rb$/}
8
+
9
+ Cucumber::Rails::World.class_eval do
10
+ dataset :help
11
+ end
@@ -0,0 +1,22 @@
1
+ module NavigationHelpers
2
+
3
+ # Extend the standard PathMatchers with your own paths
4
+ # to be used in your features.
5
+ #
6
+ # The keys and values here may be used in your standard web steps
7
+ # Using:
8
+ #
9
+ # When I go to the "help" admin page
10
+ #
11
+ # would direct the request to the path you provide in the value:
12
+ #
13
+ # admin_help_path
14
+ #
15
+ PathMatchers = {} unless defined?(PathMatchers)
16
+ PathMatchers.merge!({
17
+ # /help/i => 'admin_help_path'
18
+ })
19
+
20
+ end
21
+
22
+ World(NavigationHelpers)
data/help_extension.rb ADDED
@@ -0,0 +1,86 @@
1
+ # Uncomment this if you reference any of your controllers in activate
2
+ require_dependency 'application_controller'
3
+ # You'll need this if you are going to add regions into your extension interface.
4
+ require 'ostruct'
5
+ # These are needed for parsing the HELP.rdoc files
6
+ require 'rdoc/markup/simple_markup'
7
+ require 'rdoc/markup/simple_markup/to_html'
8
+
9
+ class HelpExtension < Radiant::Extension
10
+ version RadiantHelpExtension::VERSION
11
+ description RadiantHelpExtension::DESCRIPTION
12
+ url RadiantHelpExtension::URL
13
+
14
+ def activate
15
+ # This adds a tab to the interface after the Layouts tab, and allows all users to access it.
16
+ tab 'Help' do
17
+ add_item('Editing', '/admin/help')
18
+ add_item('Designing', '/admin/help/role/designer')
19
+ add_item('Administering', '/admin/help/role/admin')
20
+ if Rails.env.development?
21
+ add_item('Developing', '/admin/help/developing')
22
+ end
23
+ add_item('Extensions', '/admin/help/extension')
24
+ end
25
+ # The old way of doing it prior to Radiant 0.9: it now adds a NavSubItem to the "Content" NavTab (e.g. in line with "Pages")
26
+ # admin.tabs.add "Help", "/admin/help", :after => "Layouts", :visibility => [:all]
27
+
28
+ # This adds information to the Radiant interface. In this extension, we're dealing with "help" views
29
+ # so :help is an attr_accessor. If you're creating an extension for tracking moons and stars, you might
30
+ # put attr_accessor :moon, :star
31
+ Radiant::AdminUI.class_eval do
32
+ attr_accessor :help
33
+ end
34
+
35
+ # initialize regions for help (which we created above)
36
+ admin.help = load_default_help_regions
37
+
38
+ # Provide the ability to replace regions...
39
+ # Don't like how the regions are setup? Hack it without changing this extension's code
40
+ # Be forewarned, this allows you to completely change the UI
41
+ Radiant::AdminUI::RegionSet.class_eval do
42
+ def replace(region=nil, partial=nil)
43
+ raise ArgumentError, "You must specify a region and a partial" unless region and partial
44
+ self[region].replace([partial])
45
+ end
46
+ end
47
+ # You could, for example create your own role based interface with this
48
+ # admin.help.main.replace('main','main_for_admins_only')
49
+ # But I only threw this in here to allow you to change the help docs easily if you want.
50
+ # I am merely providing the rope...
51
+
52
+ # Finally, allow all the helpers to be used anywhere
53
+ ApplicationController.class_eval {
54
+ helper Admin::HelpHelper
55
+ }
56
+ end
57
+
58
+ private
59
+
60
+ # This is where we define all of the regions to be used in the views and partials
61
+ def load_default_help_regions
62
+ OpenStruct.new.tap do |help|
63
+ help.index = Radiant::AdminUI::RegionSet.new do |index|
64
+ index.main.concat %w{introduction organizing editing}
65
+ index.page_details.concat %w{page_details_introduction slug breadcrumb}
66
+ index.filter.concat %w{filter_basics}
67
+ index.available_tags.concat %w{available_tags_basics}
68
+ index.layout.concat %w{layout_basics}
69
+ index.page_type.concat %w{page_type_basics}
70
+ index.saving.concat %w{saving_basics}
71
+ index.extras.concat %w{extension_docs_list}
72
+ end
73
+ help.role = Radiant::AdminUI::RegionSet.new do |role|
74
+ role.extras.concat %w{extension_docs_list}
75
+ role.regions.concat %w{regions_introduction}
76
+ end
77
+ help.extension_doc = Radiant::AdminUI::RegionSet.new do |extension_doc|
78
+ extension_doc.extras.concat %w{extension_docs_list}
79
+ end
80
+ help.developing = Radiant::AdminUI::RegionSet.new do |developing|
81
+ developing.regions.concat %w{regions_introduction regions_map}
82
+ end
83
+ end
84
+ end
85
+
86
+ end
@@ -0,0 +1,8 @@
1
+ module RadiantHelpExtension
2
+ VERSION = "1.1.0"
3
+ SUMMARY = "Help for Radiant CMS"
4
+ DESCRIPTION = "Help Documentation for Radiant CMS!"
5
+ URL = "https://github.com/saturnflyer/radiant-help-extension"
6
+ AUTHORS = ["Jim Gay"]
7
+ EMAIL = ["jim@saturnflyer.com"]
8
+ end
@@ -0,0 +1,29 @@
1
+ namespace :radiant do
2
+ desc "Shows some help information"
3
+ task :help do
4
+ puts %{
5
+ Finding help for Radiant
6
+ ========================
7
+ The Help extension that you have installed in vendor/extensions
8
+ provides information about using Radiant.
9
+
10
+ If you need some help with your installation, try joining the
11
+ Radiant email lists and ask your questions there. For information
12
+ visit http://radiantcms.org/mailing-list/
13
+
14
+ You may also find help from the Radiant community in the
15
+ #radiantcms IRC channel on irc.freenode.net
16
+
17
+ Lastly, checkout the companies listed at
18
+ http://wiki.radiantcms.org/Radiant_Pros
19
+
20
+ Extensions
21
+ ==========
22
+ You may find other extensions at http://ext.radiantcms.org
23
+
24
+ To install them (with Radiant version 0.6.9 or later) you may
25
+ run 'script/extension install the_extension_name'. And if you'd
26
+ like more information, try 'script/extension help'
27
+ }
28
+ end
29
+ end