2012-03-04 21:44:04 +00:00
|
|
|
class HomeController < ApplicationController
|
2013-05-27 20:03:53 +00:00
|
|
|
|
2012-03-04 21:44:04 +00:00
|
|
|
def show
|
2013-11-17 15:49:46 +00:00
|
|
|
render locals: {
|
|
|
|
asciicast: asciicast,
|
|
|
|
featured_asciicasts: featured_asciicasts,
|
|
|
|
latest_asciicasts: latest_asciicasts
|
|
|
|
}
|
2012-03-04 21:44:04 +00:00
|
|
|
end
|
2013-05-27 20:03:53 +00:00
|
|
|
|
|
|
|
private
|
|
|
|
|
2013-11-17 15:49:46 +00:00
|
|
|
def asciicast
|
|
|
|
id = CFG['HOME_CAST_ID']
|
|
|
|
|
|
|
|
asciicast = if id
|
|
|
|
asciicast_repository.find(id)
|
2013-05-27 20:03:53 +00:00
|
|
|
else
|
2013-11-17 15:49:46 +00:00
|
|
|
asciicast_repository.last
|
2013-05-27 20:03:53 +00:00
|
|
|
end
|
2013-11-17 15:49:46 +00:00
|
|
|
|
|
|
|
asciicast && asciicast.decorate
|
|
|
|
end
|
|
|
|
|
|
|
|
def latest_asciicasts
|
|
|
|
asciicast_repository.latest_limited(3).decorate
|
2013-05-27 20:03:53 +00:00
|
|
|
end
|
2013-11-17 15:49:46 +00:00
|
|
|
|
|
|
|
def featured_asciicasts
|
2013-11-28 22:17:02 +00:00
|
|
|
asciicast_repository.random_featured_limited(3).decorate
|
2013-11-17 15:49:46 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def asciicast_repository
|
|
|
|
Asciicast
|
|
|
|
end
|
|
|
|
|
2012-03-04 21:44:04 +00:00
|
|
|
end
|