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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 36ad057b77352b362b1e0891a641083127eb7051
4
- data.tar.gz: 58f8e4768d7e813a1c50cd173ccccdec5ce6be21
3
+ metadata.gz: d127bb48ca96fcbcb024d22188e63e8988b74192
4
+ data.tar.gz: 617fd24717a2bb1b052257172e247ee8008548a2
5
5
  SHA512:
6
- metadata.gz: 97e38d84de662556348eb7ccc85a7160c6fa2ad71b97193a55276f87cc9bc2bac52a8af5df054da91fd04889b33e599eb442d8d4f8a6d32b23e9ee8f266935b7
7
- data.tar.gz: 29bc18ba4bc6891a17d6599d1c31845629156f59e481174f52bf42f393ef2dade2ba2128300a3cde651fe7243abbccb74ec6e2e2c883d49395b4d3319e18ff49
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(params[:spud_banner_set])
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(params[:spud_banner_set])
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
- end
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 = params[:spud_banner]
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(params[:spud_banner])
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(params[:spud_banner])
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
- end
102
+ def banner_params
103
+ params.require(:spud_banner).permit(:banner, :link_to, :link_target, :title, :alt, :sort_order)
104
+ end
105
+
106
+ end
@@ -1,8 +1,7 @@
1
1
  class SpudBanner < ActiveRecord::Base
2
- attr_accessible :banner, :link_to, :link_target, :title, :alt, :sort_order
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
- attr_accessible :cropped, :height, :name, :short_name, :width
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
- validates_presence_of :name
6
- validates_uniqueness_of :name
7
- validates_numericality_of :width, :height
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
@@ -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::Helpers::RailsHelper
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
@@ -1,5 +1,5 @@
1
1
  module Spud
2
2
  module Banners
3
- VERSION = "0.9.3"
3
+ VERSION = "1.0.0.rc1"
4
4
  end
5
5
  end
@@ -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
- # Log error messages when you accidentally call methods on nil.
10
- config.whiny_nils = true
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
- # Log error messages when you accidentally call methods on nil
15
- config.whiny_nils = true
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