nice_admin 0.0.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/lib/nice_admin.rb +37 -0
- data/readme.md +60 -0
- metadata +79 -0
data/lib/nice_admin.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
module NiceAdmin
|
2
|
+
class Engine < Rails::Engine
|
3
|
+
engine_name :nice_admin
|
4
|
+
end
|
5
|
+
|
6
|
+
def self.included(base)
|
7
|
+
base.send(:extend, ClassMethods)
|
8
|
+
end
|
9
|
+
mattr_accessor :nav_items
|
10
|
+
@@nav_items = {}
|
11
|
+
|
12
|
+
mattr_accessor :site_title
|
13
|
+
@@site_title = 'Nice Admin'
|
14
|
+
|
15
|
+
mattr_accessor :site_name
|
16
|
+
@@site_name = 'NiceA dminn'
|
17
|
+
end
|
18
|
+
|
19
|
+
module ClassMethods
|
20
|
+
def nice_admin_nav(&block)
|
21
|
+
hash = OptionsHash.new
|
22
|
+
block.call(hash)
|
23
|
+
NiceAdmin.nav_items = hash.opts
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
class OptionsHash
|
28
|
+
attr_accessor :opts
|
29
|
+
|
30
|
+
def initialize
|
31
|
+
@opts = {}
|
32
|
+
end
|
33
|
+
|
34
|
+
def method_missing(sym, *args)
|
35
|
+
@opts[args.first.to_s] = args.last.to_s
|
36
|
+
end
|
37
|
+
end
|
data/readme.md
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
# Nice Admin
|
2
|
+
|
3
|
+
A prebuilt and skinned admin centre. Because, making an admin for everything is really annoying.
|
4
|
+
|
5
|
+
# Install
|
6
|
+
|
7
|
+
simply add the following to your gemfile
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'nice_admin'
|
11
|
+
```
|
12
|
+
|
13
|
+
Then add the following to your config/environments/production.rb
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
config.assets.precompile += %w( nice_admin.js nice_admin.css )
|
17
|
+
```
|
18
|
+
|
19
|
+
# Configuring
|
20
|
+
|
21
|
+
Create an initializer called nice_admin.rb in config/initialisers, inside you can set the following..
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
NiceAdmin.site_title = 'MySiteName - Admin'
|
25
|
+
NiceAdmin.site_name = 'MySiteName'
|
26
|
+
```
|
27
|
+
|
28
|
+
Create an admin controller in your application and have it inherit from nice_admin like so
|
29
|
+
|
30
|
+
Notice this is where you also define the navigation items and include any authenticate you may need.
|
31
|
+
|
32
|
+
Nice admin DOES NOT DO AUTHENTICATION, this before filter is from devise
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
class AdminController < NiceAdminController
|
36
|
+
|
37
|
+
# devise before filter
|
38
|
+
before_filter :authenticate_admin!
|
39
|
+
|
40
|
+
# defining nav items
|
41
|
+
nice_admin_nav do |nav|
|
42
|
+
nav.item 'Home', '/admin'
|
43
|
+
nav.item 'Admins', '/admin/admins'
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
```
|
48
|
+
|
49
|
+
Now, when making admin controller they should inherit from your AdminController
|
50
|
+
nice_admin supports pagination via kaminari automatically
|
51
|
+
|
52
|
+
```ruby
|
53
|
+
class ArticlesController < AdminController
|
54
|
+
|
55
|
+
def index
|
56
|
+
@admins = Admin.order('created_at DESC').page(params[:page]).per(20)
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
```
|
metadata
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: nice_admin
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.1
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Alex Barlow
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-07-08 00:00:00 +01:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: kaminari
|
18
|
+
prerelease: false
|
19
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
|
+
none: false
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: "0"
|
25
|
+
type: :runtime
|
26
|
+
version_requirements: *id001
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: formtastic
|
29
|
+
prerelease: false
|
30
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
31
|
+
none: false
|
32
|
+
requirements:
|
33
|
+
- - ">="
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: "0"
|
36
|
+
type: :runtime
|
37
|
+
version_requirements: *id002
|
38
|
+
description: A prebuild admin, becuase, making an admin for everything sucks
|
39
|
+
email:
|
40
|
+
- alex@madebyfudge.com
|
41
|
+
executables: []
|
42
|
+
|
43
|
+
extensions: []
|
44
|
+
|
45
|
+
extra_rdoc_files: []
|
46
|
+
|
47
|
+
files:
|
48
|
+
- lib/nice_admin.rb
|
49
|
+
- readme.md
|
50
|
+
has_rdoc: true
|
51
|
+
homepage: http://madebyfudge.com
|
52
|
+
licenses:
|
53
|
+
- MIT
|
54
|
+
post_install_message:
|
55
|
+
rdoc_options: []
|
56
|
+
|
57
|
+
require_paths:
|
58
|
+
- lib
|
59
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
60
|
+
none: false
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: "0"
|
65
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: "0"
|
71
|
+
requirements: []
|
72
|
+
|
73
|
+
rubyforge_project:
|
74
|
+
rubygems_version: 1.6.2
|
75
|
+
signing_key:
|
76
|
+
specification_version: 3
|
77
|
+
summary: A prebuild admin, becuase, making an admin for everything sucks
|
78
|
+
test_files: []
|
79
|
+
|