regulate 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- regulate (0.1.0)
5
- abstract_auth (~> 0.1.0)
4
+ regulate (0.1.1)
5
+ abstract_auth (~> 0.1.3)
6
6
  grit (~> 2.3.0)
7
7
  rails (~> 3.0.0)
8
8
 
@@ -10,8 +10,8 @@ GEM
10
10
  remote: http://rubygems.org/
11
11
  specs:
12
12
  abstract (1.0.0)
13
- abstract_auth (0.1.0)
14
- module_ext (~> 0.1.0)
13
+ abstract_auth (0.1.3)
14
+ module_ext (~> 0.1.1)
15
15
  actionmailer (3.0.3)
16
16
  actionpack (= 3.0.3)
17
17
  mail (~> 2.2.9)
@@ -50,10 +50,10 @@ GEM
50
50
  rack-test (>= 0.5.4)
51
51
  selenium-webdriver (>= 0.0.27)
52
52
  xpath (~> 0.1.2)
53
- celerity (0.8.6)
53
+ celerity (0.8.7)
54
54
  childprocess (0.1.6)
55
55
  ffi (~> 0.6.3)
56
- culerity (0.2.13)
56
+ culerity (0.2.14)
57
57
  diff-lcs (1.1.2)
58
58
  erubis (2.6.6)
59
59
  abstract (>= 1.0.0)
@@ -64,13 +64,13 @@ GEM
64
64
  mime-types (~> 1.15)
65
65
  i18n (0.5.0)
66
66
  json_pure (1.4.6)
67
- mail (2.2.13)
67
+ mail (2.2.14)
68
68
  activesupport (>= 2.3.6)
69
69
  i18n (>= 0.4.0)
70
70
  mime-types (~> 1.16)
71
71
  treetop (~> 1.4.8)
72
72
  mime-types (1.16)
73
- module_ext (0.1.0)
73
+ module_ext (0.1.1)
74
74
  nokogiri (1.4.4)
75
75
  polyglot (0.3.1)
76
76
  rack (1.2.1)
@@ -103,7 +103,7 @@ GEM
103
103
  treetop (1.4.9)
104
104
  polyglot (>= 0.3.1)
105
105
  tzinfo (0.3.23)
106
- xpath (0.1.2)
106
+ xpath (0.1.3)
107
107
  nokogiri (~> 1.3)
108
108
  yard (0.6.4)
109
109
 
@@ -111,7 +111,7 @@ PLATFORMS
111
111
  ruby
112
112
 
113
113
  DEPENDENCIES
114
- abstract_auth (~> 0.1.0)
114
+ abstract_auth (~> 0.1.3)
115
115
  bluecloth (~> 2.0.9)
116
116
  bundler (~> 1.0.0)
117
117
  capybara (~> 0.4.0)
@@ -4,14 +4,11 @@ module Regulate
4
4
  module Admin
5
5
 
6
6
  # Standard CRUD Controller
7
- class PagesController < ActionController::Base
8
- # Check that a user is authenticated
9
- before_filter :is_authorized?
10
- # Check that the user is an admin
7
+ class PagesController < ::ApplicationController
8
+ include Regulate::Helpers::ControllerHelpers
9
+ before_filter :is_authenticated?
11
10
  before_filter :is_admin?, :only => [:new, :create, :destroy]
12
- # Check that the user is at least an editor
13
11
  before_filter :is_editor?, :not => [:new, :create, :destroy]
14
- # Load in our page object based on the ID
15
12
  before_filter :load_page, :only => [:edit,:update,:destroy]
16
13
 
17
14
  # POST route to create a new page
@@ -61,29 +58,6 @@ module Regulate
61
58
  render :action => :edit
62
59
  end
63
60
 
64
- private
65
-
66
- def is_authorized?
67
- @authorized_user = AbstractAuth.invoke(:authorized_user)
68
- @is_admin = AbstractAuth.invoke(:is_admin)
69
- # Uncomment the following line to test out admin interface
70
- #@is_admin = true
71
- @is_editor = AbstractAuth.invoke(:is_editor)
72
- end
73
-
74
- def is_editor?
75
- redirect_to root_path if !@is_editor
76
- end
77
-
78
- def is_admin?
79
- redirect_to regulate_admin_regulate_pages_path if !@is_admin
80
- end
81
-
82
- # Grab a page resource based on the ID passed to the URI
83
- def load_page
84
- @page = Regulate::Page.find(params[:id])
85
- end
86
-
87
61
  end # class PagesController
