[macruby-changes] [556] MacRuby/trunk/sample-macruby/FlickrDemo/FlickrDemoController.rb

source_changes at macosforge.org source_changes at macosforge.org
Thu Sep 4 18:50:09 PDT 2008


Revision: 556
          http://trac.macosforge.org/projects/ruby/changeset/556
Author:   lsansonetti at apple.com
Date:     2008-09-04 18:50:09 -0700 (Thu, 04 Sep 2008)
Log Message:
-----------
open the flickr page when double clicking

Modified Paths:
--------------
    MacRuby/trunk/sample-macruby/FlickrDemo/FlickrDemoController.rb

Modified: MacRuby/trunk/sample-macruby/FlickrDemo/FlickrDemoController.rb
===================================================================
--- MacRuby/trunk/sample-macruby/FlickrDemo/FlickrDemoController.rb	2008-09-05 01:23:09 UTC (rev 555)
+++ MacRuby/trunk/sample-macruby/FlickrDemo/FlickrDemoController.rb	2008-09-05 01:50:09 UTC (rev 556)
@@ -76,15 +76,17 @@
     photo = @cache[index]
     if photo.nil? 
       entry = @results[index]
-      url = entry.content.HTMLString.scan(/<img\s+src="([^"]+)"/)[0][0] # " stupid Xcode
-      photo = Photo.new(url)
+      html = entry.content.HTMLString
+      link = html.scan(/<a\s+href="([^"]+)" title/)[0][0] # " stupid Xcode parser
+      url = html.scan(/<img\s+src="([^"]+)"/)[0][0] # " stupid Xcode parser
+      photo = Photo.new(url, link)
       @cache[index] = photo
     end
     return photo
   end
 
   def imageBrowser(browser, cellWasDoubleClickedAtIndex:index)
-    NSWorkspace.sharedWorkspace.openURL @cache[index].url
+    NSWorkspace.sharedWorkspace.openURL @cache[index].link
   end
   
   private
@@ -103,11 +105,12 @@
 end
 
 class Photo
-  attr_reader :url
+  attr_reader :url, :link
   
-  def initialize(url)
+  def initialize(url, link)
     @urlString = url
     @url = NSURL.alloc.initWithString url
+    @link = NSURL.alloc.initWithString link
   end
   
   # IKImageBrowserItem protocol conformance
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macruby-changes/attachments/20080904/4e93ed9e/attachment.html 


More information about the macruby-changes mailing list