puffer 0.0.25 → 0.0.26

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.25
1
+ 0.0.26
@@ -135,7 +135,10 @@ var Paginator = new Widget({
135
135
 
136
136
  this.$super('paginator', element).setOptions(options);
137
137
 
138
- this.sliderValue = (this.options.current - 1) * 100 / (this.options.total - 1)
138
+
139
+ this.sliderValue = (this.options.current - 1) * 100 / (this.options.total - 1);
140
+ this.sliderValue |= 0;
141
+
139
142
  this.append(
140
143
  this.wrapper = new Element('div', {'class': 'rui-paginator-pages-wrapper'}).append(this.pages = new Paginator.Pages(this)),
141
144
  this.slider = new Slider({round: 1})
@@ -3,9 +3,9 @@ class SelectComponent < BaseComponent
3
3
  def form
4
4
  @options = case field.options[:select]
5
5
  when Symbol then
6
- parent_controller.send field.options[:select]
6
+ parent_controller.view_context.send field.options[:select]
7
7
  when Proc then
8
- field.options[:select].bind(self).call
8
+ field.options[:select].bind(parent_controller).call
9
9
  else
10
10
  field.options[:select]
11
11
  end
@@ -24,8 +24,15 @@
24
24
  <dl>
25
25
  <dt>Links</dt>
26
26
  <dd>
27
- <%= link_to t(:list, :target => resource.human), resource.collection_path %>
28
- <%= link_to t(:add, :target => resource.human), resource.new_path %>
27
+ <p>
28
+ <%= link_to t(:list, :target => resource.human), resource.collection_path %>
29
+ <%= link_to t(:add, :target => resource.human), resource.new_path %>
30
+ </p>
31
+ <p>
32
+ <% _collections.each do |collection| %>
33
+ <%= link_to collection.label, resource.collection_path(:action => collection.action) if collection.display? && [:match, :get].include?(collection.method) %>
34
+ <% end %>
35
+ </p>
29
36
  </dd>
30
37
  <dt>Search</dt>
31
38
  <dd>
@@ -1,35 +1,54 @@
1
1
  module Puffer
2
2
  module Controller
3
3
  class Actions < Array
4
+ attr_accessor :controller
5
+ attr_accessor :scope
6
+
7
+ def initialize scope
8
+ @scope = scope.to_s
9
+ super()
10
+ end
4
11
 
5
12
  %w(match get post put delete).each do |method|
6
- define_method method do |*args|
7
- push Action.new(args.unshift(method))
13
+ define_method method do |*route|
14
+ push action_class.new(controller, *route.unshift(method))
8
15
  end
9
16
  end
10
17
 
18
+ def action_class
19
+ "Puffer::Controller::#{scope.camelize}Action".constantize
20
+ end
21
+
11
22
  end
12
23
 
13
- class Action < Array
24
+ class Action
25
+ attr_accessor :controller, :route
14
26
 
15
- def initialize *args
16
- super *args
17
- options = extract_options!
27
+ def initialize controller, *route
28
+ @controller, @route = controller, route
29
+ options = route.extract_options!
18
30
  @display = options.key?(:display) ? options.delete(:display) : true
19
- @label = options.delete(:label)
20
- push options
31
+ route.push options
21
32
  end
22
33
 
23
34
  def method
24
- first
35
+ @method ||= route.first.to_sym
25
36
  end
26
37
 
27
38
  def action
28
- second
39
+ @action ||= route.second.to_sym
29
40
  end
30
41
 
31
42
  def label
32
- @label || second
43
+ I18n.t(action, :scope => i18n_scope, :default => action.to_s.humanize)
44
+ end
45
+
46
+ def i18n_scope
47
+ [:puffer, controller.controller_path.gsub(/\//, '.'), action_scope]
48
+ end
49
+
50
+ def action_scope
51
+ :actions
33
52
  end
34
53
 
35
54
  def display?
@@ -38,5 +57,21 @@ module Puffer
38
57
 
39
58
  end
40
59
 
60
+ class MemberAction < Action
61
+
62
+ def action_scope
63
+ :members
64
+ end
65
+
66
+ end
67
+
68
+ class CollectionAction < Action
69
+
70
+ def action_scope
71
+ :collections
72
+ end
73
+
74
+ end
75
+
41
76
  end
42
77
  end
@@ -5,9 +5,9 @@ module Puffer
5
5
 
6
6
  included do
7
7
  class_attribute :_members
8
- self._members = Puffer::Controller::Actions.new
8
+ self._members = Puffer::Controller::Actions.new :member
9
9
  class_attribute :_collections
10
- self._collections = Puffer::Controller::Actions.new
10
+ self._collections = Puffer::Controller::Actions.new :collection
11
11
  class_attribute :_fieldset_fallbacks
12
12
  self._fieldset_fallbacks = HashWithIndifferentAccess.new
13
13
 
@@ -30,10 +30,12 @@ module Puffer
30
30
  end
31
31
 
32
32
  def member &block
33
+ _members.controller = self
33
34
  block.bind(_members).call if block_given?
34
35
  end
35
36
 
36
37
  def collection &block
38
+ _collections.controller = self
37
39
  block.bind(_collections).call if block_given?
38
40
  end
39
41
 
@@ -50,9 +52,11 @@ module Puffer
50
52
 
51
53
  self.class.instance_eval do
52
54
  define_method action do |&block|
55
+ @_super_fields = send("_#{action}_fields")
53
56
  @_fields = send("_#{action}_fields=", Puffer::FieldSet.new(action))
54
57
  block.call if block
55
58
  remove_instance_variable :@_fields
59
+ remove_instance_variable :@_super_fields
56
60
  end
57
61
 
58
62
  define_method "#{action}_fields" do
@@ -76,7 +80,10 @@ module Puffer
76
80
 
77
81
  def field name, options = {}, &block
78
82
  field = @_fields.field(name, model, options, &block) if @_fields
79
- #generate_association_actions field if field.reflection
83
+ end
84
+
85
+ def super_fields
86
+ @_super_fields.copy_to @_fields, model if @_super_fields && @_fields
80
87
  end
81
88
 
82
89
  end
@@ -69,10 +69,10 @@ module Puffer
69
69
  collection do
70
70
  get '/event/:fieldset/:field/:event(/:identifer)', options.merge(:action => :event, :as => :event)
71
71
  post :create, options
72
- controller._collections.each do |args|
73
- opts = args.extract_options!.dup
74
- args.push options.reverse_merge(opts)
75
- send *args
72
+ controller._collections.each do |action|
73
+ opts = action.route.extract_options!.dup
74
+ action.route.push options.reverse_merge(opts)
75
+ send *action.route
76
76
  end
77
77
  end
78
78
 
@@ -85,10 +85,10 @@ module Puffer
85
85
  get :show, options
86
86
  put :update, options
87
87
  delete :destroy, options
88
- controller._members.each do |args|
89
- opts = args.extract_options!.dup
90
- args.push options.reverse_merge(opts)
91
- send *args
88
+ controller._members.each do |action|
89
+ opts = action.route.extract_options!.dup
90
+ action.route.push options.reverse_merge(opts)
91
+ send *action.route
92
92
  end
93
93
  end
94
94
 
@@ -131,10 +131,10 @@ module Puffer
131
131
  get :index, options
132
132
  get '/event/:fieldset/:field/:event(/:identifer)', options.merge(:action => :event, :as => :event)
133
133
  post :create, options
134
- controller._collections.each do |args|
135
- opts = args.extract_options!.dup
136
- args.push options.reverse_merge(opts)
137
- send *args
134
+ controller._collections.each do |action|
135
+ opts = action.route.extract_options!.dup
136
+ action.route.push options.reverse_merge(opts)
137
+ send *action.route
138
138
  end
139
139
  end
140
140
 
@@ -147,10 +147,10 @@ module Puffer
147
147
  get :show, options
148
148
  put :update, options
149
149
  delete :destroy, options
150
- controller._members.each do |args|
151
- opts = args.extract_options!.dup
152
- args.push options.reverse_merge(opts)
153
- send *args
150
+ controller._members.each do |action|
151
+ opts = action.route.extract_options!.dup
152
+ action.route.push options.reverse_merge(opts)
153
+ send *action.route
154
154
  end
155
155
  end
156
156
  end
@@ -37,5 +37,12 @@ module Puffer
37
37
  end
38
38
  end
39
39
 
40
+ def copy_to fieldset, model
41
+ each do |f|
42
+ new_field = fieldset.field f.field_name, model, f.options
43
+ f.children.copy_to new_field.children, swallow_nil{new_field.reflection.klass}
44
+ end
45
+ end
46
+
40
47
  end
41
48
  end
data/lib/puffer.rb CHANGED
@@ -31,4 +31,10 @@ module Puffer
31
31
  map_component :integer, :decimal, :to => :StringComponent
32
32
  end
33
33
 
34
+ module Controller
35
+ autoload :Action, 'puffer/controller/actions'
36
+ autoload :MemberAction, 'puffer/controller/actions'
37
+ autoload :CollectionAction, 'puffer/controller/actions'
38
+ end
39
+
34
40
  end
data/puffer.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{puffer}
8
- s.version = "0.0.25"
8
+ s.version = "0.0.26"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = [%q{pyromaniac}]
12
- s.date = %q{2011-09-09}
12
+ s.date = %q{2011-09-10}
13
13
  s.description = %q{In Soviet Russia puffer admins you}
14
14
  s.email = %q{kinwizard@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -137,6 +137,7 @@ Gem::Specification.new do |s|
137
137
  "spec/dummy/app/controllers/admin/posts_controller.rb",
138
138
  "spec/dummy/app/controllers/admin/profiles_controller.rb",
139
139
  "spec/dummy/app/controllers/admin/sessions_controller.rb",
140
+ "spec/dummy/app/controllers/admin/tagged_posts_controller.rb",
140
141
  "spec/dummy/app/controllers/admin/tags_controller.rb",
141
142
  "spec/dummy/app/controllers/admin/users_controller.rb",
142
143
  "spec/dummy/app/controllers/application_controller.rb",
@@ -148,6 +149,7 @@ Gem::Specification.new do |s|
148
149
  "spec/dummy/app/models/post_category.rb",
149
150
  "spec/dummy/app/models/profile.rb",
150
151
  "spec/dummy/app/models/tag.rb",
152
+ "spec/dummy/app/models/tagged_post.rb",
151
153
  "spec/dummy/app/models/tagging.rb",
152
154
  "spec/dummy/app/models/user.rb",
153
155
  "spec/dummy/app/views/layouts/application.html.erb",
@@ -12,9 +12,7 @@ class Admin::PostsController < Puffer::Base
12
12
  end
13
13
 
14
14
  form do
15
- field :user do
16
- field :email
17
- end
15
+ field :user
18
16
  field :status, :select => Post.statuses
19
17
  field :title
20
18
  field :body
@@ -0,0 +1,8 @@
1
+ class Admin::TaggedPostsController < Admin::PostsController
2
+
3
+ form do
4
+ super_fields
5
+ field :tags
6
+ end
7
+
8
+ end
@@ -4,6 +4,14 @@ class Admin::UsersController < Puffer::Base
4
4
  group :users
5
5
  end
6
6
 
7
+ member do
8
+ get :hello
9
+ end
10
+
11
+ collection do
12
+ get :world
13
+ end
14
+
7
15
  index do
8
16
  field :email
9
17
  field :password, :type => :password
@@ -1,8 +1,6 @@
1
1
  class Post < ActiveRecord::Base
2
2
  has_many :post_categories
3
- has_many :categories, :through => :post_categories
4
- has_many :taggings, :as => :taggable
5
- has_many :tags, :through => :taggings
3
+ has_many :categories, :through => :post_categoriess
6
4
  belongs_to :user
7
5
 
8
6
  def self.statuses
@@ -0,0 +1,4 @@
1
+ class TaggedPost < Post
2
+ has_many :taggings, :as => :taggable
3
+ has_many :tags, :through => :taggings
4
+ end
@@ -17,6 +17,11 @@ Dummy::Application.routes.draw do
17
17
  resource :user
18
18
  resources :categories
19
19
  end
20
+ resources :tagged_posts do
21
+ resource :user
22
+ resources :categories
23
+ resources :tags
24
+ end
20
25
  resources :categories do
21
26
  resources :posts
22
27
  end
@@ -7,6 +7,8 @@ class CreatePosts < ActiveRecord::Migration
7
7
  t.string :status
8
8
  t.string :filename
9
9
 
10
+ t.string :type
11
+
10
12
  t.timestamps
11
13
  end
12
14
  end
@@ -1,3 +1,4 @@
1
+ # encoding: UTF-8
1
2
  # This file is auto-generated from the current state of the database. Instead
2
3
  # of editing this file, please use the migrations feature of Active Record to
3
4
  # incrementally modify your database, and then regenerate this schema definition.
@@ -51,6 +52,7 @@ ActiveRecord::Schema.define(:version => 20110301072545) do
51
52
  t.text "body"
52
53
  t.string "status"
53
54
  t.string "filename"
55
+ t.string "type"
54
56
  t.datetime "created_at"
55
57
  t.datetime "updated_at"
56
58
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puffer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.25
4
+ version: 0.0.26
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-09-09 00:00:00.000000000Z
12
+ date: 2011-09-10 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &22403120 !ruby/object:Gem::Requirement
16
+ requirement: &17946500 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 3.1.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *22403120
24
+ version_requirements: *17946500
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: kaminari
27
- requirement: &22402300 !ruby/object:Gem::Requirement
27
+ requirement: &17920780 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *22402300
35
+ version_requirements: *17920780
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: apotomo
38
- requirement: &22401520 !ruby/object:Gem::Requirement
38
+ requirement: &17919780 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *22401520
46
+ version_requirements: *17919780
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: sqlite3
49
- requirement: &22400520 !ruby/object:Gem::Requirement
49
+ requirement: &17918520 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *22400520
57
+ version_requirements: *17918520
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rspec-rails
60
- requirement: &22399860 !ruby/object:Gem::Requirement
60
+ requirement: &17917020 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *22399860
68
+ version_requirements: *17917020
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: capybara
71
- requirement: &22398960 !ruby/object:Gem::Requirement
71
+ requirement: &17916140 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *22398960
79
+ version_requirements: *17916140
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: database_cleaner
82
- requirement: &22372900 !ruby/object:Gem::Requirement
82
+ requirement: &17915220 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *22372900
90
+ version_requirements: *17915220
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: guard
93
- requirement: &22371680 !ruby/object:Gem::Requirement
93
+ requirement: &17913940 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: '0'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *22371680
101
+ version_requirements: *17913940
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: libnotify
104
- requirement: &22370680 !ruby/object:Gem::Requirement
104
+ requirement: &17911100 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: '0'
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *22370680
112
+ version_requirements: *17911100
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: guard-rspec
115
- requirement: &22369860 !ruby/object:Gem::Requirement
115
+ requirement: &17910260 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ! '>='
@@ -120,10 +120,10 @@ dependencies:
120
120
  version: '0'
121
121
  type: :development
122
122
  prerelease: false
123
- version_requirements: *22369860
123
+ version_requirements: *17910260
124
124
  - !ruby/object:Gem::Dependency
125
125
  name: forgery
126
- requirement: &22368680 !ruby/object:Gem::Requirement
126
+ requirement: &17909240 !ruby/object:Gem::Requirement
127
127
  none: false
128
128
  requirements:
129
129
  - - ! '>='
@@ -131,10 +131,10 @@ dependencies:
131
131
  version: '0'
132
132
  type: :development
133
133
  prerelease: false
134
- version_requirements: *22368680
134
+ version_requirements: *17909240
135
135
  - !ruby/object:Gem::Dependency
136
136
  name: fabrication
137
- requirement: &22367440 !ruby/object:Gem::Requirement
137
+ requirement: &17908440 !ruby/object:Gem::Requirement
138
138
  none: false
139
139
  requirements:
140
140
  - - ! '>='
@@ -142,10 +142,10 @@ dependencies:
142
142
  version: '0'
143
143
  type: :development
144
144
  prerelease: false
145
- version_requirements: *22367440
145
+ version_requirements: *17908440
146
146
  - !ruby/object:Gem::Dependency
147
147
  name: jeweler
148
- requirement: &22366340 !ruby/object:Gem::Requirement
148
+ requirement: &17907540 !ruby/object:Gem::Requirement
149
149
  none: false
150
150
  requirements:
151
151
  - - ! '>='
@@ -153,10 +153,10 @@ dependencies:
153
153
  version: '0'
154
154
  type: :development
155
155
  prerelease: false
156
- version_requirements: *22366340
156
+ version_requirements: *17907540
157
157
  - !ruby/object:Gem::Dependency
158
158
  name: nested_set
159
- requirement: &22365440 !ruby/object:Gem::Requirement
159
+ requirement: &17906580 !ruby/object:Gem::Requirement
160
160
  none: false
161
161
  requirements:
162
162
  - - ! '>='
@@ -164,7 +164,7 @@ dependencies:
164
164
  version: '0'
165
165
  type: :development
166
166
  prerelease: false
167
- version_requirements: *22365440
167
+ version_requirements: *17906580
168
168
  description: In Soviet Russia puffer admins you
169
169
  email: kinwizard@gmail.com
170
170
  executables: []
@@ -293,6 +293,7 @@ files:
293
293
  - spec/dummy/app/controllers/admin/posts_controller.rb
294
294
  - spec/dummy/app/controllers/admin/profiles_controller.rb
295
295
  - spec/dummy/app/controllers/admin/sessions_controller.rb
296
+ - spec/dummy/app/controllers/admin/tagged_posts_controller.rb
296
297
  - spec/dummy/app/controllers/admin/tags_controller.rb
297
298
  - spec/dummy/app/controllers/admin/users_controller.rb
298
299
  - spec/dummy/app/controllers/application_controller.rb
@@ -304,6 +305,7 @@ files:
304
305
  - spec/dummy/app/models/post_category.rb
305
306
  - spec/dummy/app/models/profile.rb
306
307
  - spec/dummy/app/models/tag.rb
308
+ - spec/dummy/app/models/tagged_post.rb
307
309
  - spec/dummy/app/models/tagging.rb
308
310
  - spec/dummy/app/models/user.rb
309
311
  - spec/dummy/app/views/layouts/application.html.erb
@@ -369,7 +371,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
369
371
  version: '0'
370
372
  segments:
371
373
  - 0
372
- hash: -2583020713337993814
374
+ hash: -1489774044213861693
373
375
  required_rubygems_version: !ruby/object:Gem::Requirement
374
376
  none: false
375
377
  requirements: