Class: Lentil::ImagesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Lentil::ImagesController
- Includes:
- ActionView::Helpers::TextHelper
- Defined in:
- app/controllers/lentil/images_controller.rb
Instance Method Summary collapse
- #animate ⇒ Object
- #iframe ⇒ Object
- #index ⇒ Object
- #numeric_string?(str) ⇒ Boolean
- #popular ⇒ Object
- #recent ⇒ Object
- #show ⇒ Object
- #staff_picks ⇒ Object
- #staff_picks_animate ⇒ Object
Instance Method Details
#animate ⇒ Object
52 53 54 |
# File 'app/controllers/lentil/images_controller.rb', line 52 def animate @images = Image.approved.blend end |
#iframe ⇒ Object
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 |
#index ⇒ Object
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
61 62 63 |
# File 'app/controllers/lentil/images_controller.rb', line 61 def numeric_string?(str) Float(str) != nil rescue false end |
#popular ⇒ Object
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 |
#recent ⇒ Object
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 |
#show ⇒ Object
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_picks ⇒ Object
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 |