pagificate 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. data/.gitignore +8 -0
  2. data/Gemfile +16 -0
  3. data/Gemfile.lock +138 -0
  4. data/README.markdown +20 -0
  5. data/Rakefile +2 -0
  6. data/app/controllers/pagificate/pages_controller.rb +67 -0
  7. data/app/models/pagificate/page.rb +15 -0
  8. data/app/views/pagificate/pages/_form.html.erb +36 -0
  9. data/app/views/pagificate/pages/edit.html.erb +5 -0
  10. data/app/views/pagificate/pages/index.html.erb +49 -0
  11. data/app/views/pagificate/pages/new.html.erb +5 -0
  12. data/app/views/pagificate/pages/show.html.erb +5 -0
  13. data/config/routes.rb +5 -0
  14. data/lib/generators/pagificate/pagificate_generator.rb +23 -0
  15. data/lib/generators/pagificate/templates/migration.rb +18 -0
  16. data/lib/pagificate.rb +3 -0
  17. data/lib/pagificate/engine.rb +8 -0
  18. data/lib/pagificate/version.rb +3 -0
  19. data/pagificate.gemspec +32 -0
  20. data/spec/dummy/Rakefile +7 -0
  21. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  22. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  23. data/spec/dummy/app/views/layouts/application.html.erb +15 -0
  24. data/spec/dummy/config.ru +4 -0
  25. data/spec/dummy/config/application.rb +45 -0
  26. data/spec/dummy/config/boot.rb +10 -0
  27. data/spec/dummy/config/database.yml +22 -0
  28. data/spec/dummy/config/environment.rb +5 -0
  29. data/spec/dummy/config/environments/development.rb +26 -0
  30. data/spec/dummy/config/environments/production.rb +49 -0
  31. data/spec/dummy/config/environments/test.rb +35 -0
  32. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  33. data/spec/dummy/config/initializers/inflections.rb +10 -0
  34. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  35. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  36. data/spec/dummy/config/initializers/session_store.rb +8 -0
  37. data/spec/dummy/config/locales/en.yml +5 -0
  38. data/spec/dummy/config/routes.rb +58 -0
  39. data/spec/dummy/db/migrate/20110208222908_create_pages_table.rb +18 -0
  40. data/spec/dummy/db/schema.rb +27 -0
  41. data/spec/dummy/public/404.html +26 -0
  42. data/spec/dummy/public/422.html +26 -0
  43. data/spec/dummy/public/500.html +26 -0
  44. data/spec/dummy/public/favicon.ico +0 -0
  45. data/spec/dummy/public/javascripts/application.js +2 -0
  46. data/spec/dummy/public/javascripts/controls.js +965 -0
  47. data/spec/dummy/public/javascripts/dragdrop.js +974 -0
  48. data/spec/dummy/public/javascripts/effects.js +1123 -0
  49. data/spec/dummy/public/javascripts/prototype.js +6001 -0
  50. data/spec/dummy/public/javascripts/rails.js +175 -0
  51. data/spec/dummy/public/stylesheets/.gitkeep +0 -0
  52. data/spec/dummy/public/stylesheets/screen.css +61 -0
  53. data/spec/dummy/script/rails +6 -0
  54. data/spec/factories.rb +6 -0
  55. data/spec/integration/models/page_spec.rb +21 -0
  56. data/spec/integration/requests/manage_pages_spec.rb +64 -0
  57. data/spec/pagificate_spec.rb +7 -0
  58. data/spec/spec_helper.rb +51 -0
  59. metadata +250 -0
