diff --git a/config/_extras.yml b/config/_extras.yml index b1634f125..0f971bfa6 100644 --- a/config/_extras.yml +++ b/config/_extras.yml @@ -1,16 +1,16 @@ books: - name: 'Jump Start Bootstrap: Get Up to Speed With Bootstrap in a Weekend' + img: /assets/img/books/Jump-Start-Bootstrap-Speed-Weekend.jpg url: 'https://www.amazon.com/Jump-Start-Bootstrap-Speed-Weekend/dp/0992279437/ref=as_li_ss_il?_encoding=UTF8&psc=1&refRID=2WP7MEQ0KPAHQS6YT117&linkCode=li3&tag=bcdn-20&linkId=b44f87f6e04d5eb7e6b49af61cd0e422' - asin: '0992279437' - name: 'Building Progressive Web Apps: Bringing the Power of Native to the Browser' + img: /assets/img/books/Building-Progressive-Web-Apps-Bringing-ebook.jpg url: 'https://www.amazon.com/Building-Progressive-Web-Apps-Bringing-ebook/dp/B075HP52WY/ref=as_li_ss_il?ie=UTF8&linkCode=li3&tag=bcdn-20&linkId=013ca3a2eb57883d255384829ec0a6a2' - asin: 'B075HP52WY' - name: 'Coding For Dummies (For Dummies (Computer/Tech))' + img: /assets/img/books/Coding-Dummies-Computer-Tech.jpg url: 'https://www.amazon.com/Coding-Dummies-Computer-Tech/dp/1119293324/ref=as_li_ss_il?ie=UTF8&linkCode=li3&tag=bcdn-20&linkId=fb405dc117a040e91557b45f6dc1094b' - asin: '1119293324' - name: 'Bootstrap in 24 Hours, Sams Teach Yourself' + img: /assets/img/books/Bootstrap-Hours-Sams-Teach-Yourself-ebook.jpg url: 'https://www.amazon.com/Bootstrap-Hours-Sams-Teach-Yourself-ebook/dp/B017M8OWZQ/ref=as_li_ss_il?ie=UTF8&linkCode=li3&tag=bcdn-20&linkId=f8a39275b5204f5f2d0427a1ef1c4f83' - asin: 'B017M8OWZQ' showcase: - name: Microsoft Education img: /assets/img/showcase/microsoft-education.png diff --git a/config/helmet-csp.js b/config/helmet-csp.js index dec78cdfd..36719e652 100644 --- a/config/helmet-csp.js +++ b/config/helmet-csp.js @@ -51,10 +51,7 @@ const CSP = { '*.2mdn.net', 'launchbit.com', 'www.launchbit.com', - 'www.ziprecruiter.com', - 'ws-na.amazon-adsystem.com', - 'ir-na.amazon-adsystem.com', - 'images-na.ssl-images-amazon.com' + 'www.ziprecruiter.com' ], fontSrc: [ '\'self\'', diff --git a/public/assets/css/style.css b/public/assets/css/style.css index 7329c73c4..2391b02f2 100644 --- a/public/assets/css/style.css +++ b/public/assets/css/style.css @@ -103,3 +103,9 @@ footer { line-height: 1; text-transform: uppercase; } + +.book-card img { + /* use the height of the smallest image so that they are aligned */ + height: 250px; + width: auto; +} diff --git a/public/assets/img/books/Bootstrap-Hours-Sams-Teach-Yourself-ebook.jpg b/public/assets/img/books/Bootstrap-Hours-Sams-Teach-Yourself-ebook.jpg new file mode 100644 index 000000000..a76794f5d Binary files /dev/null and b/public/assets/img/books/Bootstrap-Hours-Sams-Teach-Yourself-ebook.jpg differ diff --git a/public/assets/img/books/Building-Progressive-Web-Apps-Bringing-ebook.jpg b/public/assets/img/books/Building-Progressive-Web-Apps-Bringing-ebook.jpg new file mode 100644 index 000000000..6952515e8 Binary files /dev/null and b/public/assets/img/books/Building-Progressive-Web-Apps-Bringing-ebook.jpg differ diff --git a/public/assets/img/books/Coding-Dummies-Computer-Tech.jpg b/public/assets/img/books/Coding-Dummies-Computer-Tech.jpg new file mode 100644 index 000000000..cc66cc9d5 Binary files /dev/null and b/public/assets/img/books/Coding-Dummies-Computer-Tech.jpg differ diff --git a/public/assets/img/books/Jump-Start-Bootstrap-Speed-Weekend.jpg b/public/assets/img/books/Jump-Start-Bootstrap-Speed-Weekend.jpg new file mode 100644 index 000000000..3cf90521d Binary files /dev/null and b/public/assets/img/books/Jump-Start-Bootstrap-Speed-Weekend.jpg differ diff --git a/test/books_test.js b/test/books_test.js index 897e97041..9d7df619b 100644 --- a/test/books_test.js +++ b/test/books_test.js @@ -1,7 +1,9 @@ 'use strict'; const assert = require('assert').strict; +const path = require('path'); const htmlEncode = require('htmlencode').htmlEncode; +const staticify = require('staticify')(path.join(__dirname, '../public')); const helpers = require('./test_helpers.js'); describe('books', () => { @@ -29,37 +31,26 @@ describe('books', () => { }); it('has page header', (done) => { - helpers.assert.pageHeader('Books', response, done); + helpers.assert.pageHeader('Bootstrap Books', response, done); }); config.books.forEach((book) => { describe(book.name, () => { - const beforeTrackImgUrl = `https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=${book.asin}&Format=_SL250_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=bcdn-20`; - const afterTrackImgUrl = `https://ir-na.amazon-adsystem.com/e/ir?t=bcdn-20&l=li3&o=1&a=${book.asin}`; - it('has name', (done) => { assert.ok(response.body.includes(book.name), `Expects response body to include "${book.name}"`); done(); }); - + it('has image', (done) => { + assert.ok(response.body.includes(staticify.getVersionedPath(book.img)), + `Expects response body to include "${book.img}"`); + done(); + }); it('has url', (done) => { assert.ok(response.body.includes(htmlEncode(book.url)), `Expects response body to include "${book.url}"`); done(); }); - - it('has before tracking image', (done) => { - assert.ok(response.body.includes(htmlEncode(beforeTrackImgUrl)), - `Expects response body to include "${beforeTrackImgUrl}"`); - done(); - }); - - it('has after tracking image', (done) => { - assert.ok(response.body.includes(htmlEncode(afterTrackImgUrl)), - `Expects response body to include "${afterTrackImgUrl}"`); - done(); - }); }); }); }); diff --git a/views/_partials/books.pug b/views/_partials/books.pug index 15db33737..00279249d 100644 --- a/views/_partials/books.pug +++ b/views/_partials/books.pug @@ -1,15 +1,9 @@ -- - const beforeTrackImgUrl = `https://ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&ASIN=${book.asin}&Format=_SL250_&ID=AsinImage&MarketPlace=US&ServiceVersion=20070822&WS=1&tag=bcdn-20`; - const afterTrackImgUrl = `https://ir-na.amazon-adsystem.com/e/ir?t=bcdn-20&l=li3&o=1&a=${book.asin}`; - .card-deck - .card.border-primary.py-3.px-md-3.mb-3.text-center + .card.border-primary.py-3.px-md-3.mb-3.text-center.book-card .card-header.bg-transparent.border-0 - h3.h4.card-title.mb-0=book.name + img.card-img-top.img-fluid.d-block.mx-auto(src=getVersionedPath(book.img), alt=`${book.name} cover`) .card-body.bg-transparent.border-0 - a(href=book.url, rel='noopener', target='_blank') - img.border-0(src=beforeTrackImgUrl, alt='') - img.border-0.m-0(src=afterTrackImgUrl, width='1', height='1', alt='') + h3.h4.card-title.mb-0=book.name .card-footer.bg-transparent.border-0 a.btn.btn-primary.btn-lg.btn-block.w-75.mx-auto.py-3(href=book.url, rel='noopener', target='_blank') Buy from Amazon diff --git a/views/books.pug b/views/books.pug index ac357994b..68096fae5 100644 --- a/views/books.pug +++ b/views/books.pug @@ -1,7 +1,7 @@ extends layout.pug block content - h2.text-center.mb-4 Books + h2.text-center.mb-4 Bootstrap Books .row each book in config.books