Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ Writebook is an easy-to-use application for publishing content on the web.
Content is authored in Markdown, and books can contain picture pages, chapters, and title pages.
Books can be published privately or publicly, and are searchable.

## Creating book pages

Editors create pages, picture pages, and sections from the controls in the book.
The controls create a page and show an inline editor. Existing pages retain autosave and Markdown image uploads.
Separate creation forms are not supported. The `/books/:book_id/pages/new`, `/books/:book_id/pictures/new`, and `/books/:book_id/sections/new` URLs return HTTP 404.

## How to get Writebook

Writebook is distributed as a Docker image.
Expand Down
4 changes: 0 additions & 4 deletions app/controllers/leafables_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ class LeafablesController < ApplicationController
before_action :ensure_editable, except: :show
before_action :broadcast_being_edited_indicator, only: :update

def new
@leafable = new_leafable
end

def create
@leaf = @book.press new_leafable, leaf_params
position_new_leaf @leaf
Expand Down
19 changes: 0 additions & 19 deletions app/views/pages/new.html.erb

This file was deleted.

19 changes: 0 additions & 19 deletions app/views/pictures/new.html.erb

This file was deleted.

19 changes: 0 additions & 19 deletions app/views/sections/new.html.erb

This file was deleted.

6 changes: 3 additions & 3 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
resource :search
end

resources :sections
resources :pictures
resources :pages
resources :sections, except: :new
resources :pictures, except: :new
resources :pages, except: :new
end

get "/:id/:slug", to: "books#show", constraints: { id: /\d+/ }, as: :slugged_book
Expand Down
6 changes: 6 additions & 0 deletions test/controllers/pages_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ class PagesControllerTest < ActionDispatch::IntegrationTest
sign_in :kevin
end

test "new is not available" do
get "#{book_pages_path(books(:handbook))}/new"

assert_response :not_found
end

test "show" do
get leafable_path(sample_page_leaf("## Hello"))

Expand Down
18 changes: 18 additions & 0 deletions test/controllers/pictures_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,24 @@ class PicturesControllerTest < ActionDispatch::IntegrationTest
sign_in :kevin
end

test "new is not available" do
get "#{book_pictures_path(books(:handbook))}/new"

assert_response :not_found
end

test "create from the book controls" do
assert_difference [ "Picture.count", "Leaf.count" ], 1 do
post book_pictures_path(books(:handbook), format: :turbo_stream), params: {
picture: { caption: "A new picture." }
}
end

assert_response :success
assert_equal "A new picture.", Picture.last.caption
assert_equal books(:handbook), Picture.last.leaf.book
end

test "update picture" do
get edit_leafable_path(leaves(:reading_picture))
assert_response :ok
Expand Down
6 changes: 6 additions & 0 deletions test/controllers/sections_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ class SectionsControllerTest < ActionDispatch::IntegrationTest
sign_in :kevin
end

test "new is not available" do
get "#{book_sections_path(books(:handbook))}/new"

assert_response :not_found
end

test "create" do
post book_sections_path(books(:handbook), format: :turbo_stream)
assert_response :success
Expand Down