DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:bookcreator

This is an old revision of the document!


BookCreator Plugin

Compatible with DokuWiki

Hrun, Adora Belle, Weatherwax, Binky,Ponder Stibbons

plugin Allow to select some pages and create a book (PDF or text)

Last updated on
2015-06-11
Provides
Syntax, Action
Repository
Source
Conflicts with
projects
Requires
dw2pdf, text

This extension has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues.

Security warning (please read plugin security guidelines): Not a security warning, but just a note: The last version of Bookcreator requires the last version of DW2pdf plugin.

Similar to dw2pdf, odt

Tagged with books, export, pdf

Description

The bookcreator plugin allow to select some pages from wiki and export to create a little book PDF or text (like a similar function of Wikipedia)

First you initialize a book by clicking an interface button or adding ?do=addtobook to the page url. Nextly, a toolbar at the top of the pages appear to add/remove more pages to the book. Also you can jump to the bookmanager (at a preconfigured page) that let you sort and finish the selections for your book, and export it to screen(html) and when the required plugins are installed: to pdf-file or text on screen.

The bookmanager let you save and load saved selections for later use. You can use drag and drop to change the order and move pages in and out.

To work, this plugin needs cookies; the PDF export required dw2pdf plugin; the Text export required the text plugin.

Usage

Create book manage tools on wiki:ebook

Before using this plugin, you need to create a page with the bookmanager. Therefore you place the syntax ~~BOOK~~ in the wiki page wiki:ebook (in the configuration manager you can change this location).

In the bookmanager can show and manage your list of selected pages

  • Reset current selection
  • Exclude/include a page from selection (up to about 80 pages1))
  • View the excluded pages and “include” them back
  • Drag and drop to change exporting order of page and remove/add page to the selection.
  • Set a title for the PDF document
  • Create the PDF book on selected pages
  • Create a printable version of selected pages
  • Extract only text of selected pages
  • Save and restore selections on a specific namespace (use ACL's rights)
Example

Put at the wiki:ebook the syntax:

~~BOOK~~

And after you mark at least one page for inclusion in the book, the bookmanager appears.

Initiate a book

Use the Add/Remove to book link or button in your template to point a first page you like to add to a pdf book. The image on the left handside is the link as added automatically to the 'dokuwiki' template, see installation instruction below for other templates. When no such link is available add ?do=addtobook or &do=addtobook to the page url.

After selecting the first page, a toolbar appears on every page that let you add or remove additional pages. This toolbar refers also to the book manage tool.

The book manage tool that you created above (default on wiki:ebook) with ~~BOOK~~ let you reorder and exclude pages to your selection. Everybody who has access to the book manage tool can export selections to pdf, or show a print version. When you have enough (at least the “change”) ACL permissions in the namespace where the selections are saved, you can also save and select these selections.

Show saved selections

Below the bookmanager is a listed displayed with saved selections. You can also display with ~~ARCHIVEBOOK:number&sort~~ such a list of saved selections (books) anywhere into your wiki.

  • Available action: Load a saved selection into the bookmanager again
  • Optionally you can specify the number of selections to display and the order:
    • date – Sort by saving date of selection
    • title – Sort by Title of the selection
    • a number limits the number of displayed selections

Default is 10 items ordered by date (last updated are sorted first). Each entry links also to the wiki page where their selection is saved. Per page only one list of saved selections is displayed.

The user can only see selections when he has at least read access for the namespace wiki:ebook: (location configurable via config manager) or the pages in this namespace. Permissions for this namespace and the pages can be set as usual via the ACL manager.

Example
~~ARCHIVEBOOK:5&date~~

Installation

To add or remove a page to the selection, you simply need to call the page passing it a do=addtobook url argument. The easiest way to implement this is to add a button or link somewhere in the template design. Some templates are supported already, some other templates require manual modifications.

'dokuwiki' template

When you are using the newest default template of DokuWiki, the “Add/remove to book” link is automatically added via javascript. It will appear when the user has at least read access to the page of the bookmanager (default wiki:ebook).

'default' template

Use the following to add another button in the upper or bottom button row of the default template2))

<form class="button" method="get" action="<?php echo wl($ID)?>">
  <div class="no">
    <input type="submit" value="Add/Remove selection" class="button" />
    <input type="hidden" name="do" value="addtobook" />
    <input type="hidden" name="id" value="<?php echo $ID?>" />
  </div>
