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.
Files changed (48) hide show
  1. data/README.md +5 -2
  2. data/VERSION +1 -1
  3. data/app/controllers/puffer/dashboard_base.rb +13 -0
  4. data/app/controllers/puffer/sessions_base.rb +17 -0
  5. data/app/helpers/puffer_helper.rb +29 -1
  6. data/app/views/layouts/puffer.html.erb +7 -1
  7. data/app/views/layouts/puffer_dashboard.html.erb +29 -0
  8. data/app/views/layouts/puffer_sessions.html.erb +21 -0
  9. data/app/views/puffer/_form.html.erb +1 -0
  10. data/app/views/puffer/edit.html.erb +0 -16
  11. data/app/views/puffer/index.html.erb +0 -12
  12. data/app/views/puffer/new.html.erb +0 -15
  13. data/app/views/puffer/show.html.erb +1 -8
  14. data/app/views/puffer_dashboard/index.html.erb +17 -0
  15. data/app/views/puffer_sessions/new.html.erb +12 -0
  16. data/config/routes.rb +0 -7
  17. data/lib/generators/puffer/controller/controller_generator.rb +1 -1
  18. data/lib/generators/puffer/controller/templates/controller.rb +4 -1
  19. data/lib/generators/puffer/install/install_generator.rb +9 -0
  20. data/lib/generators/puffer/install/templates/dashboard_controller.rb +3 -0
  21. data/lib/generators/puffer/install/templates/puffer/javascripts/puffer.js +1 -1
  22. data/lib/generators/puffer/install/templates/puffer/stylesheets/puffer.css +83 -12
  23. data/lib/generators/puffer/install/templates/sessions_controller.rb +29 -0
  24. data/lib/puffer/base.rb +2 -7
  25. data/lib/puffer/controller/config.rb +4 -4
  26. data/lib/puffer/controller/dsl.rb +1 -1
  27. data/lib/puffer/controller/helpers.rb +1 -19
  28. data/lib/puffer/controller/mutate.rb +23 -8
  29. data/lib/puffer/extensions/controller.rb +9 -0
  30. data/lib/puffer/extensions/form.rb +3 -1
  31. data/lib/puffer/extensions/mapper.rb +9 -7
  32. data/lib/puffer/fields/field.rb +12 -12
  33. data/lib/puffer/resource/routing.rb +1 -1
  34. data/lib/puffer/resource.rb +6 -6
  35. data/puffer.gemspec +14 -5
  36. data/spec/dummy/app/controllers/admin/categories_controller.rb +1 -1
  37. data/spec/dummy/app/controllers/admin/posts_controller.rb +5 -3
  38. data/spec/dummy/app/controllers/admin/profiles_controller.rb +1 -1
  39. data/spec/dummy/app/controllers/admin/users_controller.rb +1 -1
  40. data/spec/dummy/app/controllers/puffer/dashboard_controller.rb +3 -0
  41. data/spec/dummy/app/controllers/puffer/sessions_controller.rb +16 -0
  42. data/spec/dummy/config/routes.rb +5 -56
  43. data/spec/dummy/public/puffer/stylesheets/puffer.css +90 -12
  44. data/spec/lib/fields_spec.rb +13 -13
  45. metadata +16 -7
  46. data/app/controllers/admin/dashboard_controller.rb +0 -13
  47. data/app/views/admin/dashboard/index.html.erb +0 -1
  48. 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 &lt; Puffer::Base
68
- before_filter :i_didnt_forget_to_protect_this
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 &lt; 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 &lt; Puffer::Base
119
122
  before_filter :require_moderator
120
123
 
121
- config do
124
+ setup do
122
125
  destroy false
123
126
  group :posting
124
127
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.15
1
+ 0.0.16
@@ -0,0 +1,13 @@
1
+ class Puffer::DashboardBase < ApplicationController
2
+ unloadable
3
+
4
+ pufferize!
5
+ view_paths_fallbacks :puffer_dashboard
6
+
7
+ layout 'puffer_dashboard'
8
+
9
+ def index
10
+
11
+ end
12
+
13
+ end
@@ -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.prefix, record.call_chain(field.path)] rescue nil
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, admin_root_path %>
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>
@@ -9,3 +9,4 @@
9
9
  <%= f.submit 'Save and exit' %>
10
10
  <%= link_to 'cancel', (request.referer || resource.collectin_path) %>
11
11
  </div>
12
+
@@ -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
- <% content_for :additional_navigation do %>
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 %>
@@ -0,0 +1,12 @@
1
+ <%= form_for record, :url => puffer_session_path do |f| %>
2
+ <ul class="form">
3
+ <% create_fields.each do |field| -%>
4
+ <li><%= f.puffer_field field %></li>
5
+ <% end -%>
6
+ </ul>
7
+
8
+ <div class="buttons">
9
+ <%= f.submit 'Login' %>
10
+ </div>
11
+ <% end %>
12
+
data/config/routes.rb CHANGED
@@ -1,7 +0,0 @@
1
- Rails.application.routes.draw do
2
-
3
- namespace :admin do
4
- root :to => 'dashboard#index'
5
- end
6
-
7
- end
@@ -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('controller.rb', "app/controllers/#{controller_name.underscore}_controller.rb")
8
+ template 'controller.rb', "app/controllers/#{controller_name.underscore}_controller.rb"
9
9
  end
10
10
 
11
11
  private
@@ -1,5 +1,8 @@
1
1
  class <%= controller_name %>Controller < Puffer::Base
2
- before_filter :i_didnt_forget_to_protect_this
2
+
3
+ setup do
4
+ group :<%= @model_name.underscore.pluralize %>
5
+ end
3
6
 
4
7
  index do
5
8
  <% attributes.each do |attribute| -%>
@@ -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
@@ -0,0 +1,3 @@
1
+ class Puffer::DashboardController < Puffer::DashboardBase
2
+
3
+ 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
- .navigation li
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
- .navigation li:hover, .navigation li.selected
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
- .sidebar .navigation
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
- .sidebar .navigation li>a
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
- .sidebar .navigation li .additional dt
174
+ .dashboard .navigation > li ul.additional
124
175
  {
125
- margin-bottom: 2px;
176
+ padding: 6px 6px;
126
177
  }
127
178
 
128
- .sidebar .navigation li .additional dd
179
+ .dashboard .navigation > li ul.additional li
129
180
  {
130
- margin-bottom: 8px;
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
- include Puffer::Controller::Mutate
6
- include Puffer::Controller::Helpers
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, :default
11
- puffer_class_attribute :model
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
- @configuration ||= Config.new(self.class)
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 configure &block
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(model, name, options) if @_fields
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, :puffer_navigation, :sidebar_puffer_navigation, :resource, :record, :records
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