spud_banners 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/Rakefile +40 -0
  3. data/Readme.markdown +128 -0
  4. data/app/assets/javascripts/spud/admin/banners/application.js +2 -0
  5. data/app/assets/javascripts/spud/admin/banners/banner_sets.js +102 -0
  6. data/app/assets/javascripts/spud/admin/banners/banners.js +161 -0
  7. data/app/assets/stylesheets/spud/admin/banners/application.css +4 -0
  8. data/app/assets/stylesheets/spud/admin/banners/banner_sets.css +27 -0
  9. data/app/assets/stylesheets/spud/admin/banners/banners.css +36 -0
  10. data/app/controllers/spud/admin/banner_sets_controller.rb +71 -0
  11. data/app/controllers/spud/admin/banners_controller.rb +104 -0
  12. data/app/helpers/spud/admin/banner_sets_helper.rb +2 -0
  13. data/app/helpers/spud/admin/banners_helper.rb +2 -0
  14. data/app/helpers/spud_banners_helper.rb +37 -0
  15. data/app/models/spud_banner.rb +51 -0
  16. data/app/models/spud_banner_set.rb +30 -0
  17. data/app/observers/spud_banner_sweeper.rb +44 -0
  18. data/app/views/spud/admin/banner_sets/_banner_set.html.erb +8 -0
  19. data/app/views/spud/admin/banner_sets/_form.html.erb +32 -0
  20. data/app/views/spud/admin/banner_sets/create.html.erb +1 -0
  21. data/app/views/spud/admin/banner_sets/edit.html.erb +1 -0
  22. data/app/views/spud/admin/banner_sets/index.html.erb +12 -0
  23. data/app/views/spud/admin/banner_sets/new.html.erb +1 -0
  24. data/app/views/spud/admin/banner_sets/show.html.erb +11 -0
  25. data/app/views/spud/admin/banners/_banner.html.erb +7 -0
  26. data/app/views/spud/admin/banners/_form.html.erb +47 -0
  27. data/app/views/spud/admin/banners/edit.html.erb +1 -0
  28. data/app/views/spud/admin/banners/legacy.js.erb +5 -0
  29. data/app/views/spud/admin/banners/new.html.erb +1 -0
  30. data/app/views/spud/admin/banners/show.html.erb +1 -0
  31. data/config/routes.rb +14 -0
  32. data/db/migrate/20121116195139_create_spud_banners.rb +15 -0
  33. data/db/migrate/20121116195312_create_spud_banner_sets.rb +12 -0
  34. data/lib/responds_to_parent.rb +69 -0
  35. data/lib/spud_banners/configuration.rb +10 -0
  36. data/lib/spud_banners/engine.rb +25 -0
  37. data/lib/spud_banners/liquid_tags.rb +32 -0
  38. data/lib/spud_banners/version.rb +5 -0
  39. data/lib/spud_banners.rb +8 -0
  40. data/lib/tasks/spud_banners_tasks.rake +4 -0
  41. data/test/dummy/README.rdoc +261 -0
  42. data/test/dummy/Rakefile +7 -0
  43. data/test/dummy/app/assets/javascripts/application.js +15 -0
  44. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  45. data/test/dummy/app/controllers/application_controller.rb +3 -0
  46. data/test/dummy/app/helpers/application_helper.rb +2 -0
  47. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  48. data/test/dummy/config/application.rb +59 -0
  49. data/test/dummy/config/boot.rb +10 -0
  50. data/test/dummy/config/database.yml +25 -0
  51. data/test/dummy/config/environment.rb +5 -0
  52. data/test/dummy/config/environments/development.rb +37 -0
  53. data/test/dummy/config/environments/production.rb +67 -0
  54. data/test/dummy/config/environments/test.rb +37 -0
  55. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  56. data/test/dummy/config/initializers/inflections.rb +15 -0
  57. data/test/dummy/config/initializers/mime_types.rb +5 -0
  58. data/test/dummy/config/initializers/secret_token.rb +7 -0
  59. data/test/dummy/config/initializers/session_store.rb +8 -0
  60. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  61. data/test/dummy/config/locales/en.yml +5 -0
  62. data/test/dummy/config/routes.rb +4 -0
  63. data/test/dummy/config.ru +4 -0
  64. data/test/dummy/public/404.html +26 -0
  65. data/test/dummy/public/422.html +26 -0
  66. data/test/dummy/public/500.html +25 -0
  67. data/test/dummy/public/favicon.ico +0 -0
  68. data/test/dummy/script/rails +6 -0
  69. data/test/fixtures/spud_banner_sets.yml +15 -0
  70. data/test/fixtures/spud_banners.yml +15 -0
  71. data/test/functional/spud/admin/banner_sets_controller_test.rb +7 -0
  72. data/test/functional/spud/admin/banners_controller_test.rb +7 -0
  73. data/test/integration/navigation_test.rb +10 -0
  74. data/test/spud_banners_test.rb +7 -0
  75. data/test/test_helper.rb +15 -0
  76. data/test/unit/helpers/spud/admin/banner_sets_helper_test.rb +4 -0
  77. data/test/unit/helpers/spud/admin/banners_helper_test.rb +4 -0
  78. data/test/unit/spud_banner_set_test.rb +7 -0
  79. data/test/unit/spud_banner_test.rb +7 -0
  80. metadata +234 -0
