- Book-styled UI with parchment aesthetic and Russian navigation - Characters model with Konva.js 2D canvas drawing (draggable shapes) - StoryPages model with character association and page navigation - Stimulus controllers: canvas (editor) + canvas-preview (read-only) - Full Russian interface: all labels, buttons, flash messages in Russian
58 lines
1.3 KiB
Ruby
58 lines
1.3 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
class StoryPagesController < ApplicationController
|
|
before_action :set_page, only: [:show, :edit, :update, :destroy]
|
|
|
|
def index
|
|
@pages = StoryPage.includes(:character).all
|
|
end
|
|
|
|
def show
|
|
@prev_page = StoryPage.where("position < ?", @page.position).last
|
|
@next_page = StoryPage.where("position > ?", @page.position).first
|
|
end
|
|
|
|
def new
|
|
@page = StoryPage.new
|
|
@characters = Character.all.order(:name)
|
|
end
|
|
|
|
def create
|
|
@page = StoryPage.new(page_params)
|
|
if @page.save
|
|
redirect_to @page, notice: "Страница добавлена."
|
|
else
|
|
@characters = Character.all.order(:name)
|
|
render :new, status: :unprocessable_entity
|
|
end
|
|
end
|
|
|
|
def edit
|
|
@characters = Character.all.order(:name)
|
|
end
|
|
|
|
def update
|
|
if @page.update(page_params)
|
|
redirect_to @page, notice: "Страница обновлена."
|
|
else
|
|
@characters = Character.all.order(:name)
|
|
render :edit, status: :unprocessable_entity
|
|
end
|
|
end
|
|
|
|
def destroy
|
|
@page.destroy
|
|
redirect_to story_pages_path, notice: "Страница удалена."
|
|
end
|
|
|
|
private
|
|
|
|
def set_page
|
|
@page = StoryPage.find(params[:id])
|
|
end
|
|
|
|
def page_params
|
|
params.require(:story_page).permit(:title, :content, :position, :character_id)
|
|
end
|
|
end
|