journalduhacker/app/controllers/weblogs_controller.rb
joshua stein 85cb7c2057 first stab at planet rss aggregation
could probably use a prettier layout and auto-posting a weblog url
to the main site (carrying tags)
2014-08-03 22:07:57 -05:00

25 lines
503 B
Ruby

class WeblogsController < ApplicationController
before_filter { @page = page }
WEBLOGS_PER_PAGE = 10
def index
@pages = (Weblog.count / WEBLOGS_PER_PAGE.to_f).ceil
if @page > @pages
@page = @pages
end
@show_more = @page < @pages
@weblogs = Weblog.order("created_at DESC").
offset((@page - 1) * WEBLOGS_PER_PAGE).
limit(WEBLOGS_PER_PAGE)
render :action => "index"
end
private
def page
params[:page].to_i > 0 ? params[:page].to_i : 1
end
end