From d0b5be6eac73935ff04d86a9e91fbe33c650aeb0 Mon Sep 17 00:00:00 2001 From: CyberLeo Date: Sat, 8 Mar 2014 00:42:55 -0600 Subject: [PATCH] Render SVG to PNG to work aorund Firefox security constraints --- Rules | 8 ++- content/topbar.svg | 159 ++++++++++++++++++++++++------------------- layouts/default.html | 2 +- lib/svg2png.rb | 7 ++ 4 files changed, 104 insertions(+), 72 deletions(-) create mode 100644 lib/svg2png.rb diff --git a/Rules b/Rules index 872b6da..b5ff852 100644 --- a/Rules +++ b/Rules @@ -20,6 +20,7 @@ end compile '*' do if item.binary? # don’t filter binary items + filter :svg2png if item[:extension] == 'svg' else filter :erb layout 'default' @@ -33,7 +34,12 @@ end route '*' do if item.binary? # Write item with identifier /foo/ to /foo.ext - item.identifier.chop + '.' + item[:extension] + if item[:extension] == 'svg' + # SVGs are transcoded by :svg2png filter + item.identifier.chop + '.png' + else + item.identifier.chop + '.' + item[:extension] + end else # Write item with identifier /foo/ to /foo/index.html item.identifier + 'index.html' diff --git a/content/topbar.svg b/content/topbar.svg index 63a352b..f021f31 100644 --- a/content/topbar.svg +++ b/content/topbar.svg @@ -1,13 +1,11 @@ - - + + +@font-face { + font-family: 'Primalfont'; + font-weight: normal; + font-style: normal; + src: url('//cyberleo.0x44.me/fonts/primalf.eot'); + src: local('&#263a;'), + url('//cyberleo.0x44.me/fonts/primalf.eot#iefix') format('embedded-opentype'), + url('//cyberleo.0x44.me/fonts/primalf.svg#Primalfont') format('svg'), + url('//cyberleo.0x44.me/fonts/primalf.woff') format('woff'), + url('//cyberleo.0x44.me/fonts/primalf.ttf') format('truetype'); +} +@font-face { + font-family: 'Liberation Sans'; + font-weight: bold; + font-style: normal; + src: url('//cyberleo.0x44.me/fonts/LiberationSans-Bold.eot'); + src: url('//cyberleo.0x44.me/fonts/LiberationSans-Bold.eot?#iefix') format('embedded-opentype'), + url('//cyberleo.0x44.me/fonts/LiberationSans-Bold.svg#Primalfont') format('svg'), + url('//cyberleo.0x44.me/fonts/LiberationSans-Bold.woff') format('woff'), + url('//cyberleo.0x44.me/fonts/LiberationSans-Bold.ttf') format('truetype'); +} +@font-face { + font-family: 'Tahoma'; + font-weight: bold; + font-style: normal; + src: url('//cyberleo.0x44.me/fonts/tahomabd.eot'); + src: url('//cyberleo.0x44.me/fonts/tahomabd.eot?#iefix') format('embedded-opentype'), + url('//cyberleo.0x44.me/fonts/tahomabd.svg#Primalfont') format('svg'), + url('//cyberleo.0x44.me/fonts/tahomabd.woff') format('woff'), + url('//cyberleo.0x44.me/fonts/tahomabd.ttf') format('truetype'); +} + + - - - + - - - - + - - + About Us - About Us + Service Matrix - Service Matrix + Contact Us - Contact Us + Customer Login - Customer Login + Status - Status + - - - - - + - - - - CyberLeo.Net - CyberLeo.Net + CyberLeo.Net - - - + y="50.689972">CyberLeo.Net + + diff --git a/layouts/default.html b/layouts/default.html index 07ac0a5..b56b9ec 100644 --- a/layouts/default.html +++ b/layouts/default.html @@ -23,7 +23,7 @@ Customer Login Contact Us - Topbar + Topbar
diff --git a/lib/svg2png.rb b/lib/svg2png.rb new file mode 100644 index 0000000..571c5b0 --- /dev/null +++ b/lib/svg2png.rb @@ -0,0 +1,7 @@ +class Svg2Png < Nanoc::Filter + identifier :svg2png + type :binary + def run(filename, params={}) + raise Exception unless system("inkscape '--export-png=#{output_filename}' '#{filename}'") + end +end -- 2.42.0