puffer 0.0.29 → 0.0.30
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -0
- data/Gemfile.lock +56 -52
- data/README.md +51 -43
- data/VERSION +1 -1
- data/app/assets/javascripts/puffer/application.js +3 -1
- data/app/assets/stylesheets/puffer/application.css +2 -0
- data/app/assets/stylesheets/puffer/puffer.css +5 -9
- data/app/components/base_component.rb +0 -1
- data/app/components/boolean/index.html.erb +1 -1
- data/app/components/boolean_component.rb +1 -1
- data/app/components/references_many/index.html.erb +1 -0
- data/app/components/references_many_component.rb +8 -0
- data/app/components/references_one_component.rb +6 -1
- data/app/components/select/filter.html.erb +2 -0
- data/app/components/select/form.html.erb +1 -1
- data/app/components/select_component.rb +13 -2
- data/app/controllers/admin/puffer_users_controller.rb +5 -1
- data/app/controllers/admin/sessions_controller.rb +4 -1
- data/app/controllers/puffer/base.rb +1 -1
- data/app/controllers/puffer/sessions_base.rb +3 -0
- data/app/controllers/puffer/tree_base.rb +4 -4
- data/app/helpers/puffer_helper.rb +16 -15
- data/app/models/puffer/puffer_user.rb +11 -10
- data/app/models/puffer_user.rb +14 -2
- data/app/views/layouts/puffer.html.erb +16 -17
- data/app/views/layouts/puffer_base.html.erb +1 -2
- data/app/views/layouts/puffer_dashboard.html.erb +2 -2
- data/app/views/puffer/base/edit.html.erb +12 -3
- data/app/views/puffer/base/new.html.erb +12 -3
- data/app/views/puffer/dashboard_base/index.html.erb +5 -5
- data/lib/generators/puffer/component/component_generator.rb +0 -1
- data/lib/generators/puffer/controller/controller_generator.rb +1 -1
- data/lib/generators/puffer/controller/templates/controller.rb +8 -0
- data/lib/puffer.rb +77 -13
- data/lib/puffer/component.rb +14 -9
- data/lib/puffer/controller/auth.rb +41 -2
- data/lib/puffer/controller/config.rb +1 -1
- data/lib/puffer/controller/mutate.rb +15 -6
- data/lib/puffer/extensions/core.rb +4 -0
- data/lib/puffer/extensions/directive_processor.rb +36 -0
- data/lib/puffer/extensions/form.rb +1 -1
- data/lib/puffer/extensions/mapper.rb +74 -149
- data/lib/puffer/field.rb +2 -4
- data/lib/puffer/field_set.rb +3 -15
- data/lib/puffer/filters.rb +105 -0
- data/lib/puffer/orm_adapter/active_record.rb +33 -0
- data/lib/puffer/orm_adapter/base.rb +4 -0
- data/lib/puffer/orm_adapter/mongoid.rb +29 -0
- data/lib/puffer/resource.rb +63 -62
- data/lib/puffer/resource/node.rb +71 -0
- data/lib/puffer/resource/routing.rb +4 -4
- data/lib/puffer/resource/tree.rb +36 -0
- data/puffer.gemspec +28 -8
- data/spec/dummy/app/controllers/admin/posts_controller.rb +1 -1
- data/spec/dummy/app/controllers/admin/users_controller.rb +1 -0
- data/spec/dummy/app/controllers/application_controller.rb +4 -0
- data/spec/dummy/app/controllers/orms/active_record_orm_primals_controller.rb +36 -0
- data/spec/dummy/app/controllers/orms/mongoid_orm_primals_controller.rb +42 -0
- data/spec/dummy/app/models/active_record_orm.rb +5 -0
- data/spec/dummy/app/models/active_record_orm/primal.rb +2 -0
- data/spec/dummy/app/models/{mongoid_test.rb → mongoid_orm.rb} +1 -1
- data/spec/dummy/app/models/mongoid_orm/primal.rb +46 -0
- data/spec/dummy/config/environments/development.rb +3 -0
- data/spec/dummy/config/routes.rb +2 -1
- data/spec/dummy/db/migrate/20110930183902_create_active_record_orm_primals.rb +17 -0
- data/spec/dummy/db/schema.rb +15 -1
- data/spec/fabricators/active_record_orm/primal.rb +13 -0
- data/spec/fabricators/mongoid_orm/primal.rb +12 -0
- data/spec/generators/puffer/component/component_generator_spec.rb +32 -0
- data/spec/generators/puffer/controller/controller_generator_spec.rb +31 -0
- data/spec/helpers/puffer_helper_spec.rb +62 -0
- data/spec/lib/filters_spec.rb +21 -0
- data/spec/lib/orm_adapter/active_record_spec.rb +33 -0
- data/spec/lib/orm_adapter/base_shared.rb +97 -0
- data/spec/lib/orm_adapter/mongoid_spec.rb +46 -0
- data/spec/lib/resource/routing_spec.rb +5 -5
- data/spec/lib/resource/tree_spec.rb +31 -0
- data/spec/lib/resource_spec.rb +36 -37
- data/spec/spec_helper.rb +3 -2
- metadata +71 -43
- data/app/views/puffer/base/_form.html.erb +0 -11
- data/lib/generators/puffer/component/templates/component_spec.rb +0 -19
- data/lib/puffer/resource/scoping.rb +0 -19
- data/spec/dummy/app/controllers/orms/mongoid_tests_controller.rb +0 -19
- data/spec/lib/params_spec.rb +0 -120
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,39 +1,43 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
actionmailer (3.1.
|
5
|
-
actionpack (= 3.1.
|
4
|
+
actionmailer (3.1.1)
|
5
|
+
actionpack (= 3.1.1)
|
6
6
|
mail (~> 2.3.0)
|
7
|
-
actionpack (3.1.
|
8
|
-
activemodel (= 3.1.
|
9
|
-
activesupport (= 3.1.
|
7
|
+
actionpack (3.1.1)
|
8
|
+
activemodel (= 3.1.1)
|
9
|
+
activesupport (= 3.1.1)
|
10
10
|
builder (~> 3.0.0)
|
11
11
|
erubis (~> 2.7.0)
|
12
12
|
i18n (~> 0.6)
|
13
13
|
rack (~> 1.3.2)
|
14
|
-
rack-cache (~> 1.
|
14
|
+
rack-cache (~> 1.1)
|
15
15
|
rack-mount (~> 0.8.2)
|
16
16
|
rack-test (~> 0.6.1)
|
17
|
-
sprockets (~> 2.0.
|
18
|
-
activemodel (3.1.
|
19
|
-
activesupport (= 3.1.
|
20
|
-
bcrypt-ruby (~> 3.0.0)
|
17
|
+
sprockets (~> 2.0.2)
|
18
|
+
activemodel (3.1.1)
|
19
|
+
activesupport (= 3.1.1)
|
21
20
|
builder (~> 3.0.0)
|
22
21
|
i18n (~> 0.6)
|
23
|
-
activerecord (3.1.
|
24
|
-
activemodel (= 3.1.
|
25
|
-
activesupport (= 3.1.
|
22
|
+
activerecord (3.1.1)
|
23
|
+
activemodel (= 3.1.1)
|
24
|
+
activesupport (= 3.1.1)
|
26
25
|
arel (~> 2.2.1)
|
27
26
|
tzinfo (~> 0.3.29)
|
28
|
-
activeresource (3.1.
|
29
|
-
activemodel (= 3.1.
|
30
|
-
activesupport (= 3.1.
|
31
|
-
activesupport (3.1.
|
27
|
+
activeresource (3.1.1)
|
28
|
+
activemodel (= 3.1.1)
|
29
|
+
activesupport (= 3.1.1)
|
30
|
+
activesupport (3.1.1)
|
32
31
|
multi_json (~> 1.0)
|
32
|
+
ammeter (0.2.1)
|
33
|
+
activesupport (~> 3.0)
|
34
|
+
railties (~> 3.0)
|
35
|
+
rspec (~> 2.2)
|
36
|
+
rspec-rails (~> 2.2)
|
33
37
|
arel (2.2.1)
|
34
|
-
bcrypt-ruby (3.0.
|
35
|
-
bson (1.
|
36
|
-
bson_ext (1.
|
38
|
+
bcrypt-ruby (3.0.1)
|
39
|
+
bson (1.4.1)
|
40
|
+
bson_ext (1.4.0)
|
37
41
|
builder (3.0.0)
|
38
42
|
capybara (1.1.1)
|
39
43
|
mime-types (>= 1.16)
|
@@ -45,29 +49,28 @@ GEM
|
|
45
49
|
childprocess (0.2.2)
|
46
50
|
ffi (~> 1.0.6)
|
47
51
|
database_cleaner (0.6.7)
|
48
|
-
devise (1.4.
|
52
|
+
devise (1.4.8)
|
49
53
|
bcrypt-ruby (~> 3.0)
|
50
54
|
orm_adapter (~> 0.0.3)
|
51
55
|
warden (~> 1.0.3)
|
52
56
|
diff-lcs (1.1.3)
|
53
57
|
erubis (2.7.0)
|
54
|
-
fabrication (1.
|
58
|
+
fabrication (1.2.0)
|
55
59
|
ffi (1.0.9)
|
56
|
-
forgery (0.
|
57
|
-
nokogiri (~> 1.4)
|
60
|
+
forgery (0.5.0)
|
58
61
|
git (1.2.5)
|
59
|
-
guard (0.
|
62
|
+
guard (0.8.4)
|
60
63
|
thor (~> 0.14.6)
|
61
|
-
guard-rspec (0.
|
62
|
-
guard (>= 0.4
|
64
|
+
guard-rspec (0.5.0)
|
65
|
+
guard (>= 0.8.4)
|
63
66
|
hike (1.2.1)
|
64
67
|
i18n (0.6.0)
|
65
68
|
jeweler (1.6.4)
|
66
69
|
bundler (~> 1.0)
|
67
70
|
git (>= 1.2.5)
|
68
71
|
rake
|
69
|
-
|
70
|
-
|
72
|
+
json (1.6.1)
|
73
|
+
json_pure (1.6.1)
|
71
74
|
kaminari (0.12.4)
|
72
75
|
rails (>= 3.0.0)
|
73
76
|
libnotify (0.5.7)
|
@@ -76,11 +79,11 @@ GEM
|
|
76
79
|
mime-types (~> 1.16)
|
77
80
|
treetop (~> 1.4.8)
|
78
81
|
mime-types (1.16)
|
79
|
-
mongo (1.
|
80
|
-
bson (
|
81
|
-
mongoid (2.2
|
82
|
-
activemodel (~> 3.
|
83
|
-
mongo (~> 1.
|
82
|
+
mongo (1.4.1)
|
83
|
+
bson (= 1.4.1)
|
84
|
+
mongoid (2.3.2)
|
85
|
+
activemodel (~> 3.1)
|
86
|
+
mongo (~> 1.4)
|
84
87
|
tzinfo (~> 0.3.22)
|
85
88
|
multi_json (1.0.3)
|
86
89
|
nested_set (1.6.8)
|
@@ -89,8 +92,8 @@ GEM
|
|
89
92
|
nokogiri (1.5.0)
|
90
93
|
orm_adapter (0.0.5)
|
91
94
|
polyglot (0.3.2)
|
92
|
-
rack (1.3.
|
93
|
-
rack-cache (1.
|
95
|
+
rack (1.3.4)
|
96
|
+
rack-cache (1.1)
|
94
97
|
rack (>= 0.4)
|
95
98
|
rack-mount (0.8.3)
|
96
99
|
rack (>= 1.0.0)
|
@@ -98,23 +101,24 @@ GEM
|
|
98
101
|
rack
|
99
102
|
rack-test (0.6.1)
|
100
103
|
rack (>= 1.0)
|
101
|
-
rails (3.1.
|
102
|
-
actionmailer (= 3.1.
|
103
|
-
actionpack (= 3.1.
|
104
|
-
activerecord (= 3.1.
|
105
|
-
activeresource (= 3.1.
|
106
|
-
activesupport (= 3.1.
|
104
|
+
rails (3.1.1)
|
105
|
+
actionmailer (= 3.1.1)
|
106
|
+
actionpack (= 3.1.1)
|
107
|
+
activerecord (= 3.1.1)
|
108
|
+
activeresource (= 3.1.1)
|
109
|
+
activesupport (= 3.1.1)
|
107
110
|
bundler (~> 1.0)
|
108
|
-
railties (= 3.1.
|
109
|
-
railties (3.1.
|
110
|
-
actionpack (= 3.1.
|
111
|
-
activesupport (= 3.1.
|
111
|
+
railties (= 3.1.1)
|
112
|
+
railties (3.1.1)
|
113
|
+
actionpack (= 3.1.1)
|
114
|
+
activesupport (= 3.1.1)
|
112
115
|
rack-ssl (~> 1.3.2)
|
113
116
|
rake (>= 0.8.7)
|
114
117
|
rdoc (~> 3.4)
|
115
118
|
thor (~> 0.14.6)
|
116
119
|
rake (0.9.2)
|
117
|
-
rdoc (3.
|
120
|
+
rdoc (3.10)
|
121
|
+
json (~> 1.4)
|
118
122
|
rspec (2.6.0)
|
119
123
|
rspec-core (~> 2.6.0)
|
120
124
|
rspec-expectations (~> 2.6.0)
|
@@ -129,24 +133,23 @@ GEM
|
|
129
133
|
railties (~> 3.0)
|
130
134
|
rspec (~> 2.6.0)
|
131
135
|
rubyzip (0.9.4)
|
132
|
-
selenium-webdriver (2.
|
136
|
+
selenium-webdriver (2.8.0)
|
133
137
|
childprocess (>= 0.2.1)
|
134
138
|
ffi (>= 1.0.7)
|
135
139
|
json_pure
|
136
140
|
rubyzip
|
137
|
-
sprockets (2.0.
|
141
|
+
sprockets (2.0.2)
|
138
142
|
hike (~> 1.2)
|
139
143
|
rack (~> 1.0)
|
140
144
|
tilt (~> 1.1, != 1.3.0)
|
141
|
-
spruz (0.2.13)
|
142
145
|
sqlite3 (1.3.4)
|
143
146
|
thor (0.14.6)
|
144
147
|
tilt (1.3.3)
|
145
148
|
treetop (1.4.10)
|
146
149
|
polyglot
|
147
150
|
polyglot (>= 0.3.1)
|
148
|
-
tzinfo (0.3.
|
149
|
-
warden (1.0.
|
151
|
+
tzinfo (0.3.30)
|
152
|
+
warden (1.0.6)
|
150
153
|
rack (>= 1.0)
|
151
154
|
xpath (0.1.4)
|
152
155
|
nokogiri (~> 1.3)
|
@@ -155,6 +158,7 @@ PLATFORMS
|
|
155
158
|
ruby
|
156
159
|
|
157
160
|
DEPENDENCIES
|
161
|
+
ammeter
|
158
162
|
bson_ext
|
159
163
|
capybara
|
160
164
|
database_cleaner
|
data/README.md
CHANGED
@@ -1,26 +1,34 @@
|
|
1
1
|
# Puffer - YARAI (Yet Another Rails Admin Interface). Rails 3.1 only.
|
2
2
|
|
3
|
-
Puffer was created to help project owner or moderators view and edit all the project
|
3
|
+
Puffer was created to help a project owner or moderators view and edit all the project's data models. It's compatible with Rails 3.1 only.
|
4
4
|
|
5
|
-
##
|
5
|
+
## Discussion and help
|
6
6
|
|
7
|
-
|
7
|
+
puffer@conference.jabber.org
|
8
|
+
|
9
|
+
## Key features
|
10
|
+
|
11
|
+
* Full Rails integration. Puffer has no configuration, just a DSL to create interfaces. And this DSL depends on Rails conventions.
|
8
12
|
* Flexibility. Puffer designed to be as flexible as possible, so you can create your own modules easily.
|
9
13
|
* I18n. Surely.
|
10
|
-
*
|
14
|
+
* Puffer can support different ORMs or ODMs through orm_adapter.
|
15
|
+
* Implemented full AR and Mongoid support.
|
11
16
|
|
12
17
|
## Installation.
|
13
18
|
|
14
|
-
You can
|
15
|
-
|
19
|
+
You can install puffer as a gem:
|
20
|
+
|
21
|
+
`gem install puffer`
|
22
|
+
|
16
23
|
Or in Gemfile:
|
17
|
-
|
24
|
+
|
25
|
+
`gem "puffer"`
|
18
26
|
|
19
27
|
## Introduction.
|
20
28
|
|
21
|
-
|
29
|
+
Let's assume this is the data structure of your project:
|
22
30
|
|
23
|
-
|
31
|
+
```
|
24
32
|
create_table "users", :force => true do |t|
|
25
33
|
t.string "email"
|
26
34
|
t.string "password"
|
@@ -35,33 +43,35 @@ create_table "posts", :force => true do |t|
|
|
35
43
|
t.datetime "created_at"
|
36
44
|
t.datetime "updated_at"
|
37
45
|
end
|
38
|
-
|
46
|
+
```
|
39
47
|
|
40
|
-
|
48
|
+
And let's also assume your models look like this:
|
41
49
|
|
42
|
-
|
43
|
-
class User
|
50
|
+
```
|
51
|
+
class User < ActiveRecord::Base
|
44
52
|
has_many :posts
|
45
53
|
validates_presence_of :email, :password
|
46
54
|
validates_length_of :password, :minimum => 6
|
47
55
|
end
|
48
|
-
</pre>
|
49
56
|
|
50
|
-
<
|
51
|
-
class Profile < ActiveRecord::Base
|
57
|
+
class Profile < ActiveRecord::Base
|
52
58
|
belongs_to :user
|
53
59
|
validates_presence_of :name, :surname
|
54
60
|
end
|
55
|
-
|
61
|
+
```
|
62
|
+
|
63
|
+
First, let's generate Puffer controllers:
|
64
|
+
|
65
|
+
`rails g puffer:controller User`
|
56
66
|
|
57
|
-
At first, lets generate puffers controllers:
|
58
|
-
<pre>rails g puffer:controller User</pre>
|
59
67
|
and
|
60
|
-
<pre>rails g puffer:controller Post</pre>
|
61
68
|
|
62
|
-
|
63
|
-
|
64
|
-
|
69
|
+
`rails g puffer:controller Post`
|
70
|
+
|
71
|
+
This will generate this:
|
72
|
+
|
73
|
+
```
|
74
|
+
class Admin::PostsController < Puffer::Base
|
65
75
|
setup do
|
66
76
|
group :posts
|
67
77
|
end
|
@@ -85,37 +95,35 @@ class Admin::PostsController < Puffer::Base
|
|
85
95
|
end
|
86
96
|
|
87
97
|
end
|
88
|
-
|
98
|
+
```
|
89
99
|
|
90
|
-
Puffer controller
|
100
|
+
Puffer's controller DSL creates all the actions you need. Next step: routing.
|
91
101
|
|
92
|
-
|
93
|
-
namespace :admin
|
102
|
+
```
|
103
|
+
namespace :admin do
|
94
104
|
resources :users do
|
95
105
|
resources :posts
|
96
106
|
end
|
97
107
|
resources :posts
|
98
108
|
end
|
99
|
-
|
109
|
+
```
|
100
110
|
|
101
|
-
Let me explain this feature. Puffer tracks all the nested resources. So, with this routing structure we can access, for example, only specified user
|
111
|
+
Let me explain this feature. Puffer tracks all the nested resources. So, with this routing structure we can access, for example, only specified user's posts:
|
102
112
|
|
103
|
-
|
104
|
-
/admin/users/1/post
|
105
|
-
</pre>
|
113
|
+
`/admin/users/1/post`
|
106
114
|
|
107
115
|
Routing nesting defines admin interface resources nesting.
|
108
116
|
|
109
117
|
## Advanced usage
|
110
118
|
|
111
|
-
Puffer can be used in other namespaces
|
119
|
+
Puffer can be used in other namespaces than admin:
|
112
120
|
|
113
|
-
|
121
|
+
`rails g puffer:controller moderator/posts`
|
114
122
|
|
115
|
-
And we
|
123
|
+
And we'll get posts controller for moderators:
|
116
124
|
|
117
|
-
|
118
|
-
class Moderator::PostsController
|
125
|
+
```
|
126
|
+
class Moderator::PostsController < Puffer::Base
|
119
127
|
before_filter :require_moderator
|
120
128
|
|
121
129
|
setup do
|
@@ -137,14 +145,14 @@ class Moderator::PostsController < Puffer::Base
|
|
137
145
|
field :updated_at
|
138
146
|
end
|
139
147
|
end
|
140
|
-
|
148
|
+
```
|
141
149
|
|
142
|
-
As you can see, moderators can
|
143
|
-
And don`t forget about routing:
|
150
|
+
As you can see, moderators can't destroy posts. The moderator's post controller is placed in the Posting tab of the admin interface.
|
144
151
|
|
145
|
-
|
152
|
+
Finally, don't forget about routing:
|
153
|
+
|
154
|
+
```
|
146
155
|
namespace :moderator do
|
147
156
|
resources :posts
|
148
157
|
end
|
149
|
-
|
150
|
-
|
158
|
+
```
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.30
|
@@ -206,13 +206,9 @@ h2
|
|
206
206
|
{
|
207
207
|
display: table-cell;
|
208
208
|
vertical-align: top;
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
{
|
213
|
-
display: inline;
|
214
|
-
vertical-align: top;
|
215
|
-
width: expression(function(t){
|
209
|
+
_display: inline;
|
210
|
+
_vertical-align: top;
|
211
|
+
_width: expression(function(t){
|
216
212
|
var sum = 0;
|
217
213
|
for (var i = 0; i < t.parentNode.childNodes.length; i++) {
|
218
214
|
if (t.parentNode.childNodes[i] != t) {
|
@@ -220,8 +216,8 @@ h2
|
|
220
216
|
}
|
221
217
|
}
|
222
218
|
return t.parentNode.clientWidth - sum + 'px';
|
223
|
-
|
224
|
-
|
219
|
+
}(this));
|
220
|
+
zoom: 1;
|
225
221
|
}
|
226
222
|
|
227
223
|
.sidebar
|
@@ -1,3 +1,3 @@
|
|
1
1
|
<%= component_wrap do %>
|
2
|
-
<%= link_to opts[:record].call_chain(field.to_s) ? 'True' : 'False', event_path(:
|
2
|
+
<%= link_to opts[:record].call_chain(field.to_s) ? 'True' : 'False', event_path(:change, :id => opts[:record].to_param), :remote => true %>
|
3
3
|
<% end %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= link_to field.human, resource.children_hash[field.name].collection_path %>
|