Export Kirby CMS content for use with the Paperback Book Maker.
This plugin is compatible with both Kirby 3 and Kirby 4.
The plugin generates a lightly formatted plain text file from a set of pages specified by the user. The text file is used to create a “book” package which can be viewed on a Newton OS device.
An example of the exported file can be downloaded using the link below. The file contains all of the terms currently published on the Newton Glossary site.
newtonglossary.com/export/paperback
Paperback is a simple cross-platform utility created by David Fedor that takes plain text files and quickly packages them for viewing on a Newton OS device. Since the Paperback utility only runs under classic Mac OS and Windows, an online Paperback Book Maker was developed by Victor Rehorst for all your cross-platform needs.
After installing the plugin using one of the methods below, visiting yoursite.com/export/paperback
should automatically download a text file without any additional configuration.
To install the plugin manually, download the current release, decompress the archive, and put the files in:
site/plugins/paperback-export
For Kirby 2 sites, download version 1.0.1 of the plugin.
Installing the plugin as a Git submodule:
$ cd your/project/root
$ git submodule add https://github.com/splorp/kirby-paperback-export.git site/plugins/paperback-export
$ git submodule update --init --recursive
$ git commit -am "Add Kirby Paperback Export plugin"
Updating the plugin as a Git submodule:
$ cd your/project/root
$ git submodule foreach git checkout master
$ git submodule foreach git pull
$ git commit -am "Update submodules"
$ git submodule update --init --recursive
Paperback books can include a table of contents created from the text found located in the $page->title()
field. The following option can be added to the site/config/config.php
file, allowing you to specify a custom table of contents prefix.
This option is not set by default.
return [
'splorp.paperback-export.prefix' => '',
];
Specify a table of contents prefix.
return [
'splorp.paperback-export.prefix' => '@@TOC ',
];
By default, text located in the $page->title()
and $page->text()
fields will be included in the exported data. The following option can be added to the site/config/config.php
file, allowing you to specify other content fields to be included. These fields will be appended after the title and text fields.
This option is not set by default.
return [
'splorp.paperback-export.fields' => [],
];
Specify one or more content fields and their type as an array.
return [
'splorp.paperback-export.fields' => ['author' => 'text','posts' => 'related'],
];
Use the text
content type for any field containing alphanumberic data, such as an author name or date.
Use the related
content type for fields formatted using the YAML syntax for related articles. The title field of each related article or page will be included in the exported data.
By default, every page on your Kirby site will be included in the exported data. The following options can be added to the site/config/config.php
file, allowing you to filter which pages are included based on certain criteria.
This option is set to true by default.
return [
'splorp.paperback-export.includeUnlisted' => true,
];
Pages specified in this option will not be included, but the children of those pages will be included in the exported data.
This option is not set by default.
return [
'splorp.paperback-export.includeChildren' => [],
];
Specify one or more pages as an array.
return [
'splorp.paperback-export.includeChildren' => ['blog','newsletter'],
];
Pages using the templates specified in this option will be excluded from the exported data.
This option is not set by default.
return [
'splorp.paperback-export.excludeTemplate' => [],
];
Specify one or more templates as an array.
return [
'splorp.paperback-export.excludeTemplate' => ['about','search'],
];
The following option can be added to the site/config/config.php
file, allowing you to add a datestamp that indicates when the data was exported. The datestamp is formatted as YYYY-MMM-DD and is inserted after the site title and description.
This option is set to false by default.
return [
'splorp.paperback-export.includeDatestamp' => false,
];
- Improved handling of pages containing
<img>
elements
- Added option to specify inclusion of the datestamp
- Added option to specify other content fields
- Added option to specify the table of contents prefix
- Added better exception checking for option values
- Fixed malformed
support
field incomposer.json
- Removed extraneous comments from
index.php
- Added
keywords
,homepage
,support.docs
,support.source
fields tocomposer.json
- Fixed version number in
index.php
- Refactored replacement patterns in string functions
- Removed extra line breaks introduced by heading elements
- Better handling of pages containing
<img>
elements - Added the current date to the exported file
- Refactored and updated for Kirby 3
- Tweaked the option names to be more consistent and self explanatory
- Moved the file export code into
snippets/export.php
- Renamed
snippets/page.php
tosnippets/content.php
- Refactored filtering options
- Fixed formatting of paragraph breaks in
$page->text()
- Initial release
A tip of the hat to Pedro Borges and his Kirby XML Sitemap for providing the necessary framework and inspiration to attempt my own plugin.
Copyright © 2017–2024 Grant Hutchinson
This project is licensed under the short and sweet MIT License. This license allows you to do anything pretty much anything you want with the contents of the repository, as long as you provide proper attribution and don’t hold anyone liable.
See the license.txt file included in this repository for further details.