beef-slides 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.2.0
@@ -0,0 +1,83 @@
1
+ class Admin::SlideShowsController < Admin::BaseController
2
+ sortable_attributes :title, :permalink
3
+
4
+ # GET /slide_shows
5
+ # GET /slide_shows.xml
6
+ def index
7
+ @slide_shows = SlideShow.paginate :page => params[:page], :order => sort_order
8
+
9
+ respond_to do |format|
10
+ format.html # index.html.erb
11
+ format.xml { render :xml => @slide_shows }
12
+ end
13
+ end
14
+
15
+ # GET /slide_shows/1
16
+ # GET /slide_shows/1.xml
17
+ def show
18
+ @slide_show = SlideShow.find(params[:id])
19
+
20
+ respond_to do |format|
21
+ format.html
22
+ format.xml { render :xml => @slide_show }
23
+ end
24
+ end
25
+
26
+ # GET /slide_shows/new
27
+ # GET /slide_shows/new.xml
28
+ def new
29
+ @slide_show = SlideShow.new
30
+
31
+ respond_to do |format|
32
+ format.html { render :action =>'show' }
33
+ format.xml { render :xml => @slide_show }
34
+ end
35
+ end
36
+
37
+ # POST /slide_shows
38
+ # POST /slide_shows.xml
39
+ def create
40
+ @slide_show = SlideShow.new(params[:slide_show])
41
+
42
+ respond_to do |format|
43
+ if @slide_show.save
44
+ flash[:notice] = 'SlideShow was successfully created.'
45
+ format.html { redirect_to(admin_slide_shows_url) }
46
+ format.xml { render :xml => @slide_show, :status => :created, :location => @slide_show }
47
+ else
48
+ format.html { render :action => "new" }
49
+ format.xml { render :xml => @slide_show.errors, :status => :unprocessable_entity }
50
+ end
51
+ end
52
+ end
53
+
54
+ # PUT /slide_shows/1
55
+ # PUT /slide_shows/1.xml
56
+ def update
57
+ @slide_show = SlideShow.find(params[:id])
58
+
59
+ respond_to do |format|
60
+ if @slide_show.update_attributes(params[:slide_show])
61
+ flash[:notice] = 'SlideShow was successfully updated.'
62
+ format.html { redirect_to(admin_slide_shows_url) }
63
+ format.xml { head :ok }
64
+ else
65
+ format.html { render :action => "edit" }
66
+ format.xml { render :xml => @slide_show.errors, :status => :unprocessable_entity }
67
+ end
68
+ end
69
+ end
70
+
71
+ # DELETE /slide_shows/1
72
+ # DELETE /slide_shows/1.xml
73
+ def destroy
74
+ @slide_show = SlideShow.find(params[:id])
75
+ @slide_show.destroy
76
+ flash[:notice] = 'SlideShow was successfully deleted.'
77
+
78
+ respond_to do |format|
79
+ format.html { redirect_to(admin_slide_shows_url) }
80
+ format.xml { head :ok }
81
+ end
82
+ end
83
+ end
@@ -4,7 +4,8 @@ class Admin::SlidesController < Admin::BaseController
4
4
  # GET /slides
5
5
  # GET /slides.xml
6
6
  def index
7
- @slides = Slide.paginate :page => params[:page], :order => sort_order(:default => 'asc')
7
+ @slide_show = SlideShow.find(params[:slide_show_id])
8
+ @slides = @slide_show.slides.paginate :page => params[:page], :order => sort_order(:default => 'asc')
8
9
 
9
10
  respond_to do |format|
10
11
  format.html # index.html.erb
@@ -27,7 +28,8 @@ class Admin::SlidesController < Admin::BaseController
27
28
  # GET /slides/new.xml
28
29
  def new
29
30
  @slide = Slide.new
30
-
31
+ @slide.slide_show_id = params[:slide_show_id]
32
+
31
33
  respond_to do |format|
32
34
  format.html { render :action => "show" }
