BookStackApp / BookStack

A platform to create documentation/wiki content built with PHP & Laravel
https://www.bookstackapp.com/
MIT License
15.25k stars 1.9k forks source link

Redirect opening a Book to the first page instead of the page/section index if it only contains one page? #5248

Open aekramer opened 3 weeks ago

aekramer commented 3 weeks ago

Describe the feature you'd like

I use BookStack as a wiki implementation, and often only have a single page contained within a book.

It would be nice to offer the ability for the user to toggle if clicking on a book should automatically redirect the visitor to the first page, instead of showing an additional page index that is basically just a second click to get to where they wanted to go since the index is otherwise empty.

Additionally, perhaps it would be a nice feature to offer a "page redirect" automatically, so when opening a book the author can select the first page that should be displayed rather than the page index (if there are multiple pages)

Describe the benefits this would bring to existing BookStack users

More clarity and efficient browsing, I often get requests/questions from users why they have to go through 2 "layers" when accessing articles instead of being able to view the main page when clicking the book right away.

Can the goal of this request already be achieved via other means?

Not that I am aware of.

Have you searched for an existing open/closed issue?

How long have you been using BookStack?

1 to 5 years

Additional context

Example page of my bookstack integration, where I would like this to apply: https://wiki.runerealm.org/books/cape-of-accomplishment-perks

vmario89 commented 2 weeks ago

i was thinking of the same thing. Due to the fact that the editor of the shelve and the editor of the book are not that feature rich, the first item which makes sense is a page. But when creating a book with only one page it would be great to skip the book between, to shortcut the clicking

ssddanbrown commented 2 weeks ago

Relevant hacky optional JS based solution shared in this thread: https://www.reddit.com/r/BookStack/comments/14u65y3/book_with_only_one_page_automatic_opening/

vmario89 commented 2 weeks ago

indeed the problem with that code will be, that you cannot edit the book between until you deactivate the code again. This makes it unmaintainable regarding to the role based access. You do not want to make editors to admins which can change the site code

i think the problem should be resolved more generic: it would be great if we can put pages to a shelf without putting that page into a book first. In reality we have some unsorted document paper stacks too. I have shelves at my home where i put paper and later i am going to sort them into a folder, when i have time

vmario89 commented 2 weeks ago

meanwhile: added some delay to make it possible to do at least some changes clicking fast enough

<!-- Bücher mit nur einer Seite: Seite direkt anzeigen -->
<script type="module">
    const isBookPage = document.querySelector('.book-content') !== null;
    if (isBookPage) {
        const contents = document.querySelectorAll('.book-contents .entity-list-item');
        if (contents.length === 1 && contents[0].classList.contains('page')) {
            const delay = ms => new Promise(res => setTimeout(res, ms));
            await delay(3000);
            window.location = contents[0].href;
        }
    }
</script>
vmario89 commented 2 weeks ago

btw. it would be also cool to skip the book, if the shelve only contains one book, and if the book contains only one page, to open that page, so kind of double redirect. but skipping might also skip information like images or description ... hm