From d56667c6a3a85128cf0e12cb3f2f1775426cc848 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Wed, 3 Sep 2014 22:27:33 +0200 Subject: [PATCH 01/14] add cdnurl config --- _config.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/_config.yml b/_config.yml index 23899d6c..95439480 100644 --- a/_config.yml +++ b/_config.yml @@ -15,7 +15,8 @@ description: 'Blog of designer & developer Matthias Kretschmann' url: https://kremalicious.com author: Matthias Kretschmann email: m@kretschmann.io - +cdnurl: https://cdn.kremalicious.com.s3.amazonaws.com +#cdnurl: https://cdn.kremalicious.com # Urls # -------------------- From f58a77da5db4509699bb075996cb143312c704f7 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Wed, 3 Sep 2014 22:27:43 +0200 Subject: [PATCH 02/14] make jekyll-picture-tag understand custom site.cdnurl config --- _src/_plugins/picture_tag.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/_src/_plugins/picture_tag.rb b/_src/_plugins/picture_tag.rb index daf5bf05..6b242362 100755 --- a/_src/_plugins/picture_tag.rb +++ b/_src/_plugins/picture_tag.rb @@ -142,7 +142,7 @@ module Jekyll # Generate resized images instance.each { |key, source| - instance[key][:generated_src] = generate_image(source, site.source, site.dest, settings['source'], settings['output'], site.config["baseurl"]) + instance[key][:generated_src] = generate_image(source, site.source, site.dest, settings['source'], settings['output'], site.config['cdnurl'], site.config["baseurl"]) } # Construct and return tag @@ -169,7 +169,7 @@ module Jekyll picture_tag end - def generate_image(instance, site_source, site_dest, image_source, image_dest, baseurl) + def generate_image(instance, site_source, site_dest, image_source, image_dest, cdnurl, baseurl) image = MiniMagick::Image.open(File.join(site_source, image_source, instance[:src])) digest = Digest::MD5.hexdigest(image.to_blob).slice!(0..5) @@ -230,7 +230,7 @@ module Jekyll end # Return path relative to the site root for html - Pathname.new(File.join(baseurl, image_dest, image_dir, gen_name)).cleanpath + Pathname.new(File.join(cdnurl, baseurl, image_dest, image_dir, gen_name)).cleanpath end end end From d88c5c2669bdb94383c64767d04313ed0dcf6c74 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Sat, 6 Sep 2014 00:40:49 +0200 Subject: [PATCH 03/14] use cloudfront url as cdn --- _config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_config.yml b/_config.yml index 95439480..b9e41b98 100644 --- a/_config.yml +++ b/_config.yml @@ -15,7 +15,7 @@ description: 'Blog of designer & developer Matthias Kretschmann' url: https://kremalicious.com author: Matthias Kretschmann email: m@kretschmann.io -cdnurl: https://cdn.kremalicious.com.s3.amazonaws.com +cdnurl: https://d2jlreog722xe2.cloudfront.net #cdnurl: https://cdn.kremalicious.com # Urls From a6f9989fa3a70b524aead2c8ceeaacd5971cae23 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Sat, 6 Sep 2014 00:41:20 +0200 Subject: [PATCH 04/14] inject production config value during jekyll generation --- Gruntfile.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Gruntfile.js b/Gruntfile.js index 04016d69..dd207346 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -50,7 +50,8 @@ module.exports = function(grunt){ }, production: { options: { - lsi: true + lsi: true, + raw: 'production: true\n' } }, development: { From c712bb1ec59c24a19cf6808a94ab508d51759fc5 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Sat, 6 Sep 2014 00:42:39 +0200 Subject: [PATCH 05/14] insert cdnurl during picture tag creation depending on production config value --- _src/_plugins/picture_tag.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/_src/_plugins/picture_tag.rb b/_src/_plugins/picture_tag.rb index 6b242362..284f3dcc 100755 --- a/_src/_plugins/picture_tag.rb +++ b/_src/_plugins/picture_tag.rb @@ -230,7 +230,11 @@ module Jekyll end # Return path relative to the site root for html - Pathname.new(File.join(cdnurl, baseurl, image_dest, image_dir, gen_name)).cleanpath + if context.registers[:site].config['production'] + Pathname.new(File.join(cdnurl, baseurl, image_dest, image_dir, gen_name)).cleanpath + else + Pathname.new(File.join(baseurl, image_dest, image_dir, gen_name)).cleanpath + end end end end From 09ac4eb983a21d80dc0915dfefe6a93712983a61 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Sat, 6 Sep 2014 01:26:35 +0200 Subject: [PATCH 06/14] picture tag creation fix --- _src/_plugins/picture_tag.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/_src/_plugins/picture_tag.rb b/_src/_plugins/picture_tag.rb index 284f3dcc..a3f6abb9 100755 --- a/_src/_plugins/picture_tag.rb +++ b/_src/_plugins/picture_tag.rb @@ -142,7 +142,7 @@ module Jekyll # Generate resized images instance.each { |key, source| - instance[key][:generated_src] = generate_image(source, site.source, site.dest, settings['source'], settings['output'], site.config['cdnurl'], site.config["baseurl"]) + instance[key][:generated_src] = generate_image(source, site.source, site.dest, settings['source'], settings['output'], site.config['cdnurl'], site.config["baseurl"], site.config['production']) } # Construct and return tag @@ -169,7 +169,7 @@ module Jekyll picture_tag end - def generate_image(instance, site_source, site_dest, image_source, image_dest, cdnurl, baseurl) + def generate_image(instance, site_source, site_dest, image_source, image_dest, cdnurl, baseurl, production) image = MiniMagick::Image.open(File.join(site_source, image_source, instance[:src])) digest = Digest::MD5.hexdigest(image.to_blob).slice!(0..5) @@ -230,7 +230,7 @@ module Jekyll end # Return path relative to the site root for html - if context.registers[:site].config['production'] + if production Pathname.new(File.join(cdnurl, baseurl, image_dest, image_dir, gen_name)).cleanpath else Pathname.new(File.join(baseurl, image_dest, image_dir, gen_name)).cleanpath From 17fb1a4612f3213195ad9ec5a9dc8a1de45d2792 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Sat, 6 Sep 2014 14:25:18 +0200 Subject: [PATCH 07/14] also check for production value, not just key --- _config.yml | 1 + _src/_plugins/picture_tag.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/_config.yml b/_config.yml index b9e41b98..6257aa5a 100644 --- a/_config.yml +++ b/_config.yml @@ -16,6 +16,7 @@ url: https://kremalicious.com author: Matthias Kretschmann email: m@kretschmann.io cdnurl: https://d2jlreog722xe2.cloudfront.net +production: false #cdnurl: https://cdn.kremalicious.com # Urls diff --git a/_src/_plugins/picture_tag.rb b/_src/_plugins/picture_tag.rb index a3f6abb9..0f8cb657 100755 --- a/_src/_plugins/picture_tag.rb +++ b/_src/_plugins/picture_tag.rb @@ -230,7 +230,7 @@ module Jekyll end # Return path relative to the site root for html - if production + if production == 'true' Pathname.new(File.join(cdnurl, baseurl, image_dest, image_dir, gen_name)).cleanpath else Pathname.new(File.join(baseurl, image_dest, image_dir, gen_name)).cleanpath From 2d03799c90a8e1859590a6ceffe96e001540b3c4 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Sat, 6 Sep 2014 14:37:39 +0200 Subject: [PATCH 08/14] more semantic config key --- Gruntfile.js | 2 +- _config.yml | 4 ++-- _src/_plugins/picture_tag.rb | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index dd207346..a3f69c2f 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -51,7 +51,7 @@ module.exports = function(grunt){ production: { options: { lsi: true, - raw: 'production: true\n' + raw: 'enable_cdnurl: true\n' } }, development: { diff --git a/_config.yml b/_config.yml index 6257aa5a..dfdc0ab2 100644 --- a/_config.yml +++ b/_config.yml @@ -16,8 +16,8 @@ url: https://kremalicious.com author: Matthias Kretschmann email: m@kretschmann.io cdnurl: https://d2jlreog722xe2.cloudfront.net -production: false -#cdnurl: https://cdn.kremalicious.com +enable_cdnurl: false + # Urls # -------------------- diff --git a/_src/_plugins/picture_tag.rb b/_src/_plugins/picture_tag.rb index 0f8cb657..ef1772f8 100755 --- a/_src/_plugins/picture_tag.rb +++ b/_src/_plugins/picture_tag.rb @@ -142,7 +142,7 @@ module Jekyll # Generate resized images instance.each { |key, source| - instance[key][:generated_src] = generate_image(source, site.source, site.dest, settings['source'], settings['output'], site.config['cdnurl'], site.config["baseurl"], site.config['production']) + instance[key][:generated_src] = generate_image(source, site.source, site.dest, settings['source'], settings['output'], site.config['cdnurl'], site.config["baseurl"], site.config['enable_cdnurl']) } # Construct and return tag @@ -169,7 +169,7 @@ module Jekyll picture_tag end - def generate_image(instance, site_source, site_dest, image_source, image_dest, cdnurl, baseurl, production) + def generate_image(instance, site_source, site_dest, image_source, image_dest, cdnurl, baseurl, enable_cdnurl) image = MiniMagick::Image.open(File.join(site_source, image_source, instance[:src])) digest = Digest::MD5.hexdigest(image.to_blob).slice!(0..5) @@ -230,7 +230,7 @@ module Jekyll end # Return path relative to the site root for html - if production == 'true' + if enable_cdnurl == 'true' Pathname.new(File.join(cdnurl, baseurl, image_dest, image_dir, gen_name)).cleanpath else Pathname.new(File.join(baseurl, image_dest, image_dir, gen_name)).cleanpath From 3271fd851a0ecacf9c4792a2dfe517a4a703a003 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Sat, 6 Sep 2014 14:57:49 +0200 Subject: [PATCH 09/14] remove hyphenation from code elements, fixes #18 --- _src/assets/styl/code.styl | 1 + 1 file changed, 1 insertion(+) diff --git a/_src/assets/styl/code.styl b/_src/assets/styl/code.styl index ea342ad6..a5f26150 100644 --- a/_src/assets/styl/code.styl +++ b/_src/assets/styl/code.styl @@ -10,6 +10,7 @@ pre, samp font-family: $font-family-monospace font-size: $font-size-small + hyphens: none code, kbd From ae74b86bdb784811cc230238f49751af34300ddb Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Sat, 6 Sep 2014 15:30:15 +0200 Subject: [PATCH 10/14] CDN all assets called from css files with grunt-cdn --- Gruntfile.js | 16 +++++++++++++++- package.json | 3 ++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index a3f69c2f..f8599ef3 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -205,6 +205,19 @@ module.exports = function(grunt){ assetsDirs: ['<%= config.build %>', '<%= config.build %>/assets/{css,js,img,fonts}'] } }, + + // CDN some assets + cdn: { + options: { + cdn: 'https://d2jlreog722xe2.cloudfront.net/assets/', + flatten: true + }, + dist: { + src: [ + '<%= config.build %>/assets/**/*.css' // CDN all assets called from css files + ] + } + }, // rsync stuff around rsync: { @@ -288,7 +301,8 @@ module.exports = function(grunt){ 'imagemin:touchicons', 'rsync:copy_build', 'rev', - 'usemin' + 'usemin', + 'cdn' ]); // Optimze media diff --git a/package.json b/package.json index 9acaccb5..30e1ddb5 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,8 @@ "grunt-jekyll": ">=0.4.0", "grunt-rsync": ">=0.2.1", "grunt-rev": ">=0.1.0", - "grunt-usemin": ">=2.0.2" + "grunt-usemin": ">=2.0.2", + "grunt-cdn": ">=0.5.6" }, "engines": { "node": ">=0.10.29" From bc4d6154f987a60d29995c03b8e06a0ee93e6fbd Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Sat, 6 Sep 2014 15:59:08 +0200 Subject: [PATCH 11/14] cdn all js assets calls --- _src/_includes/footer.html | 2 +- _src/_includes/head.html | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/_src/_includes/footer.html b/_src/_includes/footer.html index c8f4becd..0c270125 100644 --- a/_src/_includes/footer.html +++ b/_src/_includes/footer.html @@ -32,7 +32,7 @@ - + - - + From 5a7081ec2ad9e1268e691b4c14bcf208bedee84d Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Sat, 6 Sep 2014 16:16:25 +0200 Subject: [PATCH 12/14] fix enable_cdnurl check in picture tag --- _src/_plugins/picture_tag.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/_src/_plugins/picture_tag.rb b/_src/_plugins/picture_tag.rb index ef1772f8..bf4a3f3e 100755 --- a/_src/_plugins/picture_tag.rb +++ b/_src/_plugins/picture_tag.rb @@ -230,11 +230,12 @@ module Jekyll end # Return path relative to the site root for html - if enable_cdnurl == 'true' + if enable_cdnurl == true Pathname.new(File.join(cdnurl, baseurl, image_dest, image_dir, gen_name)).cleanpath else Pathname.new(File.join(baseurl, image_dest, image_dir, gen_name)).cleanpath end + end end end From b3f2ec7432ee24ddc4bdc42ec7133d1ff28001da Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Sat, 6 Sep 2014 16:35:31 +0200 Subject: [PATCH 13/14] revert cdn of js files --- _src/_includes/footer.html | 2 +- _src/_includes/head.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/_src/_includes/footer.html b/_src/_includes/footer.html index 0c270125..c8f4becd 100644 --- a/_src/_includes/footer.html +++ b/_src/_includes/footer.html @@ -32,7 +32,7 @@ - + - + From bcec3b2390d2489a62e2c4c3dbd05310e52043c2 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Sat, 6 Sep 2014 16:36:57 +0200 Subject: [PATCH 14/14] cdnurl as gruntConfig value --- Gruntfile.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index f8599ef3..25122be9 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -11,7 +11,8 @@ module.exports = function(grunt){ css: 'assets/css', js: 'assets/js', img: 'assets/img', - fonts: 'assets/fonts' + fonts: 'assets/fonts', + cdnurl: 'https://d2jlreog722xe2.cloudfront.net/assets/' } }; @@ -209,7 +210,7 @@ module.exports = function(grunt){ // CDN some assets cdn: { options: { - cdn: 'https://d2jlreog722xe2.cloudfront.net/assets/', + cdn: '<%= config.cdnurl %>', flatten: true }, dist: {