-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
105 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
|
||
/** | ||
* Kirby Paperback Export | ||
* | ||
* @version 2.0.0 | ||
* @author Grant Hutchinson <grant@splorp.com> | ||
* @copyright Grant Hutchinson <grant@splorp.com> | ||
* @link https://github.com/splorp/kirby-paperback-export | ||
* @license MIT | ||
*/ | ||
|
||
Kirby::plugin('splorp/paperback-export', [ | ||
'snippets' => [ | ||
'paperback-export/content' => __DIR__ . '/snippets/content.php', | ||
], | ||
'routes' => [ | ||
[ | ||
'pattern' => 'export/paperback', | ||
'action' => function () { | ||
|
||
$includeUnlisted = option('splorp.paperback-export.includeUnlisted', true); | ||
$includeChildren = option('splorp.paperback-export.includeChildren', []); | ||
$excludeTemplate = option('splorp.paperback-export.excludeTemplate', []); | ||
|
||
if (! is_array($includeChildren)) { | ||
throw new Exception('The option "splorp.paperback-export.includeChildren" must be an array.'); | ||
} | ||
if (! is_array($excludeTemplate)) { | ||
throw new Exception('The option "splorp.paperback-export.excludeTemplate" must be an array.'); | ||
} | ||
|
||
$languages = site()->languages(); | ||
$pages = site()->index(); | ||
$title = site()->title(); | ||
$description = site()->description(); | ||
$version = site()->version(); | ||
$filename = str::slug($title); | ||
|
||
/* Check whether to include unlisted pages */ | ||
|
||
if (! $includeUnlisted) { | ||
$pages = $pages->listed(); | ||
} | ||
|
||
/* Include only the children of the specified page */ | ||
|
||
if ($includeChildren) { | ||
$pages = $pages->find($includeChildren)->children(); | ||
} | ||
|
||
/* Exclude pages using certain templates */ | ||
|
||
$pages = $pages->filterBy('intendedTemplate', 'not in', $excludeTemplate); | ||
|
||
$template = __DIR__ . '/snippets/export.php'; | ||
$paperback = tpl::load($template, compact('languages', 'pages', 'title', 'description', 'version', 'filename')); | ||
|
||
return new response($paperback, 'txt'); | ||
} | ||
] | ||
] | ||
]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,20 @@ | ||
{ | ||
"name": "paperback-export", | ||
"author": "Grant Hutchinson <grant@splorp.com>", | ||
"version": "1.0.1", | ||
"description": "Kirby Paperback Export", | ||
"type": "kirby-plugin", | ||
"license": "MIT" | ||
"name": "splorp/paperback-export", | ||
"description": "Export Kirby 3 CMS content for use with the PaperBack Book Maker", | ||
"version": "2.0.0", | ||
"type": "kirby-plugin", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Grant Hutchinson", | ||
"email": "grant@splorp.com", | ||
"homepage": "https://splorp.com/" | ||
} | ||
], | ||
"require": { | ||
"getkirby/composer-installer": "^1.1" | ||
}, | ||
"extra": { | ||
"installer-name": "paperback-export" | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters