[PR #3918] [MERGED] WIP: Default page templates #6277

Closed
opened 2026-02-05 10:28:20 +03:00 by OVERLORD · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/BookStackApp/BookStack/pull/3918
Author: @lennertdaniels
Created: 12/15/2022
Status: Merged
Merged: 12/12/2023
Merged by: @ssddanbrown

Base: developmentHead: default-templates


📝 Commits (5)

  • 3599a96 search-box-cancel placement
  • 1dbc358 Add default_template as Book setting
  • 99ae759 Prefill new pages with book's default template
  • ec3b06d Add notice to Page delete confirmation when in use as a template
  • ac519b3 Guest create page: name field autofocus

📊 Changes

14 files changed (+102 additions, -8 deletions)

View changed files

📝 app/Entities/Models/Book.php (+9 -1)
📝 app/Entities/Repos/PageRepo.php (+6 -0)
📝 app/Http/Controllers/BookController.php (+15 -1)
📝 app/Http/Controllers/PageController.php (+3 -1)
database/migrations/2022_12_02_104541_add_default_template_to_books.php (+32 -0)
📝 resources/lang/en/entities.php (+3 -0)
📝 resources/sass/_forms.scss (+1 -1)
📝 resources/views/books/create.blade.php (+4 -1)
📝 resources/views/books/edit.blade.php (+5 -1)
📝 resources/views/books/parts/form.blade.php (+9 -0)
resources/views/entities/template-manager.blade.php (+10 -0)
📝 resources/views/pages/delete.blade.php (+3 -0)
📝 resources/views/pages/guest-create.blade.php (+1 -1)
📝 resources/views/pages/parts/template-manager.blade.php (+1 -1)

📄 Description

I took a stab at implementing default page templates as indicated in #1803.

What I have implemented:

  • There's a book-level setting to pick a default template
  • A new page automatically copies the template's html on creation
  • A new guests page also has the template applied to it
  • Deleted pages don't work as a template anymore
  • When deleting a page that is used as a default template somewhere, there's a warning on the delete confirmation screen

image

image

What I haven't fully considered or implemented yet:

  • Any permission/scope problems
  • If there's a difference in handling HTML vs. markdown templates
  • A better selector to pick the default template (pagination, AJAX search) like the one in the book.edit sidebar (template-manager)
  • Should other entities also support a default template? (User, Shelf, Chapter) If so, which one has priority when multiple default templates are chosen on different levels?
  • Applying a template from a URL parameter (@cod3monk and #3794)

Random small fixes I came across:

  • Autofocus on the name field on guest-create.blade
  • Template Manager: fixed cancel icon placement

If anyone with more thorough knowledge of the codebase would like to shine some light onto this PR, that would be great.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/BookStackApp/BookStack/pull/3918 **Author:** [@lennertdaniels](https://github.com/lennertdaniels) **Created:** 12/15/2022 **Status:** ✅ Merged **Merged:** 12/12/2023 **Merged by:** [@ssddanbrown](https://github.com/ssddanbrown) **Base:** `development` ← **Head:** `default-templates` --- ### 📝 Commits (5) - [`3599a96`](https://github.com/BookStackApp/BookStack/commit/3599a962a38692e2704804827f461997aafeba6e) search-box-cancel placement - [`1dbc358`](https://github.com/BookStackApp/BookStack/commit/1dbc3588cf11c12fde3da0ca4cb951c55ce810d9) Add default_template as Book setting - [`99ae759`](https://github.com/BookStackApp/BookStack/commit/99ae759effb709694ab934ae640a104e59a1a509) Prefill new pages with book's default template - [`ec3b06d`](https://github.com/BookStackApp/BookStack/commit/ec3b06d83f660a90036edd76e0a0c3de52645252) Add notice to Page delete confirmation when in use as a template - [`ac519b3`](https://github.com/BookStackApp/BookStack/commit/ac519b3009e353448fc0541d21c08422d77dc57d) Guest create page: name field autofocus ### 📊 Changes **14 files changed** (+102 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `app/Entities/Models/Book.php` (+9 -1) 📝 `app/Entities/Repos/PageRepo.php` (+6 -0) 📝 `app/Http/Controllers/BookController.php` (+15 -1) 📝 `app/Http/Controllers/PageController.php` (+3 -1) ➕ `database/migrations/2022_12_02_104541_add_default_template_to_books.php` (+32 -0) 📝 `resources/lang/en/entities.php` (+3 -0) 📝 `resources/sass/_forms.scss` (+1 -1) 📝 `resources/views/books/create.blade.php` (+4 -1) 📝 `resources/views/books/edit.blade.php` (+5 -1) 📝 `resources/views/books/parts/form.blade.php` (+9 -0) ➕ `resources/views/entities/template-manager.blade.php` (+10 -0) 📝 `resources/views/pages/delete.blade.php` (+3 -0) 📝 `resources/views/pages/guest-create.blade.php` (+1 -1) 📝 `resources/views/pages/parts/template-manager.blade.php` (+1 -1) </details> ### 📄 Description I took a stab at implementing default page templates as indicated in #1803. ### What I have implemented: - There's a book-level setting to pick a default template - A new page automatically copies the template's html on creation - A new guests page also has the template applied to it - Deleted pages don't work as a template anymore - When deleting a page that is used as a default template somewhere, there's a warning on the delete confirmation screen ![image](https://user-images.githubusercontent.com/23380289/207837303-b5f49192-192f-4200-8941-0a13a67ddd3d.png) ![image](https://user-images.githubusercontent.com/23380289/207836843-ee00e031-f101-406e-a72b-9a02a68049aa.png) ### What I haven't fully considered or implemented yet: - Any permission/scope problems - If there's a difference in handling HTML vs. markdown templates - A better selector to pick the default template (pagination, AJAX search) like the one in the book.edit sidebar (template-manager) - Should other entities also support a default template? _(User, Shelf, Chapter)_ If so, which one has priority when multiple default templates are chosen on different levels? - Applying a template from a URL parameter (@cod3monk and #3794) ### Random small fixes I came across: - Autofocus on the name field on guest-create.blade - Template Manager: fixed cancel icon placement If anyone with more thorough knowledge of the codebase would like to shine some light onto this PR, that would be great. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
OVERLORD added the pull-request label 2026-02-05 10:28:20 +03:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#6277