33
35
  format.xml { render :xml => @slide }
@@ -42,7 +44,7 @@ class Admin::SlidesController < Admin::BaseController
42
44
  respond_to do |format|
43
45
  if @slide.save
44
46
  flash[:notice] = 'Slide was successfully created.'
45
- format.html { redirect_to(admin_slides_url) }
47
+ format.html { redirect_to(admin_slide_show_slides_url(@slide.slide_show)) }
46
48
  format.xml { render :xml => @slide, :status => :created, :location => @slide }
47
49
  else
48
50
  format.html { render :action => "show" }
@@ -59,7 +61,7 @@ class Admin::SlidesController < Admin::BaseController
59
61
  respond_to do |format|
60
62
  if @slide.update_attributes(params[:slide])
61
63
  flash[:notice] = 'Slide was successfully updated.'
62
- format.html { redirect_to(admin_slides_url) }
64
+ format.html { redirect_to(admin_slide_show_slides_url(@slide.slide_show)) }
63
65
  format.xml { head :ok }
64
66
  else
65
67
  format.html { render :action => "show" }
@@ -72,10 +74,11 @@ class Admin::SlidesController < Admin::BaseController
72
74
  # DELETE /slides/1.xml
73
75
  def destroy
74
76
  @slide = Slide.find(params[:id])
77
+ slide_show = @slide.slide_show
75
78
  @slide.destroy
76
79
 
77
80
  respond_to do |format|
78
- format.html { redirect_to(admin_slides_url) }
81
+ format.html { redirect_to(admin_slide_show_slides_url(slide_show)) }
79
82
  format.xml { head :ok }
80
83
  end
81
84
  end
@@ -0,0 +1,23 @@
1
+ class SlideShowsController < ApplicationController
2
+ # GET /slide_shows
3
+ # GET /slide_shows.xml
4
+ def index
5
+ @slide_shows = SlideShow.all
6
+
7
+ respond_to do |format|
8
+ format.html # index.html.erb
9
+ format.xml { render :xml => @slide_shows }
10
+ format.json { render :json => @slide_shows }
11
+ end
12
+ end
13
+
14
+
15
+ def show
16
+ @slide_show = SlideShow.find_by_permalink(params[:id])
17
+ #raise
18
+ @slides = @slide_show.slides.published
19
+ respond_to do |format|
20
+ format.json { render :json => @slides }
21
+ end
22
+ end
23
+ end
data/app/models/slide.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  class Slide < ActiveRecord::Base
2
2
  acts_as_publishable
3
- acts_as_list :insert_position => :top
3
+ acts_as_list :insert_position => :top, :scope => :slide_show_id
4
4
  has_attachment :storage => :file_system, #Should be changed to S3 for production
5
5
  :path_prefix => 'public/assets/slides', #Should be changed to S3 for production
6
6
  :max_size => 5.megabytes,
@@ -8,8 +8,9 @@ class Slide < ActiveRecord::Base
8
8
 
9
9
  validates_presence_of :size, :content_type, :if => :has_file?
10
10
  validate :attachment_attributes_valid?, :if => :has_file?
11
-
12
- attr_accessible :title, :date, :link, :strapline, :publish, :hide, :uploaded_data
11
+ belongs_to :slide_show
12
+
13
+ attr_accessible :slide_show_id, :title, :date, :link, :strapline, :publish, :hide, :uploaded_data
13
14
 
14
15
  default_scope :order => 'position ASC'
15
16
 
