Class: Lentil::ImagesController

Inherits:
ApplicationController show all
Includes:
ActionView::Helpers::TextHelper
Defined in:
app/controllers/lentil/images_controller.rb

Instance Method Summary collapse

Instance Method Details

#animateObject



52
53
54
# File 'app/controllers/lentil/images_controller.rb', line 52

def animate
  @images = Image.approved.blend
end

#iframeObject



65
66
67
68
69
# File 'app/controllers/lentil/images_controller.rb', line 65

def iframe
  @images = Image.includes(:user).approved.recent.limit(125)
  @smallest_width = numeric_string?(params['smallest_width']) ? params['smallest_width'] : 64
  render :action => "iframe", :layout => "lentil/iframe"
end

#indexObject



6
7
8
9
10
11
12
# File 'app/controllers/lentil/images_controller.rb', line 6

def index
    respond_to do |format|
      format.html { @images = Image.includes(:user).approved.recent.search(params[:page]) }
      format.atom { @images = Image.includes(:user).approved.recent.limit(200) }
      format.rss { @images = Image.includes(:user).approved.recent.limit(200) }
    end
end

#numeric_string?(str) ⇒ Boolean

Returns:

  • (Boolean)


61
62
63
# File 'app/controllers/lentil/images_controller.rb', line 61

def numeric_string?(str)
  Float(str) != nil rescue false
end


24
25
26
27
28
29
30
31
32
33
34
# File 'app/controllers/lentil/images_controller.rb', line 24

def popular
  @title = "Popular Images"
  # show about 10% of image ordered by popularity
  number_to_show = (Image.approved.count*0.1).round
  respond_to do |format|
    format.html { @images = Image.includes(:user).approved.popular.search(params[:page], number_to_show) }
    format.atom { @images = Image.includes(:user).approved.popular.limit(number_to_show) }
    format.rss { @images = Image.includes(:user).approved.popular.limit(number_to_show) }
  end
  render :action => "index"
end

#recentObject



14
15
16
17
18
19
20
21
22
# File 'app/controllers/lentil/images_controller.rb', line 14

def recent
    @title = "Recent Images"
    respond_to do |format|
      format.html { @images = Image.includes(:user).approved.recent.search(params[:page]) }
      format.atom { @images = Image.includes(:user).approved.recent.limit(200) }
      format.rss { @images = Image.includes(:user).approved.recent.limit(200) }
    end
    render :action => "index"
end

#showObject



46
47
48
49
50
# File 'app/controllers/lentil/images_controller.rb', line 46

def show
  @image = Image.approved.find(params[:id])
  short_title = truncate(@image.description, :length => 50, :separator => ' ')
  @title = "#{short_title}, #{@image.user.user_name}, Image #{@image.id}"
end

#staff_picksObject



36
37
38
39
40
41
42
43
44
# File 'app/controllers/lentil/images_controller.rb', line 36

def staff_picks
  @title = "Staff Picks"
  respond_to do |format|
    format.html { @images = Image.includes(:user).approved.staff_picks.search(params[:page]) }
    format.atom { @images = Image.includes(:user).approved.staff_picks.limit(200)}
    format.rss { @images = Image.includes(:user).approved.staff_picks.limit(200)}
  end
  render :action => "index"
end

#staff_picks_animateObject



56
57
58
59
# File 'app/controllers/lentil/images_controller.rb', line 56

def staff_picks_animate
  @images = Image.approved.staff_picks.limit(100)
  render 'animate'
end