@@ -0,0 +1,2 @@
1
+ module Spud::Admin::BannerSetsHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ module Spud::Admin::BannersHelper
2
+ end
@@ -0,0 +1,37 @@
1
+ module SpudBannersHelper
2
+
3
+ def spud_banners_for_set(set_or_identifier, options = {})
4
+ if set_or_identifier.is_a?(SpudBannerSet)
5
+ banner_set = set_or_identifier
6
+ else
7
+ banner_set = SpudBannerSet.find_by_identifier(set_or_identifier)
8
+ end
9
+ return '' if banner_set.blank?
10
+ if block_given?
11
+ banner_set.banners.each do |banner|
12
+ yield(banner)
13
+ end
14
+ else
15
+ content_tag(:div, :class => 'spud_banner_set', 'data-id' => banner_set.id) do
16
+ banner_set.banners.map do |banner|
17
+ concat(content_tag(:div, :class => 'spud_banner_set_banner', 'data-id' => banner.id){ spud_banner_tag(banner) })
18
+ end
19
+ end
20
+ end
21
+ end
22
+
23
+ def spud_banner_tag(banner)
24
+ if banner.link_to.blank?
25
+ spud_banner_image_tag(banner)
26
+ else
27
+ link_to(banner.link_to, :target => banner.link_target) do
28
+ spud_banner_image_tag(banner)
29
+ end
30
+ end
31
+ end
32
+
33
+ def spud_banner_image_tag(banner)
34
+ image_tag(banner.banner.url(:banner), :alt => banner.alt, :title => banner.title)
35
+ end
36
+
37
+ end
@@ -0,0 +1,51 @@
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'
4
+
5
+ has_attached_file :banner,
6
+ :styles => lambda { |attachment| attachment.instance.dynamic_styles },
7
+ :convert_options => {
8
+ :admin_small => '-strip -density 72x72',
9
+ :banner => '-strip -density 72x72'
10
+ },
11
+ :storage => Spud::Banners.paperclip_storage,
12
+ :s3_credentials => Spud::Banners.s3_credentials,
13
+ :url => Spud::Banners.storage_url,
14
+ :path => Spud::Banners.storage_path
15
+
16
+ validates_attachment_presence :banner
17
+
18
+ def dynamic_styles
19
+ styles = {
20
+ :spud_admin_small => '300x150'
21
+ }
22
+ owner_style = nil
23
+ if self.owner
24
+ owner_style = "#{self.owner.width}x#{self.owner.height}"
25
+ owner_style += '#' if self.owner.cropped
26
+ styles[:banner] = owner_style
27
+ end
28
+ return styles
29
+ end
30
+
31
+ def self.banners_for_set(identifier)
32
+ case identifier.class
33
+ when String
34
+ banner_set = SpudBannerSet.find_by_name(identifier)
35
+ when Symbol
36
+ banner_set = SpudBannerSet.find_by_name(identifier.to_s.titleize)
37
+ when Number
38
+ banner_set = SpudBannerSet.find(identifier)
39
+ end
40
+ if banner_set
41
+ return banner_set.banners
42
+ else
43
+ return []
44
+ end
45
+ end
46
+
47
+ def set_name
48
+ return owner.name
49
+ end
50
+
51
+ end
@@ -0,0 +1,30 @@
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
4
+
5
+ validates_presence_of :name
6
+ validates_uniqueness_of :name
7
+ validates_numericality_of :width, :height
8
+
9
+ def self.find_by_identifier(identifier)
10
+ if identifier.class == String
11
+ banner_set = SpudBannerSet.find_by_name(identifier)
12
+ elsif identifier.class == Symbol
13
+ banner_set = SpudBannerSet.find_by_name(identifier.to_s.titleize)
14
+ else
15
+ banner_set = SpudBannerSet.find(identifier)
16
+ end
17
+ return banner_set
18
+ end
19
+
20
+ def reprocess_banners!
21
+ self.banners.each do |banner|
22
+ banner.banner.reprocess!
23
+ end
24
+ end
25
+
26
+ def set_name
27
+ return name
28
+ end
29
+
30
+ end
@@ -0,0 +1,44 @@
1
+ class SpudBannerSweeper < ActionController::Caching::Sweeper
2
+ observe :spud_banner, :spud_banner_set
3
+
4
+ def before_save(record)
5
+ if record.is_a?(SpudBannerSet)
6
+ @old_name = record.name
7
+ end
8
+ end
9
+
10
+ def after_save(record)
11
+ expire_cache_for(record)
12
+ end
13
+
14
+ def after_destroy(record)
15
+ expire_cache_for(record)
16
+ end
17
+
18
+ private
19
+
20
+ def expire_cache_for(record)
21
+ # lazy full page cache clear
22
+ cache_path = ActionController::Base.page_cache_directory
23
+ if cache_path != Rails.root && cache_path != Rails.public_path && File.directory?(cache_path)
24
+ FileUtils.rm_rf(cache_path)
25
+ end
26
+
27
+ # reprocess cached liquid tags
28
+ if defined?(Spud::Cms)
29
+ values = [record.set_name]
30
+ values << @old_name if !@old_name.blank?
31
+ SpudPageLiquidTag.where(:tag_name => "snippet",:value => values).includes(:attachment).each do |tag|
32
+ partial = tag.attachment
33
+ partial.postprocess_content
34
+ partial.save
35
+ page = partial.try(:spud_page)
36
+ if page.blank? == false
37
+ page.updated_at = Time.now.utc
38
+ page.save
39
+ end
40
+ end
41
+ end
42
+ end
43
+
44
+ end
@@ -0,0 +1,8 @@
1
+ <%= content_tag :li, :class => 'spud_admin_banner_sets_list_item', 'data-id' => banner_set.id do %>
2
+ <%= banner_set.name %>
3
+ <span class="spud_admin_banner_sets_list_item_actions">
4
+ <%= link_to 'Manage Banners', spud_admin_banner_set_path(banner_set), :class => 'btn btn-small' %>
5
+ <%= link_to 'Edit Configuration', edit_spud_admin_banner_set_path(banner_set), :class => 'btn btn-small spud_banner_sets_edit' %>
6
+ <%= link_to 'Delete', spud_admin_banner_set_path(banner_set), :class => 'btn btn-small btn-danger spud_banner_sets_delete' %>
7
+ </span>
8
+ <% end %>
@@ -0,0 +1,32 @@
1
+ <%= form_for @banner_set, :url => path, :html => {:class => 'form-horizontal spud_banner_set_form'} do |f| %>
2
+
3
+ <%= error_messages_for(f.object) %>
4
+
5
+ <fieldset>
6
+ <div class="control-group">
7
+ <%= f.label :name, "Name",:class => "control-label" %>
8
+ <div class="controls">
9
+ <%= f.text_field :name %>
10
+ </div>
11
+ </div>
12
+ <div class="control-group">
13
+ <%= f.label :width, "Width", :class => "control-label" %>
14
+ <div class="controls">
15
+ <%= f.text_field :width %>
16
+ </div>
17
+ </div>
18
+ <div class="control-group">
19
+ <%= f.label :height, "Height", :class => "control-label" %>
20
+ <div class="controls">
21
+ <%= f.text_field :height %>
22
+ </div>
23
+ </div>
24
+ <div class="control-group">
25
+ <%= f.label :cropped, "Cropped", :class => "control-label" %>
26
+ <div class="controls">
27
+ <%= f.check_box :cropped %>
28
+ </div>
29
+ </div>
30
+ </fieldset>
31
+
32
+ <% end %>
@@ -0,0 +1 @@
1
+ <%= render :partial => 'banner_set', :locals => {:banner_set => @banner_set} %>
@@ -0,0 +1 @@
1
+ <%= render :partial => 'form', :locals => {:path => spud_admin_banner_set_path(@banner_set)} %>
@@ -0,0 +1,12 @@
1
+ <% content_for :data_controls do %>
2
+ <%= link_to "New Banner Set", new_spud_admin_banner_set_path, :class => "btn btn-primary spud_banner_sets_add_new", :title => "New Banner Set" %>
3
+ <% end %>
4
+
5
+ <% content_for :detail do %>
6
+ <ul class="spud_admin_banner_sets_list">
7
+ <%= render :partial => 'banner_set', :collection => @banner_sets %>
8
+ </ul>
9
+ <script>
10
+ $(document).ready(spud.admin.banner_sets.init);
11
+ </script>
12
+ <% end %>
@@ -0,0 +1 @@
1
+ <%= render :partial => 'form', :locals => {:path => spud_admin_banner_sets_path} %>
@@ -0,0 +1,11 @@
1
+ <% content_for :data_controls do %>
2
+ <%= link_to 'Upload Banner', new_spud_admin_banner_set_banner_path(@banner_set), :class => 'btn btn-primary spud_banner_add_new' %>
3
+ <% end %>
4
+
5
+ <div class="spud_banner_set_banners_container">
6
+ <%= render :partial => 'spud/admin/banners/banner', :collection => @banner_set.banners %>
7
+ </div>
8
+
9
+ <script>
10
+ $(document).ready(spud.admin.banners.init);
11
+ </script>
@@ -0,0 +1,7 @@
1
+ <%= content_tag :div, 'data-id' => banner.id, :class => 'spud_banner_set_banner_item' do %>
2
+ <%= image_tag banner.banner.url(:spud_admin_small) %>
3
+ <div class="spud_banner_set_banner_item_actions">
4
+ <%= link_to 'Edit', edit_spud_admin_banner_path(banner), :class => 'spud_banner_set_banner_item_edit' %>
5
+ <%= link_to 'Delete', spud_admin_banner_path(banner), :class => 'spud_banner_set_banner_item_delete' %>
6
+ </div>
7
+ <% end %>
@@ -0,0 +1,47 @@
1
+ <%= form_for @banner, :url => path, :html => {:class => 'form-horizontal spud_banner_form', :target => 'spud_banners_upload_target'} do |f| %>
2
+
3
+ <%= error_messages_for(f.object) %>
4
+
5
+ <fieldset>
6
+ <div class="control-group">
7
+ <%= f.label :link_to, 'Link to', :class => 'control-label' %>
8
+ <div class="controls">
9
+ <%= f.text_field :link_to %>
10
+ </div>
11
+ </div>
12
+ <div class="control-group">
13
+ <%= f.label :link_target, 'Open Link in', :class => 'control-label' %>
14
+ <div class="controls">
15
+ <%= f.select :link_target, options_for_select([
16
+ ['Same Window', '_self'],
17
+ ['New Window', '_blank']
18
+ ], @banner.link_target) %>
19
+ </div>
20
+ </div>
21
+ <div class="control-group">
22
+ <%= f.label :title, 'Image Title', :class => 'control-label' %>
23
+ <div class="controls">
24
+ <%= f.text_field :title %>
25
+ </div>
26
+ </div>
27
+ <div class="control-group">
28
+ <%= f.label :alt, 'Alt Text', :class => 'control-label' %>
29
+ <div class="controls">
30
+ <%= f.text_field :alt %>
31
+ </div>
32
+ </div>
33
+ <div class="control-group">
34
+ <%= f.label :banner, 'Banner', :class => 'control-label' %>
35
+ <div class="controls">
36
+ <%= f.file_field :banner %>
37
+ </div>
38
+ </div>
39
+ </fieldset>
40
+
41
+ <div class="progress progress-striped active spud_banner_upload_progress">
42
+ <div class="bar"></div>
43
+ </div>
44
+
45
+ <% end %>
46
+
47
+ <iframe id="spud_banners_upload_target" name="spud_banners_upload_target" style="display:none;"></iframe>
@@ -0,0 +1 @@
1
+ <%= render :partial => 'form', :locals => {:path => spud_admin_banner_path(@banner)} %>
@@ -0,0 +1,5 @@
1
+ <% if @banner.errors.any? %>
2
+ spud.admin.banners.onLegacyUploadError("<%= escape_javascript(render :partial => 'form', :locals => {:path => spud_admin_banner_set_banners_path(@banner_set)}) %>");
3
+ <% else %>
4
+ spud.admin.banners.onLegacyUploadComplete("<%= escape_javascript(render :partial => 'banner', :locals => {:banner => @banner}) %>");
5
+ <% end %>
@@ -0,0 +1 @@
1
+ <%= render :partial => 'form', :locals => {:path => spud_admin_banner_set_banners_path(@banner_set)} %>
@@ -0,0 +1 @@
1
+ <%= render :partial => 'banner', :locals => {:banner => @banner} %>
data/config/routes.rb ADDED
@@ -0,0 +1,14 @@
1
+ Rails.application.routes.draw do
2
+
3
+ namespace :spud do
4
+ namespace :admin do
5
+ resources :banner_sets do
6
+ resources :banners, :only => [:new, :create]
7
+ end
8
+ resources :banners, :only => [:show, :edit, :update, :destroy] do
9
+ put :sort, :on => :collection
10
+ end
11
+ end
12
+ end
13
+
14
+ end
@@ -0,0 +1,15 @@
1
+ class CreateSpudBanners < ActiveRecord::Migration
2
+ def change
3
+ create_table :spud_banners do |t|
4
+ t.integer :spud_banner_set_id, :null => false
5
+ t.string :link_to
6
+ t.string :link_target
7
+ t.string :title
8
+ t.string :alt
9
+ t.integer :sort_order, :default => 0
10
+ t.attachment :banner
11
+ t.timestamps
12
+ end
13
+ add_index :spud_banners, :spud_banner_set_id, :unique => false
14
+ end
15
+ end
@@ -0,0 +1,12 @@
1
+ class CreateSpudBannerSets < ActiveRecord::Migration
2
+ def change
3
+ create_table :spud_banner_sets do |t|
4
+ t.string :name, :null => false
5
+ t.integer :width, :null => false
6
+ t.integer :height, :null => false
7
+ t.boolean :cropped, :default => true
8
+ t.timestamps
9
+ end
10
+ add_index :spud_banner_sets, :name, :unique => true
11
+ end
12
+ end
@@ -0,0 +1,69 @@
1
+ # Copyright (c) 2006 Sean Treadway
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+
23
+ # Module containing the methods useful for child IFRAME to parent window communication
24
+ module RespondsToParent
25
+
26
+ # Executes the response body as JavaScript in the context of the parent window.
27
+ # Use this method of you are posting a form to a hidden IFRAME or if you would like
28
+ # to use IFRAME base RPC.
29
+ def responds_to_parent(&block)
30
+ yield
31
+
32
+ if performed?
33
+ # We're returning HTML instead of JS or XML now
34
+ response.headers['Content-Type'] = 'text/html; charset=UTF-8'
35
+
36
+ # Either pull out a redirect or the request body
37
+ script = if response.headers['Location']
38
+ #TODO: erase_redirect_results is missing in rails 3.0 has to be implemented
39
+ # erase redirect
40
+ "document.location.href = #{location.to_s.inspect}"
41
+ else
42
+ response.body
43
+ end
44
+
45
+ # Escape quotes, linebreaks and slashes, maintaining previously escaped slashes
46
+ # Suggestions for improvement?
47
+ script = (script || '').
48
+ gsub('\\', '\\\\\\').
49
+ gsub(/\r\n|\r|\n/, '\\n').
50
+ gsub(/['"]/, '\\\\\&').
51
+ gsub('</script>','</scr"+"ipt>')
52
+
53
+ # Clear out the previous render to prevent double render
54
+ response.request.env['action_controller.instance'].instance_variable_set(:@_response_body, nil)
55
+
56
+ # Eval in parent scope and replace document location of this frame
57
+ # so back button doesn't replay action on targeted forms
58
+ # loc = document.location to be set after parent is updated for IE
59
+ # with(window.parent) - pull in variables from parent window
60
+ # setTimeout - scope the execution in the windows parent for safari
61
+ # window.eval - legal eval for Opera
62
+ render :text => "<html><body><script type='text/javascript' charset='utf-8'>
63
+ var loc = document.location;
64
+ with(window.parent) { setTimeout(function() { window.eval('#{script}'); if (typeof(loc) !== 'undefined') loc.replace('about:blank'); }, 1) };
65
+ </script></body></html>".html_safe
66
+ end
67
+ end
68
+ alias respond_to_parent responds_to_parent
69
+ end
@@ -0,0 +1,10 @@
1
+ module Spud
2
+ module Banners
3
+ include ActiveSupport::Configurable
4
+ config_accessor :paperclip_storage, :s3_credentials, :storage_path, :storage_url
5
+ self.paperclip_storage = :filesystem
6
+ self.s3_credentials = "#{Rails.root}/config/s3.yml"
7
+ self.storage_path = ":rails_root/public/system/spud_banners/:id/:style/:basename.:extension"
8
+ self.storage_url = "/system/spud_banners/:id/:style/:basename.:extension"
9
+ end
10
+ end
@@ -0,0 +1,25 @@
1
+ require 'spud_core'
2
+ require 'paperclip'
3
+ require 'liquid'
4
+
5
+ module Spud
6
+ module Banners
7
+ class Engine < Rails::Engine
8
+ engine_name :spud_banners
9
+ Spud::Core.append_admin_stylesheets('spud/admin/banners/application')
10
+ Spud::Core.append_admin_javascripts('spud/admin/banners/application')
11
+ initializer :admin do
12
+ Spud::Core.config.admin_applications += [{
13
+ :name => 'Banner Sets',
14
+ :thumbnail => 'spud/photos/photo_albums_thumb.png',
15
+ :retina => true,
16
+ :url => '/spud/admin/banner_sets',
17
+ :order => 120
18
+ }]
19
+ end
20
+ initializer :liquid do
21
+ Liquid::Template.register_tag('spud_banner_set', Spud::Banners::BannerSetTag) if defined?(Liquid::Template)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,32 @@
1
+ require 'liquid'
2
+ require_relative '../../app/helpers/spud_banners_helper'
3
+
4
+ module Spud
5
+ module Banners
6
+ class BannerSetTag < Liquid::Tag
7
+
8
+ include Sprockets::Helpers::RailsHelper
9
+ include Sprockets::Helpers::IsolatedHelper
10
+ include ActionView::Helpers
11
+ include ActionView::Context
12
+ include SpudBannersHelper
13
+
14
+ def initialize(tag_name, set_identifer, tokens)
15
+ @banner_set = SpudBannerSet.find_by_identifier(set_identifer)
16
+ end
17
+
18
+ def tag_name
19
+ return 'banner_set'
20
+ end
21
+
22
+ def tag_value
23
+ return @banner_set.name
24
+ end
25
+
26
+ def render(context)
27
+ return spud_banners_for_set(@banner_set)
28
+ end
29
+
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,5 @@
1
+ module Spud
2
+ module Banners
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,8 @@
1
+ module Spud
2
+ module Banners
3
+ require 'responds_to_parent.rb'
4
+ require 'spud_banners/configuration'
5
+ require 'spud_banners/liquid_tags'
6
+ require "spud_banners/engine" if defined?(Rails)
7
+ end
8
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :spud_banners do
3
+ # # Task goes here
4
+ # end