From 1b42953b33c289be98761921db8e84b9f8254d51 Mon Sep 17 00:00:00 2001 From: Emmanuel Luciano Date: Sat, 30 Jan 2016 09:50:36 -0400 Subject: [PATCH 1/5] Removes white space in addon name. --- app/helpers/split-prefix.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/split-prefix.js b/app/helpers/split-prefix.js index 4074af2..37eb4b6 100644 --- a/app/helpers/split-prefix.js +++ b/app/helpers/split-prefix.js @@ -16,7 +16,7 @@ export function splitPrefix(value) { const prefix = parts[1]; const name = Ember.Handlebars.Utils.escapeExpression(parts[2]); - return new Ember.Handlebars.SafeString(`${prefix} ${name}`); + return new Ember.Handlebars.SafeString(`${prefix}${name}`); } export default Ember.Helper.helper(splitPrefix); From 1a9ae9b2d4f59784205a70071df58594db821610 Mon Sep 17 00:00:00 2001 From: Emmanuel Luciano Date: Sat, 30 Jan 2016 11:18:29 -0400 Subject: [PATCH 2/5] Fixes layout break on long names --- app/styles/app.css | 19 +++++++++++++++++++ app/templates/components/em-pkg.hbs | 10 +++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/app/styles/app.css b/app/styles/app.css index fdd8bdf..08e13e9 100644 --- a/app/styles/app.css +++ b/app/styles/app.css @@ -152,11 +152,30 @@ a.sort-button { margin-top: 20px; } +.gravatar--wrapper { + display: inline; +} + .gravatar { border-radius: 50%; margin-right: 5px; } +.author-information { + display: inline-block; + vertical-align: middle; + max-width: 130px; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + text-decoration: none; +} + +.author-information__anchor:hover { + text-decoration: none; + color: #D02714; +} + .package-link { font-size: 24px; } diff --git a/app/templates/components/em-pkg.hbs b/app/templates/components/em-pkg.hbs index fa0a748..1701e57 100644 --- a/app/templates/components/em-pkg.hbs +++ b/app/templates/components/em-pkg.hbs @@ -29,9 +29,13 @@ {{/if}} - - - {{user.name}} + +
+ +
+
+ {{user.name}} +
From ff6932989819e8a49ef7341fc76243490a336319 Mon Sep 17 00:00:00 2001 From: Emmanuel Luciano Date: Tue, 2 Feb 2016 22:50:24 -0400 Subject: [PATCH 3/5] Adds initial version of service worker. The worker is missing a cache busting strategy and it doesn't work when the user enters the app with a query string. --- app/index.html | 14 +++++++++++++- package.json | 3 ++- public/sw.js | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 public/sw.js diff --git a/app/index.html b/app/index.html index a895bd8..2a16509 100644 --- a/app/index.html +++ b/app/index.html @@ -65,7 +65,19 @@

Loading...

- + + {{content-for 'body-footer'}} diff --git a/package.json b/package.json index ed2ba5c..5c9e8c7 100644 --- a/package.json +++ b/package.json @@ -43,5 +43,6 @@ "ember-legacy-views": "0.2.0", "ember-load": "0.0.3", "ember-moment": "^4.1.0" - } + }, + "dependencies": {} } diff --git a/public/sw.js b/public/sw.js new file mode 100644 index 0000000..ee69cce --- /dev/null +++ b/public/sw.js @@ -0,0 +1,50 @@ +var addonsLink = 'https://io-builtwithember-addons-data.s3.amazonaws.com/addons.json'; + +var CACHE_DEPENDENCIES_NAME = 'ADDONS_DEPENDENCIES'; +var CACHE_DEPENDENCIES = [ + './', + 'sw.js', + 'assets/vendor.css', + 'assets/vendor.js', + 'assets/ember-addons-website.css', + 'assets/ember-addons-website.js', + 'assets/favicon.png', + 'fonts/fontawesome-webfont.woff?v=4.4.0', + 'fonts/fontawesome-webfont.woff2?v=4.4.0', + 'assets/github-logo.svg' +]; +CACHE_DEPENDENCIES.push(addonsLink); + +function urlsToPrefetch(cache) { + return fetch(addonsLink).then(function(response) { + return response.json(); + }).then(function(json) { + return json.map(function(curr) { + return curr["_npmUser"].gravatar + '?s=30&d=retro'; + }).filter(function(data, index, array) { + if (array.indexOf(data) === index) { + return data; + } + }).concat(CACHE_DEPENDENCIES); + }); +} + +self.addEventListener('install', function(event) { + event.waitUntil( + urlsToPrefetch().then(function(urls) { + caches.open(CACHE_DEPENDENCIES_NAME).then(function(cache) { + cache.addAll(urls); + }); + }) + ); +}); + +self.addEventListener('fetch', function(event) { + event.respondWith( + caches.match(event.request).then(function(res) { + if (res) { + return res; + } + }) + ); +}); From b7a86f7a72902d16680f96d581d6e4ace3c13828 Mon Sep 17 00:00:00 2001 From: Emmanuel Luciano Date: Thu, 4 Feb 2016 09:42:28 -0400 Subject: [PATCH 4/5] Service worker --- public/sw.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/sw.js b/public/sw.js index ee69cce..0a10c0c 100644 --- a/public/sw.js +++ b/public/sw.js @@ -15,7 +15,7 @@ var CACHE_DEPENDENCIES = [ ]; CACHE_DEPENDENCIES.push(addonsLink); -function urlsToPrefetch(cache) { +function urlsToPrefetch() { return fetch(addonsLink).then(function(response) { return response.json(); }).then(function(json) { From c4869959610b2a97cc9b4301f5470c2a7270fc83 Mon Sep 17 00:00:00 2001 From: Emmanuel Luciano Date: Thu, 4 Feb 2016 10:16:17 -0400 Subject: [PATCH 5/5] Adds comments to methods. --- public/sw.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/public/sw.js b/public/sw.js index 0a10c0c..d496a48 100644 --- a/public/sw.js +++ b/public/sw.js @@ -2,8 +2,6 @@ var addonsLink = 'https://io-builtwithember-addons-data.s3.amazonaws.com/addons. var CACHE_DEPENDENCIES_NAME = 'ADDONS_DEPENDENCIES'; var CACHE_DEPENDENCIES = [ - './', - 'sw.js', 'assets/vendor.css', 'assets/vendor.js', 'assets/ember-addons-website.css', @@ -15,6 +13,8 @@ var CACHE_DEPENDENCIES = [ ]; CACHE_DEPENDENCIES.push(addonsLink); +// Request the addons.js, filter the gravatar ulrs and +// add the new urls to the CACHE_DEPENDENCIES array. function urlsToPrefetch() { return fetch(addonsLink).then(function(response) { return response.json(); @@ -29,9 +29,13 @@ function urlsToPrefetch() { }); } +// waitUntil expects a promise and it will stop the worker execution +// until the promise is resolved. self.addEventListener('install', function(event) { event.waitUntil( urlsToPrefetch().then(function(urls) { + // Open the specified cache if it exists. If the cache doesn't exist + // create it and add prefetch the urls on the array. caches.open(CACHE_DEPENDENCIES_NAME).then(function(cache) { cache.addAll(urls); }); @@ -39,6 +43,8 @@ self.addEventListener('install', function(event) { ); }); +// Intercept every request that the app makes. If it the request matches +// a request that has been stored in the cache return the response that is stored. self.addEventListener('fetch', function(event) { event.respondWith( caches.match(event.request).then(function(res) {