bouquins-ror/app/controllers/books_controller.rb

28 lines
542 B
Ruby
Raw Normal View History

2015-06-28 12:29:09 +00:00
class BooksController < ApplicationController
include PreferencesHelper
include ERB::Util
before_action :preferences, only: :index
2015-06-28 12:29:09 +00:00
def show
@book = Book.find(params[:id])
2015-06-28 13:03:30 +00:00
@title = @book.title
end
def index
@books = Book.where(initial_filter).order(:sort)
.paginate(page: params[:page], per_page: session[:current_per_page])
2015-06-28 13:03:30 +00:00
@title = "Books"
2015-06-29 16:58:02 +00:00
respond_to do |format|
format.html
format.js
end
2015-06-28 12:29:09 +00:00
end
def cover
@book = Book.find(params[:id])
redirect_to "/calibre/#{url_encode(@book.path)}/cover.jpg"
end
2015-06-28 12:29:09 +00:00
end