puffer 0.0.19 → 0.0.20
Sign up to get free protection for your applications and to get access to all the features.
- data/.rvmrc +1 -0
- data/Gemfile +11 -8
- data/Gemfile.lock +117 -103
- data/Guardfile +20 -0
- data/VERSION +1 -1
- data/app/assets/javascripts/puffer/application.js +5 -0
- data/{lib/generators/puffer/install/templates/puffer/javascripts → app/assets/javascripts/puffer}/puffer.js +0 -0
- data/{lib/generators/puffer/install/templates/puffer/javascripts → app/assets/javascripts/puffer}/rails.js +0 -0
- data/{lib/generators/puffer/install/templates/puffer/javascripts → app/assets/javascripts/puffer}/right-autocompleter.js +0 -0
- data/{lib/generators/puffer/install/templates/puffer/javascripts → app/assets/javascripts/puffer}/right-calendar.js +0 -0
- data/{lib/generators/puffer/install/templates/puffer/javascripts → app/assets/javascripts/puffer}/right.js +0 -0
- data/app/assets/stylesheets/puffer/application.css +4 -0
- data/{lib/generators/puffer/install/templates/puffer/stylesheets → app/assets/stylesheets/puffer}/puffer.css +2 -1
- data/{lib/generators/puffer/install/templates/puffer/stylesheets → app/assets/stylesheets/puffer}/reset.css +0 -0
- data/app/controllers/puffer/dashboard.rb +12 -0
- data/app/controllers/puffer/{sessions_base.rb → sessions.rb} +1 -2
- data/app/helpers/puffer_helper.rb +2 -10
- data/app/views/layouts/puffer.html.erb +24 -5
- data/app/views/layouts/puffer_dashboard.html.erb +3 -3
- data/app/views/layouts/puffer_sessions.html.erb +3 -3
- data/app/views/puffer/{_form.html.erb → base/_form.html.erb} +2 -2
- data/app/views/puffer/{associated → base/associated}/_many.html.erb +1 -1
- data/app/views/puffer/{associated → base/associated}/many.rjs +0 -0
- data/app/views/puffer/{associated → base/associated}/one.js.erb +1 -1
- data/app/views/puffer/{association → base/association}/_many.html.erb +0 -0
- data/app/views/puffer/{edit.html.erb → base/edit.html.erb} +1 -1
- data/app/views/puffer/{index.html.erb → base/index.html.erb} +2 -2
- data/app/views/puffer/{new.html.erb → base/new.html.erb} +1 -1
- data/app/views/puffer/{show.html.erb → base/show.html.erb} +1 -1
- data/app/views/{puffer_dashboard → puffer/dashboard}/index.html.erb +0 -0
- data/app/views/{puffer_sessions → puffer/sessions}/new.html.erb +0 -0
- data/config/locales/puffer.yml +5 -0
- data/lib/generators/puffer/install/install_generator.rb +0 -8
- data/lib/generators/puffer/install/templates/dashboard_controller.rb +1 -1
- data/lib/generators/puffer/install/templates/sessions_controller.rb +1 -1
- data/lib/puffer.rb +0 -16
- data/lib/puffer/base.rb +8 -3
- data/lib/puffer/controller/config.rb +2 -0
- data/lib/puffer/controller/dsl.rb +2 -2
- data/lib/puffer/controller/generated.rb +4 -4
- data/lib/puffer/controller/helpers.rb +1 -1
- data/lib/puffer/controller/mutate.rb +0 -14
- data/lib/puffer/customs.rb +1 -0
- data/lib/puffer/engine.rb +0 -4
- data/lib/puffer/extensions/mapper.rb +5 -1
- data/lib/puffer/fields.rb +2 -2
- data/lib/puffer/fields/field.rb +16 -17
- data/lib/puffer/inputs/association.rb +3 -2
- data/lib/puffer/resource.rb +13 -12
- data/lib/puffer/resource/routing.rb +1 -1
- data/lib/puffer/resource/scoping.rb +2 -2
- data/puffer.gemspec +63 -126
- data/spec/dummy/.rvmrc +1 -0
- data/spec/dummy/Rakefile +1 -1
- data/spec/dummy/app/assets/images/rails.png +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +9 -0
- data/spec/dummy/app/assets/stylesheets/application.css +7 -0
- data/spec/dummy/app/controllers/admin/posts_controller.rb +3 -1
- data/spec/dummy/app/controllers/admin/profiles_controller.rb +4 -1
- data/spec/dummy/app/controllers/puffer/dashboard_controller.rb +1 -1
- data/spec/dummy/app/controllers/puffer/sessions_controller.rb +1 -1
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config/application.rb +5 -9
- data/spec/dummy/config/boot.rb +5 -7
- data/spec/dummy/config/database.yml +4 -1
- data/spec/dummy/config/environments/development.rb +4 -3
- data/spec/dummy/config/environments/production.rb +17 -12
- data/spec/dummy/config/environments/test.rb +5 -1
- data/spec/dummy/config/initializers/secret_token.rb +1 -1
- data/spec/dummy/config/initializers/session_store.rb +1 -1
- data/spec/dummy/config/initializers/wrap_parameters.rb +12 -0
- data/spec/dummy/config/locales/en.yml +1 -1
- data/spec/dummy/db/seeds.rb +7 -0
- data/spec/dummy/public/robots.txt +5 -0
- data/spec/fabricators/posts_fabricator.rb +1 -1
- data/spec/fabricators/profiles_fabricator.rb +1 -1
- data/spec/fabricators/users_fabricator.rb +1 -1
- data/spec/lib/resource/routing_spec.rb +5 -5
- data/spec/lib/resource_spec.rb +37 -88
- data/spec/spec_helper.rb +15 -0
- metadata +171 -272
- data/app/cells/puffer/base/additional.html.erb +0 -25
- data/app/cells/puffer/base_cell.rb +0 -25
- data/app/controllers/puffer/dashboard_base.rb +0 -13
- data/autotest/discover.rb +0 -2
- data/lib/generators/puffer/install/templates/puffer.rb +0 -12
- data/lib/puffer/path_set.rb +0 -24
- data/spec/dummy/app/views/admin/users/index.html.erb +0 -3
- data/spec/dummy/config/initializers/puffer.rb +0 -12
- data/spec/dummy/db/schema.rb +0 -83
- data/spec/dummy/public/javascripts/application.js +0 -2
- data/spec/dummy/public/javascripts/controls.js +0 -965
- data/spec/dummy/public/javascripts/dragdrop.js +0 -974
- data/spec/dummy/public/javascripts/effects.js +0 -1123
- data/spec/dummy/public/javascripts/prototype.js +0 -6001
- data/spec/dummy/public/javascripts/rails.js +0 -175
- data/spec/dummy/public/puffer/javascripts/puffer.js +0 -10
- data/spec/dummy/public/puffer/javascripts/rails.js +0 -57
- data/spec/dummy/public/puffer/javascripts/right-autocompleter.js +0 -621
- data/spec/dummy/public/puffer/javascripts/right-calendar.js +0 -1461
- data/spec/dummy/public/puffer/javascripts/right.js +0 -5892
- data/spec/dummy/public/puffer/stylesheets/puffer.css +0 -469
- data/spec/dummy/public/puffer/stylesheets/reset.css +0 -60
- data/spec/dummy/public/stylesheets/.gitkeep +0 -0
- data/spec/lib/render_fallback_spec.rb +0 -17
@@ -4,16 +4,16 @@
|
|
4
4
|
<title><%= [@title, 'Puffer'].compact.join(' - ') %></title>
|
5
5
|
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
|
6
6
|
<%= csrf_meta_tag %>
|
7
|
-
<%=
|
7
|
+
<%= stylesheet_link_tag "puffer/application" %>
|
8
|
+
<%= javascript_include_tag "puffer/application" %>
|
8
9
|
<%= yield :stylesheets %>
|
9
|
-
<%= puffer_javascripts %>
|
10
10
|
<%= yield :javascripts %>
|
11
11
|
</head>
|
12
12
|
<body>
|
13
13
|
<div class="body">
|
14
14
|
<div class="header">
|
15
15
|
<div class="logo">
|
16
|
-
<%= link_to
|
16
|
+
<%= link_to t('puffer.logo'), puffer_root_path %>
|
17
17
|
</div>
|
18
18
|
<ul class="namespaces">
|
19
19
|
<% puffer_namespaces do |title, path, current| %>
|
@@ -4,16 +4,16 @@
|
|
4
4
|
<title><%= [@title, 'Puffer'].compact.join(' - ') %></title>
|
5
5
|
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
|
6
6
|
<%= csrf_meta_tag %>
|
7
|
-
<%=
|
7
|
+
<%= stylesheet_link_tag "puffer/application" %>
|
8
|
+
<%= javascript_include_tag "puffer/application" %>
|
8
9
|
<%= yield :stylesheets %>
|
9
|
-
<%= puffer_javascripts %>
|
10
10
|
<%= yield :javascripts %>
|
11
11
|
</head>
|
12
12
|
<body>
|
13
13
|
<div class="body">
|
14
14
|
<div class="header">
|
15
15
|
<div class="logo">
|
16
|
-
<span><%=
|
16
|
+
<span><%= t('puffer.logo') %></span>
|
17
17
|
</div>
|
18
18
|
</div>
|
19
19
|
<div class="content sessions">
|
File without changes
|
@@ -5,7 +5,7 @@
|
|
5
5
|
<div class="title"><strong><%= record[primary_key] %></strong> — <%= record.to_title %></div>
|
6
6
|
<div class="description">
|
7
7
|
<% @field.association_columns.searchable.each do |column| %>
|
8
|
-
<div><strong><%= column.
|
8
|
+
<div><strong><%= column.human %>:</strong> <%= render_field column, record %></div>
|
9
9
|
<% end %>
|
10
10
|
</div>
|
11
11
|
</li>
|
File without changes
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<% @title = "Edit #{resource.human}" %>
|
2
2
|
<h1><%= @title %></h1>
|
3
3
|
<%= form_for record, :url => resource.member_path, :html => {:multipart => true} do |f| %>
|
4
|
-
<%= render :partial => '
|
4
|
+
<%= render :partial => 'form', :locals => { :f => f, :action => 'edit' } %>
|
5
5
|
<% end %>
|
6
6
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<% @title = resource.human %>
|
2
2
|
<h1><%= @title %></h1>
|
3
|
-
<%=
|
3
|
+
<%= paginate records, :url => resource.collection_path(:page => '') %>
|
4
4
|
<% if records.present? %>
|
5
5
|
<table class="list_table">
|
6
6
|
<thead>
|
@@ -31,5 +31,5 @@
|
|
31
31
|
<% else %>
|
32
32
|
<p>Sorry, but there is no records in <%= resource.human %></p>
|
33
33
|
<% end %>
|
34
|
-
<%=
|
34
|
+
<%= paginate records, :url => resource.collection_path(:page => '') %>
|
35
35
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<% @title = "New #{resource.human}" %>
|
2
2
|
<h1><%= @title %></h1>
|
3
3
|
<%= form_for record, :url => resource.collection_path, :html => {:multipart => true} do |f| %>
|
4
|
-
<%= render :partial => '
|
4
|
+
<%= render :partial => 'form', :locals => { :f => f, :action => 'new' } %>
|
5
5
|
<% end %>
|
6
6
|
|
File without changes
|
File without changes
|
@@ -1,14 +1,6 @@
|
|
1
1
|
class Puffer::InstallGenerator < Rails::Generators::Base
|
2
2
|
source_root File.expand_path('../templates', __FILE__)
|
3
3
|
|
4
|
-
def generate_assets
|
5
|
-
directory 'puffer', 'public/puffer'
|
6
|
-
end
|
7
|
-
|
8
|
-
def generate_config
|
9
|
-
copy_file 'puffer.rb', 'config/initializers/puffer.rb'
|
10
|
-
end
|
11
|
-
|
12
4
|
def generate_puffer_controllers
|
13
5
|
copy_file 'sessions_controller.rb', 'app/controllers/puffer/sessions_controller.rb'
|
14
6
|
copy_file 'dashboard_controller.rb', 'app/controllers/puffer/dashboard_controller.rb'
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class Puffer::SessionsController < Puffer::
|
1
|
+
class Puffer::SessionsController < Puffer::Sessions
|
2
2
|
# This is example session controller for puffer authentication.
|
3
3
|
# You can define your own actions.
|
4
4
|
# Also, you can redefine <tt>new<tt> action view as you wish,
|
data/lib/puffer.rb
CHANGED
@@ -1,27 +1,11 @@
|
|
1
1
|
module Puffer
|
2
2
|
|
3
|
-
mattr_accessor :stylesheets
|
4
|
-
self.stylesheets = %w(reset puffer)
|
5
|
-
|
6
|
-
mattr_accessor :javascripts
|
7
|
-
self.javascripts = %w(right right-calendar right-autocompleter rails puffer)
|
8
|
-
|
9
|
-
mattr_accessor :logo
|
10
|
-
self.logo = 'Puffer'
|
11
|
-
|
12
|
-
def self.setup
|
13
|
-
yield self
|
14
|
-
end
|
15
|
-
|
16
3
|
def self.customs
|
17
4
|
Puffer::Customs
|
18
5
|
end
|
19
6
|
|
20
7
|
end
|
21
8
|
|
22
|
-
require 'will_paginate'
|
23
|
-
require 'cells'
|
24
|
-
|
25
9
|
require 'puffer/engine'
|
26
10
|
require 'puffer/extensions/activerecord'
|
27
11
|
require 'puffer/extensions/controller'
|
data/lib/puffer/base.rb
CHANGED
@@ -3,7 +3,6 @@ module Puffer
|
|
3
3
|
unloadable
|
4
4
|
|
5
5
|
pufferize!
|
6
|
-
view_paths_fallbacks :puffer
|
7
6
|
define_fields :index, :show, :form, :create, :update
|
8
7
|
|
9
8
|
respond_to :html, :js
|
@@ -27,13 +26,13 @@ module Puffer
|
|
27
26
|
def create
|
28
27
|
@record = resource.new_member
|
29
28
|
@record.save
|
30
|
-
respond_with @record, :location =>
|
29
|
+
respond_with @record, :location => puffer_saving_location
|
31
30
|
end
|
32
31
|
|
33
32
|
def update
|
34
33
|
@record = resource.member
|
35
34
|
@record.update_attributes resource.attributes
|
36
|
-
respond_with @record, :location =>
|
35
|
+
respond_with @record, :location => puffer_saving_location
|
37
36
|
end
|
38
37
|
|
39
38
|
def destroy
|
@@ -42,5 +41,11 @@ module Puffer
|
|
42
41
|
redirect_to (request.referrer || resource.collection_path)
|
43
42
|
end
|
44
43
|
|
44
|
+
private
|
45
|
+
|
46
|
+
def puffer_saving_location
|
47
|
+
params[:commit] == t('puffer.save') ? resource.edit_path(record) : resource.collection_path
|
48
|
+
end
|
49
|
+
|
45
50
|
end
|
46
51
|
end
|
@@ -53,8 +53,8 @@ module Puffer
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
-
def field name, options = {}
|
57
|
-
field = @_fields.field(name, model, options) if @_fields
|
56
|
+
def field name, options = {}, &block
|
57
|
+
field = @_fields.field(name, model, options, &block) if @_fields
|
58
58
|
generate_association_actions field if field.reflection
|
59
59
|
#generate_change_actions field if field.toggable?
|
60
60
|
end
|
@@ -19,7 +19,7 @@ module Puffer
|
|
19
19
|
@field = field
|
20
20
|
@record = resource.member if params[:id]
|
21
21
|
@records = field.reflection.klass.includes(field.association_columns.includes).where(field.association_columns.searches(params[:search])).limit(100).all
|
22
|
-
render '
|
22
|
+
render :action => 'associated/one'
|
23
23
|
end
|
24
24
|
|
25
25
|
collection do
|
@@ -32,7 +32,7 @@ module Puffer
|
|
32
32
|
@record = resource.member
|
33
33
|
@records = field.association.klass.scoped(:conditions => {:id => params[:ids]}).scoped(:conditions => search_query(field.association_fields)).paginate(:page => params[:page], :include => includes(field.association_fields))
|
34
34
|
@field = field
|
35
|
-
render '
|
35
|
+
render :action => 'associated/many'
|
36
36
|
end
|
37
37
|
|
38
38
|
define_method "associated_#{field}_choosing" do
|
@@ -40,7 +40,7 @@ module Puffer
|
|
40
40
|
@records = field.association.klass.scoped(:conditions => search_query(field.association_fields)).paginate(:page => params[:page], :include => includes(field.association_fields))
|
41
41
|
@choosen = field.association.klass.scoped(:conditions => {:id => params[:ids]}).scoped(:conditions => search_query(field.association_fields)).paginate(:page => params[:page], :include => includes(field.association_fields))
|
42
42
|
@field = field
|
43
|
-
render '
|
43
|
+
render :action => 'associated/many'
|
44
44
|
end
|
45
45
|
|
46
46
|
collection do
|
@@ -54,7 +54,7 @@ module Puffer
|
|
54
54
|
@record = model.find params[:id]
|
55
55
|
@field = field
|
56
56
|
@record.toggle! field.name.to_sym
|
57
|
-
render '
|
57
|
+
render :action => 'toggle'
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
@@ -43,20 +43,6 @@ module Puffer
|
|
43
43
|
@model ||= model_name.camelize.constantize rescue nil
|
44
44
|
end
|
45
45
|
|
46
|
-
def view_paths_fallbacks *args
|
47
|
-
temp = Puffer::PathSet.new view_paths
|
48
|
-
temp._fallbacks = args.flatten
|
49
|
-
self.view_paths = temp
|
50
|
-
end
|
51
|
-
|
52
|
-
def view_paths_fallbacks_prepend *args
|
53
|
-
view_paths_fallbacks args, view_paths._fallbacks
|
54
|
-
end
|
55
|
-
|
56
|
-
def view_paths_fallbacks_append *args
|
57
|
-
view_paths_fallbacks view_paths._fallbacks, args
|
58
|
-
end
|
59
|
-
|
60
46
|
end
|
61
47
|
|
62
48
|
end
|
data/lib/puffer/customs.rb
CHANGED
data/lib/puffer/engine.rb
CHANGED
@@ -1,9 +1,5 @@
|
|
1
1
|
module Puffer
|
2
2
|
class Engine < Rails::Engine
|
3
3
|
config.autoload_paths << File.join(root, 'lib')
|
4
|
-
|
5
|
-
initializer 'puffer.add_cells_paths', :after => :add_view_paths do
|
6
|
-
::Cell::Base.prepend_view_path(Cells::DEFAULT_VIEW_PATHS.map { |path| File.join(root, path) })
|
7
|
-
end
|
8
4
|
end
|
9
5
|
end
|
@@ -160,7 +160,11 @@ module Puffer
|
|
160
160
|
include InstanceMethods
|
161
161
|
|
162
162
|
alias_method_chain :clear!, :puffer
|
163
|
-
|
163
|
+
attr_writer :puffer
|
164
|
+
|
165
|
+
def puffer
|
166
|
+
@puffer ||= ActiveSupport::OrderedHash.new
|
167
|
+
end
|
164
168
|
end
|
165
169
|
end
|
166
170
|
|
data/lib/puffer/fields.rb
CHANGED
data/lib/puffer/fields/field.rb
CHANGED
@@ -2,12 +2,18 @@ module Puffer
|
|
2
2
|
class Fields
|
3
3
|
class Field
|
4
4
|
|
5
|
-
attr_accessor :resource, :
|
5
|
+
attr_accessor :resource, :field_name, :options, :fields
|
6
6
|
|
7
|
-
def initialize
|
8
|
-
@
|
7
|
+
def initialize field_name, *resource_and_options, &block
|
8
|
+
@field_name = field_name.to_s
|
9
9
|
@options = resource_and_options.extract_options!
|
10
10
|
@resource = resource_and_options.first
|
11
|
+
@fields = Puffer::Fields.new
|
12
|
+
block.bind(self).call if block
|
13
|
+
end
|
14
|
+
|
15
|
+
def field name, options = {}, &block
|
16
|
+
@fields.field(name, swallow_nil{reflection.klass}, options, &block)
|
11
17
|
end
|
12
18
|
|
13
19
|
def native?
|
@@ -15,15 +21,15 @@ module Puffer
|
|
15
21
|
end
|
16
22
|
|
17
23
|
def name
|
18
|
-
@name ||=
|
24
|
+
@name ||= field_name.split('.').last
|
19
25
|
end
|
20
26
|
|
21
27
|
def path
|
22
|
-
@path ||=
|
28
|
+
@path ||= field_name.split('.')[0..-2].join('.')
|
23
29
|
end
|
24
30
|
|
25
|
-
def
|
26
|
-
@
|
31
|
+
def human
|
32
|
+
@human ||= model && model.human_attribute_name(name)
|
27
33
|
end
|
28
34
|
|
29
35
|
def order
|
@@ -35,7 +41,7 @@ module Puffer
|
|
35
41
|
end
|
36
42
|
|
37
43
|
def to_s
|
38
|
-
|
44
|
+
field_name
|
39
45
|
end
|
40
46
|
|
41
47
|
def reflection
|
@@ -56,7 +62,7 @@ module Puffer
|
|
56
62
|
|
57
63
|
def model
|
58
64
|
@model ||= begin
|
59
|
-
associations =
|
65
|
+
associations = field_name.split('.')
|
60
66
|
associations.pop
|
61
67
|
temp = resource
|
62
68
|
while temp.reflect_on_association(association = swallow_nil{associations.shift.to_sym}) do
|
@@ -67,14 +73,7 @@ module Puffer
|
|
67
73
|
end
|
68
74
|
|
69
75
|
def association_columns
|
70
|
-
|
71
|
-
@reflection_fields ||= begin
|
72
|
-
fields = Puffer::Fields.new
|
73
|
-
options[:columns].each do |field_name|
|
74
|
-
fields.field field_name, reflection.klass
|
75
|
-
end
|
76
|
-
fields
|
77
|
-
end
|
76
|
+
@association_columns ||= fields
|
78
77
|
end
|
79
78
|
|
80
79
|
def column
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# coding: utf-8
|
1
2
|
module Puffer
|
2
3
|
module Inputs
|
3
4
|
class Association < Puffer::Inputs::Base
|
@@ -11,7 +12,7 @@ module Puffer
|
|
11
12
|
'data-autocompleter' => "{url: '#{resource.collection_path(:action => "associated_#{field}_choosing")}', onDone: association_done}"
|
12
13
|
)}
|
13
14
|
<div class="association_clear">×</div>
|
14
|
-
#{builder.hidden_field field.reflection.
|
15
|
+
#{builder.hidden_field field.reflection.foreign_key}
|
15
16
|
</div>
|
16
17
|
INPUT
|
17
18
|
end
|
@@ -28,7 +29,7 @@ module Puffer
|
|
28
29
|
end
|
29
30
|
|
30
31
|
def error
|
31
|
-
builder.object.errors[field.reflection.
|
32
|
+
builder.object.errors[field.reflection.foreign_key.to_sym].first ||
|
32
33
|
builder.object.errors[field.name.to_sym].first.presence
|
33
34
|
end
|
34
35
|
|