88
62
 
89
63
  end # module Admin
@@ -1,12 +1,12 @@
1
1
  module Regulate
2
2
 
3
- # @todo Build out XHR-only methods for frontend inline editing
4
- class PagesController < ActionController::Base
3
+ class PagesController < ::ApplicationController
4
+ include Regulate::Helpers::ControllerHelpers
5
+ before_filter :load_page
6
+ before_filter :is_authenticated?
7
+ before_filter :is_published?
5
8
 
6
- # Show function for front-end
7
- def show
8
- @page = Regulate::Page.find(params[:id])
9
- end
9
+ def show; end
10
10
 
11
11
  end # class PagesController
12
12
 
@@ -12,7 +12,7 @@ module Regulate
12
12
  # Make sure that we're setting our ID.
13
13
  # This needs to be URI-friendly
14
14
  #@id = self.title.gsub(%r{[ /<>]}, '-').downcase
15
- @id = self.title.gsub(/[^a-zA-Z0-9']+/, "-").chomp('-').reverse.chomp('-').reverse.downcase
15
+ @id = self.title.gsub(/[^a-zA-Z0-9]+/, "-").chomp('-').reverse.chomp('-').reverse.downcase
16
16
  end
17
17
 
18
18
  end
@@ -20,6 +20,10 @@ textarea {height:250px;}
20
20
  Title: <%= @page.title %>
21
21
  </div>
22
22
  <% end %>
23
+ <div class="form_row">
24
+ <%= f.label :published %>
25
+ <%= f.check_box :published %>
26
+ </div>
23
27
  <% if @is_admin %>
24
28
  <div class="form_row">
25
29
  <%= f.label :view %>
@@ -6,6 +6,7 @@
6
6
  <% @pages.each do |page| %>
7
7
  <li>
8
8
  <%= page.title %>
9
+ <%= link_to "Show" , regulate_page_path(page) %>
9
10
  <%= link_to "Edit" , edit_regulate_admin_regulate_page_path(page) %>
10
11
  <% if @is_admin %>
11
12
  <%= link_to "Delete" , regulate_admin_regulate_page_path(page), :confirm => 'Are you sure?', :method => :delete, :class => 'delete_link' %>
@@ -1,5 +1,10 @@
1
1
  <h2><%= @page.title %></h2>
2
2
  <cite>by, <%= @page.versions.first.author.name %></cite>
3
+ <% if !@page.published? %>
4
+ <div>
5
+ THIS PAGE HAS NOT YET BEEN PUBLISHED
6
+ </div>
7
+ <% end %>
3
8
  <div>
4
9
  <%= raw @page.rendered %>
5
10
  </div>
data/config/routes.rb CHANGED
@@ -17,6 +17,7 @@ Rails.application.routes.draw do
17
17
  scope "admin", :module => :admin, :as => :admin_regulate do
18
18
  resources :pages
19
19
  end
20
+
20
21
  end
21
22
 
22
23
  end
@@ -1,32 +1,33 @@
1
- Regulate.setup do |config|
2
-
3
- # Role that allows a user to manage pages and define what parts are editable, default is :admin
4
- # The namespace that you would like to use for the routes. The default is 'cms'.
5
- # @example Setting a custom route namespace
6
- # Regulate.setup do |config|
7
- # config.route_namespace = 'my_custom_route_namespace'
8
- # end
9
- #
10
- # config.route_namespace = 'my_custom_route_namespace'
11
-
12
- end
1
+ # Role that allows a user to manage pages and define what parts are editable, default is :admin
2
+ # The namespace that you would like to use for the routes. The default is 'cms'.
3
+ # Run rake:routes to see this in action
4
+ # @example Setting a custom route namespace
5
+ # Regulate.setup do |config|
6
+ # config.route_namespace = 'my_custom_route_namespace'
7
+ # end
13
8
 
14
9
  # AbstractAuth Implementations
15
10
  # You NEED to set these methods appropriately for Regulate to function
16
- # This method should return a the currently authenticated resource
17
- #AbstractAuth.implement :authorized_user do
18
- #::ApplicationController.send('current_user')
11
+ # This method should return the currently authenticated resource if they are authorized to manage the cms
12
+ # The following should work with Devise/AuthLogic
13
+ #AbstractAuth.implement :authenticated_user do
14
+ # current_user
19
15
  #end
16
+
20
17
  # This method should return whether the currently authenticated resource is an admin or not
21
18
  # Admins are able to edit the view field on a CMS page and define the editable regions
22
19
  # If you want any authenticated user to be able to have this ability, simply return true in your implementation
20
+ # This must return true for a user if they are supposed to be able to create new pages and edit the view of a page
23
21
  #AbstractAuth.implement :is_admin do
24
- #::ApplicationController.send('current_user').is_admin?
22
+ # current_user.is_admin?
25
23
  #end
24
+
26
25
  # This method should return whether the currently authenticated resource is an admin or not
27
26
  # Editors only have the ability to change the content of editable regions on the page
28
27
  # If you want any authenticated user to be able to have this ability, simply return true in your implementation
28
+ # In other words, this must return true for a user to have any access/management rights in the CMS
29
+ # If this returns false, the user will be redirected to the root path of the app
29
30
  #AbstractAuth.implement :is_editor do
30
- #::ApplicationController.send('current_user').is_editor?
31
+ # current_user.is_editor?
31
32
  #end
32
33
 
data/lib/regulate.rb CHANGED
@@ -8,10 +8,11 @@ module Regulate
8
8
 
9
9
  # Autoloads
10
10
  autoload :Git , 'regulate/git'
11
+ autoload :Helpers , 'regulate/helpers'
11
12
 
12
13
  # Setup our AbstractAuth requirements
13
14
  AbstractAuth.setup do |config|
14
- config.requires :authorized_user , :is_admin , :is_editor
15
+ config.requires :authenticated_user , :is_admin , :is_editor
15
16
  end
16
17
 
17
18
  # Our host application root path
@@ -254,7 +254,12 @@ module Regulate
254
254
  end
255
255
 
256
256
  # These attributes will be required for all of our models, so we set them here
257
- attributes :id, :commit_message, :author_name, :author_email, :title, :view, :edit_regions
257
+ attributes :id, :commit_message, :author_name, :author_email, :title, :view, :edit_regions, :published
258
+
259
+ # Override the published? method
260
+ def published?
261
+ published == true || published == "1" || published == "t" || published == "true"
262
+ end
258
263
 
259
264
  protected
260
265
 
@@ -0,0 +1,10 @@
1
+ module Regulate
2
+
3
+ module Helpers
4
+
5
+ autoload :ControllerHelpers , 'regulate/helpers/controller_helpers'
6
+
7
+ end
8
+
9
+ end
10
+
@@ -0,0 +1,46 @@
1
+ module Regulate
2
+
3
+ module Helpers
4
+
5
+ module ControllerHelpers
6
+
7
+ private
8
+
9
+ # Check that a user is authenticated
10
+ def is_authenticated?
11
+ @authenticated_user = instance_eval &AbstractAuth.invoke(:authenticated_user)
12
+ @is_admin = instance_eval &AbstractAuth.invoke(:is_admin)
13
+ # Uncomment the following line to test out admin interface
14
+ #@is_admin = true
15
+ @is_editor = instance_eval &AbstractAuth.invoke(:is_editor)
16
+ end
17
+
18
+ # Check that the user is at least an editor
19
+ def is_editor?
20
+ redirect_to root_path if !@is_editor
21
+ end
22
+
23
+ # Check that the user is an admin
24
+ def is_admin?
25
+ redirect_to regulate_admin_regulate_pages_path if !@is_admin
26
+ end
27
+
28
+ # Grab a page resource based on the ID passed to the URI
29
+ # Load in our page object based on the ID
30
+ def load_page
31
+ @page = Regulate::Page.find(params[:id])
32
+ end
33
+
34
+ # Check whether a page is published
35
+ def is_published?
36
+ if !@is_admin || !@is_editor
37
+ redirect_to root_path if !@page.published?
38
+ end
39
+ end
40
+
41
+ end
42
+
43
+ end
44
+
45
+ end
46
+
@@ -1,4 +1,5 @@
1
1
  module Regulate
2
2
  # Our gem version
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
+
data/regulate.gemspec CHANGED
@@ -9,14 +9,14 @@ Gem::Specification.new do |s|
9
9
  s.authors = ["Collin Schaafsma", "Ryan Cook"]
10
10
  s.email = ["collin@quickleft.com", "ryan@quickleft.com"]
11
11
  s.homepage = ""
12
- s.summary = %q{The CMS we always wanted.}
13
- s.description = %q{The CMS we always wanted.}
12
+ s.summary = %q{Rails 3 engine that provides a Git backed CMS that allows for an admin to define editable regions in a page view.}
13
+ s.description = %q{Rails 3 engine that provides a Git backed CMS that allows for an admin to define editable regions in a page view.}
14
14
 
15
15
  s.rubyforge_project = "regulate"
16
16
 
17
17
  s.add_dependency "rails", "~> 3.0.0"
18
18
  s.add_dependency "grit", "~> 2.3.0"
19
- s.add_dependency "abstract_auth", "~> 0.1.0"
19
+ s.add_dependency "abstract_auth", "~> 0.1.3"
20
20
  s.add_development_dependency "bluecloth", "~> 2.0.9"
21
21
  s.add_development_dependency "bundler", "~> 1.0.0"
22
22
  s.add_development_dependency "capybara", "~> 0.4.0"
@@ -1,8 +1,12 @@
1
1
  class ApplicationController < ActionController::Base
2
2
 
3
+ def home
4
+ render :text => "hello"
5
+ end
6
+
3
7
  protect_from_forgery
4
8
 
5
- def self.current_user
9
+ def current_user
6
10
  User.new
7
11
  end
8
12
 
@@ -1,14 +1,13 @@
1
- # Regulate stuff
2
-
3
1
  # AbstractAuth Implementations
4
- AbstractAuth.implement :authorized_user do
5
- ::ApplicationController.instance_eval "current_user"
2
+ AbstractAuth.implement :authenticated_user do
3
+ current_user
6
4
  end
7
5
 
8
6
  AbstractAuth.implement :is_admin do
9
- ::ApplicationController.instance_eval("current_user").is_admin?
7
+ current_user.is_admin?
10
8
  end
11
9
 
12
10
  AbstractAuth.implement :is_editor do
13
- ::ApplicationController.instance_eval("current_user").is_editor?
11
+ current_user.is_editor?
14
12
  end
13
+
@@ -1,4 +1,5 @@
1
1
  Dummy::Application.routes.draw do
2
+ root :to => "application#home"
2
3
  # The priority is based upon order of creation:
3
4
  # first created -> highest priority.
4
5
 
@@ -16,4 +16,11 @@ class Regulate::PageTest < ActiveSupport::TestCase
16
16
  assert_equal "a-fa-ncy-title" , page.id
17
17
  end
18
18
 
19
+ test "removes apostrophes when creating id from title" do
20
+ page = Regulate::Page.new({
21
+ :title => "We'll LOVE you FORever"
22
+ })
23
+ assert_equal "we-ll-love-you-forever" , page.id
24
+ end
25
+
19
26
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: regulate
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 1
10
+ version: 0.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Collin Schaafsma
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-01-12 00:00:00 -07:00
19
+ date: 2011-01-13 00:00:00 -07:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -59,12 +59,12 @@ dependencies:
59
59
  requirements:
60
60
  - - ~>
61
61
  - !ruby/object:Gem::Version
62
- hash: 27
62
+ hash: 29
63
63
  segments:
64
64
  - 0
65
65
  - 1
66
- - 0
67
- version: 0.1.0
66
+ - 3
67
+ version: 0.1.3
68
68
  type: :runtime
69
69
  version_requirements: *id003
70
70
  - !ruby/object:Gem::Dependency
@@ -147,7 +147,7 @@ dependencies:
147
147
  version: 0.6.4
148
148
  type: :development
149
149
  version_requirements: *id008
150
- description: The CMS we always wanted.
150
+ description: Rails 3 engine that provides a Git backed CMS that allows for an admin to define editable regions in a page view.
151
151
  email:
152
152
  - collin@quickleft.com
153
153
  - ryan@quickleft.com
@@ -190,6 +190,8 @@ files:
190
190
  - lib/regulate/git/interface.rb
191
191
  - lib/regulate/git/model.rb
192
192
  - lib/regulate/git/model/base.rb
193
+ - lib/regulate/helpers.rb
194
+ - lib/regulate/helpers/controller_helpers.rb
193
195
  - lib/regulate/version.rb
194
196
  - public/javascripts/jquery.min.js
195
197
  - public/javascripts/regulate_admin.js
@@ -276,7 +278,7 @@ rubyforge_project: regulate
276
278
  rubygems_version: 1.3.7
277
279
  signing_key:
278
280
  specification_version: 3
279
- summary: The CMS we always wanted.
281
+ summary: Rails 3 engine that provides a Git backed CMS that allows for an admin to define editable regions in a page view.
280
282
  test_files:
281
283
  - test/dummy/Rakefile
282
284
  - test/dummy/app/controllers/application_controller.rb