shakespeare 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. data/README.md +88 -84
  2. data/Rakefile +42 -42
  3. data/app/controllers/admin/pages_controller.rb +46 -46
  4. data/app/controllers/pages_controller.rb +4 -4
  5. data/app/models/page.rb +9 -9
  6. data/app/views/admin/pages/_form.html.erb +37 -37
  7. data/app/views/admin/pages/edit.html.erb +2 -2
  8. data/app/views/admin/pages/index.html.erb +23 -23
  9. data/app/views/admin/pages/new.html.erb +2 -2
  10. data/app/views/layouts/admin.html.erb +8 -8
  11. data/app/views/pages/show.html.erb +2 -2
  12. data/config/cucumber.yml +7 -7
  13. data/config/routes.rb +7 -7
  14. data/features/admin_pages.feature +37 -37
  15. data/features/public_pages.feature +11 -11
  16. data/features/step_definitions/page_steps.rb +6 -6
  17. data/features/step_definitions/web_steps.rb +258 -258
  18. data/features/support/env.rb +55 -55
  19. data/features/support/paths.rb +32 -32
  20. data/features/support/shakespeare_env.rb +2 -2
  21. data/generators/shakespeare/USAGE +4 -4
  22. data/generators/shakespeare/shakespeare_generator.rb +7 -7
  23. data/generators/shakespeare/templates/20091230095600_create_pages.rb +25 -25
  24. data/lib/shakespeare.rb +6 -6
  25. data/lib/shakespeare/helpers.rb +15 -15
  26. data/lib/shakespeare/settings.rb +29 -29
  27. data/lib/shakespeare/shakespeare.rb +7 -7
  28. data/lib/shakespeare/view_helpers.rb +28 -28
  29. data/rerun.txt +1 -1
  30. data/shakespeare.gemspec +89 -0
  31. data/spec/blueprints.rb +8 -8
  32. data/spec/controllers/admin/pages_controller_spec.rb +34 -34
  33. data/spec/database.yml +20 -20
  34. data/spec/helpers_spec.rb +19 -19
  35. data/spec/models/page_spec.rb +27 -27
  36. data/spec/schema.rb +15 -15
  37. data/spec/shakespeare_generator_spec.rb +35 -35
  38. data/spec/shakespeare_spec.rb +2 -2
  39. data/spec/spec_helper.rb +40 -40
  40. data/spec/view_helpers_spec.rb +102 -102
  41. metadata +2 -1
