puffer 0.0.15 → 0.0.16
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/README.md +5 -2
- data/VERSION +1 -1
- data/app/controllers/puffer/dashboard_base.rb +13 -0
- data/app/controllers/puffer/sessions_base.rb +17 -0
- data/app/helpers/puffer_helper.rb +29 -1
- data/app/views/layouts/puffer.html.erb +7 -1
- data/app/views/layouts/puffer_dashboard.html.erb +29 -0
- data/app/views/layouts/puffer_sessions.html.erb +21 -0
- data/app/views/puffer/_form.html.erb +1 -0
- data/app/views/puffer/edit.html.erb +0 -16
- data/app/views/puffer/index.html.erb +0 -12
- data/app/views/puffer/new.html.erb +0 -15
- data/app/views/puffer/show.html.erb +1 -8
- data/app/views/puffer_dashboard/index.html.erb +17 -0
- data/app/views/puffer_sessions/new.html.erb +12 -0
- data/config/routes.rb +0 -7
- data/lib/generators/puffer/controller/controller_generator.rb +1 -1
- data/lib/generators/puffer/controller/templates/controller.rb +4 -1
- data/lib/generators/puffer/install/install_generator.rb +9 -0
- data/lib/generators/puffer/install/templates/dashboard_controller.rb +3 -0
- data/lib/generators/puffer/install/templates/puffer/javascripts/puffer.js +1 -1
- data/lib/generators/puffer/install/templates/puffer/stylesheets/puffer.css +83 -12
- data/lib/generators/puffer/install/templates/sessions_controller.rb +29 -0
- data/lib/puffer/base.rb +2 -7
- data/lib/puffer/controller/config.rb +4 -4
- data/lib/puffer/controller/dsl.rb +1 -1
- data/lib/puffer/controller/helpers.rb +1 -19
- data/lib/puffer/controller/mutate.rb +23 -8
- data/lib/puffer/extensions/controller.rb +9 -0
- data/lib/puffer/extensions/form.rb +3 -1
- data/lib/puffer/extensions/mapper.rb +9 -7
- data/lib/puffer/fields/field.rb +12 -12
- data/lib/puffer/resource/routing.rb +1 -1
- data/lib/puffer/resource.rb +6 -6
- data/puffer.gemspec +14 -5
- data/spec/dummy/app/controllers/admin/categories_controller.rb +1 -1
- data/spec/dummy/app/controllers/admin/posts_controller.rb +5 -3
- data/spec/dummy/app/controllers/admin/profiles_controller.rb +1 -1
- data/spec/dummy/app/controllers/admin/users_controller.rb +1 -1
- data/spec/dummy/app/controllers/puffer/dashboard_controller.rb +3 -0
- data/spec/dummy/app/controllers/puffer/sessions_controller.rb +16 -0
- data/spec/dummy/config/routes.rb +5 -56
- data/spec/dummy/public/puffer/stylesheets/puffer.css +90 -12
- data/spec/lib/fields_spec.rb +13 -13
- metadata +16 -7
- data/app/controllers/admin/dashboard_controller.rb +0 -13
- data/app/views/admin/dashboard/index.html.erb +0 -1
- data/app/views/puffer/toggle.rjs +0 -1
data/README.md
CHANGED
@@ -65,7 +65,9 @@ and
|
|
65
65
|
This will generate a kind of:
|
66
66
|
<pre>
|
67
67
|
class Admin::PostsController < Puffer::Base
|
68
|
-
|
68
|
+
setup do
|
69
|
+
group :posts
|
70
|
+
end
|
69
71
|
|
70
72
|
index do
|
71
73
|
field :id
|
@@ -84,6 +86,7 @@ class Admin::PostsController < Puffer::Base
|
|
84
86
|
field :created_at
|
85
87
|
field :updated_at
|
86
88
|
end
|
89
|
+
|
87
90
|
end
|
88
91
|
</pre>
|
89
92
|
|
@@ -118,7 +121,7 @@ And we`ll get posts controller for moderator:
|
|
118
121
|
class Moderator::PostsController < Puffer::Base
|
119
122
|
before_filter :require_moderator
|
120
123
|
|
121
|
-
|
124
|
+
setup do
|
122
125
|
destroy false
|
123
126
|
group :posting
|
124
127
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.16
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class Puffer::SessionsBase < ApplicationController
|
2
|
+
unloadable
|
3
|
+
|
4
|
+
pufferize!
|
5
|
+
view_paths_fallbacks :puffer_sessions
|
6
|
+
define_fields :create
|
7
|
+
|
8
|
+
layout 'puffer_sessions'
|
9
|
+
|
10
|
+
respond_to :html
|
11
|
+
|
12
|
+
create do
|
13
|
+
field :email
|
14
|
+
field :password
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -1,5 +1,33 @@
|
|
1
1
|
module PufferHelper
|
2
2
|
|
3
|
+
def puffer_namespaces
|
4
|
+
Rails.application.routes.puffer.each do |(prefix, groups)|
|
5
|
+
controller = groups.values.first.first
|
6
|
+
title = prefix.to_s.humanize
|
7
|
+
path = send("#{prefix}_#{controller.controller_name}_path")
|
8
|
+
current = controller.namespace == namespace
|
9
|
+
yield title, path, current
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def puffer_navigation
|
14
|
+
Rails.application.routes.puffer[namespace].values.map(&:first).each do |controller|
|
15
|
+
title = controller.configuration.group.to_s.humanize
|
16
|
+
path = send("#{namespace}_#{controller.controller_name}_path")
|
17
|
+
current = configuration.group && resource.root.controller.configuration.group == controller.configuration.group
|
18
|
+
yield title, path, current
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def sidebar_puffer_navigation
|
23
|
+
(Rails.application.routes.puffer[namespace][configuration.group] || []).each do |controller|
|
24
|
+
title = controller.model.model_name.human
|
25
|
+
path = send("#{namespace}_#{controller.controller_name}_path")
|
26
|
+
current = controller.controller_name == resource.root.controller_name
|
27
|
+
yield title, path, current
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
3
31
|
def puffer_stylesheets
|
4
32
|
stylesheet_link_tag *Puffer.stylesheets.map {|path| "/puffer/stylesheets/#{path}"}.uniq.compact
|
5
33
|
end
|
@@ -25,7 +53,7 @@ module PufferHelper
|
|
25
53
|
res = record.call_chain(field.field)
|
26
54
|
end
|
27
55
|
unless field.native?
|
28
|
-
url = edit_polymorphic_path [resource.
|
56
|
+
url = edit_polymorphic_path [resource.namespace, record.call_chain(field.path)] rescue nil
|
29
57
|
res = link_to res, url if url
|
30
58
|
end
|
31
59
|
res
|
@@ -13,14 +13,20 @@
|
|
13
13
|
<div class="body">
|
14
14
|
<div class="header">
|
15
15
|
<div class="logo">
|
16
|
-
<%= link_to Puffer.logo,
|
16
|
+
<%= link_to Puffer.logo, puffer_root_path %>
|
17
17
|
</div>
|
18
|
+
<ul class="namespaces">
|
19
|
+
<% puffer_namespaces do |title, path, current| %>
|
20
|
+
<li<%= raw(current ? ' class="selected"' : '') %>><%= link_to title, path %></li>
|
21
|
+
<% end %>
|
22
|
+
</ul>
|
18
23
|
<ul class="navigation">
|
19
24
|
<% puffer_navigation do |title, path, current| %>
|
20
25
|
<li<%= raw(current ? ' class="selected"' : '') %>><%= link_to title, path %></li>
|
21
26
|
<% end %>
|
22
27
|
</ul>
|
23
28
|
<div class="logout">
|
29
|
+
<%= link_to t('puffer.logout'), puffer_session_url, :method => :delete %>
|
24
30
|
</div>
|
25
31
|
</div>
|
26
32
|
<div class="columns">
|
@@ -0,0 +1,29 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title><%= [@title, 'Puffer'].compact.join(' - ') %></title>
|
5
|
+
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
|
6
|
+
<%= csrf_meta_tag %>
|
7
|
+
<%= puffer_stylesheets %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
<div class="body">
|
11
|
+
<div class="header">
|
12
|
+
<div class="logo">
|
13
|
+
<%= link_to Puffer.logo, puffer_root_path %>
|
14
|
+
</div>
|
15
|
+
<ul class="namespaces">
|
16
|
+
<% puffer_namespaces do |title, path, current| %>
|
17
|
+
<li<%= raw(current ? ' class="selected"' : '') %>><%= link_to title, path %></li>
|
18
|
+
<% end %>
|
19
|
+
</ul>
|
20
|
+
<div class="logout">
|
21
|
+
<%= link_to t('puffer.logout'), puffer_session_url, :method => :delete %>
|
22
|
+
</div>
|
23
|
+
</div>
|
24
|
+
<div class="content dashboard">
|
25
|
+
<%= yield %>
|
26
|
+
</div>
|
27
|
+
</div>
|
28
|
+
</body>
|
29
|
+
</html>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title><%= [@title, 'Puffer'].compact.join(' - ') %></title>
|
5
|
+
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
|
6
|
+
<%= csrf_meta_tag %>
|
7
|
+
<%= puffer_stylesheets %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
<div class="body">
|
11
|
+
<div class="header">
|
12
|
+
<div class="logo">
|
13
|
+
<span><%= Puffer.logo %></span>
|
14
|
+
</div>
|
15
|
+
</div>
|
16
|
+
<div class="content sessions">
|
17
|
+
<%= yield %>
|
18
|
+
</div>
|
19
|
+
</div>
|
20
|
+
</body>
|
21
|
+
</html>
|
@@ -4,19 +4,3 @@
|
|
4
4
|
<%= render :partial => 'terbium/form', :locals => { :f => f, :action => 'edit' } %>
|
5
5
|
<% end %>
|
6
6
|
|
7
|
-
|
8
|
-
<% if false %>
|
9
|
-
<% content_for :additional_navigation do %>
|
10
|
-
<ul class="buttons">
|
11
|
-
<% 0.upto(resource_ancestors_records.length - 1) do |i| %>
|
12
|
-
<li><%= link_to resource_ancestors[i].to_s.pluralize.humanize, polymorphic_path([route_prefix] + resource_ancestors_records[0..i-3] + [resource_ancestors[i].to_s.pluralize]) %></li>
|
13
|
-
<li><%= link_to resource_ancestors_records[i].to_title, polymorphic_path([route_prefix] + resource_ancestors_records[0..i]) %></li>
|
14
|
-
<% end %>
|
15
|
-
<% if plural? %>
|
16
|
-
<li><%= link_to controller.model_name.pluralize.humanize, resources_path %></li>
|
17
|
-
<% else %>
|
18
|
-
<li><%= link_to resource.humanize, resource_path %></li>
|
19
|
-
<% end %>
|
20
|
-
</ul>
|
21
|
-
<% end %>
|
22
|
-
<% end %>
|
@@ -33,15 +33,3 @@
|
|
33
33
|
<% end %>
|
34
34
|
<%= will_paginate records, :url => resource.collection_path(:page => '') %>
|
35
35
|
|
36
|
-
<% if false %>
|
37
|
-
<% content_for :additional_navigation do %>
|
38
|
-
<ul class="buttons">
|
39
|
-
<% resource.ancestors.each do |resource| %>
|
40
|
-
<%= link_to resource.plural? ? resource.human : resource.member.to_title, resource.collection_path %>
|
41
|
-
<%= link_to resource.member.to_title, resource.member_path unless resource.plural? %>
|
42
|
-
<% end %>
|
43
|
-
<%= link_to resource.plural? ? resource.human : resource.member.to_title, resource.collection_path %>
|
44
|
-
</ul>
|
45
|
-
<% end %>
|
46
|
-
<% end %>
|
47
|
-
|
@@ -4,18 +4,3 @@
|
|
4
4
|
<%= render :partial => 'terbium/form', :locals => { :f => f, :action => 'new' } %>
|
5
5
|
<% end %>
|
6
6
|
|
7
|
-
<% if false %>
|
8
|
-
<% content_for :additional_navigation do %>
|
9
|
-
<ul class="buttons">
|
10
|
-
<% 0.upto(resource_ancestors_records.length - 1) do |i| %>
|
11
|
-
<li><%= link_to resource_ancestors[i].to_s.pluralize.humanize, polymorphic_path([route_prefix] + resource_ancestors_records[0..i-3] + [resource_ancestors[i].to_s.pluralize]) %></li>
|
12
|
-
<li><%= link_to resource_ancestors_records[i].to_title, polymorphic_path([route_prefix] + resource_ancestors_records[0..i]) %></li>
|
13
|
-
<% end %>
|
14
|
-
<% if plural? %>
|
15
|
-
<li><%= link_to controller.model_name.pluralize.humanize, resources_path %></li>
|
16
|
-
<% else %>
|
17
|
-
<li><%= link_to resource.humanize, resource_path %></li>
|
18
|
-
<% end %>
|
19
|
-
</ul>
|
20
|
-
<% end %>
|
21
|
-
<% end %>
|
@@ -19,11 +19,4 @@
|
|
19
19
|
</li>
|
20
20
|
<% end if show_fields && record -%>
|
21
21
|
</ul>
|
22
|
-
|
23
|
-
<ul class="buttons">
|
24
|
-
<% (resource.ancestors + [resource]).each do |resource| %>
|
25
|
-
<%= link_to resource.plural? ? resource.human : resource.member.to_title, resource.collection_path %>
|
26
|
-
<%= link_to resource.member.to_title, resource.member_path unless resource.plural? %>
|
27
|
-
<% end %>
|
28
|
-
</ul>
|
29
|
-
<% end %>
|
22
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<% Rails.application.routes.puffer.each do |(namespace, groups)| %>
|
2
|
+
<h2><%= namespace.to_s.humanize %></h2>
|
3
|
+
<ul class="navigation">
|
4
|
+
<% groups.each do |(group, controllers)| %>
|
5
|
+
<li>
|
6
|
+
<span><%= group.to_s.humanize %></span>
|
7
|
+
<ul class="additional">
|
8
|
+
<% controllers.each do |controller| %>
|
9
|
+
<li>
|
10
|
+
<%= link_to controller.model.model_name.human, send("#{namespace}_#{controller.controller_name}_path") %>
|
11
|
+
</li>
|
12
|
+
<% end %>
|
13
|
+
</ul>
|
14
|
+
</li>
|
15
|
+
<% end %>
|
16
|
+
</ul>
|
17
|
+
<% end %>
|
data/config/routes.rb
CHANGED
@@ -5,7 +5,7 @@ class Puffer::ControllerGenerator < Rails::Generators::NamedBase
|
|
5
5
|
@modules = name.classify.split('::')
|
6
6
|
@model_name = @modules.delete_at(-1)
|
7
7
|
|
8
|
-
template
|
8
|
+
template 'controller.rb', "app/controllers/#{controller_name.underscore}_controller.rb"
|
9
9
|
end
|
10
10
|
|
11
11
|
private
|
@@ -9,4 +9,13 @@ class Puffer::InstallGenerator < Rails::Generators::Base
|
|
9
9
|
copy_file 'puffer.rb', 'config/initializers/puffer.rb'
|
10
10
|
end
|
11
11
|
|
12
|
+
def generate_puffer_controllers
|
13
|
+
copy_file 'sessions_controller.rb', 'app/controllers/puffer/sessions_controller.rb'
|
14
|
+
copy_file 'dashboard_controller.rb', 'app/controllers/puffer/dashboard_controller.rb'
|
15
|
+
end
|
16
|
+
|
17
|
+
def generate_routes
|
18
|
+
route "namespace :puffer do\n root :to => 'dashboard#index'\n resource :session\n end"
|
19
|
+
end
|
20
|
+
|
12
21
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
var association_done = function(event) {
|
2
|
-
current = this.first('li.current')
|
2
|
+
current = this.first('li.current');
|
3
3
|
this.input.next('input[type=hidden]').value(current.get('data-id'));
|
4
4
|
this.input.value(current.find('.title').first().html().stripTags()).disable();
|
5
5
|
}
|
@@ -26,6 +26,12 @@ h1
|
|
26
26
|
margin-bottom: 10px;
|
27
27
|
}
|
28
28
|
|
29
|
+
h2
|
30
|
+
{
|
31
|
+
font-size: 17px;
|
32
|
+
margin-bottom: 10px;
|
33
|
+
}
|
34
|
+
|
29
35
|
.body
|
30
36
|
{
|
31
37
|
position: relative;
|
@@ -49,7 +55,7 @@ h1
|
|
49
55
|
left: 20px;
|
50
56
|
}
|
51
57
|
|
52
|
-
.logo a
|
58
|
+
.logo a, .logo span
|
53
59
|
{
|
54
60
|
color: #ddd;
|
55
61
|
font-size: 30pt;
|
@@ -65,7 +71,19 @@ h1
|
|
65
71
|
bottom: 20px;
|
66
72
|
}
|
67
73
|
|
68
|
-
.
|
74
|
+
.namespaces
|
75
|
+
{
|
76
|
+
position: absolute;
|
77
|
+
right: 10px;
|
78
|
+
top: 0;
|
79
|
+
}
|
80
|
+
|
81
|
+
.dashboard .navigation
|
82
|
+
{
|
83
|
+
margin-bottom: 10px;
|
84
|
+
}
|
85
|
+
|
86
|
+
.navigation > li, .namespaces > li
|
69
87
|
{
|
70
88
|
display: inline-block;
|
71
89
|
*display: inline;
|
@@ -74,7 +92,13 @@ h1
|
|
74
92
|
border-radius: 3px;
|
75
93
|
}
|
76
94
|
|
77
|
-
.
|
95
|
+
.namespaces > li
|
96
|
+
{
|
97
|
+
-moz-border-radius: 0 0 3px 3px;
|
98
|
+
border-radius: 0 0 3px 3px;
|
99
|
+
}
|
100
|
+
|
101
|
+
.navigation > li:hover, .navigation > li.selected, .namespaces > li:hover, .namespaces > li.selected
|
78
102
|
{
|
79
103
|
-moz-box-shadow: -1px -1px 0 #0A2337;
|
80
104
|
-webkit-box-shadow: -1px -1px 0 #0A2337;
|
@@ -82,7 +106,7 @@ h1
|
|
82
106
|
background: #536C80;
|
83
107
|
}
|
84
108
|
|
85
|
-
.navigation li>a
|
109
|
+
.navigation > li > a, .navigation > li > span, .namespaces > li > a, .namespaces > li > span
|
86
110
|
{
|
87
111
|
display: inline-block;
|
88
112
|
*display: inline;
|
@@ -94,23 +118,50 @@ h1
|
|
94
118
|
text-shadow: #304759 -1px -1px 0;
|
95
119
|
}
|
96
120
|
|
97
|
-
.
|
121
|
+
.namespaces > li > a, .namespaces > li > span
|
122
|
+
{
|
123
|
+
padding: 5px 12px;
|
124
|
+
}
|
125
|
+
|
126
|
+
.sidebar .navigation, .dashboard .navigation
|
98
127
|
{
|
99
128
|
position: static;
|
100
129
|
}
|
101
130
|
|
102
|
-
.sidebar .navigation li
|
131
|
+
.sidebar .navigation > li, .dashboard .navigation > li
|
103
132
|
{
|
104
133
|
display: block;
|
105
134
|
margin-bottom: 5px;
|
106
135
|
}
|
107
136
|
|
108
|
-
.
|
137
|
+
.dashboard .navigation > li
|
138
|
+
{
|
139
|
+
background: #536C80;
|
140
|
+
}
|
141
|
+
|
142
|
+
.dashboard .navigation > li:hover, .dashboard .navigation > li.selected
|
143
|
+
{
|
144
|
+
-moz-box-shadow: none;
|
145
|
+
-webkit-box-shadow: none;
|
146
|
+
box-shadow: none;
|
147
|
+
}
|
148
|
+
|
149
|
+
.sidebar .navigation > li > a
|
109
150
|
{
|
110
151
|
display: block;
|
111
152
|
}
|
112
153
|
|
113
|
-
.sidebar .navigation li .additional
|
154
|
+
.sidebar .navigation > li .additional dt
|
155
|
+
{
|
156
|
+
margin-bottom: 2px;
|
157
|
+
}
|
158
|
+
|
159
|
+
.sidebar .navigation > li .additional dd
|
160
|
+
{
|
161
|
+
margin-bottom: 8px;
|
162
|
+
}
|
163
|
+
|
164
|
+
.sidebar .navigation > li .additional, .dashboard .navigation > li ul.additional
|
114
165
|
{
|
115
166
|
padding: 10px 12px;
|
116
167
|
background: #eee;
|
@@ -120,14 +171,21 @@ h1
|
|
120
171
|
border-bottom-right-radius: 3px;
|
121
172
|
}
|
122
173
|
|
123
|
-
.
|
174
|
+
.dashboard .navigation > li ul.additional
|
124
175
|
{
|
125
|
-
|
176
|
+
padding: 6px 6px;
|
126
177
|
}
|
127
178
|
|
128
|
-
.
|
179
|
+
.dashboard .navigation > li ul.additional li
|
129
180
|
{
|
130
|
-
|
181
|
+
list-style: none;
|
182
|
+
padding: 5px 12px;
|
183
|
+
}
|
184
|
+
|
185
|
+
.dashboard .navigation > li ul.additional li > a
|
186
|
+
{
|
187
|
+
color: #222;
|
188
|
+
font-size: 10pt;
|
131
189
|
}
|
132
190
|
|
133
191
|
.columns
|
@@ -183,6 +241,19 @@ h1
|
|
183
241
|
padding: 30px;
|
184
242
|
}
|
185
243
|
|
244
|
+
.sessions
|
245
|
+
{
|
246
|
+
min-height: 10px;
|
247
|
+
margin: 50px auto 0 auto;
|
248
|
+
width: 400px;
|
249
|
+
}
|
250
|
+
|
251
|
+
.dashboard
|
252
|
+
{
|
253
|
+
min-height: 10px;
|
254
|
+
margin-left: 20px;
|
255
|
+
}
|
256
|
+
|
186
257
|
.list_table
|
187
258
|
{
|
188
259
|
width: 100%;
|
@@ -0,0 +1,29 @@
|
|
1
|
+
class Puffer::SessionsController < Puffer::SessionsBase
|
2
|
+
# This is example session controller for puffer authentication.
|
3
|
+
# You can define your own actions.
|
4
|
+
# Also, you can redefine <tt>new<tt> action view as you wish,
|
5
|
+
# but more effectively will be definig fields with standart
|
6
|
+
# puffer DSL:
|
7
|
+
# create do
|
8
|
+
# field :login
|
9
|
+
# field :password
|
10
|
+
# field :remember_me
|
11
|
+
# end
|
12
|
+
#
|
13
|
+
# By default defined <tt>email<tt> and <tt>password<tt> fields.
|
14
|
+
|
15
|
+
def new
|
16
|
+
# @record = UserSession.new
|
17
|
+
end
|
18
|
+
|
19
|
+
def create
|
20
|
+
# @record = UserSession.new params[:user_session]
|
21
|
+
# respond_with record, :location => puffer_root_url
|
22
|
+
end
|
23
|
+
|
24
|
+
def destroy
|
25
|
+
# @record = UserSession.find
|
26
|
+
# @record.destroy
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
data/lib/puffer/base.rb
CHANGED
@@ -2,13 +2,8 @@ module Puffer
|
|
2
2
|
class Base < ApplicationController
|
3
3
|
unloadable
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
include Puffer::Controller::Dsl
|
8
|
-
include Puffer::Controller::Mapping
|
9
|
-
include Puffer::Controller::Config
|
10
|
-
include Puffer::Controller::Generated
|
11
|
-
|
5
|
+
pufferize!
|
6
|
+
view_paths_fallbacks :puffer
|
12
7
|
define_fields :index, :show, :form, :create, :update
|
13
8
|
|
14
9
|
respond_to :html, :js
|
@@ -7,8 +7,8 @@ module Puffer
|
|
7
7
|
extend ClassMethods
|
8
8
|
include InstanceMethods
|
9
9
|
|
10
|
-
puffer_class_attribute :group
|
11
|
-
puffer_class_attribute :
|
10
|
+
puffer_class_attribute :group
|
11
|
+
puffer_class_attribute :model_name
|
12
12
|
puffer_class_attribute :destroy, true
|
13
13
|
|
14
14
|
helper_method :configuration
|
@@ -18,7 +18,7 @@ module Puffer
|
|
18
18
|
module InstanceMethods
|
19
19
|
|
20
20
|
def configuration
|
21
|
-
|
21
|
+
self.class.configuration
|
22
22
|
end
|
23
23
|
|
24
24
|
end
|
@@ -30,7 +30,7 @@ module Puffer
|
|
30
30
|
send "_puffer_attribute_#{name}=", default
|
31
31
|
end
|
32
32
|
|
33
|
-
def
|
33
|
+
def setup &block
|
34
34
|
block.bind(Config.new(self)).call
|
35
35
|
end
|
36
36
|
|
@@ -54,7 +54,7 @@ module Puffer
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def field name, options = {}
|
57
|
-
field = @_fields.field(
|
57
|
+
field = @_fields.field(name, model, options) if @_fields
|
58
58
|
generate_association_actions field if field.reflection
|
59
59
|
#generate_change_actions field if field.toggable?
|
60
60
|
end
|
@@ -6,30 +6,12 @@ module Puffer
|
|
6
6
|
base.class_eval do
|
7
7
|
include InstanceMethods
|
8
8
|
|
9
|
-
helper_method :resource_session, :
|
9
|
+
helper_method :resource_session, :resource, :record, :records
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
13
|
module InstanceMethods
|
14
14
|
|
15
|
-
def puffer_navigation
|
16
|
-
Rails.application.routes.puffer[resource.prefix].values.map(&:first).each do |controller|
|
17
|
-
title = controller.configuration.group.to_s.humanize
|
18
|
-
path = send("#{resource.prefix}_#{controller.controller_name}_path")
|
19
|
-
current = puffer? && resource.root.controller.configuration.group == controller.configuration.group
|
20
|
-
yield title, path, current
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def sidebar_puffer_navigation
|
25
|
-
(Rails.application.routes.puffer[resource.prefix][configuration.group] || []).each do |controller|
|
26
|
-
title = controller.model.model_name.human
|
27
|
-
path = send("#{resource.prefix}_#{controller.controller_name}_path")
|
28
|
-
current = controller.controller_name == resource.controller_name
|
29
|
-
yield title, path, current
|
30
|
-
end if puffer?
|
31
|
-
end
|
32
|
-
|
33
15
|
def resource
|
34
16
|
@resource ||= Puffer::Resource.new params, request
|
35
17
|
end
|