[Logilogi-svn] SF.net SVN: logilogi: [324] projects/ogog/trunk
Status: Beta
Brought to you by:
wybow
|
From: <wy...@us...> - 2007-05-25 18:04:41
|
Revision: 324
http://logilogi.svn.sourceforge.net/logilogi/?rev=324&view=rev
Author: wybow
Date: 2007-05-25 11:04:39 -0700 (Fri, 25 May 2007)
Log Message:
-----------
Added test for multiple images per post.
Modified Paths:
--------------
projects/ogog/trunk/app/models/post.rb
projects/ogog/trunk/lib/attribute_images.rb
projects/ogog/trunk/public/pub/test/image/post.html
projects/ogog/trunk/test/unit/post_test.rb
Added Paths:
-----------
projects/ogog/trunk/public/pub/test/image/img/sunshine.gif
Modified: projects/ogog/trunk/app/models/post.rb
===================================================================
--- projects/ogog/trunk/app/models/post.rb 2007-05-25 16:58:56 UTC (rev 323)
+++ projects/ogog/trunk/app/models/post.rb 2007-05-25 18:04:39 UTC (rev 324)
@@ -43,7 +43,7 @@
i_p.widths << a_i.width
i_p.heights << a_i.height
# returns the web-url it was saved to
- a_i.web_dir
+ a_i.web_filename
rescue
i_p.widths << 200
i_p.heights << 30
Modified: projects/ogog/trunk/lib/attribute_images.rb
===================================================================
--- projects/ogog/trunk/lib/attribute_images.rb 2007-05-25 16:58:56 UTC (rev 323)
+++ projects/ogog/trunk/lib/attribute_images.rb 2007-05-25 18:04:39 UTC (rev 324)
@@ -14,7 +14,7 @@
# For resizing images to fit, and for saving them.
class AttributeImages
- attr_reader :web_dir, :width, :height
+ attr_reader :web_filename, :width, :height
def initialize(class_name, id)
@dir = 'public/var/images/' + class_name + '/' + id.to_s
@@ -29,13 +29,15 @@
if img.size > 1
raise 'Animated, not doing that'
end
- img.resize_to_fit!(380,600)
+ if img.columns > 380 or img.rows > 600
+ img.resize_to_fit!(380,600)
+ end
@width = img.columns
@height = img.rows
Dir.mkdir(@dir) unless File.exists?(@dir)
filename = File.basename(original_location).gsub(/[^\w._-]/, '')
- @web_dir += '/' + filename
+ @web_filename = @web_dir + '/' + filename
img.write(@dir + '/' + filename)
end
Added: projects/ogog/trunk/public/pub/test/image/img/sunshine.gif
===================================================================
(Binary files differ)
Property changes on: projects/ogog/trunk/public/pub/test/image/img/sunshine.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: projects/ogog/trunk/public/pub/test/image/post.html
===================================================================
--- projects/ogog/trunk/public/pub/test/image/post.html 2007-05-25 16:58:56 UTC (rev 323)
+++ projects/ogog/trunk/public/pub/test/image/post.html 2007-05-25 18:04:39 UTC (rev 324)
@@ -1 +1 @@
-<p><img title='The 2600 joystick goes wireless... kinda' src='http://localhost:3000/pub/test/image/img/atari2600remote.jpg' border='0' alt='Atari 2600 remote'/></p><b>The Atari 2600 joystick is my favourite.</b><p>Alan explains, <em>"I wanted a simple remote that could be used to easily control the volume and mute the TV when the phone rings. I have replaced all of my remotes with a single Harmony 880 control which works great, but I wanted something a bit more cool to compliment it. Building the retro remote was fun and simple since the mini remote that I used was very easy to hack."</em>
+<p><img title='The 2600 joystick goes wireless... kinda' src='http://localhost:3000/pub/test/image/img/atari2600remote.jpg' border='0' alt='Atari 2600 remote'/></p><b>The Atari 2600 joystick is my favourite.</b><p>Alan explains, <em>"I wanted a simple remote that could be used to<img src="http://localhost:3000/pub/test/image/img/sunshine.gif">easily control the volume and mute the TV when the phone rings. I have replaced all of my remotes with a single Harmony 880 control which works great, but I wanted something a bit more cool to compliment it. Building the retro remote was fun and simple since the mini remote that I used was very easy to hack."</em>
Modified: projects/ogog/trunk/test/unit/post_test.rb
===================================================================
--- projects/ogog/trunk/test/unit/post_test.rb 2007-05-25 16:58:56 UTC (rev 323)
+++ projects/ogog/trunk/test/unit/post_test.rb 2007-05-25 18:04:39 UTC (rev 324)
@@ -22,10 +22,10 @@
p = Post.new(:feed => f, :title => 'test', :url => "http://localhost:3000/pub/test/image/post.html",
:body => Net::HTTP.get(URI.parse("http://localhost:3000/pub/test/image/post.html")), :published_at => Time.now)
assert p.save
- assert_equal '<p><img src="/var/images/post/' + p.id.to_s + '/atari2600remote.jpg" title="The 2600 joystick goes wireless... kinda" alt="Atari 2600 remote" height="276" width="380" /></p><b>The Atari 2600 joystick is my favourite.</b><p>Alan explains, <em>"I wanted a simple remote that could be used to easily control the volume and mute the TV when the phone rings. I have replaced all of my remotes with a single Harmony 880 control which works great, but I wanted something a bit more cool to compliment it. Building the retro remote was fun and simple since the mini remote that I used was very easy to hack."</em></p>',
+ assert_equal '<p><img src="/var/images/post/' + p.id.to_s + '/atari2600remote.jpg" title="The 2600 joystick goes wireless... kinda" alt="Atari 2600 remote" height="276" width="380" /></p><b>The Atari 2600 joystick is my favourite.</b><p>Alan explains, <em>"I wanted a simple remote that could be used to<img src="/var/images/post/' + p.id.to_s + '/sunshine.gif" height="100" width="100" />easily control the volume and mute the TV when the phone rings. I have replaced all of my remotes with a single Harmony 880 control which works great, but I wanted something a bit more cool to compliment it. Building the retro remote was fun and simple since the mini remote that I used was very easy to hack."</em></p>',
p.body
- assert_equal '<img src="/var/images/post/' + p.id.to_s + '/atari2600remote.jpg" title="The 2600 joystick goes wireless... kinda" alt="Atari 2600 remote" height="276" width="380" /><b>The Atari 2600 joystick is my favourite.</b>Alan explains, <em>"I wanted a simple remote that could be used to easily control the volume an</em>',
+ assert_equal '<img src="/var/images/post/' + p.id.to_s + '/atari2600remote.jpg" title="The 2600 joystick goes wireless... kinda" alt="Atari 2600 remote" height="276" width="380" /><b>The Atari 2600 joystick is my favourite.</b>Alan explains, <em>"I wanted a simple remote that could</em>',
p.snippet
assert File.exists?('public/var/images/post/' + p.id.to_s)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|