2012-03-29 19:43:07 +02:00
|
|
|
require 'image_size'
|
2012-04-19 00:17:54 +02:00
|
|
|
require 'set'
|
2012-03-29 19:43:07 +02:00
|
|
|
|
2012-04-16 15:33:11 +02:00
|
|
|
def image(name, title="", link=nil)
|
2012-04-11 12:04:41 +02:00
|
|
|
# all images are stored at content/pigs and only the main site routes them
|
2012-04-18 02:08:04 +02:00
|
|
|
ret = ""
|
2012-04-11 12:04:41 +02:00
|
|
|
|
2012-04-18 02:08:04 +02:00
|
|
|
# read image size
|
2012-04-19 00:17:54 +02:00
|
|
|
img = ImageSize.new IO.read("content_#{$site}/pigs/#{name}")
|
|
|
|
|
2012-04-18 02:08:04 +02:00
|
|
|
# if it's too large, redirect to smaller version (which is generated with 'nanoc images')
|
|
|
|
if img.width > 400 and not name.end_with? ".gif"
|
|
|
|
link = "/pigs/#{name}" if link.nil? # link to big version
|
|
|
|
name.gsub! /^(.+)\.(\w+)$/, '\1_small.\2'
|
2012-04-19 00:17:54 +02:00
|
|
|
img = ImageSize.new IO.read("content_#{$site}/pigs/#{name}") # re-read image
|
2012-04-18 02:08:04 +02:00
|
|
|
end
|
2012-04-16 15:33:11 +02:00
|
|
|
|
|
|
|
ret += "<a href='#{link}'>" unless link.nil?
|
2012-04-18 03:47:38 +02:00
|
|
|
ret += "<img src='/pigs/#{name}' height='#{img.height}' width='#{img.width}' title=\"#{title}\" alt=\"#{title}\"/>"
|
2012-04-16 15:33:11 +02:00
|
|
|
ret += "</a>" unless link.nil?
|
2012-04-18 03:47:38 +02:00
|
|
|
|
2012-04-16 15:33:11 +02:00
|
|
|
ret
|
2012-03-29 19:43:07 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def youtube(url)
|
|
|
|
<<EOL
|
|
|
|
<div align="center">
|
|
|
|
<object width="420" height="315">
|
|
|
|
<param name="movie" value="#{url}"></param>
|
|
|
|
<param name="allowFullScreen" value="true"></param>
|
|
|
|
<param name="allowscriptaccess" value="always"></param>
|
|
|
|
<embed src="#{url}" type="application/x-shockwave-flash" width="420" height="315" allowscriptaccess="always" allowfullscreen="true"></embed>
|
|
|
|
</object>
|
|
|
|
</div>
|
|
|
|
EOL
|
|
|
|
end
|
|
|
|
|
|
|
|
def dailymotion(url)
|
|
|
|
<<EOL
|
|
|
|
<div align="center">
|
|
|
|
<object width="480" height="327">
|
|
|
|
<param name="movie" WWvalue="#{url}" />
|
|
|
|
<param name="allowFullScreen" value="true" />
|
|
|
|
<param name="allowScriptAccess" value="always" />
|
|
|
|
<embed type="application/x-shockwave-flash" width="480" height="327" src="#{url}" allowfullscreen="true" allowscriptaccess="always"></embed>
|
|
|
|
</object>
|
|
|
|
</div>
|
|
|
|
EOL
|
|
|
|
end
|
|
|
|
|
|
|
|
def google_video(url)
|
|
|
|
<<EOL
|
|
|
|
<div align="center">
|
|
|
|
<object id="VideoPlayback" style="width: 400px; height: 326px;" width="100" height="100" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0">
|
|
|
|
<param name="src" value="#{url}" />
|
|
|
|
<param name="allowfullscreen" value="true" />
|
|
|
|
<embed id="VideoPlayback" style="width: 400px; height: 326px;" width="100" height="100" type="application/x-shockwave-flash" src="#{url}" allowfullscreen="true" />
|
|
|
|
</object>
|
|
|
|
</div>
|
|
|
|
EOL
|
|
|
|
end
|
|
|
|
|
2012-04-16 19:28:41 +02:00
|
|
|
def vimeo(url)
|
|
|
|
<<EOL
|
|
|
|
<div align="center">
|
|
|
|
<iframe src="#{url}?portrait=0&color=000000" frameborder="0" width="400" height="320">
|
|
|
|
</iframe>
|
|
|
|
</div>
|
|
|
|
EOL
|
|
|
|
end
|