Skip to content
This repository has been archived by the owner on Feb 1, 2020. It is now read-only.

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tdreyno committed Oct 6, 2009
1 parent d1fdd23 commit 8fed2c1
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 14 deletions.
46 changes: 45 additions & 1 deletion lib/slickmap.rb
@@ -1 +1,45 @@
require File.join(File.dirname(__FILE__), 'slickmap', 'compass_plugin')
require 'base64'
require File.join(File.dirname(__FILE__), 'slickmap', 'compass_plugin')

module Compass::SlickmapImage
def slickmap_image(path, mime_type = nil)
path = path.value
real_path = File.join(File.dirname(__FILE__), "..", "templates", "project", "images", path)
url = "url('data:#{compute_mime_type(path,mime_type)};base64,#{data(real_path)}')"
Sass::Script::String.new(url)
end

private
def compute_mime_type(path, mime_type)
return mime_type if mime_type
case path
when /\.png$/i
'image/png'
when /\.jpe?g$/i
'image/jpeg'
when /\.gif$/i
'image/gif'
when /\.([a-zA-Z]+)$/
"image/#{Regexp.last_match(1).downcase}"
else
raise Compass::Error, "A mime type could not be determined for #{path}, please specify one explicitly."
end
end

def data(real_path)
if File.readable?(real_path)
Base64.encode64(File.read(real_path)).gsub("\n","")
else
raise Compass::Error, "File not found or cannot be read: #{real_path}"
end
end
end


module ::Sass::Script::Functions
include Compass::SlickmapImage
end

class ::Sass::Script::Functions::EvaluationContext
include ::Sass::Script::Functions
end
2 changes: 1 addition & 1 deletion lib/slickmap/compass_plugin.rb
Expand Up @@ -2,4 +2,4 @@
options[:stylesheets_directory] = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'sass'))
options[:templates_directory] = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'templates'))

Compass::Frameworks.register('slickmap', options)
Compass::Frameworks.register('slickmap', options)
23 changes: 11 additions & 12 deletions sass/_slickmap.sass
@@ -1,5 +1,4 @@
@import compass/utilities/general/reset.sass
!slickmap_image_prefix ||= ""

=slickmap(!body_selector = "body")
+global-reset
Expand Down Expand Up @@ -49,7 +48,7 @@
clear: left
margin-top: 0
padding: 10px 0 0 0
background= image_url("#{!slickmap_image_prefix}vertical-line.png") "center" "bottom" "repeat-y"
background= slickmap_image("vertical-line.png") "center" "bottom" "repeat-y"
a
background-color: #cee3ac
border-color: #b8da83
Expand All @@ -59,7 +58,7 @@
&:first-child
padding-top: 30px
&:last-child
background= image_url("#{!slickmap_image_prefix}vertical-line.png") "center" "bottom" "repeat-y"
background= slickmap_image("vertical-line.png") "center" "bottom" "repeat-y"

a:link:before, a:visited:before
color: #8faf5c
Expand All @@ -70,10 +69,10 @@
width: 100%
float: right
padding: 9px 0 10px 0
background= #fff image_url("#{!slickmap_image_prefix}L3-ul-top.png") "center" "top" "no-repeat"
background= #fff slickmap_image("L3-ul-top.png") "center" "top" "no-repeat"

li
background= image_url("#{!slickmap_image_prefix}L3-center.png") "left" "center" "no-repeat"
background= slickmap_image("L3-center.png") "left" "center" "no-repeat"
padding: 5px 0
a
background-color: #fff7aa
Expand All @@ -87,20 +86,20 @@
border-color: #d1b62c
&:first-child
padding: 15px 0 5px 0
background= image_url("#{!slickmap_image_prefix}L3-li-top.png") "left" "center" "no-repeat"
background= slickmap_image("L3-li-top.png") "left" "center" "no-repeat"
&:last-child
background= image_url("#{!slickmap_image_prefix}L3-bottom.png") "left" "center" "no-repeat"
background= slickmap_image("L3-bottom.png") "left" "center" "no-repeat"
a:link:before, a:visited:before
color: #ccae14
font-size: 9px

li
float: left
background= image_url("#{!slickmap_image_prefix}L1-center.png") "center" "top" "no-repeat"
background= slickmap_image("L1-center.png") "center" "top" "no-repeat"
padding: 30px 0
margin-top: -30px
&:last-child
background= image_url("#{!slickmap_image_prefix}L1-right.png") "center" "top" "no-repeat"
background= slickmap_image("L1-right.png") "center" "top" "no-repeat"
a
margin: 0 20px 0 0
padding: 10px 0
Expand All @@ -109,7 +108,7 @@
font-weight: bold
text-align: center
color: black
background= #c3eafb image_url("#{!slickmap_image_prefix}white-highlight.png") "top" "left" "repeat-x"
background= #c3eafb slickmap_image("white-highlight.png") "top" "left" "repeat-x"
border: 2px solid #b5d9ea
-moz-border-radius: 5px
-webkit-border-radius: 5px
Expand All @@ -122,7 +121,7 @@
=slickmap-primary-nav-home
display: block
float: none
background= #fff image_url("#{!slickmap_image_prefix}L1-left.png") "center" "bottom" "no-repeat"
background= #fff slickmap_image("L1-left.png") "center" "bottom" "no-repeat"
position: relative
z-index: 2
padding: 0 0 30px 0
Expand All @@ -143,7 +142,7 @@
font-weight: bold
text-align: center
color: black
background= #fff7aa image_url("#{!slickmap_image_prefix}white-highlight.png") "top" "left" "repeat-x"
background= #fff7aa slickmap_image("white-highlight.png") "top" "left" "repeat-x"
-moz-border-radius: 5px
-webkit-border-radius: 5px
-webkit-box-shadow: rgba(0,0,0,0.5) 2px 2px 2px
Expand Down

0 comments on commit 8fed2c1

Please sign in to comment.