data/README.md CHANGED
@@ -1,85 +1,89 @@
1
- Shakespeare
2
- ===========
3
-
4
- Shakespeare is a Ruby on Rails content manager plugin.
5
-
6
- Shakespeare allows:
7
-
8
- - User-editable page titles, descriptions, meta info and content blocks for dynamic requests
9
- - User editable content-only pages
10
-
11
- Shakespeare is a super simple bolt-on CMS for any Rails app.
12
-
13
- Installation
14
- ============
15
-
16
- Shakespeare is easy to install.
17
-
18
- As a plugin:
19
-
20
- ./script/plugin install git://github.com/paulca/shakespeare.git
21
-
22
- Or as a gem. Add this to your environment.rb:
23
-
24
- config.gem 'shakespeare'
25
-
26
- Then generate the migration to create the pages table:
27
-
28
- ./script/generate shakespeare
29
-
30
- And run the migration:
31
-
32
- rake db:migrate
33
-
34
- Basic Usage
35
- ===========
36
-
37
- Once Shakespeare is installed, every controller action can now have its own content. You an access this content in the controller or the view with the `page_content` method.
38
-
39
- View Helpers
40
- ============
41
-
42
- In your views, you have access to a number of helpers for generating your page meta-data.
43
-
44
- - `page_title` is the title of the page
45
- - `keywords_meta_tag` generates a <meta> tag for the page keywords, or returns nil if it's left blank
46
- - `description_meta_tag` generates a <meta> tag for the page description, or returns nil if it's left blank
47
- - `robots_meta_tag` generates a <meta> tag for the robots no-index and/or nofollow meta tag options, or returns nil if it's left blank
48
- - `canonical_link_tag` generates a <link> tag with the canonical URL for the page, if `enable_canonical` is set to true
49
-
50
- Web Interface
51
- =============
52
-
53
- Using Rails' Engines feature, Shakespeare comes with a web interface that is available to your app straight away at `http://localhost:3000/admin/pages`.
54
-
55
- By default, this comes with no styling, but you can create a layout in `app/layouts/admin.html.erb`, or set a layout by setting `Shakespare::Settings.layout`
56
-
57
- For example, to use your standard application layout, create a `config/initializers/shakespeare.rb` like this:
58
-
59
- Shakespeare::Settings.layout = 'application'
60
-
61
- You can also add before_filters to protect the controller from outsiders:
62
-
63
- Shakespeare::Settings.before_filters << 'require_admin_user'
64
-
65
- By default, in production, if `Shakespeare::Settings.before_filters` is empty, `/admin/pages` is protected. You can disable this protection by setting `Behavior::Settings.allow_anonymous` to true.
66
-
67
- Running the tests
68
- =================
69
-
70
- You can run the tests by checking out the code into vendor/plugins of a Rails app and running:
71
-
72
- rake
73
-
74
- It also comes with a set of cucumber features:
75
-
76
- cucumber
77
-
78
- About me
79
- ========
80
-
81
- I'm Paul Campbell. I'm an avid Ruby on Rails web developer. Follow my ramblings at [http://www.pabcas.com](http://www.pabcas.com)
82
-
83
- Follow me on Twitter [http://twitter.com/paulca](http://twitter.com/paulca)
84
-
1
+ Shakespeare
2
+ ===========
3
+
4
+ Shakespeare is a Ruby on Rails content manager plugin.
5
+
6
+ Shakespeare allows:
7
+
8
+ - User-editable page titles, descriptions, meta info and content blocks for dynamic requests
9
+ - User editable content-only pages
10
+
11
+ Shakespeare is a super simple bolt-on CMS for any Rails app.
12
+
13
+ Installation
14
+ ============
15
+
16
+ Shakespeare is easy to install.
17
+
18
+ As a plugin:
19
+
20
+ ./script/plugin install git://github.com/paulca/shakespeare.git
21
+
22
+ Or as a gem. Add this to your environment.rb:
23
+
24
+ config.gem 'shakespeare'
25
+
26
+ Then generate the migration to create the pages table:
27
+
28
+ ./script/generate shakespeare
29
+
30
+ And run the migration:
31
+
32
+ rake db:migrate
33
+
34
+ Basic Usage
35
+ ===========
36
+
37
+ Once Shakespeare is installed, every controller action can now have its own content. You an access this content in the controller or the view with the `page_content` method.
38
+
39
+ View Helpers
40
+ ============
41
+
42
+ In your views, you have access to a number of helpers for generating your page meta-data.
43
+
44
+ - `page_title` is the title of the page
45
+ - `keywords_meta_tag` generates a <meta> tag for the page keywords, or returns nil if it's left blank
46
+ - `description_meta_tag` generates a <meta> tag for the page description, or returns nil if it's left blank
47
+ - `robots_meta_tag` generates a <meta> tag for the robots no-index and/or nofollow meta tag options, or returns nil if it's left blank
48
+ - `canonical_link_tag` generates a <link> tag with the canonical URL for the page, if `enable_canonical` is set to true
49
+
50
+ You also get access to route helpers:
51
+
52
+ - `admin_pages_path` and `admin_pages_url` point to the pages admin interface
53
+
54
+ Web Interface
55
+ =============
56
+
57
+ Using Rails' Engines feature, Shakespeare comes with a web interface that is available to your app straight away at `http://localhost:3000/admin/pages`.
58
+
59
+ By default, this comes with no styling, but you can create a layout in `app/layouts/admin.html.erb`, or set a layout by setting `Shakespare::Settings.layout`
60
+
61
+ For example, to use your standard application layout, create a `config/initializers/shakespeare.rb` like this:
62
+
63
+ Shakespeare::Settings.layout = 'application'
64
+
65
+ You can also add before_filters to protect the controller from outsiders:
66
+
67
+ Shakespeare::Settings.before_filters << 'require_admin_user'
68
+
69
+ By default, in production, if `Shakespeare::Settings.before_filters` is empty, `/admin/pages` is protected. You can disable this protection by setting `Behavior::Settings.allow_anonymous` to true.
70
+
71
+ Running the tests
72
+ =================
73
+
74
+ You can run the tests by checking out the code into vendor/plugins of a Rails app and running:
75
+
76
+ rake
77
+
78
+ It also comes with a set of cucumber features:
79
+
80
+ cucumber
81
+
82
+ About me
83
+ ========
84
+
85
+ I'm Paul Campbell. I'm an avid Ruby on Rails web developer. Follow my ramblings at [http://www.pabcas.com](http://www.pabcas.com)
86
+
87
+ Follow me on Twitter [http://twitter.com/paulca](http://twitter.com/paulca)
88
+
85
89
  Copyright (c) 2009 Paul Campbell, released under the MIT license
data/Rakefile CHANGED
@@ -1,43 +1,43 @@
1
- require 'rake'
2
- require 'spec/rake/spectask'
3
-
4
- desc 'Default: run specs.'
5
- task :default => :spec
6
-
7
- desc 'Run the specs'
8
- Spec::Rake::SpecTask.new(:spec) do |t|
9
- t.spec_opts = ['--colour --format progress --loadby mtime --reverse']
10
- t.spec_files = FileList['spec/**/*_spec.rb']
11
- end
12
-
13
- PKG_FILES = FileList[
14
- '[a-zA-Z]*',
15
- 'app/**/*',
16
- 'generators/**/*',
17
- 'config/*',
18
- 'lib/**/*',
19
- 'rails/**/*',
20
- 'spec/**/*',
21
- 'features/**/*'
22
- ]
23
-
24
- begin
25
- require 'jeweler'
26
- Jeweler::Tasks.new do |s|
27
- s.name = "shakespeare"
28
- s.version = "0.1.0"
29
- s.author = "Paul Campbell"
30
- s.email = "paul@rslw.com"
31
- s.homepage = "http://www.github.com/paulca/shakespeare"
32
- s.platform = Gem::Platform::RUBY
33
- s.summary = "A Rails drop in CMS."
34
- s.files = PKG_FILES.to_a
35
- s.require_path = "lib"
36
- s.has_rdoc = false
37
- s.extra_rdoc_files = ["README.md"]
38
- end
39
- rescue LoadError
40
- puts "Jeweler not available. Install it with: sudo gem install jeweler"
41
- end
42
-
1
+ require 'rake'
2
+ require 'spec/rake/spectask'
3
+
4
+ desc 'Default: run specs.'
5
+ task :default => :spec
6
+
7
+ desc 'Run the specs'
8
+ Spec::Rake::SpecTask.new(:spec) do |t|
9
+ t.spec_opts = ['--colour --format progress --loadby mtime --reverse']
10
+ t.spec_files = FileList['spec/**/*_spec.rb']
11
+ end
12
+
13
+ PKG_FILES = FileList[
14
+ '[a-zA-Z]*',
15
+ 'app/**/*',
16
+ 'generators/**/*',
17
+ 'config/*',
18
+ 'lib/**/*',
19
+ 'rails/**/*',
20
+ 'spec/**/*',
21
+ 'features/**/*'
22
+ ]
23
+
24
+ begin
25
+ require 'jeweler'
26
+ Jeweler::Tasks.new do |s|
27
+ s.name = "shakespeare"
28
+ s.version = "0.1.1"
29
+ s.author = "Paul Campbell"
30
+ s.email = "paul@rslw.com"
31
+ s.homepage = "http://www.github.com/paulca/shakespeare"
32
+ s.platform = Gem::Platform::RUBY
33
+ s.summary = "A Rails drop in CMS."
34
+ s.files = PKG_FILES.to_a
35
+ s.require_path = "lib"
36
+ s.has_rdoc = false
37
+ s.extra_rdoc_files = ["README.md"]
38
+ end
39
+ rescue LoadError
40
+ puts "Jeweler not available. Install it with: sudo gem install jeweler"
41
+ end
42
+
43
43
  Jeweler::GemcutterTasks.new
@@ -1,47 +1,47 @@
1
- class Admin::PagesController < ApplicationController
2
-
3
-
4
- Shakespeare::Settings.before_filters.each do |filter|
5
- before_filter filter
6
- end
7
- before_filter :protect_in_production if Shakespeare::Settings.before_filters.empty?
8
-
9
- layout Shakespeare::Settings.layout
10
-
11
- def index
12
- @pages = Page.all
13
- end
14
-
15
- def new
16
- @page = Page.new
17
- end
18
-
19
- def create
20
- @page = Page.new(params[:page])
21
- if @page.save
22
- redirect_to admin_pages_path
23
- else
24
- render :new
25
- end
26
- end
27
-
28
- def edit
29
- @page = Page.find(params[:id])
30
- end
31
-
32
- def update
33
- @page = Page.find(params[:id])
34
- if @page.update_attributes(params[:page])
35
- redirect_to admin_pages_path
36
- else
37
- render :edit
38
- end
39
- end
40
-
41
- def destroy
42
- @page = Page.find(params[:id])
43
- @page.destroy
44
- redirect_to admin_pages_path
45
- end
46
-
1
+ class Admin::PagesController < ApplicationController
2
+
3
+
4
+ Shakespeare::Settings.before_filters.each do |filter|
5
+ before_filter filter
6
+ end
7
+ before_filter :protect_in_production if Shakespeare::Settings.before_filters.empty?
8
+
9
+ layout Shakespeare::Settings.layout
10
+
11
+ def index
12
+ @pages = Page.all
13
+ end
14
+
15
+ def new
16
+ @page = Page.new
17
+ end
18
+
19
+ def create
20
+ @page = Page.new(params[:page])
21
+ if @page.save
22
+ redirect_to admin_pages_path
23
+ else
24
+ render :new
25
+ end
26
+ end
27
+
28
+ def edit
29
+ @page = Page.find(params[:id])
30
+ end
31
+
32
+ def update
33
+ @page = Page.find(params[:id])
34
+ if @page.update_attributes(params[:page])
35
+ redirect_to admin_pages_path
36
+ else
37
+ render :edit
38
+ end
39
+ end
40
+
41
+ def destroy
42
+ @page = Page.find(params[:id])
43
+ @page.destroy
44
+ redirect_to admin_pages_path
45
+ end
46
+
47
47
  end
@@ -1,5 +1,5 @@
1
- class PagesController < ApplicationController
2
- def show
3
- @page = Page.find(params[:id])
4
- end
1
+ class PagesController < ApplicationController
2
+ def show
3
+ @page = Page.find(params[:id])
4
+ end
5
5
  end
data/app/models/page.rb CHANGED
@@ -1,10 +1,10 @@
1
- class Page < ActiveRecord::Base
2
-
3
- def robots
4
- out = []
5
- out << 'noindex' if noindex?
6
- out << 'nofollow' if nofollow?
7
- out.join(', ')
8
- end
9
-
1
+ class Page < ActiveRecord::Base
2
+
3
+ def robots
4
+ out = []
5
+ out << 'noindex' if noindex?
6
+ out << 'nofollow' if nofollow?
7
+ out.join(', ')
8
+ end
9
+
10
10
  end
@@ -1,38 +1,38 @@
1
- <% form_for [:admin, @page] do |f| -%>
2
-
3
- <%= f.error_messages %>
4
-
5
- <fieldset>
6
- <%= f.label :url, "URL" %> <%= f.text_field :url %> <em><%= t('page.maps_to') %></em> <br />
7
- </fieldset>
8
-
9
- <fieldset>
10
- <%= f.label :title, "Title" %>
11
- <%= f.text_field :title %> <br />
12
- <fieldset>
13
- <legend>Robots</legend>
14
-
15
- <%= f.check_box :noindex %>
16
- <%= f.label :noindex, "No-Index", :class => 'inline' %>
17
-
18
- <%= f.check_box :nofollow %>
19
- <%= f.label :nofollow, "No-follow", :class => 'inline' %>
20
-
21
- <%= f.check_box :enable_canonical %>
22
- <%= f.label :enable_canonical, "Set Canonical Tag?", :class => 'inline' %>
23
-
24
- <%= f.label :canonical, "Canonical URL" %>
25
- <%= f.text_field :canonical %> <br />
26
-
27
-
28
- <%= f.label :description, "Description" %> <%= f.text_area :description, :class => "small-text" %> <br />
29
- <%= f.label :keywords, "Keywords" %> <%= f.text_field :keywords %> <br />
30
- </fieldset>
31
-
32
- <fieldset>
33
- <%= f.label :content, "Content" %> <%= f.text_area :content %> <br />
34
- </fieldset>
35
-
36
-
37
- <%= f.submit "Save" %> or <%= link_to "Cancel", admin_pages_path %>
1
+ <% form_for [:admin, @page] do |f| -%>
2
+
3
+ <%= f.error_messages %>
4
+
5
+ <fieldset>
6
+ <%= f.label :url, "URL" %> <%= f.text_field :url %> <em>This can be an existing controller_name/action_name combo, or a completely new URL.</em> <br />
7
+ </fieldset>
8
+
9
+ <fieldset>
10
+ <%= f.label :title, "Title" %>
11
+ <%= f.text_field :title %> <br />
12
+ <fieldset>
13
+ <legend>Robots</legend>
14
+
15
+ <%= f.check_box :noindex %>
16
+ <%= f.label :noindex, "No-Index", :class => 'inline' %>
17
+
18
+ <%= f.check_box :nofollow %>
19
+ <%= f.label :nofollow, "No-follow", :class => 'inline' %>
20
+
21
+ <%= f.check_box :enable_canonical %>
22
+ <%= f.label :enable_canonical, "Set Canonical Tag?", :class => 'inline' %>
23
+
24
+ <%= f.label :canonical, "Canonical URL" %>
25
+ <%= f.text_field :canonical %> <br />
26
+
27
+
28
+ <%= f.label :description, "Description" %> <%= f.text_area :description, :class => "small-text" %> <br />
29
+ <%= f.label :keywords, "Keywords" %> <%= f.text_field :keywords %> <br />
30
+ </fieldset>
31
+
32
+ <fieldset>
33
+ <%= f.label :content, "Content" %> <%= f.text_area :content %> <br />
34
+ </fieldset>
35
+
36
+
37
+ <%= f.submit "Save" %> or <%= link_to "Cancel", admin_pages_path %>
38
38
  <% end -%>