This commit is contained in:
14
app/controllers/books/bookmarks_controller.rb
Normal file
14
app/controllers/books/bookmarks_controller.rb
Normal file
@@ -0,0 +1,14 @@
|
||||
class Books::BookmarksController < ApplicationController
|
||||
allow_unauthenticated_access
|
||||
|
||||
include BookScoped
|
||||
|
||||
def show
|
||||
@leaf = @book.leaves.active.find_by(id: last_read_leaf_id) if last_read_leaf_id.present?
|
||||
end
|
||||
|
||||
private
|
||||
def last_read_leaf_id
|
||||
cookies["reading_progress_#{@book.id}"]
|
||||
end
|
||||
end
|
||||
19
app/controllers/books/leaves/moves_controller.rb
Normal file
19
app/controllers/books/leaves/moves_controller.rb
Normal file
@@ -0,0 +1,19 @@
|
||||
class Books::Leaves::MovesController < ApplicationController
|
||||
include BookScoped
|
||||
|
||||
before_action :ensure_editable
|
||||
|
||||
def create
|
||||
leaf, *followed_by = leaves
|
||||
leaf.move_to_position(position, followed_by: followed_by)
|
||||
end
|
||||
|
||||
private
|
||||
def position
|
||||
params[:position].to_i
|
||||
end
|
||||
|
||||
def leaves
|
||||
@book.leaves.find(Array(params[:id]))
|
||||
end
|
||||
end
|
||||
21
app/controllers/books/publications_controller.rb
Normal file
21
app/controllers/books/publications_controller.rb
Normal file
@@ -0,0 +1,21 @@
|
||||
class Books::PublicationsController < ApplicationController
|
||||
include BookScoped
|
||||
|
||||
before_action :ensure_editable, only: %i[ edit update ]
|
||||
|
||||
def show
|
||||
end
|
||||
|
||||
def edit
|
||||
end
|
||||
|
||||
def update
|
||||
@book.update! book_params
|
||||
redirect_to book_slug_url(@book)
|
||||
end
|
||||
|
||||
private
|
||||
def book_params
|
||||
params.require(:book).permit(:published, :slug)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user