spud_banners 0.9.3 → 1.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/spud/admin/banner_sets_controller.rb +9 -7
- data/app/controllers/spud/admin/banners_controller.rb +11 -9
- data/app/models/spud_banner.rb +2 -3
- data/app/models/spud_banner_set.rb +19 -5
- data/lib/spud_banners/engine.rb +2 -1
- data/lib/spud_banners/liquid_tags.rb +3 -3
- data/lib/spud_banners/version.rb +1 -1
- data/spec/dummy/config/environments/development.rb +3 -4
- data/spec/dummy/config/environments/test.rb +3 -4
- data/spec/dummy/log/test.log +636 -0
- data/spec/spec_helper.rb +1 -1
- metadata +31 -30
- data/app/observers/spud_banner_sweeper.rb +0 -52
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d127bb48ca96fcbcb024d22188e63e8988b74192
|
4
|
+
data.tar.gz: 617fd24717a2bb1b052257172e247ee8008548a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12e2edaf15ad49fb75f969b84f5d3fc942593861fd843a2e216edbfbef7f9467d137f236a84c0f22ae938018aedc5c53035498eac39dbe1e418a0eb3324e32e3
|
7
|
+
data.tar.gz: 9b4dab04dffc026d37f41bd30a6acdc69840c9be6743dd0015e44e676882e7663dce367affd912693731f9007f74d586a3d298a9675b7326a1247f6e0a843788
|
@@ -1,6 +1,4 @@
|
|
1
1
|
class Spud::Admin::BannerSetsController < Spud::Admin::ApplicationController
|
2
|
-
|
3
|
-
cache_sweeper :spud_banner_sweeper, :only => [:create, :update, :destroy]
|
4
2
|
before_filter :get_record, :only => [:show, :edit, :update, :destroy]
|
5
3
|
respond_to :html
|
6
4
|
belongs_to_spud_app :banner_sets
|
@@ -22,9 +20,9 @@ class Spud::Admin::BannerSetsController < Spud::Admin::ApplicationController
|
|
22
20
|
end
|
23
21
|
|
24
22
|
def create
|
25
|
-
@banner_set = SpudBannerSet.new(
|
23
|
+
@banner_set = SpudBannerSet.new(banner_set_params)
|
26
24
|
if @banner_set.save
|
27
|
-
flash.now[:notice] = 'BannerSet created successfully'
|
25
|
+
flash.now[:notice] = 'BannerSet created successfully'
|
28
26
|
render 'create'
|
29
27
|
else
|
30
28
|
render 'new', :status => 422
|
@@ -36,7 +34,7 @@ class Spud::Admin::BannerSetsController < Spud::Admin::ApplicationController
|
|
36
34
|
end
|
37
35
|
|
38
36
|
def update
|
39
|
-
if @banner_set.update_attributes(
|
37
|
+
if @banner_set.update_attributes(banner_set_params)
|
40
38
|
flash.now[:notice] = 'BannerSet updated successfully'
|
41
39
|
@banner_set.reprocess_banners!
|
42
40
|
render 'create'
|
@@ -47,7 +45,7 @@ class Spud::Admin::BannerSetsController < Spud::Admin::ApplicationController
|
|
47
45
|
|
48
46
|
def destroy
|
49
47
|
if @banner_set.destroy
|
50
|
-
flash.now[:notice] = 'BannerSet deleted successfully'
|
48
|
+
flash.now[:notice] = 'BannerSet deleted successfully'
|
51
49
|
end
|
52
50
|
render :nothing => true
|
53
51
|
end
|
@@ -65,4 +63,8 @@ private
|
|
65
63
|
end
|
66
64
|
end
|
67
65
|
|
68
|
-
|
66
|
+
def banner_set_params
|
67
|
+
params.require(:spud_banner_set).permit(:cropped, :height, :name, :short_name, :width)
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
@@ -1,8 +1,6 @@
|
|
1
1
|
class Spud::Admin::BannersController < Spud::Admin::ApplicationController
|
2
2
|
|
3
3
|
include RespondsToParent
|
4
|
-
|
5
|
-
cache_sweeper :spud_banner_sweeper, :only => [:create, :update, :destroy]
|
6
4
|
before_filter :get_set, :only => [:new, :create]
|
7
5
|
before_filter :get_record, :only => [:edit, :update, :destroy]
|
8
6
|
respond_to :html
|
@@ -15,7 +13,7 @@ class Spud::Admin::BannersController < Spud::Admin::ApplicationController
|
|
15
13
|
|
16
14
|
def create
|
17
15
|
@banner = @banner_set.banners.build
|
18
|
-
@banner.attributes =
|
16
|
+
@banner.attributes = banner_params
|
19
17
|
|
20
18
|
last_banner = SpudBanner.select('sort_order').where(:spud_banner_set_id => @banner_set.id).order('sort_order desc').first
|
21
19
|
if last_banner
|
@@ -24,7 +22,7 @@ class Spud::Admin::BannersController < Spud::Admin::ApplicationController
|
|
24
22
|
|
25
23
|
if request.xhr?
|
26
24
|
if @banner.save
|
27
|
-
flash.now[:notice] = 'SpudBanner created successfully'
|
25
|
+
flash.now[:notice] = 'SpudBanner created successfully'
|
28
26
|
render 'show'
|
29
27
|
else
|
30
28
|
render 'new', :status => 422
|
@@ -43,14 +41,14 @@ class Spud::Admin::BannersController < Spud::Admin::ApplicationController
|
|
43
41
|
|
44
42
|
def update
|
45
43
|
if request.xhr?
|
46
|
-
if @banner.update_attributes(
|
47
|
-
flash.now[:notice] = 'SpudBanner created successfully'
|
44
|
+
if @banner.update_attributes(banner_params)
|
45
|
+
flash.now[:notice] = 'SpudBanner created successfully'
|
48
46
|
render 'show'
|
49
47
|
else
|
50
48
|
render 'edit', :status => 422
|
51
49
|
end
|
52
50
|
else
|
53
|
-
@banner.update_attributes(
|
51
|
+
@banner.update_attributes(banner_params)
|
54
52
|
respond_to_parent do
|
55
53
|
render 'legacy', :formats => [:js]
|
56
54
|
end
|
@@ -59,7 +57,7 @@ class Spud::Admin::BannersController < Spud::Admin::ApplicationController
|
|
59
57
|
|
60
58
|
def destroy
|
61
59
|
if @banner.destroy
|
62
|
-
flash.now[:notice] = 'SpudBanner deleted successfully'
|
60
|
+
flash.now[:notice] = 'SpudBanner deleted successfully'
|
63
61
|
status = 200
|
64
62
|
else
|
65
63
|
status = 422
|
@@ -101,4 +99,8 @@ private
|
|
101
99
|
end
|
102
100
|
end
|
103
101
|
|
104
|
-
|
102
|
+
def banner_params
|
103
|
+
params.require(:spud_banner).permit(:banner, :link_to, :link_target, :title, :alt, :sort_order)
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
data/app/models/spud_banner.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
class SpudBanner < ActiveRecord::Base
|
2
|
-
|
3
|
-
belongs_to :owner, :class_name => 'SpudBannerSet', :foreign_key => 'spud_banner_set_id', :inverse_of => :banners
|
2
|
+
belongs_to :owner, :class_name => 'SpudBannerSet', :foreign_key => 'spud_banner_set_id', :inverse_of => :banners, :touch => true
|
4
3
|
|
5
|
-
has_attached_file :banner,
|
4
|
+
has_attached_file :banner,
|
6
5
|
:styles => lambda { |attachment| attachment.instance.dynamic_styles },
|
7
6
|
:convert_options => {
|
8
7
|
:admin_small => '-strip -density 72x72',
|
@@ -1,10 +1,13 @@
|
|
1
1
|
class SpudBannerSet < ActiveRecord::Base
|
2
|
-
|
3
|
-
has_many :banners, :class_name => 'SpudBanner', :order => 'sort_order asc', :dependent => :destroy, :inverse_of => :owner
|
2
|
+
has_many :banners, -> { order :sort_order }, :class_name => 'SpudBanner', :dependent => :destroy, :inverse_of => :owner
|
4
3
|
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
validates :name, :presence => true, :uniqueness => true
|
5
|
+
validates :width, :numericality => true
|
6
|
+
validates :height, :numericality => true
|
7
|
+
|
8
|
+
after_destroy :expire_cache
|
9
|
+
after_save :expire_cache
|
10
|
+
after_touch :expire_cache
|
8
11
|
|
9
12
|
def self.find_by_identifier(identifier)
|
10
13
|
if identifier.class == String
|
@@ -27,4 +30,15 @@ class SpudBannerSet < ActiveRecord::Base
|
|
27
30
|
return name
|
28
31
|
end
|
29
32
|
|
33
|
+
def expire_cache
|
34
|
+
if defined?(Spud::Cms)
|
35
|
+
old_name = self.name_was
|
36
|
+
values = [self.name]
|
37
|
+
values << old_name if !old_name.blank?
|
38
|
+
SpudPageLiquidTag.where(:tag_name => ["spud_banner_set","banner_set"], :value => values).includes(:attachment).each do |tag|
|
39
|
+
partial = tag.touch
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
30
44
|
end
|
data/lib/spud_banners/engine.rb
CHANGED
@@ -14,11 +14,12 @@ module Spud
|
|
14
14
|
:thumbnail => 'spud/admin/banners/banners.png',
|
15
15
|
:retina => true,
|
16
16
|
:url => '/spud/admin/banner_sets',
|
17
|
-
:order => 120
|
17
|
+
:order => 120
|
18
18
|
}]
|
19
19
|
end
|
20
20
|
initializer :liquid do
|
21
21
|
Liquid::Template.register_tag('spud_banner_set', Spud::Banners::BannerSetTag) if defined?(Liquid::Template)
|
22
|
+
Liquid::Template.register_tag('banner_set', Spud::Banners::BannerSetTag) if defined?(Liquid::Template)
|
22
23
|
end
|
23
24
|
end
|
24
25
|
end
|
@@ -5,8 +5,8 @@ module Spud
|
|
5
5
|
module Banners
|
6
6
|
class BannerSetTag < Liquid::Tag
|
7
7
|
|
8
|
-
include Sprockets::
|
9
|
-
include Sprockets::Helpers::IsolatedHelper
|
8
|
+
include Sprockets::Rails::Helper
|
9
|
+
# include Sprockets::Rails::Helpers::IsolatedHelper
|
10
10
|
include ActionView::Helpers
|
11
11
|
include ActionView::Context
|
12
12
|
include SpudBannersHelper
|
@@ -29,4 +29,4 @@ module Spud
|
|
29
29
|
|
30
30
|
end
|
31
31
|
end
|
32
|
-
end
|
32
|
+
end
|
data/lib/spud_banners/version.rb
CHANGED
@@ -6,8 +6,9 @@ Dummy::Application.configure do
|
|
6
6
|
# since you don't have to restart the web server when you make code changes.
|
7
7
|
config.cache_classes = false
|
8
8
|
|
9
|
-
|
10
|
-
|
9
|
+
|
10
|
+
|
11
|
+
config.eager_load = false
|
11
12
|
|
12
13
|
# Show full error reports and disable caching
|
13
14
|
config.consider_all_requests_local = true
|
@@ -22,8 +23,6 @@ Dummy::Application.configure do
|
|
22
23
|
# Only use best-standards-support built into browsers
|
23
24
|
config.action_dispatch.best_standards_support = :builtin
|
24
25
|
|
25
|
-
# Raise exception on mass assignment protection for Active Record models
|
26
|
-
config.active_record.mass_assignment_sanitizer = :strict
|
27
26
|
|
28
27
|
# Log the query plan for queries taking more than this (works
|
29
28
|
# with SQLite, MySQL, and PostgreSQL)
|
@@ -11,8 +11,9 @@ Dummy::Application.configure do
|
|
11
11
|
config.serve_static_assets = true
|
12
12
|
config.static_cache_control = "public, max-age=3600"
|
13
13
|
|
14
|
-
|
15
|
-
config.
|
14
|
+
|
15
|
+
config.eager_load = false
|
16
|
+
|
16
17
|
|
17
18
|
# Show full error reports and disable caching
|
18
19
|
config.consider_all_requests_local = true
|
@@ -29,8 +30,6 @@ Dummy::Application.configure do
|
|
29
30
|
# ActionMailer::Base.deliveries array.
|
30
31
|
config.action_mailer.delivery_method = :test
|
31
32
|
|
32
|
-
# Raise exception on mass assignment protection for Active Record models
|
33
|
-
config.active_record.mass_assignment_sanitizer = :strict
|
34
33
|
|
35
34
|
# Print deprecation notices to the stderr
|
36
35
|
config.active_support.deprecation = :stderr
|