From 4d81a1eb22b51eef485420be897bbea937d37f28 Mon Sep 17 00:00:00 2001 From: Alex Wood Date: Mon, 3 Aug 2015 15:39:53 -0400 Subject: [PATCH] Fix broken links to assets. Fixes #359. --- .../generator/template/darkfish/_head.rhtml | 2 +- .../generator/template/darkfish/css/fonts.css | 12 ++++++------ lib/rdoc/servlet.rb | 6 +++--- test/test_rdoc_servlet.rb | 19 +++++++++++-------- 4 files changed, 21 insertions(+), 18 deletions(-) diff --git a/lib/rdoc/generator/template/darkfish/_head.rhtml b/lib/rdoc/generator/template/darkfish/_head.rhtml index 70f1c188d6..2a1d0b89d7 100644 --- a/lib/rdoc/generator/template/darkfish/_head.rhtml +++ b/lib/rdoc/generator/template/darkfish/_head.rhtml @@ -3,7 +3,7 @@ <%= h @title %> diff --git a/lib/rdoc/generator/template/darkfish/css/fonts.css b/lib/rdoc/generator/template/darkfish/css/fonts.css index e9e721183b..57302b5183 100644 --- a/lib/rdoc/generator/template/darkfish/css/fonts.css +++ b/lib/rdoc/generator/template/darkfish/css/fonts.css @@ -17,7 +17,7 @@ font-weight: 400; src: local("Source Code Pro"), local("SourceCodePro-Regular"), - url("fonts/SourceCodePro-Regular.ttf") format("truetype"); + url("../fonts/SourceCodePro-Regular.ttf") format("truetype"); } @font-face { @@ -26,7 +26,7 @@ font-weight: 700; src: local("Source Code Pro Bold"), local("SourceCodePro-Bold"), - url("fonts/SourceCodePro-Bold.ttf") format("truetype"); + url("../fonts/SourceCodePro-Bold.ttf") format("truetype"); } /* @@ -46,7 +46,7 @@ font-weight: 300; src: local("Lato Light"), local("Lato-Light"), - url("fonts/Lato-Light.ttf") format("truetype"); + url("../fonts/Lato-Light.ttf") format("truetype"); } @font-face { @@ -55,7 +55,7 @@ font-weight: 300; src: local("Lato Light Italic"), local("Lato-LightItalic"), - url("fonts/Lato-LightItalic.ttf") format("truetype"); + url("../fonts/Lato-LightItalic.ttf") format("truetype"); } @font-face { @@ -64,7 +64,7 @@ font-weight: 700; src: local("Lato Regular"), local("Lato-Regular"), - url("fonts/Lato-Regular.ttf") format("truetype"); + url("../fonts/Lato-Regular.ttf") format("truetype"); } @font-face { @@ -73,7 +73,7 @@ font-weight: 700; src: local("Lato Italic"), local("Lato-Italic"), - url("fonts/Lato-RegularItalic.ttf") format("truetype"); + url("../fonts/Lato-RegularItalic.ttf") format("truetype"); } /* diff --git a/lib/rdoc/servlet.rb b/lib/rdoc/servlet.rb index ec8fd739f1..94c3d39626 100644 --- a/lib/rdoc/servlet.rb +++ b/lib/rdoc/servlet.rb @@ -114,8 +114,8 @@ def do_GET req, res case req.path when '/' then root req, res - when '/rdoc.css', '/js/darkfish.js', '/js/jquery.js', '/js/search.js', - %r%^/images/% then + when '/js/darkfish.js', '/js/jquery.js', '/js/search.js', + %r%^/css/%, %r%^/images/%, %r%^/fonts/% then asset :darkfish, req, res when '/js/navigation.js', '/js/searcher.js' then asset :json_index, req, res @@ -202,7 +202,7 @@ def error exception, req, res Error - #{ERB::Util.html_escape exception.class} - +

Error

diff --git a/test/test_rdoc_servlet.rb b/test/test_rdoc_servlet.rb index 143e2f225b..acd37cf402 100644 --- a/test/test_rdoc_servlet.rb +++ b/test/test_rdoc_servlet.rb @@ -65,14 +65,15 @@ def teardown def test_asset temp_dir do - now = Time.now + FileUtils.mkdir 'css' - open 'rdoc.css', 'w' do |io| io.write 'h1 { color: red }' end - File.utime now, now, 'rdoc.css' + now = Time.now + open 'css/rdoc.css', 'w' do |io| io.write 'h1 { color: red }' end + File.utime now, now, 'css/rdoc.css' @s.asset_dirs[:darkfish] = '.' - @req.path = 'rdoc.css' + @req.path = '/css/rdoc.css' @s.asset :darkfish, @req, @res @@ -94,11 +95,12 @@ def test_do_GET def test_do_GET_asset_darkfish temp_dir do - FileUtils.touch 'rdoc.css' + FileUtils.mkdir 'css' + FileUtils.touch 'css/rdoc.css' @s.asset_dirs[:darkfish] = '.' - @req.path = '/rdoc.css' + @req.path = '/css/rdoc.css' @s.do_GET @req, @res @@ -135,11 +137,12 @@ def test_do_GET_mount_path @s = RDoc::Servlet.new @server, @stores, @cache, '/mount/path' temp_dir do - FileUtils.touch 'rdoc.css' + FileUtils.mkdir 'css' + FileUtils.touch 'css/rdoc.css' @s.asset_dirs[:darkfish] = '.' - @req.path = '/mount/path/rdoc.css' + @req.path = '/mount/path/css/rdoc.css' @s.do_GET @req, @res