governor 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. data/.document +5 -0
  2. data/.rspec +1 -0
  3. data/Gemfile +24 -0
  4. data/Gemfile.lock +123 -0
  5. data/LICENSE.txt +20 -0
  6. data/README.markdown +28 -0
  7. data/Rakefile +50 -0
  8. data/VERSION +1 -0
  9. data/app/controllers/governor/articles_controller.rb +94 -0
  10. data/app/helpers/governor_helper.rb +26 -0
  11. data/app/views/governor/articles/_article.html.erb +11 -0
  12. data/app/views/governor/articles/_form.html.erb +28 -0
  13. data/app/views/governor/articles/edit.html.erb +6 -0
  14. data/app/views/governor/articles/index.html.erb +4 -0
  15. data/app/views/governor/articles/new.html.erb +5 -0
  16. data/app/views/governor/articles/show.html.erb +10 -0
  17. data/config/locales/en.yml +6 -0
  18. data/governor.gemspec +198 -0
  19. data/lib/generators/USAGE +8 -0
  20. data/lib/generators/governor/create_articles_generator.rb +40 -0
  21. data/lib/generators/governor/install_generator.rb +9 -0
  22. data/lib/generators/governor/migrate_generator.rb +25 -0
  23. data/lib/generators/governor/templates/governor.rb +22 -0
  24. data/lib/generators/governor/templates/migrations/create_articles.rb +15 -0
  25. data/lib/generators/governor/templates/models/article.rb +3 -0
  26. data/lib/governor.rb +32 -0
  27. data/lib/governor/article.rb +26 -0
  28. data/lib/governor/controllers/helpers.rb +58 -0
  29. data/lib/governor/formatters.rb +43 -0
  30. data/lib/governor/mapping.rb +32 -0
  31. data/lib/governor/plugin.rb +13 -0
  32. data/lib/governor/plugin_manager.rb +20 -0
  33. data/lib/governor/rails.rb +7 -0
  34. data/lib/governor/rails/routes.rb +12 -0
  35. data/lib/tasks/.gitkeep +0 -0
  36. data/script/rails +6 -0
  37. data/spec/controllers/governor/articles_controller_spec.rb +64 -0
  38. data/spec/governor/article_spec.rb +28 -0
  39. data/spec/governor/plugin_manager_spec.rb +11 -0
  40. data/spec/governor_spec.rb +40 -0
  41. data/spec/rails_app/.gitignore +4 -0
  42. data/spec/rails_app/Gemfile +38 -0
  43. data/spec/rails_app/Gemfile.lock +91 -0
  44. data/spec/rails_app/README +256 -0
  45. data/spec/rails_app/Rakefile +7 -0
  46. data/spec/rails_app/app/controllers/application_controller.rb +3 -0
  47. data/spec/rails_app/app/controllers/home_controller.rb +2 -0
  48. data/spec/rails_app/app/helpers/application_helper.rb +2 -0
  49. data/spec/rails_app/app/helpers/home_helper.rb +2 -0
  50. data/spec/rails_app/app/models/article.rb +5 -0
  51. data/spec/rails_app/app/models/user.rb +9 -0
  52. data/spec/rails_app/app/views/home/index.html.erb +0 -0
  53. data/spec/rails_app/app/views/layouts/application.html.erb +14 -0
  54. data/spec/rails_app/config.ru +4 -0
  55. data/spec/rails_app/config/application.rb +42 -0
  56. data/spec/rails_app/config/boot.rb +14 -0
  57. data/spec/rails_app/config/database.yml +19 -0
  58. data/spec/rails_app/config/environment.rb +5 -0
  59. data/spec/rails_app/config/environments/development.rb +26 -0
  60. data/spec/rails_app/config/environments/production.rb +49 -0
  61. data/spec/rails_app/config/environments/test.rb +35 -0
  62. data/spec/rails_app/config/initializers/backtrace_silencers.rb +7 -0
  63. data/spec/rails_app/config/initializers/devise.rb +142 -0
  64. data/spec/rails_app/config/initializers/governor.rb +1 -0
  65. data/spec/rails_app/config/initializers/inflections.rb +10 -0
  66. data/spec/rails_app/config/initializers/mime_types.rb +5 -0
  67. data/spec/rails_app/config/initializers/secret_token.rb +7 -0
  68. data/spec/rails_app/config/initializers/session_store.rb +8 -0
  69. data/spec/rails_app/config/locales/devise.en.yml +39 -0
  70. data/spec/rails_app/config/locales/en.yml +5 -0
  71. data/spec/rails_app/config/routes.rb +64 -0
  72. data/spec/rails_app/db/migrate/20110329032256_devise_create_users.rb +26 -0
  73. data/spec/rails_app/db/migrate/20110330020108_governor_create_articles.rb +15 -0
  74. data/spec/rails_app/db/schema.rb +45 -0
  75. data/spec/rails_app/db/seeds.rb +7 -0
  76. data/spec/rails_app/lib/tasks/.gitkeep +0 -0
  77. data/spec/rails_app/public/404.html +26 -0
  78. data/spec/rails_app/public/422.html +26 -0
  79. data/spec/rails_app/public/500.html +26 -0
  80. data/spec/rails_app/public/favicon.ico +0 -0
  81. data/spec/rails_app/public/images/rails.png +0 -0
  82. data/spec/rails_app/public/javascripts/application.js +2 -0
  83. data/spec/rails_app/public/javascripts/controls.js +965 -0
  84. data/spec/rails_app/public/javascripts/dragdrop.js +974 -0
  85. data/spec/rails_app/public/javascripts/effects.js +1123 -0
  86. data/spec/rails_app/public/javascripts/prototype.js +6001 -0
  87. data/spec/rails_app/public/javascripts/rails.js +191 -0
  88. data/spec/rails_app/public/robots.txt +5 -0
  89. data/spec/rails_app/public/stylesheets/.gitkeep +0 -0
  90. data/spec/rails_app/script/rails +6 -0
  91. data/spec/rails_app/spec/factories.rb +11 -0
  92. data/spec/rails_app/vendor/plugins/.gitkeep +0 -0
  93. data/spec/spec_helper.rb +21 -0
  94. metadata +367 -0
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,24 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'rails', '~> 3.0.5'
4
+
5
+ group :development, :test do
6
+ gem 'jeweler', '~> 1.5.2'
7
+ gem 'sqlite3'
8
+ gem 'rspec-rails'
9
+ gem 'mocha'
10
+ gem 'factory_girl', '~> 2.0.0.beta'
11
+ gem 'factory_girl_rails', '~> 1.1.beta'
12
+ gem 'activerecord-nulldb-adapter'
13
+
14
+ gem 'will_paginate', '~> 3.0.beta'
15
+ gem 'devise'
16
+ gem 'governor', :path => './'
17
+ gem 'dynamic_form'
18
+ end
19
+ # group :development do
20
+ # gem "rspec", "~> 2.3.0"
21
+ # gem "bundler", "~> 1.0.0"
22
+ # gem "jeweler", "~> 1.5.2"
23
+ # gem "rcov", ">= 0"
24
+ # end
@@ -0,0 +1,123 @@
1
+ PATH
2
+ remote: ./
3
+ specs:
4
+ governor (0.0.0)
5
+ rails (~> 3.0.5)
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ abstract (1.0.0)
11
+ actionmailer (3.0.5)
12
+ actionpack (= 3.0.5)
13
+ mail (~> 2.2.15)
14
+ actionpack (3.0.5)
15
+ activemodel (= 3.0.5)
16
+ activesupport (= 3.0.5)
17
+ builder (~> 2.1.2)
18
+ erubis (~> 2.6.6)
19
+ i18n (~> 0.4)
20
+ rack (~> 1.2.1)
21
+ rack-mount (~> 0.6.13)
22
+ rack-test (~> 0.5.7)
23
+ tzinfo (~> 0.3.23)
24
+ activemodel (3.0.5)
25
+ activesupport (= 3.0.5)
26
+ builder (~> 2.1.2)
27
+ i18n (~> 0.4)
28
+ activerecord (3.0.5)
29
+ activemodel (= 3.0.5)
30
+ activesupport (= 3.0.5)
31
+ arel (~> 2.0.2)
32
+ tzinfo (~> 0.3.23)
33
+ activerecord-nulldb-adapter (0.2.1)
34
+ activerecord (>= 2.0.0, < 3.1)
35
+ activeresource (3.0.5)
36
+ activemodel (= 3.0.5)
37
+ activesupport (= 3.0.5)
38
+ activesupport (3.0.5)
39
+ arel (2.0.9)
40
+ bcrypt-ruby (2.1.4)
41
+ builder (2.1.2)
42
+ devise (1.1.7)
43
+ bcrypt-ruby (~> 2.1.2)
44
+ warden (~> 1.0.2)
45
+ diff-lcs (1.1.2)
46
+ dynamic_form (1.1.3)
47
+ erubis (2.6.6)
48
+ abstract (>= 1.0.0)
49
+ factory_girl (2.0.0.beta2)
50
+ factory_girl_rails (1.1.beta1)
51
+ factory_girl (~> 2.0.0.beta)
52
+ rails (>= 3.0.0)
53
+ git (1.2.5)
54
+ i18n (0.5.0)
55
+ jeweler (1.5.2)
56
+ bundler (~> 1.0.0)
57
+ git (>= 1.2.5)
58
+ rake
59
+ mail (2.2.15)
60
+ activesupport (>= 2.3.6)
61
+ i18n (>= 0.4.0)
62
+ mime-types (~> 1.16)
63
+ treetop (~> 1.4.8)
64
+ mime-types (1.16)
65
+ mocha (0.9.12)
66
+ polyglot (0.3.1)
67
+ rack (1.2.1)
68
+ rack-mount (0.6.13)
69
+ rack (>= 1.0.0)
70
+ rack-test (0.5.7)
71
+ rack (>= 1.0)
72
+ rails (3.0.5)
73
+ actionmailer (= 3.0.5)
74
+ actionpack (= 3.0.5)
75
+ activerecord (= 3.0.5)
76
+ activeresource (= 3.0.5)
77
+ activesupport (= 3.0.5)
78
+ bundler (~> 1.0)
79
+ railties (= 3.0.5)
80
+ railties (3.0.5)
81
+ actionpack (= 3.0.5)
82
+ activesupport (= 3.0.5)
83
+ rake (>= 0.8.7)
84
+ thor (~> 0.14.4)
85
+ rake (0.8.7)
86
+ rspec (2.5.0)
87
+ rspec-core (~> 2.5.0)
88
+ rspec-expectations (~> 2.5.0)
89
+ rspec-mocks (~> 2.5.0)
90
+ rspec-core (2.5.1)
91
+ rspec-expectations (2.5.0)
92
+ diff-lcs (~> 1.1.2)
93
+ rspec-mocks (2.5.0)
94
+ rspec-rails (2.5.0)
95
+ actionpack (~> 3.0)
96
+ activesupport (~> 3.0)
97
+ railties (~> 3.0)
98
+ rspec (~> 2.5.0)
99
+ sqlite3 (1.3.3)
100
+ thor (0.14.6)
101
+ treetop (1.4.9)
102
+ polyglot (>= 0.3.1)
103
+ tzinfo (0.3.24)
104
+ warden (1.0.3)
105
+ rack (>= 1.0.0)
106
+ will_paginate (3.0.pre2)
107
+
108
+ PLATFORMS
109
+ ruby
110
+
111
+ DEPENDENCIES
112
+ activerecord-nulldb-adapter
113
+ devise
114
+ dynamic_form
115
+ factory_girl (~> 2.0.0.beta)
116
+ factory_girl_rails (~> 1.1.beta)
117
+ governor!
118
+ jeweler (~> 1.5.2)
119
+ mocha
120
+ rails (~> 3.0.5)
121
+ rspec-rails
122
+ sqlite3
123
+ will_paginate (~> 3.0.beta)
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Liam Morley
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,28 @@
1
+ Governor
2
+ ========
3
+
4
+ **Governor** (named after Rod Blagojevich) is the pluggable blogging platform
5
+ for Rails, built for people who want to build their blog into their website,
6
+ not build their website into their blog.
7
+
8
+ I'm just getting started, but feel free to poke around. I'm sure that when
9
+ this starts getting functional, I'll write some setup documentation here. And
10
+ try the specs, they're fresh!
11
+
12
+ Contributing to Governor
13
+ ------------------------
14
+
15
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
16
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
17
+ * Fork the project
18
+ * Start a feature/bugfix branch
19
+ * Commit and push until you are happy with your contribution
20
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
21
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
22
+
23
+ Copyright
24
+ ---------
25
+
26
+ Copyright &copy; 2011 Liam Morley. See LICENSE.txt for
27
+ further details.
28
+
@@ -0,0 +1,50 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'rake'
11
+
12
+ require 'jeweler'
13
+ Jeweler::Tasks.new do |gem|
14
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
15
+ gem.name = "governor"
16
+ gem.homepage = "http://github.com/carpeliam/governor"
17
+ gem.license = "MIT"
18
+ gem.summary = %Q{A pluggable blogging system for Rails 3.}
19
+ gem.description = %Q{Because Blogojevich would be too tough to remember. It's a pluggable blogging system for Rails 3.}
20
+ gem.email = "liam@carpeliam.com"
21
+ gem.authors = ["Liam Morley"]
22
+ # Include your dependencies below. Runtime dependencies are required when using your gem,
23
+ # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
24
+ # gem.add_runtime_dependency 'jabber4r', '> 0.1'
25
+ # gem.add_development_dependency 'rspec', '> 1.2.3'
26
+ end
27
+ Jeweler::RubygemsDotOrgTasks.new
28
+
29
+ require 'rspec/core'
30
+ require 'rspec/core/rake_task'
31
+ RSpec::Core::RakeTask.new(:spec) do |spec|
32
+ spec.pattern = FileList['spec/**/*_spec.rb']
33
+ end
34
+
35
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
36
+ spec.pattern = 'spec/**/*_spec.rb'
37
+ spec.rcov = true
38
+ end
39
+
40
+ task :default => :spec
41
+
42
+ require 'rake/rdoctask'
43
+ Rake::RDocTask.new do |rdoc|
44
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
45
+
46
+ rdoc.rdoc_dir = 'rdoc'
47
+ rdoc.title = "governor #{version}"
48
+ rdoc.rdoc_files.include('README*')
49
+ rdoc.rdoc_files.include('lib/**/*.rb')
50
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,94 @@
1
+ class Governor::ArticlesController < ApplicationController
2
+ include Governor::Controllers::Helpers
3
+ before_filter :init_resource, :only => [:show, :edit, :update, :destroy]
4
+ before_filter :authorize_governor!, :only => [:new, :edit, :create, :update, :destroy]
5
+ helper :governor
6
+ helper Governor::Controllers::Helpers
7
+
8
+ # GET /articles
9
+ # GET /articles.xml
10
+ def index
11
+ set_resources model_class.paginate :page => params[:page], :order => 'created_at DESC'
12
+ respond_to do |format|
13
+ format.html # index.html.erb
14
+ format.xml { render :xml => resources }
15
+ end
16
+ end
17
+
18
+ # GET /articles/1
19
+ # GET /articles/1.xml
20
+ def show
21
+ respond_to do |format|
22
+ format.html # show.html.erb
23
+ format.xml { render :xml => resource }
24
+ end
25
+ end
26
+
27
+ # GET /articles/new
28
+ # GET /articles/new.xml
29
+ def new
30
+ set_resource model_class.new
31
+
32
+ respond_to do |format|
33
+ format.html # new.html.erb
34
+ format.xml { render :xml => resource }
35
+ end
36
+ end
37
+
38
+ # GET /articles/1/edit
39
+ def edit
40
+ end
41
+
42
+ # POST /articles
43
+ # POST /articles.xml
44
+ def create
45
+ set_resource model_class.new(params[mapping.singular])
46
+ resource.author = GOVERNOR_AUTHOR.call(self)
47
+
48
+ respond_to do |format|
49
+ if resource.save
50
+ flash[:notice] = "#{mapping.humanize} was successfully created."
51
+ format.html { redirect_to(resource) }
52
+ format.xml { render :xml => resource, :status => :created, :location => resource }
53
+ else
54
+ format.html { render :action => 'new' }
55
+ format.xml { render :xml => resource.errors, :status => :unprocessable_entity }
56
+ end
57
+ end
58
+ end
59
+
60
+ # PUT /articles/1
61
+ # PUT /articles/1.xml
62
+ def update
63
+ respond_to do |format|
64
+ if resource.update_attributes(params[mapping.singular])
65
+ flash[:notice] = "#{mapping.humanize} was successfully updated."
66
+ format.html { redirect_to(resource) }
67
+ format.xml { head :ok }
68
+ else
69
+ format.html { render :action => 'edit' }
70
+ format.xml { render :xml => resource.errors, :status => :unprocessable_entity }
71
+ end
72
+ end
73
+ end
74
+
75
+ # DELETE /articles/1
76
+ # DELETE /articles/1.xml
77
+ def destroy
78
+ resource.destroy
79
+
80
+ respond_to do |format|
81
+ format.html { redirect_to(resources_url) }
82
+ format.xml { head :ok }
83
+ end
84
+ end
85
+
86
+ def find_by_date
87
+ set_resources model_class.find_all_by_date(params[:year], params[:month], params[:day], params[:page] || 1)
88
+
89
+ respond_to do |format|
90
+ format.html { render :action => 'index' }
91
+ format.xml { render :xml => resources }
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,26 @@
1
+ module GovernorHelper
2
+ @@months = %w(January February March April May June July August September October November December)
3
+
4
+ def render_plugin_partial(where, options = {})
5
+ output = ""
6
+ Governor::PluginManager.view_hooks[where].each do |f|
7
+ opts = options.merge( {:file => f} )
8
+ output << render(opts)
9
+ end
10
+ return output
11
+ end
12
+
13
+ def get_date_label
14
+ if not params[:day].nil?
15
+ "#{@@months[params[:month].to_i - 1]} #{params[:day]}, #{params[:year]}"
16
+ elsif not params[:month].nil?
17
+ "#{@@months[params[:month].to_i - 1]} #{params[:year]}"
18
+ else
19
+ params[:year]
20
+ end
21
+ end
22
+
23
+ def show_time_ago(date)
24
+ %{<acronym title="#{date.strftime '%A, %B %d, %Y at %I:%M %p'}">#{distance_of_time_in_words_to_now date}</acronym> ago}.html_safe
25
+ end
26
+ end
@@ -0,0 +1,11 @@
1
+ <h1><%= link_to_unless_current resource.title, resource %></h1>
2
+ <div class='subtitle'>
3
+ <div class='desc'>
4
+ <%= resource.description %>
5
+ <%= render_plugin_partial('after_desc', :locals => {:article => resource}) %>
6
+ </div>
7
+ <div class='date'>
8
+ posted <%= show_time_ago resource.created_at %>
9
+ </div>
10
+ </div>
11
+ <%= Governor::Formatters.format_article resource %>
@@ -0,0 +1,28 @@
1
+ <%= error_messages_for resource_sym %>
2
+
3
+ <%= form_for resource do |f| %>
4
+ <p>
5
+ <b><%= f.label :title %></b><br>
6
+ <%= f.text_field :title %>
7
+ </p>
8
+
9
+ <p>
10
+ <b><%= f.label :description %></b><br>
11
+ <%= f.text_field :description %>
12
+ </p>
13
+
14
+ <p id="article_text">
15
+ <b><%= f.label :post %></b><br>
16
+ <%= f.text_area :post %>
17
+ </p>
18
+
19
+ <p>
20
+ <b><%= f.label :format %></b> <%= f.select :format, Governor::Formatters.available_formatters.keys %>
21
+ </p>
22
+
23
+ <%= render_plugin_partial('bottom_of_form', :locals => {:f => f}) %>
24
+
25
+ <p>
26
+ <%= f.submit "#{controller.action_name.titleize} Article" %>
27
+ </p>
28
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <h1>Editing article</h1>
2
+
3
+ <%= render :partial => 'form' %>
4
+
5
+ <%= link_to 'Show', resource %> |
6
+ <%= link_to 'Back', resources_url %>
@@ -0,0 +1,4 @@
1
+ <h1>List</h1>
2
+ <% resources.each do |resource| %>
3
+ <%= link_to resource.title, resource %><br>
4
+ <% end %>
@@ -0,0 +1,5 @@
1
+ <h1>New article</h1>
2
+
3
+ <%= render :partial => 'form' %>
4
+
5
+ <%= link_to 'Back', resources_url %>