adding basic support for screenshots.
This commit is contained in:
parent
622e971e52
commit
b3ac631a55
3 changed files with 28 additions and 2 deletions
|
@ -10,7 +10,9 @@ class ScreenshotController < ApplicationController
|
|||
end
|
||||
|
||||
def single
|
||||
@screenshot = "x"
|
||||
@fpath = "screenshots/" + params[:filename]
|
||||
fabsolute = RAILS_ROOT + "/public/images/screenshots/" + params[:filename]
|
||||
@fsize = IO.read(fabsolute)[0x10..0x18].unpack('NN')
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
<%
|
||||
width = nil ; height = nil ;
|
||||
if (@fsize[0] >= @fsize[1]) then
|
||||
if (@fsize[0] >= 500) then
|
||||
width = 500
|
||||
else
|
||||
width = @fsize[0]
|
||||
end
|
||||
else
|
||||
if (@fsize[1] >= 500) then
|
||||
height = 500
|
||||
width = (( @fsize[0] / @fsize[1].to_f ) * 500).to_i
|
||||
else
|
||||
height = @fsize[1]
|
||||
end
|
||||
end
|
||||
|
||||
%>
|
||||
|
||||
<div class="box">
|
||||
<div class="border" style="width:<%= width %>;">
|
||||
<%= image_tag @fpath , :width => width , :height => height%>
|
||||
</div>
|
||||
</div>
|
|
@ -43,7 +43,7 @@ ActionController::Routing::Routes.draw do |map|
|
|||
map.connect 'f/:id', :controller => "flickr", :action => "photo"
|
||||
|
||||
map.connect 's/i', :controller => "screenshot", :action => "index"
|
||||
map.connect 's/:id', :controller => "screenshot", :action => "single"
|
||||
map.connect 's/:filename', :controller => "screenshot", :action => "single", :requirements => { :filename => /.*/ }
|
||||
|
||||
map.connect 'i/:action', :controller => "info"
|
||||
|
||||
|
|
Loading…
Reference in a new issue