@@ -0,0 +1,11 @@
1
+ class SlideShow < ActiveRecord::Base
2
+ has_many :slides
3
+
4
+ before_save :set_url
5
+
6
+ private
7
+
8
+ def set_url
9
+ write_attribute :permalink, title.parameterize if permalink.blank?
10
+ end
11
+ end
@@ -0,0 +1,32 @@
1
+ <h1>Listing slide shows</h1>
2
+
3
+ <ul class="choices">
4
+ <li><%= link_to 'New slide_show', new_admin_slide_show_path %></li>
5
+ </ul>
6
+
7
+ <table>
8
+ <thead>
9
+ <tr>
10
+ <%= sortable_table_header :name => "Title", :sort => "title" %>
11
+ <th># Slides</th>
12
+ <th colspan="2">Actions</th>
13
+ </tr>
14
+ </thead>
15
+ <tbody>
16
+ <% @slide_shows.each do |slide_show| %>
17
+ <tr id="slide_show-<%= slide_show.id %>">
18
+ <td><%= link_to slide_show.title, admin_slide_show_path(slide_show) %></td>
19
+ <td><%= link_to pluralize(slide_show.slides.count, "Slide"), admin_slide_show_slides_path(slide_show), :class => 'view', :title => 'Click to view these slides' %></td>
20
+ <td><%= link_to 'Edit', admin_slide_show_path(slide_show), :class => 'edit' %></td>
21
+ <td><%= link_to 'Destroy', admin_slide_show_path(slide_show), :confirm => 'Are you sure?', :method => :delete, :class => 'delete' %></td>
22
+ </tr>
23
+ <% end %>
24
+ </tbody>
25
+ <tfoot>
26
+ <tr>
27
+ <%= sortable_table_header :name => "Title", :sort => "title" %>
28
+ <th># Slides</th>
29
+ <th colspan="2">Actions</th>
30
+ </tr>
31
+ </tfoot>
32
+ </table>
@@ -0,0 +1,14 @@
1
+ <h1><%= @slide_show.new_record? ? 'New' : 'Editing' %> slide_show</h1>
2
+
3
+ <% form_for([:admin, @slide_show]) do |f| %>
4
+ <%= f.error_messages %>
5
+
6
+ <p>
7
+ <%= f.label :title %><br />
8
+ <%= f.text_field :title %>
9
+ </p>
10
+ <p class="submission">
11
+ <%= f.submit @slide_show.new_record? ? 'Create' : 'Update', :disable_with => 'Submitting...' %> or <%= link_to 'Cancel', admin_slide_shows_path %>
12
+ </p>
13
+ <% end %>
14
+
@@ -1,7 +1,7 @@
1
- <h1>Listing slides</h1>
1
+ <h1>Listing slides for <%= @slide_show.title %></h1>
2
2
 
3
3
  <ul class="choices">
4
- <li><%= link_to 'New slide', new_admin_slide_path %></li>
4
+ <li><%= link_to 'New slide', new_admin_slide_show_slide_path(@slide_show) %></li>
5
5
  </ul>
6
6
 
7
7
  <table>
@@ -11,6 +11,8 @@
11
11
  <th>Image</th>
12
12
  <%= sortable_table_header :name => "Title", :sort => "title" %>
13
13
  <td>Status</td>
14
+ <%= sortable_table_header :name => "Created At", :sort => "created_at" %>
15
+ <%= sortable_table_header :name => "Updated At", :sort => "updated_at" %>
14
16
  <%= sortable_table_header :name => "Published At", :sort => "published_at" %>
15
17
  <%= sortable_table_header :name => "Published To", :sort => "published_to" %>
16
18
  <th>Actions</th>
@@ -24,13 +26,15 @@
24
26
  <td><%= image_tag slide.public_filename, :width => 100 unless slide.filename == 'no_file' %></td>
25
27
  <td><%=h slide.title %></td>
26
28
  <td><%= content_status(slide) %></td>
29
+ <td><%=h slide.created_at.strftime('%d %b') %></td>
30
+ <td><%=h slide.updated_at.strftime('%d %b') %></td>
27
31
  <td><%=h slide.published_at.strftime('%d %b') unless slide.published_at.blank? %></td>
28
32
  <td><%=h slide.published_to.strftime('%d %b') unless slide.published_to.blank? %></td>
29
33
  <td>
30
- <%= link_to 'Move Up', move_up_admin_slide_path(slide), :class => 'move-up' unless slide.position == 0 %>
31
- <%= link_to 'Move Down', move_down_admin_slide_path(slide), :class => 'move-down' unless slide.position == @slides.length-1 %>
32
- <%= link_to 'Edit', [:admin, slide], :class => 'edit' %>
33
- <%= link_to 'Destroy', [:admin, slide], :confirm => 'Are you sure?', :method => :delete, :class => 'delete' %>
34
+ <%= link_to 'Move Up', move_up_admin_slide_path(slide), :class => 'move-up' unless slide.first? %>
35
+ <%= link_to 'Move Down', move_down_admin_slide_path(slide), :class => 'move-down' unless slide.last? %>
36
+ <%= link_to 'Edit', admin_slide_path(slide), :class => 'edit' %>
37
+ <%= link_to 'Destroy', admin_slide_path(slide), :confirm => 'Are you sure?', :method => :delete, :class => 'delete' %>
34
38
  </td>
35
39
  </tr>
36
40
  <% end %>
@@ -42,6 +46,8 @@
42
46
  <th>Image</th>
43
47
  <%= sortable_table_header :name => "Title", :sort => "title" %>
44
48
  <td>Status</td>
49
+ <%= sortable_table_header :name => "Created At", :sort => "created_at" %>
50
+ <%= sortable_table_header :name => "Updated At", :sort => "updated_at" %>
45
51
  <%= sortable_table_header :name => "Published At", :sort => "published_at" %>
46
52
  <%= sortable_table_header :name => "Published To", :sort => "published_to" %>
47
53
  <th>Actions</th>
@@ -1,6 +1,7 @@
1
1
  <h1>Editing slide</h1>
2
2
 
3
3
  <% form_for([:admin, @slide], :html => { :multipart => true}) do |f| %>
4
+ <%= f.hidden_field :slide_show_id %>
4
5
  <%= f.error_messages %>
5
6
 
6
7
  <p>
@@ -26,7 +27,7 @@
26
27
  <p class="submission">
27
28
  <%= f.submit 'Publish', :name => 'slide[publish]' %>
28
29
  <%= f.submit 'Save as draft', :name => 'slide[hide]' %>
29
- or <%= link_to 'Cancel', admin_slides_path %>
30
+ or <%= link_to 'Cancel', admin_slide_show_slides_path(@slide.slide_show_id) %>
30
31
  </p>
31
32
  </div>
32
33
  <% end %>
data/config/routes.rb CHANGED
@@ -1,6 +1,10 @@
1
1
  ActionController::Routing::Routes.draw do |map|
2
2
  map.namespace(:admin) do |admin|
3
+ admin.resources :slide_shows do |slide_show|
4
+ slide_show.resources :slides, :member => { :move_up => :get, :move_down => :get }
5
+ end
3
6
  admin.resources :slides, :member => { :move_up => :get, :move_down => :get }
4
7
  end
5
8
  map.resources :slides, :only => :index
9
+ map.resources :slide_shows, :has_many => :slides
6
10
  end
@@ -11,14 +11,21 @@ class CreateSlides < ActiveRecord::Migration
11
11
  t.string :filename, :default => 'no_file'
12
12
  t.string :content_type
13
13
  t.integer :size, :height, :width
14
- t.references :parent
14
+ t.references :parent, :slide_show
15
15
  t.string :thumbnail
16
16
 
17
+ t.timestamps
18
+ end
19
+
20
+ create_table :slide_shows do |t|
21
+ t.string :title, :permalink
22
+
17
23
  t.timestamps
18
24
  end
19
25
  end
20
26
 
21
27
  def self.down
22
28
  drop_table :slides
29
+ drop_table :slide_shows
23
30
  end
24
31
  end
data/slides.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{slides}
5
- s.version = "0.1.1"
5
+ s.version = "0.2.0"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Daniel Craig"]
9
- s.date = %q{2009-07-14}
9
+ s.date = %q{2009-09-02}
10
10
  s.email = %q{daniel@wearebeef.co.uk}