</form>

Monobook

When using the template “monobook for DokuWiki”, to have an Add/Remove link, in /user/tabs.php, use this code

//pdfbook plugin: add/remove selection
if (file_exists(DOKU_PLUGIN."bookcreator/action.php") &&
    !plugin_isdisabled("bookcreator")){
    $_monobook_tabs["tab-bookcreator"]["text"] = "Add/Remove to selection";
    $_monobook_tabs["tab-bookcreator"]["href"] = wl(getID(), array("do" => "addtobook"), false, "&");
}

Vector

Add this code to /lib/tpl/vector/conf/boxes.php (best way is from line 131 to line 142, between the ODT and PDF export) to create a link in the vector template which adds the displayed page to the book:

//pdfbook plugin: add/remove selection
if (file_exists(DOKU_PLUGIN."bookcreator/action.php") &&
   !plugin_isdisabled("bookcreator")){
   $_vector_boxes["p-coll-print_export"]["xhtml"]  .= "        <li id=\"coll-create-book\"><a href=\"".wl(cleanID(getId()), array("do" => "addtobook"))."\" rel=\"nofollow\">".hsc($lang["vector_exportbxdef_createbook"])."</a></li>\n";
}

As a second step, open the language file for the vector template, for example /lib/tpl/vector/lang/en/lang.php (depends on the language you are using) and add the following line to the code:

$lang["vector_exportbxdef_createbook"] = "Add/Remove to selection";

This is the text which is used for the link to display.

Changing the order of wiki pages

To change the order of wiki pages in your book, simply move the pages in the list. To do so, hover over the page title to move, click and drag it to the new location. Release the mouse button to finish moving the page to its new location.

Saving books

Format of stored book pages: when you save a book, it is stored in the format shown below.

====== MyBookName ======
  * [[:first_pages]]
  * [[:second_page]]
  * [[:namespace:third_page]]
  * .....
  * [[:last_page]]

You can also manually create a book from scratch by using the same format.

  • Take care of prefixing of links by :
  • To create a book from scratch, start a new page such as wiki:ebook:mybookname (default). The namespace can be changed at admin side configuration.

Configuration

Available configuration options.

Name Description
toolbar Show toolbar: Never, when selection is not empty or always
book_page Wiki page where show your book manager. Put here the ~~BOOK~~ syntax.
help_page Wiki page with info and instructions
save_namespace Namespace where the book manager will save selections.
skip_ids Don't show tools if pageid contains one of these ids.

Version history

Recent changes:

  • 2013-06-12
    • Removed inline javascript
    • Rewritten javascript by using jQuery. JQuery UI for sorting.
    • Refactored Bookmanager code
    • Included some localisations
    • There are some new strings added
    • In the 'dokuwiki' template the 'Add/Remove to book' is automatically added
    • Removed BOM at begin of /de/lang.php
    • Fixed Call-time pass-by-reference search function
    • Adopted by Klap-in. Moved development resources to Github.

Original author: Luigi Micco

  • 2010-04-19
    • add support for ARCHIVE mode
    • rewritten part of code to avoid conflict with other scripts
    • support for use ACL's permissions on pages and book's namespace
  • 2010-04-15
    • some bugs removed (thanks to Karl for tips)
    • allow set wich user's group can save/remove selections
    • hide list of selections if empty
  • 2010-04-15
    • allow to export selection to a text only version (text plugin required)
    • solved problems with cache system
  • 2010-04-14
    • admin side configuration
    • toolbar like Wikipedia “Book creator”
    • support for “Help page
    • allow to set a title for the PDF document (see dw2pdf update)
    • allow to save and restore selections
    • allow to export selection to a printable version

This plugin was the former Pdfbook Plugin.

Bug reports and feature requests

Please refer to the issue tracker for reporting issues.

1)
Size is limited by maximum size of cookies. Number is lower when using long pageids.
2)
In /lib/tpl/default/main.php, there are two divs that contain some buttons: <div class="bar" id="bar__top"> and <div class="bar" id="bar__bottom">. Just insert the HTML code inside one of the two divs (left or right
plugin/bookcreator.1434015507.txt.gz · Last modified: 2015-06-11 11:38 by 130.112.1.3

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki