Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bookshelf feature #2347

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Bookshelf feature #2347

wants to merge 2 commits into from

Conversation

Coi-l
Copy link

@Coi-l Coi-l commented Mar 29, 2024

Background

A while ago the need to bundle together multiple mdBooks arose for me. I did some digging but I could only find a number of feature requests in the issues list. So I decided to try and prototype something myself. Adding a 'shelf' command to the CLI.

Strategy

The feature is based around a shelf.toml file which contains a number of books to include in your bookshelf. They can either be locally present on the filesystem or a git repository. If you use a git repository you can optionally provide a path inside git repository where the file is present and a branch.

These books are then build by the shelf command.

In addition to this one more book is built, the actual "shelf". This is also an mdBook. It will will contain an index and a separate page for each book containing a bit more information.

Every book built by the shelf command will have an additional icon in the top right corner of a book. Clicking this will bring you back to the bookshelf.
image
It is the fa-book icon. I would have liked to use something more like this: https://fontawesome.com/icons/books?f=classic&s=solid but all those seem to be "Pro".

You can see a working example here:

https://coi-l.github.io/mdBook/bookshelf/index/book/index.html
or here:
https://coi-l.github.io/mdBook/bookshelf-multi/index/book/index.html

These to sites display the two options available. The first simple one with just one "shelf" in the bookshelf, and the seconds with multiple "shelves". This second option can be used to categorize the mdBooks.

Trying it out

You can try this out for yourself by checking out the PR code and building the mdBook binary.
Then navigate to the 'test_shelf' directory where there is a shelf.toml file prepared. Run the mdBook binary with 'shelf' as the command. This will build the same bookshelf as provided in the link above.

Summing it up

What I am looking for is comments regarding the PR.
First and foremost if this is something that is desired. There seems to be a number of feature requests for this, but maybe this strategy is not the way to go about it?

If you think this sounds like a good way forward I'd appreciate feedback on the code and on the actual design of the shelf book and UI in general. I don't mind polishing this to make it look good. Perhaps tables would be better or something.

Maybe the book icon in the books should produce a dropdown instead so you can easily select another book, or move back to the bookshelf.

The actual directory structure that the shelf command produces can also be adjusted.

Issues I think are requesting something like this, but I might have misunderstood:

#1748
#1347
#1666
#1042

@rustbot rustbot added the S-waiting-on-review Status: waiting on a review label Mar 29, 2024
@shenef
Copy link

shenef commented Mar 29, 2024

Looking at your example, it seems there are some sub-pages where the "Return to shelf" URL is not generated correcly.
Instead of using
https://coi-l.github.io/mdBook/shelf/book/index.html some of them use
https://coi-l.github.io/mdBook/books/shelf/book/index.html which results in a 404.
In the rust documentation book it works correctly on every page i tried but in the mdbook docs and the test book there are some pages that have the wrong URL and some that have the correct one.

@Coi-l
Copy link
Author

Coi-l commented Mar 29, 2024

Looking at your example, it seems there are some sub-pages where the "Return to shelf" URL is not generated correcly. Instead of using https://coi-l.github.io/mdBook/shelf/book/index.html some of them use https://coi-l.github.io/mdBook/books/shelf/book/index.html which results in a 404. In the rust documentation book it works correctly on every page i tried but in the mdbook docs and the test book there are some pages that have the wrong URL and some that have the correct one.

Yes, you are correct. Using relative paths was not a good idea.
I've updated the code and the link to the example with a fix for this.

Thanks for the feedback!

Initial processing of the shelf.toml file.
Build the books in the current_dir.
@Coi-l Coi-l changed the title RFC: Bookshelf feature prototype Bookshelf feature Apr 7, 2024
@ksd3
Copy link

ksd3 commented Aug 18, 2024

Out of curiosity, was this ever merged? This is the exact thing I'm looking for.

@Coi-l
Copy link
Author

Coi-l commented Aug 19, 2024

Out of curiosity, was this ever merged? This is the exact thing I'm looking for.

No. I haven't really gotten any kind of response from the maintainers unfortunately.

Have you tried it? Did it work well for you?

@ksd3
Copy link

ksd3 commented Aug 19, 2024

Out of curiosity, was this ever merged? This is the exact thing I'm looking for.

No. I haven't really gotten any kind of response from the maintainers unfortunately.

Have you tried it? Did it work well for you?

I'm new to Rust, so I don't quite know how to even get it to work. I'm fine with downgrading my version of mdbook - could you provide instructions on how to install it?

@Coi-l
Copy link
Author

Coi-l commented Aug 19, 2024

Out of curiosity, was this ever merged? This is the exact thing I'm looking for.

No. I haven't really gotten any kind of response from the maintainers unfortunately.
Have you tried it? Did it work well for you?

I'm new to Rust, so I don't quite know how to even get it to work. I'm fine with downgrading my version of mdbook - could you provide instructions on how to install it?

I wouldn't recommend installing this instead of the official one. But if you want to try it out you can clone the repository and do a cargo build. That will give you the binary with the 'shelf' command included. And in the 'test_shelf' directory there is a toml file you can adapt.

@ksd3
Copy link

ksd3 commented Aug 19, 2024

Out of curiosity, was this ever merged? This is the exact thing I'm looking for.

No. I haven't really gotten any kind of response from the maintainers unfortunately.
Have you tried it? Did it work well for you?

I'm new to Rust, so I don't quite know how to even get it to work. I'm fine with downgrading my version of mdbook - could you provide instructions on how to install it?

I wouldn't recommend installing this instead of the official one. But if you want to try it out you can clone the repository and do a cargo build. That will give you the binary with the 'shelf' command included. And in the 'test_shelf' directory there is a toml file you can adapt.

Wasn't this implemented only half a year ago?...I don't think too many features have been added to mdbook after it - but yeah, worst case scenario, I just run a script that produces the bookshelf rather than having it in an executable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: waiting on a review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants