-
Notifications
You must be signed in to change notification settings - Fork 356
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Base64 encode fonts and images for PDF rendering
* Encode FontAwesome and Patternfly icon fonts * Add new image tag and path helpers to encode assets when necessary * Move pdf_generator_spec to main repo
- Loading branch information
Showing
27 changed files
with
150 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Encoded FontAwesome ttf | ||
*/ | ||
|
||
@font-face { | ||
font-family: 'FontAwesome'; | ||
src: url(<%= asset_data_uri("font-awesome/fontawesome-webfont.ttf") %>); | ||
font-weight: normal; | ||
font-style: normal; | ||
} | ||
|
||
/* | ||
* Encoded PatternFly ttf | ||
*/ | ||
|
||
@font-face { | ||
font-family: "PatternFlyIcons-webfont"; | ||
src:url(<%= asset_data_uri("patternfly/PatternFlyIcons-webfont.ttf") %>); | ||
font-weight: normal; | ||
font-style: normal; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
body {font: 12px/1.231 Arial,Helvetica,sans-serif; padding-top: 100px;} | ||
|
||
#xyz_main { | ||
position: absolute; | ||
top: 0px; | ||
left: 50%; | ||
height: 200px !important; | ||
width: 100px; | ||
margin-left: -55px; | ||
text-align: left; | ||
} | ||
|
||
#quadicon {color: #e3e4e4;float:left; height: 72px; padding: 0px 1px 1px 0px;position: relative;text-transform: none;width: 72px;} | ||
#quadicon img {border:0px;} | ||
|
||
.flobj { position: absolute;z-index: auto;width: 72px;} | ||
.flobj p { margin: 0 0 0 0;padding: 0;color: #e3e4e4;vertical-align: middle;text-align:center;text-transform: none;text-shadow: 0 0 3px #000;font: normal 16px OpenSansSemibold,Arial,Helvetica,sans-serif !important;} | ||
.a72 { padding: 3px 0 0 5px; width: 28px; height: 28px;font-size: 1.3em;line-height: 1.8em;} | ||
.b72 { padding: 3px 0 0 37px; width: 28px; height: 28px;font-size: 1.3em;line-height: 1.8em;} | ||
.c72 { padding: 38px 0 0 5px; width: 31px; height: 31px;font-size: 1.3em;line-height: 1.7em;} | ||
.d72 { padding: 38px 0 0 39px; width: 31px; height: 31px;font-size: 1.3em;line-height: 1.7em;} | ||
.e72 { padding: 6px 0 0 6px; width: 35px; height: 35px;font-size: 1.3em;line-height: 2em;} | ||
.f72 { padding: 22px 0 0 24px; width: 24px; height: 24px;} | ||
.g72 { padding: 16px 0 0 19px; width: 24px; height: 24px;} | ||
.b72 img {margin-top: -3px; width: 34px; height: 34px;} | ||
.a72 img,.c72 img,.d72 img{ width: 28px; height: 28px;} | ||
.f72 img,.f72 img { width: 24px; height: 24px;} | ||
.g72 img,.g72 img { width: 36px; height: 36px;} | ||
.e72 img { width: 60px; height: 60px;} | ||
|
||
dl{float:left;width:100%;} | ||
dl.col2 dd {float:left;width:47%;margin:0;margin-right:15px;padding:0;} | ||
|
||
table {background-color: #ededed;border-spacing: 1px;margin-bottom: 15px;width: 100%;color: #4b4b4b;} | ||
table tr th {height: 19px;padding: 4px;padding-left:10px;font: normal 12px Arial,Helvetica,sans-serif !important;line-height: 19px;} | ||
table tr td.label{font: 12px Arial,Helvetica,sans-serif;width: 33%; text-align: right;cursor: default;} | ||
table tr td {background: #fff; vertical-align: top; padding: 3px 6px 3px 6px} | ||
table tr td img {height: 16px;width: 16px;float: left; padding-right: 3px; } | ||
table tr.row0 td {background: #fff} | ||
table tr.row1 td {background: #f5f5f5} | ||
|
||
.b72 .stretch { | ||
background-repeat: no-repeat; | ||
width: 35px; | ||
height: 32px; | ||
margin: -3px 0 -2px 1px; | ||
border-top-right-radius: 15px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,4 @@ | ||
body {font: 12px/1.231 Arial,Helvetica,sans-serif; padding-top: 100px;} | ||
|
||
#xyz_main { | ||
position: absolute; | ||
top: 0px; | ||
left: 50%; | ||
height: 200px !important; | ||
width: 100px; | ||
margin-left: -55px; | ||
text-align: left; | ||
} | ||
|
||
#quadicon {color: #e3e4e4;float:left; height: 72px; padding: 0px 1px 1px 0px;position: relative;text-transform: none;width: 72px;} | ||
#quadicon img {border:0px;} | ||
|
||
.flobj { position: absolute;z-index: auto;width: 72px;} | ||
.flobj p { margin: 0 0 0 0;padding: 0;color: #e3e4e4;vertical-align: middle;text-align:center;text-transform: none;text-shadow: 0 0 3px #000;font: normal 16px OpenSansSemibold,Arial,Helvetica,sans-serif !important;} | ||
.a72 { padding: 3px 0 0 5px; width: 28px; height: 28px;font-size: 1.3em;line-height: 1.8em;} | ||
.b72 { padding: 3px 0 0 37px; width: 28px; height: 28px;font-size: 1.3em;line-height: 1.8em;} | ||
.c72 { padding: 38px 0 0 5px; width: 31px; height: 31px;font-size: 1.3em;line-height: 1.7em;} | ||
.d72 { padding: 38px 0 0 39px; width: 31px; height: 31px;font-size: 1.3em;line-height: 1.7em;} | ||
.e72 { padding: 6px 0 0 6px; width: 35px; height: 35px;font-size: 1.3em;line-height: 2em;} | ||
.f72 { padding: 22px 0 0 24px; width: 24px; height: 24px;} | ||
.g72 { padding: 16px 0 0 19px; width: 24px; height: 24px;} | ||
.b72 img {margin-top: -3px; width: 34px; height: 34px;} | ||
.a72 img,.c72 img,.d72 img{ width: 28px; height: 28px;} | ||
.f72 img,.f72 img { width: 24px; height: 24px;} | ||
.g72 img,.g72 img { width: 36px; height: 36px;} | ||
.e72 img { width: 60px; height: 60px;} | ||
|
||
dl{float:left;width:100%;} | ||
dl.col2 dd {float:left;width:47%;margin:0;margin-right:15px;padding:0;} | ||
|
||
table {background-color: #ededed;border-spacing: 1px;margin-bottom: 15px;width: 100%;color: #4b4b4b;} | ||
table tr th {height: 19px;padding: 4px;padding-left:10px;font: normal 12px Arial,Helvetica,sans-serif !important;line-height: 19px;} | ||
table tr td.label{font: 12px Arial,Helvetica,sans-serif;width: 33%; text-align: right;cursor: default;} | ||
table tr td {background: #fff; vertical-align: top; padding: 3px 6px 3px 6px} | ||
table tr td img {height: 16px;width: 16px;float: left; padding-right: 3px; } | ||
table tr.row0 td {background: #fff} | ||
table tr.row1 td {background: #f5f5f5} | ||
/* | ||
*= require pdf/_summary | ||
*= require pdf/_fontawesome | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
module ImageEncodeHelper | ||
def encodable_image_tag(source, options = {}) | ||
image_tag(encodable_image_source(source), options) | ||
end | ||
alias eimage_tag encodable_image_tag | ||
|
||
def encodable_image_source(source) | ||
if base64_encode_images? && source.present? | ||
base64_encoded_uri(source) | ||
else | ||
path_to_image(source) | ||
end | ||
end | ||
alias eimage_source encodable_image_source | ||
|
||
def base64_encode_images? | ||
@base64_encode_images | ||
end | ||
|
||
def base64_encoded_uri(source) | ||
asset = Rails.application.assets[source] | ||
|
||
if asset.content_type == 'image/svg+xml' | ||
encoding = 'charset=utf-8' | ||
data = CGI.escape(asset.source).gsub('+', '%20') | ||
else | ||
encoding = 'base64' | ||
data = Base64.encode64(asset.source) | ||
end | ||
|
||
"data:#{asset.content_type};#{encoding},#{data}" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
- if item[:icon] | ||
%i{:class => item[:icon], :title => item[:title]} | ||
- elsif item[:image] | ||
= image_tag(image_path(item[:image]), :alt => item[:title], :title => item[:title]) | ||
= encodable_image_tag(item[:image], :alt => item[:title], :title => item[:title]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
spec/views/layouts/listnav/_availability_zone.html.haml_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.