11
11
  s.extra_rdoc_files = [
12
12
  "LICENSE",
@@ -19,10 +19,15 @@ Gem::Specification.new do |s|
19
19
  "README.rdoc",
20
20
  "Rakefile",
21
21
  "VERSION",
22
+ "app/controllers/admin/slide_shows_controller.rb",
22
23
  "app/controllers/admin/slides_controller.rb",
24
+ "app/controllers/slide_shows_controller.rb",
23
25
  "app/controllers/slides_controller.rb",
24
26
  "app/helpers/slides_helper.rb",
25
27
  "app/models/slide.rb",
28
+ "app/models/slide_show.rb",
29
+ "app/views/admin/slide_shows/index.html.erb",
30
+ "app/views/admin/slide_shows/show.html.erb",
26
31
  "app/views/admin/slides/index.html.erb",
27
32
  "app/views/admin/slides/show.html.erb",
28
33
  "config/routes.rb",
@@ -31,16 +36,18 @@ Gem::Specification.new do |s|
31
36
  "lib/slides.rb",
32
37
  "public/javascripts/swfobject.js",
33
38
  "slides.gemspec",
39
+ "test/slide_show_test.rb",
34
40
  "test/slides_test.rb",
35
41
  "test/test_helper.rb"
36
42
  ]
37
43
  s.homepage = %q{http://github.com/dougle/slides}
38
44
  s.rdoc_options = ["--charset=UTF-8"]
39
45
  s.require_paths = ["lib"]
40
- s.rubygems_version = %q{1.3.3}
46
+ s.rubygems_version = %q{1.3.5}
41
47
  s.summary = %q{Slide show generation}
42
48
  s.test_files = [
43
- "test/slides_test.rb",
49
+ "test/slide_show_test.rb",
50
+ "test/slides_test.rb",
44
51
  "test/test_helper.rb"
45
52
  ]
46
53
 
@@ -0,0 +1,8 @@
1
+ require 'test_helper'
2
+
3
+ class SlideShowTest < ActiveSupport::TestCase
4
+ # Replace this with your real tests.
5
+ test "the truth" do
6
+ assert true
7
+ end
8
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beef-slides
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Craig
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-07-14 00:00:00 -07:00
12
+ date: 2009-09-02 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -29,10 +29,15 @@ files:
29
29
  - README.rdoc
30
30
  - Rakefile
31
31
  - VERSION
32
+ - app/controllers/admin/slide_shows_controller.rb
32
33
  - app/controllers/admin/slides_controller.rb
34
+ - app/controllers/slide_shows_controller.rb
33
35
  - app/controllers/slides_controller.rb
34
36
  - app/helpers/slides_helper.rb
35
37
  - app/models/slide.rb
38
+ - app/models/slide_show.rb
39
+ - app/views/admin/slide_shows/index.html.erb
40
+ - app/views/admin/slide_shows/show.html.erb
36
41
  - app/views/admin/slides/index.html.erb
37
42
  - app/views/admin/slides/show.html.erb
38
43
  - config/routes.rb
@@ -41,10 +46,12 @@ files:
41
46
  - lib/slides.rb
42
47
  - public/javascripts/swfobject.js
43
48
  - slides.gemspec
49
+ - test/slide_show_test.rb
44
50
  - test/slides_test.rb
45
51
  - test/test_helper.rb
46
52
  has_rdoc: false
47
53
  homepage: http://github.com/dougle/slides
54
+ licenses:
48
55
  post_install_message:
49
56
  rdoc_options:
50
57
  - --charset=UTF-8
@@ -65,10 +72,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
65
72
  requirements: []
66
73
 
67
74
  rubyforge_project:
68
- rubygems_version: 1.2.0
75
+ rubygems_version: 1.3.5
69
76
  signing_key:
70
77
  specification_version: 3
71
78
  summary: Slide show generation
72
79
  test_files:
80
+ - test/slide_show_test.rb
73
81
  - test/slides_test.rb
74
82
  - test/test_helper.rb