-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
36 additions
and
0 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,14 @@ | ||
module Whereuat | ||
module Assets | ||
class Context | ||
def bg_url | ||
Image.new(images_root+'uat-bg.png') | ||
end | ||
|
||
def images_root | ||
@images_root ||= Whereuat.dev_root+'images' | ||
end | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
module Whereuat | ||
module Assets | ||
class Image | ||
def initialize(path) | ||
@path = Pathname(path) | ||
end | ||
|
||
def to_s | ||
"data:#{content_type};base64," + ([@path.read].pack("m").gsub("\n",'')) | ||
end | ||
|
||
def content_type | ||
case @path.to_s[/\.([^\.]+)$/,1] | ||
when 'png' | ||
'image/png' | ||
when 'gif' | ||
'image/gif' | ||
end | ||
end | ||
end | ||
end | ||
end |