@@ -0,0 +1,8 @@
1
+ *.gem
2
+ .bundle/
3
+ .rvmrc
4
+ log/*.log
5
+ pkg/
6
+ spec/dummy/db/*.sqlite3
7
+ spec/dummy/log/*.log
8
+ spec/dummy/tmp/
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in pagificate.gemspec
4
+ gemspec
5
+
6
+ gem 'permalink_fu'
7
+
8
+ group :development, :test do
9
+ gem 'rspec', '2.4.0'
10
+ gem 'rspec-rails', '2.4.0'
11
+ gem 'capybara', '0.4.0'
12
+ gem 'factory_girl_rails', '1.0.1'
13
+ gem 'database_cleaner', '0.6.2'
14
+ gem 'sqlite3-ruby', :require => 'sqlite3'
15
+ gem 'launchy', '0.3.7'
16
+ end
@@ -0,0 +1,138 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ pagificate (0.0.1)
5
+ permalink_fu (= 1.0.0)
6
+ rails (= 3.0.3)
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ abstract (1.0.0)
12
+ actionmailer (3.0.3)
13
+ actionpack (= 3.0.3)
14
+ mail (~> 2.2.9)
15
+ actionpack (3.0.3)
16
+ activemodel (= 3.0.3)
17
+ activesupport (= 3.0.3)
18
+ builder (~> 2.1.2)
19
+ erubis (~> 2.6.6)
20
+ i18n (~> 0.4)
21
+ rack (~> 1.2.1)
22
+ rack-mount (~> 0.6.13)
23
+ rack-test (~> 0.5.6)
24
+ tzinfo (~> 0.3.23)
25
+ activemodel (3.0.3)
26
+ activesupport (= 3.0.3)
27
+ builder (~> 2.1.2)
28
+ i18n (~> 0.4)
29
+ activerecord (3.0.3)
30
+ activemodel (= 3.0.3)
31
+ activesupport (= 3.0.3)
32
+ arel (~> 2.0.2)
33
+ tzinfo (~> 0.3.23)
34
+ activeresource (3.0.3)
35
+ activemodel (= 3.0.3)
36
+ activesupport (= 3.0.3)
37
+ activesupport (3.0.3)
38
+ arel (2.0.8)
39
+ builder (2.1.2)
40
+ capybara (0.4.0)
41
+ celerity (>= 0.7.9)
42
+ culerity (>= 0.2.4)
43
+ mime-types (>= 1.16)
44
+ nokogiri (>= 1.3.3)
45
+ rack (>= 1.0.0)
46
+ rack-test (>= 0.5.4)
47
+ selenium-webdriver (>= 0.0.27)
48
+ xpath (~> 0.1.2)
49
+ celerity (0.8.7)
50
+ childprocess (0.1.6)
51
+ ffi (~> 0.6.3)
52
+ configuration (1.2.0)
53
+ culerity (0.2.14)
54
+ database_cleaner (0.6.2)
55
+ diff-lcs (1.1.2)
56
+ erubis (2.6.6)
57
+ abstract (>= 1.0.0)
58
+ factory_girl (1.3.3)
59
+ factory_girl_rails (1.0.1)
60
+ factory_girl (~> 1.3)
61
+ railties (>= 3.0.0)
62
+ ffi (0.6.3)
63
+ rake (>= 0.8.7)
64
+ i18n (0.5.0)
65
+ json_pure (1.4.6)
66
+ launchy (0.3.7)
67
+ configuration (>= 0.0.5)
68
+ rake (>= 0.8.1)
69
+ mail (2.2.15)
70
+ activesupport (>= 2.3.6)
71
+ i18n (>= 0.4.0)
72
+ mime-types (~> 1.16)
73
+ treetop (~> 1.4.8)
74
+ mime-types (1.16)
75
+ nokogiri (1.4.4)
76
+ permalink_fu (1.0.0)
77
+ polyglot (0.3.1)
78
+ rack (1.2.1)
79
+ rack-mount (0.6.13)
80
+ rack (>= 1.0.0)
81
+ rack-test (0.5.7)
82
+ rack (>= 1.0)
83
+ rails (3.0.3)
84
+ actionmailer (= 3.0.3)
85
+ actionpack (= 3.0.3)
86
+ activerecord (= 3.0.3)
87
+ activeresource (= 3.0.3)
88
+ activesupport (= 3.0.3)
89
+ bundler (~> 1.0)
90
+ railties (= 3.0.3)
91
+ railties (3.0.3)
92
+ actionpack (= 3.0.3)
93
+ activesupport (= 3.0.3)
94
+ rake (>= 0.8.7)
95
+ thor (~> 0.14.4)
96
+ rake (0.8.7)
97
+ rspec (2.4.0)
98
+ rspec-core (~> 2.4.0)
99
+ rspec-expectations (~> 2.4.0)
100
+ rspec-mocks (~> 2.4.0)
101
+ rspec-core (2.4.0)
102
+ rspec-expectations (2.4.0)
103
+ diff-lcs (~> 1.1.2)
104
+ rspec-mocks (2.4.0)
105
+ rspec-rails (2.4.0)
106
+ actionpack (~> 3.0)
107
+ activesupport (~> 3.0)
108
+ railties (~> 3.0)
109
+ rspec (~> 2.4.0)
110
+ rubyzip (0.9.4)
111
+ selenium-webdriver (0.1.2)
112
+ childprocess (~> 0.1.5)
113
+ ffi (~> 0.6.3)
114
+ json_pure
115
+ rubyzip
116
+ sqlite3 (1.3.3)
117
+ sqlite3-ruby (1.3.3)
118
+ sqlite3 (>= 1.3.3)
119
+ thor (0.14.6)
120
+ treetop (1.4.9)
121
+ polyglot (>= 0.3.1)
122
+ tzinfo (0.3.24)
123
+ xpath (0.1.3)
124
+ nokogiri (~> 1.3)
125
+
126
+ PLATFORMS
127
+ ruby
128
+
129
+ DEPENDENCIES
130
+ capybara (= 0.4.0)
131
+ database_cleaner (= 0.6.2)
132
+ factory_girl_rails (= 1.0.1)
133
+ launchy (= 0.3.7)
134
+ pagificate!
135
+ permalink_fu
136
+ rspec (= 2.4.0)
137
+ rspec-rails (= 2.4.0)
138
+ sqlite3-ruby
@@ -0,0 +1,20 @@
1
+ Pagificate
2
+ ==========
3
+
4
+ Setup
5
+ ----------
6
+
7
+ - In your gemfile
8
+
9
+ gem 'pagificate'
10
+ $ bundle install
11
+
12
+ - To create migration file run:
13
+
14
+ $ rails g pagificate
15
+
16
+ - **Don't forget to run your migrations in your app!**
17
+
18
+ - In your layout be sure to yield titles.
19
+
20
+ <title><%= yield :title %></title>
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,67 @@
1
+ module Pagificate
2
+
3
+ class PagesController < ApplicationController
4
+
5
+ unloadable
6
+
7
+ before_filter :find_page, :except => [:index, :new, :create, :show]
8
+
9
+ def index
10
+ @published_pages = Page.where('pages.published = ?', true)
11
+ @unpublished_pages = Page.where('pages.published = ?', false)
12
+ end
13
+
14
+ def show
15
+ page = Page.find_by_permalink params[:id]
16
+ page.published? ? @page = page : redirect_to('/', :notice => 'No such page exists')
17
+ render :layout => false unless @page.use_site_layout?
18
+ end
19
+
20
+ def new
21
+ @page = Page.new
22
+ end
23
+
24
+ def create
25
+ @page = Page.new params[:page]
26
+
27
+ respond_to do |format|
28
+ if @page.save
29
+ format.html { redirect_to pages_path, :notice => 'Page created successfully.' }
30
+ else
31
+ flash[:error] = 'Page could not be created.'
32
+ format.html { render :action => :new }
33
+ end
34
+ end
35
+ end
36
+
37
+ def edit
38
+ end
39
+
40
+ def update
41
+ respond_to do |format|
42
+ if @page.update_attributes(params[:page])
43
+ format.html { redirect_to pages_path, :notice => 'Page updated.'}
44
+ else
45
+ flash[:error] = 'Page could not be updated.'
46
+ format.html { render :action => :edit }
47
+ end
48
+ end
49
+ end
50
+
51
+ def destroy
52
+ @page.destroy
53
+
54
+ respond_to do |format|
55
+ format.html { redirect_to pages_path, :notice => 'Page deleted.'}
56
+ end
57
+ end
58
+
59
+ private
60
+
61
+ def find_page
62
+ @page = Page.find_by_permalink params[:id]
63
+ end
64
+
65
+ end
66
+
67
+ end
@@ -0,0 +1,15 @@
1
+ module Pagificate
2
+
3
+ class Page < ActiveRecord::Base
4
+
5
+ has_permalink :title
6
+
7
+ validates :title, :presence => true, :uniqueness => true
8
+
9
+ def to_param
10
+ permalink
11
+ end
12
+
13
+ end
14
+
15
+ end
@@ -0,0 +1,36 @@
1
+ <% if @page.errors.any? %>
2
+ <div id="error_explanation">
3
+ <h2><%= pluralize(@page.errors.count, "error") %> prohibited this page from being saved:</h2>
4
+
5
+ <ul>
6
+ <% @page.errors.full_messages.each do |msg| %>
7
+ <li><%= msg %></li>
8
+ <% end %>
9
+ </ul>
10
+ </div>
11
+ <% end %>
12
+
13
+
14
+ <p>
15
+ <%= f.label :title, 'Title' %><br />
16
+ <%= f.text_field :title %>
17
+ </p>
18
+
19
+ <p>
20
+ <%= f.label :body, 'Body' %><br />
21
+ <%= f.text_area :body %>
22
+ </p>
23
+
24
+ <p>
25
+ <%= f.label :published, 'Published' %><br />
26
+ <%= f.check_box :published %>
27
+ </p>
28
+
29
+ <p>
30
+ <%= f.label :use_site_layout, 'Use Site Layout' %><br />
31
+ <%= f.check_box :use_site_layout %>
32
+ </p>
33
+
34
+ <p>
35
+ <%= f.submit 'Save', :disable_with => 'Saving...' %>
36
+ </p>
@@ -0,0 +1,5 @@
1
+ <h1>Editing <%= @page.title %></h1>
2
+
3
+ <%= form_for :page, :url => page_path(@page), :html => { :method => :put } do |f| -%>
4
+ <%= render :partial => 'form', :locals => { :f => f } %>
5
+ <% end -%>
@@ -0,0 +1,49 @@
1
+ <h1>Pages</h1>
2
+
3
+ <%= link_to 'Add a new page', new_page_path %>
4
+
5
+ <h2>Published</h2>
6
+
7
+ <table border="0" cellspacing="5" cellpadding="5">
8
+
9
+ <thead>
10
+ <tr>
11
+ <th>Title</th>
12
+ <th colspan='2'>&nbsp;</th>
13
+ </tr>
14
+ </thead>
15
+
16
+ <tbody>
17
+ <% @published_pages.each do |page| %>
18
+ <tr>
19
+ <td><%= link_to page.title, page_path(page) %></td>
20
+ <td><%= link_to 'Edit', edit_page_path(page) %></td>
21
+ <td><%= link_to 'Delete', page_path(page), :method => :delete %></td>
22
+ </tr>
23
+ <% end %>
24
+ </tbody>
25
+
26
+ </table>
27
+
28
+ <h2>Draft</h2>
29
+
30
+ <table border="0" cellspacing="5" cellpadding="5">
31
+
32
+ <thead>
33
+ <tr>
34
+ <th>Title</th>
35
+ <th colspan='2'>&nbsp;</th>
36
+ </tr>
37
+ </thead>
38
+
39
+ <tbody>
40
+ <% @unpublished_pages.each do |page| %>
41
+ <tr>
42
+ <td><%= page.title %></td>
43
+ <td><%= link_to 'Edit', edit_page_path(page) %></td>
44
+ <td><%= link_to 'Delete', page_path(page), :method => :delete %></td>
45
+ </tr>
46
+ <% end %>
47
+ </tbody>
48
+
49
+ </table>
@@ -0,0 +1,5 @@
1
+ <h1>New Page</h1>
2
+
3
+ <%= form_for :page, :url => pages_path do |f| -%>
4
+ <%= render :partial => 'form', :locals => { :f => f } %>
5
+ <% end -%>
@@ -0,0 +1,5 @@
1
+ <% content_for :title do %>
2
+ <%= @page.title %>
3
+ <% end %>
4
+
5
+ <%= raw @page.body %>
@@ -0,0 +1,5 @@
1
+ Rails.application.routes.draw do
2
+
3
+ resources :pages, :controller => 'pagificate/pages'
4
+
5
+ end
@@ -0,0 +1,23 @@
1
+ require 'rails/generators'
2
+ require 'rails/generators/migration'
3
+
4
+ class PagificateGenerator < Rails::Generators::Base
5
+ include Rails::Generators::Migration
6
+
7
+ def self.source_root
8
+ @source_root ||= File.join(File.dirname(__FILE__), 'templates')
9
+ end
10
+
11
+ def self.next_migration_number(dirname)
12
+ if ActiveRecord::Base.timestamped_migrations
13
+ Time.new.utc.strftime("%Y%m%d%H%M%S")
14
+ else
15
+ "%.3d" % (current_migration_number(dirname) + 1)
16
+ end
17
+ end
18
+
19
+ def create_migration_file
20
+ migration_template 'migration.rb', 'db/migrate/create_pages_table.rb'
21
+ end
22
+
23
+ end
@@ -0,0 +1,18 @@
1
+ class CreatePagesTable < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :pages do |t|
4
+ t.string :title, :null => false
5
+ t.text :body
6
+ t.boolean :use_site_layout, :default => true
7
+ t.boolean :published, :default => false
8
+ t.string :permalink
9
+ t.timestamps
10
+ end
11
+
12
+ add_index :pages, :title
13
+ end
14
+
15
+ def self.down
16
+ drop_table :pages
17
+ end
18
+ end
@@ -0,0 +1,3 @@
1
+ module Pagificate
2
+ require 'pagificate/engine' if defined?(Rails)
3
+ end
@@ -0,0 +1,8 @@
1
+ require 'pagificate'
2
+ require 'rails'
3
+ require 'permalink_fu'
4
+
5
+ module Pagificate
6
+ class Engine < Rails::Engine
7
+ end
8
+ end