rails_apps_pages 0.5.13 → 0.5.14
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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ef359a0fec8a858da4b7bf89214f3aab064861d
|
4
|
+
data.tar.gz: ff1b5c84ba18d0d9eaa635a416d9c04aacdf050f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aafba5f5bd885a5521cc643e50716c4a0cdf23127356ee48357e1643beb10c9705de7a5002eff15bbf4b4e4250507e3a527d9bb52174821f80f488793c5018cd
|
7
|
+
data.tar.gz: 386ef8b2f30d39068a7027c89e4df20adad5c1b94d3d88fcb8138b662db60d181ecb6d7bb9088ca66f83827eac88bf76f89415ebf84b069476d988572a05fb3b
|
data/CHANGELOG.textile
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
# config/initializers/upmin.rb
|
2
|
+
# Extends the Upmin ApplicationController to limit access to users with an admin role.
|
3
|
+
# Depends on Devise for authentication plus role-based authorization.
|
4
|
+
# Be sure to restart your server when you modify this file.
|
5
|
+
module AdminOnly
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
included do
|
9
|
+
before_filter :authenticate_user!
|
10
|
+
before_filter :admin_only
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def admin_only
|
16
|
+
unless current_user.admin?
|
17
|
+
redirect_to :back, :alert => "Access denied."
|
18
|
+
end
|
19
|
+
rescue ActionController::RedirectBackError
|
20
|
+
redirect_to '/', :alert => "Access denied."
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
Upmin::ApplicationController.send :include, AdminOnly
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
module Pages
|
4
|
+
module Generators
|
5
|
+
class UpminGenerator < ::Rails::Generators::Base
|
6
|
+
source_root File.expand_path("../templates", __FILE__)
|
7
|
+
|
8
|
+
desc "Add Upmin for an admin interface. Requires Devise and role-based authentication."
|
9
|
+
|
10
|
+
def add_upmin
|
11
|
+
copy_file 'upmin.rb', 'config/initializers/upmin.rb'
|
12
|
+
route = " mount Upmin::Engine => '/admin'"
|
13
|
+
inject_into_file 'config/routes.rb', route + "\n", :after => "routes.draw do\n"
|
14
|
+
navlink = " <li><%= link_to 'Admin', '/admin' %></li>"
|
15
|
+
inject_into_file 'app/views/layouts/_navigation_links.html.erb', navlink + "\n", :after => "<% if current_user.admin? %>\n"
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_apps_pages
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Kehoe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -78,6 +78,8 @@ files:
|
|
78
78
|
- lib/generators/pages/roles/templates/devise/users_controller.rb
|
79
79
|
- lib/generators/pages/roles/templates/omniauth/users_controller.rb
|
80
80
|
- lib/generators/pages/roles/templates/users/_user.html.erb
|
81
|
+
- lib/generators/pages/upmin/templates/upmin.rb
|
82
|
+
- lib/generators/pages/upmin/upmin_generator.rb
|
81
83
|
- lib/generators/pages/users/templates/devise/devise_permitted_parameters.rb
|
82
84
|
- lib/generators/pages/users/templates/devise/users_controller.rb
|
83
85
|
- lib/generators/pages/users/templates/omniauth/_user.html.erb
|