This repository has been archived by the owner on May 4, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Compatibility with Pressbooks 4.0, fixes #19.
- Loading branch information
Ned Zimmerman
committed
Jul 9, 2017
1 parent
947c42b
commit 86a869e
Showing
30 changed files
with
1,375 additions
and
365 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
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,5 @@ | ||
vendor/* | ||
!vendor/autoload.php | ||
!vendor/composer/* | ||
!vendor/mpdf/* | ||
!vendor/setasign/* |
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,2 +1,3 @@ | ||
# pressbooks-mpdf | ||
Open source PDF generation for Pressbooks via the mPDF library. | ||
# Pressbooks mPDF | ||
|
||
Open source PDF generation for [Pressbooks](https://github.com/pressbooks/pressbooks) via the [mPDF](https://github.com/mpdf/mpdf) library. |
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,5 +1,18 @@ | ||
{ | ||
"require": { | ||
"mpdf/mpdf": "^6.1" | ||
} | ||
"license": "GPL-2.0+", | ||
"type" : "wordpress-plugin", | ||
"require": { | ||
"mpdf/mpdf": "^6.1" | ||
}, | ||
"require-dev": { | ||
"humanmade/coding-standards": "^0.2.1" | ||
}, | ||
"scripts": { | ||
"test": [ | ||
"@standards" | ||
], | ||
"standards": [ | ||
"vendor/bin/phpcs --standard=phpcs.ruleset.xml *.php inc/" | ||
] | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,12 @@ | ||
<?php | ||
|
||
/** | ||
* Add this format to the export page formats list. | ||
* | ||
* @author Book Oven Inc. <code@pressbooks.com> | ||
* @param array $formats a multidimensional array of standard and exotic formats | ||
* @return array $formats | ||
*/ | ||
function pb_mpdf_add_to_formats( $formats ) { | ||
$formats['standard'] = array( 'mpdf' => __( 'PDF (mPDF)', 'pressbooks' ) ) + $formats['standard']; | ||
return $formats; | ||
} | ||
add_filter( 'pb_export_formats', 'pb_mpdf_add_to_formats' ); | ||
|
||
/** | ||
* Add this module to the export batch currently in progress. | ||
* | ||
* @author Book Oven Inc. <code@pressbooks.com> | ||
* @param array $modules an array of active export module classnames | ||
* @return array $modules | ||
*/ | ||
function pb_mpdf_add_to_modules( $modules ) { | ||
if ( isset( $_POST['export_formats']['mpdf'] ) ) { // @codingStandardsIgnoreLine | ||
$modules[] = '\Pressbooks\Modules\Export\Mpdf\Pdf'; | ||
} | ||
return $modules; | ||
} | ||
add_filter( 'pb_active_export_modules', 'pb_mpdf_add_to_modules' ); | ||
|
||
/** | ||
* Add format-specific theme options to the theme options page. | ||
* | ||
* @author Book Oven Inc. <code@pressbooks.com> | ||
* @param array $tabs an array of theme options tabs ('slug' => '\Classname') | ||
* @return array $tabs | ||
*/ | ||
function pb_mpdf_add_theme_options_tab( $tabs ) { | ||
$tabs['mpdf'] = '\Pressbooks\Modules\ThemeOptions\MPDFOptions'; | ||
return $tabs; | ||
} | ||
add_filter( 'pb_theme_options_tabs', 'pb_mpdf_add_theme_options_tab' ); | ||
|
||
/** | ||
* MPDF overrides. | ||
* @author Brad Payne <brad@bradpayne.ca> | ||
* @license GPLv2 | ||
* @copyright Brad Payne | ||
* | ||
* @param string $scss | ||
* @return string $scss | ||
*/ | ||
function pb_mpdf_theme_css_override( $scss ) { | ||
$options = get_option( 'pressbooks_theme_options_mpdf' ); | ||
$global_options = get_option( 'pressbooks_theme_options_global' ); | ||
|
||
// indent paragraphs | ||
if ( $options['mpdf_indent_paragraphs'] ) { | ||
$scss .= "p + p, .indent {text-indent: 2.0 em; }" . "\n"; | ||
} | ||
// hyphenation | ||
if ( $options['mpdf_hyphens'] ) { | ||
$scss .= "p {hyphens: auto;}" . "\n"; | ||
} | ||
// font-size | ||
if ( $options['mpdf_fontsize'] ){ | ||
$scss .= 'body {font-size: 1.3em; line-height: 1.3; }' . "\n"; | ||
} | ||
// chapter numbers | ||
if ( ! $global_options['chapter_numbers'] ) { | ||
$scss .= "h3.chapter-number {display: none;}" . "\n"; | ||
} | ||
return $scss; | ||
} | ||
add_filter( 'pb_mpdf_css_override', 'pb_mpdf_theme_css_override' ); | ||
add_filter( 'pb_export_formats', [ '\Pressbooks\Modules\Export\Mpdf\Pdf', 'addToFormats' ] ); | ||
add_filter( 'pb_active_export_modules', [ '\Pressbooks\Modules\Export\Mpdf\Pdf', 'addToModules' ] ); | ||
add_filter( 'pb_theme_options_tabs', [ '\Pressbooks\Modules\ThemeOptions\MpdfOptions', 'addTab' ] ); | ||
add_filter( 'pb_mpdf_css_override', [ '\Pressbooks\Modules\ThemeOptions\MpdfOptions', 'scssOverrides' ] ); |
Oops, something went wrong.