Browse Source

feat: new frontend catalog

pull/369/head
arzola 2 years ago
parent
commit
e97df95414
  1. 23
      assets/scripts/featured-books.js
  2. 4
      assets/scripts/routes/catalog.js
  3. 77
      assets/styles/components/_book.scss
  4. 61
      dist/scripts/aldine.js
  5. 2
      dist/scripts/call-to-action.js
  6. 4
      dist/scripts/catalog-admin.js
  7. 2
      dist/scripts/customizer-toggle.js
  8. 2
      dist/scripts/customizer.js
  9. 2
      dist/scripts/page-section.js
  10. 88
      dist/styles/aldine.css
  11. 1
      functions.php
  12. 37
      inc/customizer/namespace.php
  13. 84
      inc/helpers/namespace.php
  14. 4
      page-catalog.php
  15. 50
      partials/book.php
  16. 51
      partials/content-front-page.php
  17. 2
      partials/content-page-catalog.php

23
assets/scripts/featured-books.js

@ -0,0 +1,23 @@
/**
* Disallow duplicate books in the featured books list.
*/
window.addEventListener( 'load', function () {
const selects = document.querySelectorAll( '#sub-accordion-section-pb_front_page_catalog select' );
/**
*
* @param current
* @param value
*/
let checkOtherValues = function ( current, value ) {
selects.forEach( function ( select ) {
if ( current.id !== select.id && select.value === value ) {
select.selectedIndex = -1;
}
} );
};
selects.forEach( function ( select ) {
select.addEventListener( 'change', function ( event ) {
checkOtherValues( event.target, event.target.value );
} );
} );
} );

4
assets/scripts/routes/catalog.js

@ -30,7 +30,7 @@ export default {
while (
elem.nextElementSibling &&
elem.nextElementSibling.tagName !== 'H2'
) {
) {
elems.push( elem.nextElementSibling );
elem = elem.nextElementSibling;
}
@ -100,7 +100,7 @@ export default {
while (
elem.nextElementSibling &&
elem.nextElementSibling.tagName !== 'H3'
) {
) {
elems.push( elem.nextElementSibling );
elem = elem.nextElementSibling;
}

77
assets/styles/components/_book.scss

@ -3,18 +3,16 @@
flex-direction: column;
justify-content: flex-start;
width: 100%;
max-width: 22.9375rem;
height: 24.125rem;
max-width: 18rem;
height: 25rem;
border: solid 1px var(--accent);
margin: 0 0 2rem;
padding: 1.5rem 1rem 2rem;
@media #{$breakpoint-not-small} { padding: 1.5rem 1.85rem 2.1875rem; }
border: solid 2px var(--accent);
background: var(--accent);
a, p {
font-family: $font-family-sans-serif;
color: var(--accent-fg);
&__cover {
width: 100%;
height: 80%;
background-repeat: no-repeat;
background-size: cover;
}
a {
@ -25,62 +23,9 @@
}
&__title {
margin: 0;
font-size: 1.25rem;
@media #{$breakpoint-not-small} { font-size: 1.75rem; }
display: flex;
justify-content: center;
align-items: center;
font-weight: 500;
line-height: 1.2;
text-align: left;
}
&__subject {
margin: 0;
font-size: 0.75rem;
@media #{$breakpoint-not-small} {
font-size: 1rem;
}
text-align: left;
}
&__institutions {
margin: .5rem 0 0;
font-size: 0.875rem;
text-align: left;
display: box;
overflow: hidden;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
&__read-more {
margin: auto 0 0;
font-size: 1rem;
@media #{$breakpoint-not-small} { font-size: 1.125rem; }
text-align: left;
a {
svg {
width: 1rem;
height: 1rem;
@media #{$breakpoint-not-small} {
width: 1.125rem;
height: 1.125rem;
margin-left: 0.5rem;
}
vertical-align: middle;
}
}
}
&:last-child {
margin-bottom: 0;
@media #{$breakpoint-large} {
margin-bottom: 2rem;
}
}
}

61
dist/scripts/aldine.js vendored

File diff suppressed because one or more lines are too long

2
dist/scripts/call-to-action.js vendored

File diff suppressed because one or more lines are too long

4
dist/scripts/catalog-admin.js vendored

File diff suppressed because one or more lines are too long

2
dist/scripts/customizer-toggle.js vendored

@ -15,7 +15,7 @@
\*********************************************/
/***/ (function() {
eval("document.addEventListener('DOMContentLoaded', function () {\n var checkbox = document.getElementById('_customize-input-pb_network_contact_form');\n var email = document.getElementById('customize-control-pb_network_contact_email');\n var link = document.getElementById('customize-control-pb_network_contact_link');\n var title = document.getElementById('customize-control-pb_network_contact_form_title');\n checkbox.addEventListener('click', toggleReadOnly);\n /**\n *\n */\n\n function toggleReadOnly() {\n if (checkbox.checked === false) {\n email.classList.add('hidden');\n email.style.cssText = null;\n title.classList.add('hidden');\n title.style.cssText = null;\n link.classList.remove('hidden');\n link.style.cssText = 'display: list-item;';\n } else {\n email.classList.remove('hidden');\n email.style.cssText = 'display: list-item;';\n title.classList.remove('hidden');\n title.style.cssText = 'display: list-item;';\n link.classList.add('hidden');\n link.style.cssText = null;\n }\n }\n\n toggleReadOnly();\n});//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly9AcHJlc3Nib29rcy9wcmVzc2Jvb2tzLWFsZGluZS8uL2Fzc2V0cy9zY3JpcHRzL2N1c3RvbWl6ZXItdG9nZ2xlLmpzP2U0Y2IiXSwibmFtZXMiOlsiZG9jdW1lbnQiLCJhZGRFdmVudExpc3RlbmVyIiwiY2hlY2tib3giLCJnZXRFbGVtZW50QnlJZCIsImVtYWlsIiwibGluayIsInRpdGxlIiwidG9nZ2xlUmVhZE9ubHkiLCJjaGVja2VkIiwiY2xhc3NMaXN0IiwiYWRkIiwic3R5bGUiLCJjc3NUZXh0IiwicmVtb3ZlIl0sIm1hcHBpbmdzIjoiQUFBQUEsUUFBUSxDQUFDQyxnQkFBVCxDQUEyQixrQkFBM0IsRUFBK0MsWUFBWTtBQUMxRCxNQUFJQyxRQUFRLEdBQUdGLFFBQVEsQ0FBQ0csY0FBVCxDQUF5QiwwQ0FBekIsQ0FBZjtBQUNBLE1BQUlDLEtBQUssR0FBR0osUUFBUSxDQUFDRyxjQUFULENBQXlCLDRDQUF6QixDQUFaO0FBQ0EsTUFBSUUsSUFBSSxHQUFHTCxRQUFRLENBQUNHLGNBQVQsQ0FBeUIsMkNBQXpCLENBQVg7QUFDQSxNQUFJRyxLQUFLLEdBQUdOLFFBQVEsQ0FBQ0csY0FBVCxDQUF5QixpREFBekIsQ0FBWjtBQUVBRCxFQUFBQSxRQUFRLENBQUNELGdCQUFULENBQTJCLE9BQTNCLEVBQW9DTSxjQUFwQztBQUVBO0FBQ0Q7QUFDQTs7QUFDQyxXQUFTQSxjQUFULEdBQTBCO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b3ZlKCAnaGlkZGVuJyApO1xuXHRcdFx0ZW1haWwuc3R5bGUuY3NzVGV4dCA9ICdkaXNwbGF5OiBsaXN0LWl0ZW07JztcblxuXHRcdFx0dGl0bGUuY2xhc3NMaXN0LnJlbW92ZSggJ2hpZGRlbicgKTtcblx0XHRcdHRpdGxlLnN0eWxlLmNzc1RleHQgPSAnZGlzcGxheTogbGlzdC1pdGVtOyc7XG5cblx0XHRcdGxpbmsuY2xhc3NMaXN0LmFkZCggJ2hpZGRlbicgKTtcblx0XHRcdGxpbmsuc3R5bGUuY3NzVGV4dCA9IG51bGw7XG5cdFx0fVxuXHR9XG5cblx0dG9nZ2xlUmVhZE9ubHkoKTtcblxufSApO1xuIl0sImZpbGUiOiIuL2Fzc2V0cy9zY3JpcHRzL2N1c3RvbWl6ZXItdG9nZ2xlLmpzLmpzIiwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///./assets/scripts/customizer-toggle.js\n");
eval("document.addEventListener('DOMContentLoaded', function () {\n var checkbox = document.getElementById('_customize-input-pb_network_contact_form');\n var email = document.getElementById('customize-control-pb_network_contact_email');\n var link = document.getElementById('customize-control-pb_network_contact_link');\n var title = document.getElementById('customize-control-pb_network_contact_form_title');\n checkbox.addEventListener('click', toggleReadOnly);\n\n /**\n *\n */\n function toggleReadOnly() {\n if (checkbox.checked === false) {\n email.classList.add('hidden');\n email.style.cssText = null;\n title.classList.add('hidden');\n title.style.cssText = null;\n link.classList.remove('hidden');\n link.style.cssText = 'display: list-item;';\n } else {\n email.classList.remove('hidden');\n email.style.cssText = 'display: list-item;';\n title.classList.remove('hidden');\n title.style.cssText = 'display: list-item;';\n link.classList.add('hidden');\n link.style.cssText = null;\n }\n }\n toggleReadOnly();\n});//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJkb2N1bWVudCIsImFkZEV2ZW50TGlzdGVuZXIiLCJjaGVja2JveCIsImdldEV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QyxDQUFFIiwiZmlsZSI6Ii4vYXNzZXRzL3NjcmlwdHMvY3VzdG9taXplci10b2dnbGUuanMuanMiLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///./assets/scripts/customizer-toggle.js\n");
/***/ })

