governor 0.5.3 → 0.5.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -1
- data/Gemfile.lock +3 -3
- data/README.rdoc +30 -25
- data/VERSION +1 -1
- data/app/helpers/governor_helper.rb +1 -1
- data/app/views/governor/articles/_article.html.erb +16 -12
- data/app/views/governor/articles/index.html.erb +2 -4
- data/governor.gemspec +5 -5
- data/lib/governor/mapping.rb +8 -2
- data/spec/rails_app/Gemfile.lock +2 -2
- metadata +5 -5
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ./
|
3
3
|
specs:
|
4
|
-
governor (0.5.
|
5
|
-
rails (
|
4
|
+
governor (0.5.4)
|
5
|
+
rails (>= 3.0.5)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: http://rubygems.org/
|
@@ -122,7 +122,7 @@ DEPENDENCIES
|
|
122
122
|
governor!
|
123
123
|
jeweler (~> 1.5.2)
|
124
124
|
mocha
|
125
|
-
rails (
|
125
|
+
rails (>= 3.0.5)
|
126
126
|
rcov
|
127
127
|
rspec-rails
|
128
128
|
sqlite3
|
data/README.rdoc
CHANGED
@@ -4,10 +4,6 @@
|
|
4
4
|
for Rails, built for people who want to build their blog into their website,
|
5
5
|
not build their website into their blog.
|
6
6
|
|
7
|
-
I'm just getting started, but feel free to poke around. I'm sure that when
|
8
|
-
this starts getting functional, I'll write some setup documentation here. And
|
9
|
-
try the specs, they're fresh!
|
10
|
-
|
11
7
|
== Dependencies
|
12
8
|
|
13
9
|
* ActiveRecord
|
@@ -22,13 +18,7 @@ Gemfile.
|
|
22
18
|
|
23
19
|
gem 'governor'
|
24
20
|
|
25
|
-
|
26
|
-
|
27
|
-
rails generate governor:install
|
28
|
-
|
29
|
-
This will add an initializer which allows you some loose configuration of
|
30
|
-
Governor. As Governor grows, the initializer will actually get some teeth. Now
|
31
|
-
you're ready to add a model:
|
21
|
+
Now you're ready to add a model:
|
32
22
|
|
33
23
|
rails generate governor:create_articles [CLASS_NAME]
|
34
24
|
|
@@ -42,27 +32,42 @@ Now that you have an article model and a set of routes, you're ready to plug
|
|
42
32
|
it into your app. I'd recommend running `rake routes` to see what routes have
|
43
33
|
been added, as they depend on the model name you chose.
|
44
34
|
|
45
|
-
The Governor initialization will check if Devise is installed, and will try to
|
46
|
-
Do The Right Thing if it is. If not, it'll yell at you, so be sure to set up
|
47
|
-
your authorization rules in this file.
|
48
|
-
|
49
35
|
== Authentication/Authorization
|
50
36
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
37
|
+
Governor checks to see if any of the popular authentication schemes are in
|
38
|
+
place, and should work with Devise, Authlogic, and Clearance. If you're using
|
39
|
+
something else, It's fairly easy to plug in to Governor. Running the following
|
40
|
+
generator will add an initializer to your app:
|
41
|
+
|
42
|
+
rails generate governor:configure
|
43
|
+
|
44
|
+
Here's a snippet from the initializer:
|
45
|
+
|
46
|
+
# How to reference the author of an article
|
47
|
+
Governor.author = Proc.new do
|
48
|
+
if defined?(Devise)
|
49
|
+
send("current_#{Devise.default_scope}")
|
50
|
+
elsif respond_to?(:current_user)
|
51
|
+
current_user
|
52
|
+
else
|
53
|
+
raise "Please define Governor.author. Run `rails generator governor:configure` to install an initializer."
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
Replace the block with your own code. This will allow you to define
|
58
|
+
app-specific definitions for the author of an article; authorization rules for
|
59
|
+
editing/deleting articles; and what the application should do if someone
|
60
|
+
breaks those rules.
|
56
61
|
|
57
62
|
== Roadmap
|
58
63
|
|
59
64
|
Less of a roadmap as a politician's promise of what will exist in future
|
60
65
|
versions of Governor:
|
61
66
|
|
62
|
-
*
|
63
|
-
*
|
64
|
-
*
|
65
|
-
|
67
|
+
* A better-documented plugin API.
|
68
|
+
* More plugins[https://github.com/carpeliam/governor/wiki/Plugins].
|
69
|
+
* The ability for a plugin to modify the rendering of an existing element on
|
70
|
+
the page.
|
66
71
|
* A chicken in every pot and a car in every garage.
|
67
72
|
|
68
73
|
Until v1.0 (or at least until things start to stabilize), I won't promise
|
@@ -86,6 +91,6 @@ developers. Still, if you're interested in improving this, let's talk.
|
|
86
91
|
|
87
92
|
== Copyright
|
88
93
|
|
89
|
-
Copyright (
|
94
|
+
Copyright (c) 2011 Liam Morley. See LICENSE.txt for
|
90
95
|
further details.
|
91
96
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.4
|
@@ -15,6 +15,6 @@ module GovernorHelper
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def show_time_ago(date)
|
18
|
-
%{<
|
18
|
+
%{<time pubdate="" datetime="#{date.localtime.iso8601}" title="#{l date}">#{distance_of_time_in_words_to_now date} ago</time>}.html_safe
|
19
19
|
end
|
20
20
|
end
|
@@ -1,12 +1,16 @@
|
|
1
|
-
<
|
2
|
-
<
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
1
|
+
<article>
|
2
|
+
<header>
|
3
|
+
<h1><%= link_to_unless_current article.title, article %></h1>
|
4
|
+
<div class='subtitle'>
|
5
|
+
<div class='desc'>
|
6
|
+
<%= article.description %>
|
7
|
+
<%= render_plugin_partial(:after_article_description, :locals => {:article => article}) %>
|
8
|
+
</div>
|
9
|
+
<div class='date'>
|
10
|
+
posted <%= show_time_ago article.created_at %>
|
11
|
+
</div>
|
12
|
+
</div>
|
13
|
+
</header>
|
14
|
+
<%= Governor::Formatters.format_article article %>
|
15
|
+
<%= render_plugin_partial(:after_article_summary, :locals => {:article => article}) unless current_page?(article) %>
|
16
|
+
</article>
|
@@ -1,7 +1,5 @@
|
|
1
1
|
<% if resources.blank? %><%= (@blank_msg or "There are no articles for this time period.") %><% end %>
|
2
2
|
<%= render_plugin_partial :before_articles %>
|
3
|
-
<%= render :partial => '
|
3
|
+
<%= render :partial => 'governor/articles/article', :collection => resources %>
|
4
4
|
|
5
|
-
|
6
|
-
<%= will_paginate(resources) if respond_to?(:will_paginate) %>
|
7
|
-
</p>
|
5
|
+
<%= will_paginate(resources) if respond_to?(:will_paginate) %>
|
data/governor.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{governor}
|
8
|
-
s.version = "0.5.
|
8
|
+
s.version = "0.5.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Liam Morley"]
|
12
|
-
s.date = %q{2011-05-
|
12
|
+
s.date = %q{2011-05-14}
|
13
13
|
s.description = %q{Because Blogojevich would be too tough to remember. It's a pluggable blogging system for Rails 3.}
|
14
14
|
s.email = %q{liam@carpeliam.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -171,7 +171,7 @@ Gem::Specification.new do |s|
|
|
171
171
|
s.specification_version = 3
|
172
172
|
|
173
173
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
174
|
-
s.add_runtime_dependency(%q<rails>, ["
|
174
|
+
s.add_runtime_dependency(%q<rails>, [">= 3.0.5"])
|
175
175
|
s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
|
176
176
|
s.add_development_dependency(%q<sqlite3>, [">= 0"])
|
177
177
|
s.add_development_dependency(%q<rspec-rails>, [">= 0"])
|
@@ -185,7 +185,7 @@ Gem::Specification.new do |s|
|
|
185
185
|
s.add_development_dependency(%q<governor>, [">= 0"])
|
186
186
|
s.add_development_dependency(%q<dynamic_form>, [">= 0"])
|
187
187
|
else
|
188
|
-
s.add_dependency(%q<rails>, ["
|
188
|
+
s.add_dependency(%q<rails>, [">= 3.0.5"])
|
189
189
|
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
190
190
|
s.add_dependency(%q<sqlite3>, [">= 0"])
|
191
191
|
s.add_dependency(%q<rspec-rails>, [">= 0"])
|
@@ -200,7 +200,7 @@ Gem::Specification.new do |s|
|
|
200
200
|
s.add_dependency(%q<dynamic_form>, [">= 0"])
|
201
201
|
end
|
202
202
|
else
|
203
|
-
s.add_dependency(%q<rails>, ["
|
203
|
+
s.add_dependency(%q<rails>, [">= 3.0.5"])
|
204
204
|
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
205
205
|
s.add_dependency(%q<sqlite3>, [">= 0"])
|
206
206
|
s.add_dependency(%q<rspec-rails>, [">= 0"])
|
data/lib/governor/mapping.rb
CHANGED
@@ -8,7 +8,9 @@ module Governor
|
|
8
8
|
@singular = (options[:singular] || @plural.to_s.singularize).to_sym
|
9
9
|
|
10
10
|
@class_name = (options[:class_name] || resource.to_s.classify).to_s
|
11
|
-
@ref = ActiveSupport::Dependencies
|
11
|
+
@ref = defined?(ActiveSupport::Dependencies::ClassCache) ?
|
12
|
+
ActiveSupport::Dependencies::Reference.store(@class_name) :
|
13
|
+
ActiveSupport::Dependencies.ref(@class_name)
|
12
14
|
|
13
15
|
@path = (options[:path] || resource).to_s
|
14
16
|
@path_prefix = options[:path_prefix]
|
@@ -18,7 +20,11 @@ module Governor
|
|
18
20
|
|
19
21
|
# Provides the resource class.
|
20
22
|
def to
|
21
|
-
|
23
|
+
if defined?(ActiveSupport::Dependencies::ClassCache)
|
24
|
+
@ref.get @class_name
|
25
|
+
else
|
26
|
+
@ref.get
|
27
|
+
end
|
22
28
|
end
|
23
29
|
|
24
30
|
# Presents a human-readable identifier of the resource type.
|
data/spec/rails_app/Gemfile.lock
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: governor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 3
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 5
|
9
|
-
-
|
10
|
-
version: 0.5.
|
9
|
+
- 4
|
10
|
+
version: 0.5.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Liam Morley
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-05-
|
18
|
+
date: 2011-05-14 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -25,7 +25,7 @@ dependencies:
|
|
25
25
|
version_requirements: &id001 !ruby/object:Gem::Requirement
|
26
26
|
none: false
|
27
27
|
requirements:
|
28
|
-
- -
|
28
|
+
- - ">="
|
29
29
|
- !ruby/object:Gem::Version
|
30
30
|
hash: 13
|
31
31
|
segments:
|