Cloning individual book pages

Hi everyone! Apologies in advance if this has been asked already and I just couldn’t find it. I’ve been tasked with so many other projects I’ve had to stop following discourse for a while.

I’m curious about the current functionality of Book cloning. Is it at all possible to clone an individual page or pages of a book and not all of its content? From my quick stint at user testing, I’m not seeing that as a feature right now. Thoughts?

Bryan

PS - looks like I’ll be able to spend a bit more time and focus here for the nearish future, so I’m stoked to get caught up with this community again. Cheers!

1 Like

Hi Bryan,
You can’t do that with the cloning tool, but you can do it with the importer, which is under Tools > Import. Just select Web Page in the drop-down menu, then import via the URL. You’ll get an interface where you can select the chapters you want.

2 Likes

Clever! Thanks.

Is the importer accessible via PB API? It’d be really cool if we could send a request to an API endpoint that clones a given page or pages using the import tool mechanism you describe above.

Hi @bryan! And welcome back!

Just to clarify, you’re wondering if you can make an API request to a Pressbooks book asking it to clone content from a different book? That’s not something the API supports at present (it provides full content CRUD access to book structure/contents with some caveats). But it’s a super interesting use case.

Hey @ned!

Essentially yes. What we’d like to do is be able to have an edit/copy button on content pages that, when clicked by a user clones the content of that page into a new book. We don’t want users to be able to just edit the content of a page that they’re accessing (because maybe it’s a “master” version of a book) and instead provide them with the ability to copy the content they like and edit as desired but in their own “version” of the content.

Cool! Would you mind opening a ticket describing that functionality over at https://github.com/pressbooks/ideas? I think it’s definitely a concept we’d like to discuss further. I think a lot of the underpinnings are there in the codebase already.

1 Like

Rad! I’ll try to hop on over there later today. Cheers!

1 Like

Hi @bryan - nice to have you back. I’m glad you mentioned this as a use case and I want to add my support to the idea — it’s been something I’ve been wanting to pursue for a few years now (since 2016) but haven’t been able to carve out the time. I thought a button to copy a page/book could be also be the first step in an onboarding process if the user wasn’t already authenticated in the PB system. If it’s helpful, and (hopefully) still relevant, I did write an overly wordy blog post about Stigmergic Collaboration (inspired by your very own David Wiley) and tried to flesh out some of the workflow details to address a very similar use case https://github.com/BCcampus/pressbooks-textbook/projects/2

Also somewhat relevant, though I would caution against counting on this being robust, is the search and import feature in Textbooks for Pressbooks which uses the PB API v1 to search for, and then import individual pages. It was meant to serve an already authenticated user, and needs a lot of update love, but the proof-of-concept is there. Certainly building on top of PB API v2 is going to deliver the best long term results.

Hi @brad!

Definitely interested in your wordy blog post on the topic. Thank you! :slight_smile:

I’d actually love it if you had half an hour or hour to invest in a conversation about what you’ve thought about on this feature and how we might be able to tackle it. I’m pretty open the rest of the day today and tomorrow. We also have a particular use-case in mind, and if there’s interest and it benefits the larger community, that’s awesome.

Let me know if you’d like to coordinate something. My email is:

bryan@lumenlearning.com

Idea submitted:

1 Like

Hey @brad, I’m looking at this comment again and really interested in exploring this. Would you be able to point me in a direction? There’s been a lot of cool development happening in PB since the last time I looked. We’re currently on PB v4.5.1, but are looking to do another big update to get current again soon (i’m working on advocating not habitually falling this far behind in the future). :stuck_out_tongue:

The Cloner is fairly portable. To clone a single chapter the code would look something like:

$c = new \Pressbooks\Cloner( $src_url, $target_url );
$c->setupSource();
$c->clonePreProcess();
$c->cloneChapter( $chapter_id, $part_id );
$c->clonePostProcess();

There are public methods for frontmatter, parts, backmatter, terms and glossary. There are public methods related to respecting the Creative Commons licenses. Etc.

A hop skip and a jump away from an API endpoint that clones for you, but maybe this can give you some ideas.

2 Likes