Skip to content

Commit

Permalink
Approach with us hosting the images.
Browse files Browse the repository at this point in the history
  • Loading branch information
XhmikosR committed May 26, 2018
1 parent 022bd8e commit 0a251f9
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 33 deletions.
8 changes: 4 additions & 4 deletions config/_extras.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 1 addition & 4 deletions config/helmet-csp.js
Original file line number Diff line number Diff line change
Expand Up @@ -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\'',
Expand Down
6 changes: 6 additions & 0 deletions public/assets/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 7 additions & 16 deletions test/books_test.js
Original file line number Diff line number Diff line change
@@ -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', () => {
Expand Down Expand Up @@ -34,32 +36,21 @@ describe('books', () => {

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();
});
});
});
});
12 changes: 3 additions & 9 deletions views/_partials/books.pug
Original file line number Diff line number Diff line change
@@ -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

Expand Down

0 comments on commit 0a251f9

Please sign in to comment.