Skip to content

Commit

Permalink
Include sanitized site title as part of exported filename
Browse files Browse the repository at this point in the history
  • Loading branch information
splorp committed Nov 1, 2017
1 parent 5efe7fa commit 8e5406c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion paperback-export.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
$title = site()->title();
$description = site()->description();
$version = site()->version();
$filename = str::slug($title);

if (! $includeInvisibles) {
$pages = $pages->visible();
Expand Down Expand Up @@ -63,7 +64,7 @@
}

$template = __DIR__ . DS . 'paperback-export.txt.php';
$paperback = tpl::load($template, compact('languages', 'pages', 'title', 'description', 'version'));
$paperback = tpl::load($template, compact('languages', 'pages', 'title', 'description', 'version', 'filename'));

return new response($paperback, 'txt');
}
Expand Down
2 changes: 1 addition & 1 deletion paperback-export.txt.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php header('Content-Type:text/plain'); ?>
<?php header('Content-Disposition: attachment; filename="paperback.txt"'); ?>
<?php header('Content-Disposition: attachment; filename="' . $filename .'-paperback.txt"'); ?>
<?php echo $title, PHP_EOL, PHP_EOL ?>
<?php if ($description != '') { echo $description, PHP_EOL, PHP_EOL ; } ?>
<?php if ($version != '') { echo 'Version ', $version, PHP_EOL, PHP_EOL ; } ?>
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ Paperback is a simple cross-platform utility created by [David Fedor](http://the

+ Paragraphs in the exported text should be separated by double line breaks
+ The exported content is not timestamped or versioned
+ The filename used for the exported content is generic
+ Page filtering and selection options are not currently functional
+ Output is currently optimized for the [Newton Glossary](http://newtonglossary.com/) instance of [Kirby](https://getkirby.com/)

### Release Notes

Expand Down

0 comments on commit 8e5406c

Please sign in to comment.