2
dist/scripts/customizer.js vendored

@ -15,7 +15,7 @@
\**************************************/
/***/ (function() {
eval("wp.customize('blogname', function (value) {\n value.bind(function (to) {\n return document.querySelector('.home .entry-title').textContent = to;\n });\n});\nwp.customize('blogdescription', function (value) {\n value.bind(function (to) {\n return document.querySelector('.home .entry-description').textContent = to;\n });\n});//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly9AcHJlc3Nib29rcy9wcmVzc2Jvb2tzLWFsZGluZS8uL2Fzc2V0cy9zY3JpcHRzL2N1c3RvbWl6ZXIuanM/ZWIyMCJdLCJuYW1lcyI6WyJ3cCIsImN1c3RvbWl6ZSIsInZhbHVlIiwiYmluZCIsInRvIiwiZG9jdW1lbnQiLCJxdWVyeVNlbGVjdG9yIiwidGV4dENvbnRlbnQiXSwibWFwcGluZ3MiOiJBQUFBQSxFQUFFLENBQUNDLFNBQUgsQ0FBYyxVQUFkLEVBQTBCLFVBQUFDLEtBQUssRUFBSTtBQUNsQ0EsRUFBQUEsS0FBSyxDQUFDQyxJQUFOLENBQVksVUFBQUMsRUFBRTtBQUFBLFdBQUlDLFFBQVEsQ0FBQ0MsYUFBVCxDQUF3QixvQkFBeEIsRUFBK0NDLFdBQS9DLEdBQTZESCxFQUFqRTtBQUFBLEdBQWQ7QUFDQSxDQUZEO0FBSUFKLEVBQUUsQ0FBQ0MsU0FBSCxDQUFjLGlCQUFkLEVBQWlDLFVBQUFDLEtBQUssRUFBSTtBQUN6Q0EsRUFBQUEsS0FBSyxDQUFDQyxJQUFOLENBQVksVUFBQUMsRUFBRTtBQUFBLFdBQUlDLFFBQVEsQ0FBQ0MsYUFBVCxDQUF3QiwwQkFBeEIsRUFBcURDLFdBQXJELEdBQW1FSCxFQUF2RTtBQUFBLEdBQWQ7QUFDQSxDQUZEIiwic291cmNlc0NvbnRlbnQiOlsid3AuY3VzdG9taXplKCAnYmxvZ25hbWUnLCB2YWx1ZSA9PiB7XG5cdHZhbHVlLmJpbmQoIHRvID0+IGRvY3VtZW50LnF1ZXJ5U2VsZWN0b3IoICcuaG9tZSAuZW50cnktdGl0bGUnICkudGV4dENvbnRlbnQgPSB0byApO1xufSApO1xuXG53cC5jdXN0b21pemUoICdibG9nZGVzY3JpcHRpb24nLCB2YWx1ZSA9PiB7XG5cdHZhbHVlLmJpbmQoIHRvID0+IGRvY3VtZW50LnF1ZXJ5U2VsZWN0b3IoICcuaG9tZSAuZW50cnktZGVzY3JpcHRpb24nICkudGV4dENvbnRlbnQgPSB0byApO1xufSApO1xuIl0sImZpbGUiOiIuL2Fzc2V0cy9zY3JpcHRzL2N1c3RvbWl6ZXIuanMuanMiLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///./assets/scripts/customizer.js\n");
eval("wp.customize('blogname', function (value) {\n value.bind(function (to) {\n return document.querySelector('.home .entry-title').textContent = to;\n });\n});\nwp.customize('blogdescription', function (value) {\n value.bind(function (to) {\n return document.querySelector('.home .entry-description').textContent = to;\n });\n});//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJ3cCIsImN1c3RvbWl6ZSIsInZhbHVlIiwiYmluZCIsInRvIiwiZG9jdW1lbnQiLCJxdWVyeVNlbGVjdG9yIiwidGV4dENvbnRlbnQiXSwic291cmNlcyI6WyJ3ZWJwYWNrOi8vQHByZXNzYm9va3MvcHJlc3Nib29rcy1hbGRpbmUvLi9hc3NldHMvc2NyaXB0cy9jdXN0b21pemVyLmpzPzE2NzciXSwic291cmNlc0NvbnRlbnQiOlsid3AuY3VzdG9taXplKCAnYmxvZ25hbWUnLCB2YWx1ZSA9PiB7XG5cdHZhbHVlLmJpbmQoIHRvID0+IGRvY3VtZW50LnF1ZXJ5U2VsZWN0b3IoICcuaG9tZSAuZW50cnktdGl0bGUnICkudGV4dENvbnRlbnQgPSB0byApO1xufSApO1xuXG53cC5jdXN0b21pemUoICdibG9nZGVzY3JpcHRpb24nLCB2YWx1ZSA9PiB7XG5cdHZhbHVlLmJpbmQoIHRvID0+IGRvY3VtZW50LnF1ZXJ5U2VsZWN0b3IoICcuaG9tZSAuZW50cnktZGVzY3JpcHRpb24nICkudGV4dENvbnRlbnQgPSB0byApO1xufSApO1xuIl0sIm1hcHBpbmdzIjoiQUFBQUEsRUFBRSxDQUFDQyxTQUFTLENBQUUsVUFBVSxFQUFFLFVBQUFDLEtBQUssRUFBSTtFQUNsQ0EsS0FBSyxDQUFDQyxJQUFJLENBQUUsVUFBQUMsRUFBRTtJQUFBLE9BQUlDLFFBQVEsQ0FBQ0MsYUFBYSxDQUFFLG9CQUFvQixDQUFFLENBQUNDLFdBQVcsR0FBR0gsRUFBRTtFQUFBLEVBQUU7QUFDcEYsQ0FBQyxDQUFFO0FBRUhKLEVBQUUsQ0FBQ0MsU0FBUyxDQUFFLGlCQUFpQixFQUFFLFVBQUFDLEtBQUssRUFBSTtFQUN6Q0EsS0FBSyxDQUFDQyxJQUFJLENBQUUsVUFBQUMsRUFBRTtJQUFBLE9BQUlDLFFBQVEsQ0FBQ0MsYUFBYSxDQUFFLDBCQUEwQixDQUFFLENBQUNDLFdBQVcsR0FBR0gsRUFBRTtFQUFBLEVBQUU7QUFDMUYsQ0FBQyxDQUFFIiwiZmlsZSI6Ii4vYXNzZXRzL3NjcmlwdHMvY3VzdG9taXplci5qcy5qcyIsInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///./assets/scripts/customizer.js\n");
/***/ })

