Commit 484367d6 authored by Julius Volz's avatar Julius Volz

Merge pull request #374 from prometheus/cachebusting

Add cachebusting fingerprints to asset files.
parents 597dce44 e40149e3
......@@ -12,3 +12,4 @@ gem 'builder'
gem 'rb-inotify', :require => false
gem 'rb-fsevent', :require => false
gem 'rb-fchange', :require => false
gem 'nanoc-cachebuster'
......@@ -42,6 +42,8 @@ GEM
multi_json (1.11.2)
nanoc (3.7.3)
cri (~> 2.3)
nanoc-cachebuster (0.3.1)
nanoc (>= 3.3.0)
nokogiri (1.6.3.1)
mini_portile (= 0.6.0)
posix-spawn (0.3.9)
......@@ -75,6 +77,7 @@ DEPENDENCIES
guard-nanoc
kramdown
nanoc
nanoc-cachebuster
nokogiri
pygments.rb
rb-fchange
......
......@@ -17,8 +17,13 @@ compile '/assets/*' do
end
route '/assets/*' do
# /assets/foo.html/ → /foo.html
item.identifier[0..-2]
# Cachebuster currently doesn't fingerprint all needed files (SVG and font
# extensions are missing), so we need to differentiate here.
if Nanoc::Cachebuster::FILETYPES_TO_FINGERPRINT.include?(item[:extension])
item.identifier[0..-(3 + item[:extension].length)] + fingerprint(item[:filename]) + '.' + item[:extension]
else
item.identifier[0..-2]
end
end
route '/README/' do
......@@ -40,7 +45,6 @@ compile '*' do
if item[:title] == 'README.md'
# Don't filter; this should propagate verbatim to the output GitHub repository.
elsif item[:extension] == 'md'
#filter :kramdown
filter :redcarpet, options: {filter_html: true, autolink: true, no_intraemphasis: true, fenced_code_blocks: true, gh_blockcode: true, tables: true}, renderer_options: {with_toc_data: true}
filter :add_anchors
filter :bootstrappify
......@@ -61,6 +65,8 @@ compile '*' do
else
layout 'default'
end
filter :cache_buster
end
route '/blog/' do
......@@ -78,7 +84,7 @@ end
route '*' do
if item[:extension] == 'css'
# Write item with identifier /foo/ to /foo.css
item.identifier.chop + '.css'
item.identifier.chop + fingerprint(item[:filename]) + '.css'
elsif item.binary?
# Write item with identifier /foo/ to /foo.ext
item.identifier.chop + '.' + item[:extension]
......
......@@ -39,7 +39,7 @@
<link href="/assets/bootstrap-3.3.1/css/bootstrap.min.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="/assets/docs.css" rel="stylesheet">
<link href="/css/docs.css" rel="stylesheet">
<!-- Custom Fonts -->
<link href="/assets/font-awesome-4.2.0/css/font-awesome.min.css" rel="stylesheet" type="text/css">
......
# All files in the 'lib' directory will be loaded
# before nanoc starts compiling.
require 'nanoc/cachebuster'
include Nanoc::Helpers::LinkTo
include Nanoc::Helpers::Rendering
include Nanoc3::Helpers::Blogging
include Nanoc3::Helpers::Tagging
include Nanoc::Helpers::CacheBusting
module BlogHelper
def get_pretty_date(post)
......@@ -18,7 +21,7 @@ module BlogHelper
"<div class='read-more'><a href='#{post.path}'>Continue reading &rsaquo;</a></div>"
end
return content
end
end
end
include BlogHelper
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment