From 3f0d1ab92b8f474c1b2d7164f2c04bbdd681687d Mon Sep 17 00:00:00 2001 From: Felipe Dalcin Date: Fri, 14 Jan 2022 23:11:00 -0300 Subject: [PATCH] feat: Add institution info and filter to catalog (#308) * Add institution info to aldine catalog book card * Remove unneeded OS dependency step from CI pipeline Co-authored-by: SteelWagstaff --- .github/workflows/.pipeline.yml | 3 -- assets/scripts/routes/catalog.js | 74 ++++++++++++++++++----------- assets/styles/components/_book.scss | 17 ++++++- dist/mix-manifest.json | 4 +- dist/scripts/aldine.js | 2 +- dist/styles/aldine.css | 2 +- inc/helpers/namespace.php | 34 +++++++++++++ page-catalog.php | 5 ++ partials/book.php | 11 ++++- partials/content-page-catalog.php | 15 ++++++ 10 files changed, 129 insertions(+), 38 deletions(-) diff --git a/.github/workflows/.pipeline.yml b/.github/workflows/.pipeline.yml index 3d6ab30..271cd3e 100644 --- a/.github/workflows/.pipeline.yml +++ b/.github/workflows/.pipeline.yml @@ -41,9 +41,6 @@ jobs: with: node-version: '14' - - name: Install OS dependencies - run: sudo apt-get install libxml2-utils ghostscript poppler-utils - - name: Start required services run: sudo systemctl start mysql.service diff --git a/assets/scripts/routes/catalog.js b/assets/scripts/routes/catalog.js index de2cdfa..6a3c06a 100644 --- a/assets/scripts/routes/catalog.js +++ b/assets/scripts/routes/catalog.js @@ -165,6 +165,7 @@ export default { } ); let licenses = document.querySelector( '.license-filters' ); let subjects = document.querySelector( '.subject-filters' ); + let institutions = document.querySelector( '.institution-filters' ); let sorts = document.querySelector( '.sorts' ); let clearFilters = document.querySelector( '.clear-filters' ); clearFilters.hidden = false; @@ -172,47 +173,66 @@ export default { if ( event.target.type !== 'radio' ) { return; } - let license = ''; - let subject = ''; - let filterValue = '*'; - if ( subjects.querySelector( 'input[type="radio"]:checked' ).value ) { - subject = `[data-subject="${ - subjects.querySelector( 'input[type="radio"]:checked' ).value - }"]`; - } - if ( event.target.value ) { - license = `[data-license="${event.target.value}"]`; - } - if ( license || subject ) { - filterValue = `${license}${subject}`; + + const subject = subjects.querySelector( 'input[type="radio"]:checked' ).value + ? `[data-subject="${subjects.querySelector( 'input[type="radio"]:checked' ).value}"]` + : ''; + const institution = institutions.querySelector( 'input[type="radio"]:checked' ).value + ? `[data-institution*="${institutions.querySelector( 'input[type="radio"]:checked' ).value}"]` + : ''; + const license = event.target.value + ? `[data-license="${event.target.value}"]` + : ''; + + const filterValue = subject || license || institution ? `${subject}${license}${institution}` : '*'; + + $grid.isotope( { filter: filterValue } ); + } ); + institutions.addEventListener( 'click', function ( event ) { + if ( event.target.type !== 'radio' ) { + return; } + + const subject = subjects.querySelector( 'input[type="radio"]:checked' ).value + ? `[data-subject="${subjects.querySelector( 'input[type="radio"]:checked' ).value}"]` + : ''; + const license = licenses.querySelector( 'input[type="radio"]:checked' ).value + ? `[data-license="${licenses.querySelector( 'input[type="radio"]:checked' ).value}"]` + : ''; + const institution = event.target.value + ? `[data-institution*="${event.target.value}"]` + : ''; + + const filterValue = subject || license || institution ? `${subject}${license}${institution}` : '*'; + $grid.isotope( { filter: filterValue } ); } ); subjects.addEventListener( 'click', function ( event ) { if ( event.target.type !== 'radio' ) { return; } - let license = ''; - let subject = ''; - let filterValue = '*'; - if ( licenses.querySelector( 'input[type="radio"]:checked' ).value ) { - license = `[data-license="${ - licenses.querySelector( 'input[type="radio"]:checked' ).value - }"]`; - } - if ( event.target.value ) { - subject = `[data-subject="${event.target.value}"]`; - } - if ( license || subject ) { - filterValue = `${license}${subject}`; - } + + const license = licenses.querySelector( 'input[type="radio"]:checked' ).value + ? `[data-license="${licenses.querySelector( 'input[type="radio"]:checked' ).value}"]` + : ''; + const institution = institutions.querySelector( 'input[type="radio"]:checked' ).value + ? `[data-institution*="${institutions.querySelector( 'input[type="radio"]:checked' ).value}"]` + : ''; + const subject = event.target.value + ? `[data-subject="${event.target.value}"]` + : ''; + + const filterValue = subject || license || institution ? `${subject}${license}${institution}` : '*'; + $grid.isotope( { filter: filterValue } ); } ); clearFilters.addEventListener( 'click', function () { let allLicenses = document.getElementById( 'all-licenses' ); let allSubjects = document.getElementById( 'all-subjects' ); + let allInstitutions = document.getElementById( 'all-institutions' ); allLicenses.checked = true; allSubjects.checked = true; + allInstitutions.checked = true; $grid.isotope( { filter: '*' } ); } ); sorts.addEventListener( 'click', function ( event ) { diff --git a/assets/styles/components/_book.scss b/assets/styles/components/_book.scss index 7d41841..b8f335b 100644 --- a/assets/styles/components/_book.scss +++ b/assets/styles/components/_book.scss @@ -11,10 +11,13 @@ border: solid 2px var(--accent); background: var(--accent); - a { - margin: 0; + a, p { font-family: $font-family-sans-serif; color: var(--accent-fg); + } + + a { + margin: 0; text-decoration: none; text-align: center; hyphens: auto; @@ -38,6 +41,16 @@ text-align: left; } + &__institutions { + margin: .5rem 0 0 0; + font-size: 0.875rem; + text-align: left; + display: -webkit-box; + overflow: hidden; + -webkit-line-clamp: 2; + -webkit-box-orient: vertical; + } + &__read-more { margin: auto 0 0; font-size: 1rem; diff --git a/dist/mix-manifest.json b/dist/mix-manifest.json index 929e107..bc7f337 100644 --- a/dist/mix-manifest.json +++ b/dist/mix-manifest.json @@ -1,12 +1,12 @@ { - "/scripts/aldine.js": "/scripts/aldine.js?id=5c7f11a799783d9738e0", + "/scripts/aldine.js": "/scripts/aldine.js?id=f7e0ad5cfcc135b918f6", "/scripts/call-to-action.js": "/scripts/call-to-action.js?id=33370b66c7af12320fc0", "/scripts/catalog-admin.js": "/scripts/catalog-admin.js?id=e8d84fb090536b8e49e9", "/scripts/customizer.js": "/scripts/customizer.js?id=14dca3944228dd789c27", "/scripts/customizer-toggle.js": "/scripts/customizer-toggle.js?id=c31594589675d7c5662a", "/scripts/page-section.js": "/scripts/page-section.js?id=19d5c30146ea1a763bcf", "/styles/editor.css": "/styles/editor.css?id=b7c2449babe566571767", - "/styles/aldine.css": "/styles/aldine.css?id=1d7ece82cd6c0f6f8c90", + "/styles/aldine.css": "/styles/aldine.css?id=8d3bfb61118a9ee435a1", "/fonts/pressbooks-theme.woff": "/fonts/pressbooks-theme.woff?id=2a7aae81673f4707bbe7", "/images/banner.jpg": "/images/banner.jpg?id=04a813e0b4f94ddfef19", "/images/catalog-header.jpg": "/images/catalog-header.jpg?id=223b9f7a23985f2a72df", diff --git a/dist/scripts/aldine.js b/dist/scripts/aldine.js index d2efbf4..9fee860 100644 --- a/dist/scripts/aldine.js +++ b/dist/scripts/aldine.js @@ -1,2 +1,2 @@ /*! For license information please see aldine.js.LICENSE.txt */ -!function(){var t,e={612:function(t,e,n){"use strict";var i=n(755),r=n(391),o=n(831),s={init:function(){var t;t=document.querySelectorAll("fieldset h2"),Array.prototype.forEach.call(t,(function(t){t.innerHTML='\n\t\t\t\t\n\t\t\t ');var e=function(t){for(var e=[];t.nextElementSibling&&"H2"!==t.nextElementSibling.tagName;)e.push(t.nextElementSibling),t=t.nextElementSibling;return e.forEach((function(t){t.parentNode.removeChild(t)})),e}(t),n=document.createElement("div");n.hidden=!0,e.forEach((function(t){n.appendChild(t)})),t.parentNode.insertBefore(n,t.nextElementSibling);var i=t.querySelector("button");i.onclick=function(){var t="true"===i.getAttribute("aria-expanded")||!1;i.setAttribute("aria-expanded",!t),n.hidden=t}})),function(){var t=document.querySelectorAll("fieldset h3");Array.prototype.forEach.call(t,(function(t){t.innerHTML='\n\t\t\t\t\n\t\t\t ');var e=function(t){for(var e=[];t.nextElementSibling&&"H3"!==t.nextElementSibling.tagName;)e.push(t.nextElementSibling),t=t.nextElementSibling;return e.forEach((function(t){t.parentNode.removeChild(t)})),e}(t),n=document.createElement("div");n.hidden=!0,e.forEach((function(t){n.appendChild(t)})),t.parentNode.insertBefore(n,t.nextElementSibling);var i=t.querySelector("button");i.onclick=function(){var t="true"===i.getAttribute("aria-expanded")||!1;i.setAttribute("aria-expanded",!t),n.hidden=t}}))}(),i((function(t){o("isotope",r,t);var e=t(".books");e.isotope({itemSelector:".book",getSortData:{title:".book__title a",subject:"[data-subject]",latest:"[data-date-published]"},sortAscending:{title:!0,subject:!1,latest:!1}});var n=document.querySelector(".license-filters"),i=document.querySelector(".subject-filters"),s=document.querySelector(".sorts"),a=document.querySelector(".clear-filters");a.hidden=!1,n.addEventListener("click",(function(t){if("radio"===t.target.type){var n="",r="",o="*";i.querySelector('input[type="radio"]:checked').value&&(r='[data-subject="'.concat(i.querySelector('input[type="radio"]:checked').value,'"]')),t.target.value&&(n='[data-license="'.concat(t.target.value,'"]')),(n||r)&&(o="".concat(n).concat(r)),e.isotope({filter:o})}})),i.addEventListener("click",(function(t){if("radio"===t.target.type){var i="",r="",o="*";n.querySelector('input[type="radio"]:checked').value&&(i='[data-license="'.concat(n.querySelector('input[type="radio"]:checked').value,'"]')),t.target.value&&(r='[data-subject="'.concat(t.target.value,'"]')),(i||r)&&(o="".concat(i).concat(r)),e.isotope({filter:o})}})),a.addEventListener("click",(function(){var t=document.getElementById("all-licenses"),n=document.getElementById("all-subjects");t.checked=!0,n.checked=!0,e.isotope({filter:"*"})})),s.addEventListener("click",(function(t){"radio"===t.target.type&&e.isotope({sortBy:t.target.value})}))}))},finalize:function(){}},a=n(755),u={init:function(){document.body.classList.remove("no-js"),document.body.classList.add("js"),a((function(t){t(document).ready((function(){for(var e=document.getElementsByTagName("section"),n=0,i=e.length;n1&&void 0!==arguments[1]?arguments[1]:"init",n=arguments.length>2?arguments[2]:void 0,i=""!==t&&this.routes[t]&&"function"==typeof this.routes[t][e];i&&this.routes[t][e](n)}},{key:"loadEvents",value:function(){var t=this;this.fire("common"),document.body.className.toLowerCase().replace(/-/g,"_").split(/\s+/).map(l).forEach((function(e){t.fire(e),t.fire(e,"finalize")})),this.fire("common","finalize")}}])&&c(e.prototype,n),i&&c(e,i),t}(),h=n(755),d=new f({common:u,home:{init:function(){},finalize:function(){}},catalog:s});h(document).ready((function(){return d.loadEvents()}))},741:function(t,e,n){var i,r;!function(o,s){"use strict";void 0===(r="function"==typeof(i=s)?i.call(e,n,e,t):i)||(t.exports=r)}(window,(function(){"use strict";var t=function(){var t=window.Element.prototype;if(t.matches)return"matches";if(t.matchesSelector)return"matchesSelector";for(var e=["webkit","moz","ms","o"],n=0;n