2
dist/scripts/page-section.js vendored

File diff suppressed because one or more lines are too long

88
dist/styles/aldine.css vendored

@ -1851,21 +1851,16 @@ nav {
-ms-flex-pack: start;
justify-content: flex-start;
width: 100%;
max-width: 22.9375rem;
height: 24.125rem;
max-width: 18rem;
height: 25rem;
border: solid 1px var(--accent);
margin: 0 0 2rem;
padding: 1.5rem 1rem 2rem;
border: solid 2px var(--accent);
background: var(--accent);
}
@media screen and (min-width: 30rem) {
.book {
padding: 1.5rem 1.85rem 2.1875rem;
}
}
.book a, .book p {
font-family: "Karla", sans-serif;
color: var(--accent-fg);
.book__cover {
width: 100%;
height: 80%;
background-repeat: no-repeat;
background-size: cover;
}
.book a {
margin: 0;
@ -1876,65 +1871,16 @@ nav {
hyphens: auto;
}
.book__title {
margin: 0;
font-size: 1.25rem;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
font-weight: 500;
line-height: 1.2;
text-align: left;
}
@media screen and (min-width: 30rem) {
.book__title {
font-size: 1.75rem;
}
}
.book__subject {
margin: 0;
font-size: 0.75rem;
text-align: left;
}
@media screen and (min-width: 30rem) {
.book__subject {
font-size: 1rem;
}
}
.book__institutions {
margin: 0.5rem 0 0;
font-size: 0.875rem;
text-align: left;
display: box;
overflow: hidden;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
.book__read-more {
margin: auto 0 0;
font-size: 1rem;
text-align: left;
}
@media screen and (min-width: 30rem) {
.book__read-more {
font-size: 1.125rem;
}
}
.book__read-more a svg {
width: 1rem;
height: 1rem;
vertical-align: middle;
}
@media screen and (min-width: 30rem) {
.book__read-more a svg {
width: 1.125rem;
height: 1.125rem;
margin-left: 0.5rem;
}
}
.book:last-child {
margin-bottom: 0;
}
@media screen and (min-width: 60rem) {
.book:last-child {
margin-bottom: 2rem;
}
}
label {

1
functions.php

@ -64,6 +64,7 @@ add_action( 'updated_option', '\Aldine\Actions\add_color_variants', 10, 3 );
add_action( 'customize_register', '\Aldine\Customizer\customize_register' );
add_action( 'customize_preview_init', '\Aldine\Customizer\customize_preview_js' );
add_action( 'customize_controls_enqueue_scripts', '\Aldine\Customizer\enqueue_color_contrast_validator' );
add_action( 'customize_controls_enqueue_scripts', '\Aldine\Customizer\featured_books_scripts' );
add_action( 'customize_controls_enqueue_scripts', '\Aldine\Customizer\enqueue_contact_form_tweaks' );
add_action( 'customize_controls_enqueue_scripts', '\Aldine\Customizer\enqueue_pb_a11y_in_customizer' );

37
inc/customizer/namespace.php

@ -7,8 +7,11 @@
namespace Aldine\Customizer;
use function Aldine\Helpers\get_catalog_options;
use PressbooksMix\Assets;
const MAX_FEATURED_BOOKS = 4;
/**
* Add postMessage support for site title and description for the Theme Customizer.
*
@ -177,14 +180,16 @@ function customize_register( \WP_Customize_Manager $wp_customize ) {
$wp_customize->add_setting(
'pb_front_page_catalog', [
'type' => 'option',
]
],
);
$wp_customize->add_control(
'pb_front_page_catalog', [
'label' => __( 'Show Front Page Catalog', 'pressbooks-aldine' ),
'section' => 'pb_front_page_catalog',
'settings' => 'pb_front_page_catalog',
'type' => 'checkbox',
'default' => '0',
]
);
$wp_customize->add_setting(
@ -201,6 +206,26 @@ function customize_register( \WP_Customize_Manager $wp_customize ) {
'settings' => 'pb_front_page_catalog_title',
]
);
$options = get_catalog_options();
$books = collect( $options['books'] )->pluck( 'title', 'id' )->toArray();
foreach ( range( 1, MAX_FEATURED_BOOKS ) as $i ) {
$wp_customize->add_setting(
"pb_front_page_catalog_book_{$i}", [
'type' => 'option',
]
);
$wp_customize->add_control(
"pb_front_page_catalog_book_{$i}", [
'label' => __( 'Featured book', 'pressbooks-aldine' ) . " {$i}",
'section' => 'pb_front_page_catalog',
'settings' => "pb_front_page_catalog_book_{$i}",
'type' => 'select',
'choices' => $books,
]
);
}
}
$wp_customize->add_section(
@ -274,6 +299,16 @@ function customize_preview_js() {
wp_enqueue_script( 'aldine/customizer', $assets->getPath( 'scripts/customizer.js' ), [ 'customize-preview' ], false, null );
}
/**
* Binds JS handlers to make Theme Customizer preview reload changes asynchronously.
*/
function featured_books_scripts() {
$assets = new Assets( 'pressbooks-aldine', 'theme' );
$assets->setSrcDirectory( 'assets' )->setDistDirectory( 'dist' );
wp_enqueue_script( 'aldine/featured-books', $assets->getPath( 'scripts/featured-books.js' ), [], false, null );
}
/**
* Load color contrast validation tool
*

84
inc/helpers/namespace.php

@ -7,33 +7,22 @@
namespace Aldine\Helpers;
use const Aldine\Customizer\MAX_FEATURED_BOOKS;
use function Pressbooks\Metadata\get_institutions_flattened;
use function \Pressbooks\Metadata\book_information_to_schema;
use function \Pressbooks\Metadata\is_bisac;
use function \Pressbooks\Utility\str_starts_with;
use Pressbooks\DataCollector\Book as BookDataCollector;
use Pressbooks\Licensing;
/**
* Get catalog data
*
* @param int $page Catalog page
* @param int $per_page Books per page
* @param string $orderby Sort order
* @param string $license Copyright license
* @param string $subject Subject
* Get all the books in the catalog
*
* @return array
* @return array[]
*/
function get_catalog_data( $page = 1, $per_page = 10, $orderby = 'title', $license = '', $subject = '' ) {
if ( ! defined( 'PB_PLUGIN_VERSION' ) ) {
return [
'pages' => 0,
'books' => [],
];
}
function get_catalog_options(): array {
$dc = BookDataCollector::init();
/**
* Filter the WP_Site_Query args for the catalog display.
*
@ -62,7 +51,40 @@ function get_catalog_data( $page = 1, $per_page = 10, $orderby = 'title', $licen
]
)
);
return get_catalog_data( $args );
}
/**
* Get featured books
*
* @return array
*/
function get_featured_books(): array {
$featured_books = [];
foreach ( range( 1, MAX_FEATURED_BOOKS ) as $book ) {
$book = get_option( 'pb_front_page_catalog_book_' . $book );
if ( $book ) {
$featured_books[] = $book;
}
}
$args = [
'site__in' => $featured_books,
];
return get_catalog_data( $args );
}
/**
* Get catalog data
*
* @param array $args Query arguments
* @return array[]
*/
function get_catalog_data( array $args ): array {
$dc = BookDataCollector::init();
/**
* WordPress site
*
@ -75,38 +97,20 @@ function get_catalog_data( $page = 1, $per_page = 10, $orderby = 'title', $licen
$site->pb_title = $dc->get( $site->blog_id, $dc::TITLE );
$sites_in_catalog[] = $site;
}
if ( $orderby === 'latest' ) {
$sites_in_catalog = wp_list_sort( $sites_in_catalog, 'last_updated', 'DESC' );
} else {
$sites_in_catalog = wp_list_sort( $sites_in_catalog, 'pb_title', 'ASC' );
}
$total_pages = ceil( count( $sites_in_catalog ) / $per_page );
$offset = ( $page - 1 ) * $per_page;
$books = [];
foreach ( $sites_in_catalog as $i => $site ) {
if ( $i < $offset ) {
continue;
}
foreach ( $sites_in_catalog as $site ) {
$book_information = $dc->get( $site->blog_id, $dc::BOOK_INFORMATION_ARRAY );
if ( is_array( $book_information ) && ! empty( $book_information ) ) {
$schema = book_information_to_schema( $book_information );
$book['title'] = $schema['name'];
$book['date-published'] = $schema['datePublished'] ?? '';
$book['subject'] = $schema['about'][0]['identifier'] ?? '';
$book['id'] = $site->blog_id;
$book['link'] = get_blogaddress_by_id( $site->blog_id );
$book['metadata'] = $schema;
$books[] = $book;
}
if ( count( $books ) >= $per_page ) {
break;
}
}
return [
'pages' => $total_pages,
'books' => $books,
];
}
@ -118,7 +122,7 @@ function get_catalog_data( $page = 1, $per_page = 10, $orderby = 'title', $licen
*/
function get_catalog_licenses() {
if ( defined( 'PB_PLUGIN_VERSION' ) ) {
$licenses = ( new \Pressbooks\Licensing() )->getSupportedTypes();
$licenses = ( new Licensing() )->getSupportedTypes();
foreach ( $licenses as $key => $value ) {
$licenses[ $key ] = preg_replace( '/\([^)]+\)/', '', $value['desc'] );
}
@ -136,7 +140,7 @@ function get_catalog_licenses() {
*/
function get_available_licenses( $catalog_data ) {
$licenses = [];
$licensing = new \Pressbooks\Licensing();
$licensing = new Licensing();
foreach ( $catalog_data['books'] as $book ) {
$license = $licensing->getLicenseFromUrl( $book['metadata']['license']['url'] );
@ -158,7 +162,7 @@ function get_institutions(): array {
return [];
}
return \Pressbooks\Metadata\get_institutions_flattened();
return get_institutions_flattened();
}
/**

4
page-catalog.php

@ -17,8 +17,8 @@ if ( has_filter( 'pb_network_catalog' ) ) {
use function Aldine\Helpers\get_available_institutions;
use function Aldine\Helpers\get_available_licenses;
use function Aldine\Helpers\get_available_subjects;
use function Aldine\Helpers\get_catalog_data;
use function Aldine\Helpers\get_catalog_licenses;
use function Aldine\Helpers\get_featured_books;
use function Aldine\Helpers\get_institutions;
$current_page = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
@ -26,7 +26,7 @@ $orderby = ( get_query_var( 'orderby' ) ) ? get_query_var( 'orderby' ) : 'title'
$subject = ( get_query_var( 'subject' ) ) ? get_query_var( 'subject' ) : '';
$license = ( get_query_var( 'license' ) ) ? get_query_var( 'license' ) : '';
$institution = get_query_var( 'institution' ) ?? '';
$catalog_data = get_catalog_data( $current_page, 9, $orderby, $license, $subject );
$catalog_data = get_featured_books();
$previous_page = ( $current_page > 1 ) ? $current_page - 1 : 0;
$next_page = $current_page + 1;
$licenses = get_catalog_licenses();

50
partials/book.php

@ -6,54 +6,10 @@
*/
use function \Aldine\Helpers\maybe_truncate_string;
use function \Pressbooks\Metadata\is_bisac;
$subject = ( isset( $book['subject'] ) && ! is_bisac( $book['subject'] ) ) ? substr( $book['subject'], 0, 2 ) : '';
$date = ( isset( $book['metadata']['datePublished'] ) ) ? str_replace( '-', '', $book['metadata']['datePublished'] ) : '';
$institution_codes = array_map( static function ( $item ) {
return $item['code'];
}, $book['metadata']['institutions'] ?? [] );
$institution_names = array_map( static function ( $item ) {
return \Pressbooks\Metadata\get_institution_name( $item['code'] );
}, $book['metadata']['institutions'] ?? [] );
?>
<li class="book"
<?php
if ( $date ) {
?>
data-date-published="<?php echo $date; ?>"<?php } ?>
data-license="<?php echo ( new \Pressbooks\Licensing() )->getLicenseFromUrl( $book['metadata']['license']['url'] ); ?>"
data-institution="<?php echo implode( ',', $institution_codes ); ?>"
<?php
if ( ! empty( $subject ) ) {
?>
data-subject="<?php echo $subject ?>"<?php } ?>
>
<div class="book">
<div class="book__cover" style="background-image: url('<?php echo $book['metadata']['image']; ?>' );"></div>
<p class="book__title">
<a href="<?php echo $book['link']; ?>"><?php echo maybe_truncate_string( $book['metadata']['name'] ); ?></a>
</p>
<?php
/*
<?php if (isset( $book['metadata']['author'] ) ) { ?>
<p class="book__author">
<?php _e( 'By', 'pressbooks-aldine' ); ?> <?php foreach ( $book['metadata']['author'] as $author ) {
echo $author['name'];
} ?>
</p>
<?php } ?>
*/
?>
<?php if ( ! empty( $subject ) ) { ?>
<p class="book__subject">
<a href="<?php echo network_home_url( "/catalog/#$subject" ) ?>"><?php echo \Pressbooks\Metadata\get_subject_from_thema( $book['subject'] ); ?></a>
</p>
<?php } ?>
<?php if ( $institution_names ) : ?>
<p class="book__institutions">
<?php echo implode( ', ', $institution_names ); ?>
</p>
<?php endif; ?>
<p class="book__read-more">
<a href="<?php echo $book['link']; ?>"><?php _e( 'About this book', 'pressbooks-aldine' ); ?> <svg aria-hidden="true"><use xlink:href="#arrow-right" /></svg></a>
</p>
</li>
</div>

51
partials/content-front-page.php

@ -7,19 +7,18 @@
* @package Aldine
*/
use function Aldine\Helpers\get_catalog_data;
use function Aldine\Helpers\get_catalog_page;
use function Aldine\Helpers\get_featured_books;
use function Aldine\Helpers\has_sections;
$pb_front_page_catalog_title = get_option( 'pb_front_page_catalog_title' );
$latest_books_title = ( ! empty( $pb_front_page_catalog_title ) ) ? $pb_front_page_catalog_title : __( 'Our Latest Titles', 'pressbooks-aldine' );
$latest_books_title = ( ! empty( $pb_front_page_catalog_title ) ) ? $pb_front_page_catalog_title : __('Our Latest Titles',
'pressbooks-aldine');
if ( get_option( 'pb_front_page_catalog' ) ) {
$page = ( get_query_var( 'page' ) ) ? get_query_var( 'page' ) : 1;
$catalog_data = get_catalog_data( $page, 3, 'latest' );
$previous_page = ( $page > 1 ) ? $page - 1 : 0;
$next_page = $page + 1;
$catalog_data = get_featured_books();
}
$catalog_page = \Aldine\Helpers\get_catalog_page();
$catalog_page = get_catalog_page();
if ( $catalog_page ) {
$catalog_permalink = get_permalink( $catalog_page->ID );
}
@ -51,29 +50,23 @@ if ( $catalog_page ) {
?>
</div><!-- .entry-content -->
</article><!-- #post-<?php the_ID(); ?> -->
<?php if ( get_option( 'pb_front_page_catalog' ) && ! empty( $catalog_data['books'] ) ) : ?>
<div id="latest-books" class="latest-books">
<h2 id="latest-books-title"><?php echo $latest_books_title; ?></h2>
<div class="slider" role="region" aria-labelledby="latest-books-title" data-total-pages="<?php echo $catalog_data['pages']; ?>"
<?php
if ( $next_page <= $catalog_data['pages'] ) :
<div id="latest-books" class="latest-books">
<h2 id="latest-books-title"><?php echo $latest_books_title; ?></h2>
<div class="books">
<?php
foreach ( $catalog_data['books'] as $book ) :
include( locate_template( 'partials/book.php' ) );
endforeach;
?>
data-next-page="<?php echo $next_page; ?>"<?php endif; ?>>
<ul class="books">
<?php
foreach ( $catalog_data['books'] as $book ) :
include( locate_template( 'partials/book.php' ) );
endforeach;
?>
</ul>
<?php
if ( $previous_page || $next_page ) {
include( locate_template( 'partials/paged-navigation.php' ) ); }
?>
</div>
<p class="catalog-link">
<a class="call-to-action" href="<?php echo $catalog_permalink ?? ''; ?>">
<?php
_e('View Complete Catalog',
'pressbooks-aldine');
?>
</a>
</p>
</div>
<p class="catalog-link">
<a class="call-to-action" href="<?php echo $catalog_permalink ?? ''; ?>"><?php _e( 'View Complete Catalog', 'pressbooks-aldine' ); ?></a>
</p>
</div>
<?php endif; ?>

2
partials/content-page-catalog.php

@ -89,7 +89,7 @@
endforeach;
?>
</ul>
<?php if ( $catalog_data['pages'] > 1 ) : ?>
<?php if ( isset($catalog_data['pages']) && $catalog_data['pages'] > 1 ) : ?>
<nav class="catalog-navigation">
<?php
if ( $previous_page ) :

Loading…
Cancel
Save