asciinema.org/app/controllers/home_controller.rb
2013-11-28 23:17:02 +01:00

38 lines
659 B
Ruby

class HomeController < ApplicationController
def show
render locals: {
asciicast: asciicast,
featured_asciicasts: featured_asciicasts,
latest_asciicasts: latest_asciicasts
}
end
private
def asciicast
id = CFG['HOME_CAST_ID']
asciicast = if id
asciicast_repository.find(id)
else
asciicast_repository.last
end
asciicast && asciicast.decorate
end
def latest_asciicasts
asciicast_repository.latest_limited(3).decorate
end
def featured_asciicasts
asciicast_repository.random_featured_limited(3).decorate
end
def asciicast_repository
Asciicast
end
end