Changeset 2925

Show
Ignore:
Timestamp:
05/28/05 17:15:14 (4 years ago)
Author:
morris
Message:

Add support for Atom streams for Flickr, in addition to RSS streams

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • Footagehead/trunk/English.lproj/ReleaseNotes.rtf

    r2919 r2925  
    1919\f1\b0 \cf0 \ 
    2020Footagehead is a fast local and remote image browser. With it, you can quickly navigate your local disks and display pictures in a window, or as a slideshow. Footagehead can also open images remotely from the web.\ 
     21\ 
     22 
     23\f0\b \cf2 What formats are supported? 
     24\f1\b0 \cf0 \ 
     25Footagehead supports all native Mac OS X image formats. That is, anything that Preview can open, Footagehead should also be able to open.\ 
     26\ 
     27 
     28\f0\b \cf2 What remote browsing schemes are supported? 
     29\f1\b0 \cf0 \ 
     30Footagehead can browse the following types of sites remotely:\ 
     31\ 
     32- Single image ( 
     33\f2\i http://www.zankasoftware.com/images/footagehead-screen1.jpg 
     34\f1\i0 )\ 
     35- HTML page with inline images or links to images ( 
     36\f2\i http://www.apple.com/macosx/ 
     37\f1\i0 )\ 
     38- Range of images ( 
     39\f2\i http://images.ucomics.com/comics/ch/1994/ch9405[01-30].gif 
     40\f1\i0 )\ 
     41- Flickr photo stream ( 
     42\f2\i http://www.flickr.com/services/feeds/photos_public.gne?id=81007463@N00&tags=knockoff&format=rss_200 
     43\f1\i0 )\ 
    2144\ 
    2245 
     
    5578- Fast thumbnail generation for JPEG files\ 
    5679- Spotlight image search support\ 
    57 - Flickr RSS stream support\ 
     80- Flickr RSS/Atom stream support\ 
    5881- Zoom command\ 
    5982 
  • Footagehead/trunk/FHFlickrHandler.h

    r2919 r2925  
    2929#import "FHHandler.h" 
    3030 
    31 @class FHRSSParser; 
     31@class FHStreamParser; 
    3232 
    3333@interface FHFlickrHandler : FHHandler { 
    34         FHRSSParser                           *_parser; 
     34        FHStreamParser                                *_parser; 
    3535} 
    3636 
  • Footagehead/trunk/FHFlickrHandler.m

    r2920 r2925  
    3434 
    3535+ (BOOL)handlesURL:(ZAURL *)url isPrimary:(BOOL)primary { 
    36         return ([[url host] containsSubstring:@"flickr.com"] && [[url path] containsSubstring:@"format=rss_200"]); 
     36        return ([[url host] containsSubstring:@"flickr.com"] && [[url path] hasPrefix:@"/services/feeds/"]); 
    3737} 
    3838 
     
    5050        self = [super initWithURL:url hint:hint]; 
    5151         
    52         _parser = [[FHRSSParser alloc] initParserWithURL:[self URL]]; 
     52        _parser = [[FHStreamParser alloc] initParserWithURL:[self URL]]; 
    5353         
    5454        if(!_parser) { 
     
    7777        NSDictionary    *item; 
    7878        NSMutableString *address; 
    79         NSString                *name, *description, *string; 
     79        NSString                *name, *content, *string; 
    8080        NSScanner               *scanner; 
    8181        FHFile                  *file; 
     
    9090                        item = [items objectAtIndex:i]; 
    9191                        name = [item objectForKey:@"title"]; 
    92                         description = [item objectForKey:@"description"]; 
     92                        content = [item objectForKey:[[_parser class] itemContentKey]]; 
    9393                         
    94                         scanner = [NSScanner scannerWithString:description]; 
     94                        scanner = [NSScanner scannerWithString:content]; 
    9595 
    9696                        if(![scanner scanUpToString:@"img src=\"" intoString:NULL]) 
  • Footagehead/trunk/FHHandler.m

    r2919 r2925  
    346346                class = [FHHandlerHints objectForKey:[NSNumber numberWithInt:hint]]; 
    347347                 
    348                 return [[class alloc] initWithURL:url hint:hint]; 
     348                return [[class allocWithZone:zone] initWithURL:url hint:hint]; 
    349349        } 
    350350         
     
    355355                 
    356356                if([class handlesURL:url isPrimary:YES]) 
    357                         return [[class alloc] initWithURL:url hint:hint]; 
     357                        return [[class allocWithZone:zone] initWithURL:url hint:hint]; 
    358358        } 
    359359         
     
    362362                 
    363363                if([class handlesURL:url isPrimary:NO]) 
    364                         return [[class alloc] initWithURL:url hint:hint]; 
     364                        return [[class allocWithZone:zone] initWithURL:url hint:hint]; 
    365365        } 
    366366         
  • Footagehead/trunk/FHRSSStreamParser.h

    r2919 r2925  
    2727 */ 
    2828 
    29 @interface FHRSSParser : ZAObject { 
    30         CFXMLTreeRef                    _tree; 
     29#import "FHStreamParser.h" 
     30 
     31@interface FHRSSStreamParser : FHStreamParser { 
    3132        CFXMLTreeRef                    _channelTree; 
    32          
    33         NSMutableDictionary             *_header; 
    34         NSMutableArray                  *_items; 
    3533} 
    3634 
    37  
    38 - (id)initParserWithData:(NSData *)data; 
    39 - (id)initParserWithURL:(ZAURL *)url; 
    40  
    41 - (NSDictionary *)header; 
    42 - (NSArray *)items; 
    43  
    4435@end 
  • Footagehead/trunk/FHRSSStreamParser.m

    r2919 r2925  
    2727 */ 
    2828 
    29 #import "FHRSSParser.h" 
     29#import "FHRSSStreamParser.h" 
    3030 
    31 @interface FHRSSParser(Private) 
     31@interface FHRSSStreamParser(Private) 
    3232 
    3333- (void)parseHeader; 
     
    3535- (void)parseItems; 
    3636 
    37 - (CFXMLTreeRef)treeWithName:(NSString *)name inTree:(CFXMLTreeRef)tree; 
    38 - (NSString *)valueOfTree: (CFXMLTreeRef) tree; 
    39  
    4037@end 
    4138 
    4239 
    43 @implementation FHRSSParser 
     40@implementation FHRSSStreamParser 
    4441 
    45 - (id)initParserWithData:(NSData *)data { 
     42+ (NSString *)itemContentKey { 
     43        return @"description"; 
     44
     45 
     46 
     47 
     48#pragma mark - 
     49 
     50- (id)initParserWithTree:(CFXMLTreeRef)tree { 
    4651        CFXMLTreeRef    rssTree; 
    4752         
    48         self = [super init]; 
    49          
    50         _tree = CFXMLTreeCreateFromData(kCFAllocatorDefault, (CFDataRef) data, 
    51                                                                         NULL, kCFXMLParserSkipWhitespace, 
    52                                                                         kCFXMLNodeCurrentVersion); 
    53          
    54         if(!_tree) { 
    55                 [self release]; 
    56                  
    57                 return NULL; 
    58         } 
     53        self = [super initParserWithTree:tree]; 
    5954         
    6055        rssTree = [self treeWithName:@"rss" inTree:_tree]; 
     
    8176         
    8277        return self; 
    83 } 
    84  
    85  
    86  
    87 - (id)initParserWithURL:(ZAURL *)url { 
    88         NSData          *data; 
    89          
    90         data = [[NSData alloc] initWithContentsOfURL:[url URL]]; 
    91         self = [self initParserWithData:data]; 
    92         [data release]; 
    93          
    94         return self; 
    95 } 
    96  
    97  
    98  
    99 - (void) dealloc { 
    100         CFRelease(_tree); 
    101          
    102         [_header release]; 
    103         [_items release]; 
    104  
    105         [super dealloc]; 
    10678} 
    10779 
     
    134106        unsigned int    i, count; 
    135107         
     108        _header = [[NSMutableDictionary alloc] initWithCapacity:10]; 
    136109        count = CFTreeGetChildCount(_channelTree); 
    137         _header = [[NSMutableDictionary alloc] initWithCapacity:count]; 
    138110                 
    139111        for(i = 0; i < count; i++) { 
     
    191163                 
    192164                itemCount = CFTreeGetChildCount(tree); 
    193                 items = [[NSMutableDictionary alloc] initWithCapacity: itemCount]; 
     165                items = [[NSMutableDictionary alloc] initWithCapacity:itemCount]; 
    194166                 
    195167                for(j = 0; j < itemCount; j++) { 
     
    205177} 
    206178 
    207  
    208  
    209 - (CFXMLTreeRef)treeWithName:(NSString *)name inTree:(CFXMLTreeRef)tree { 
    210         NSString                *itemName; 
    211         CFXMLTreeRef    child; 
    212         CFXMLNodeRef    node; 
    213         unsigned int    i, count; 
    214          
    215         count = CFTreeGetChildCount(tree); 
    216          
    217         for(i = 0; i < count; i++) { 
    218                 child           = CFTreeGetChildAtIndex(tree, i); 
    219                 node            = CFXMLTreeGetNode(child); 
    220                 itemName        = (NSString *) CFXMLNodeGetString(node); 
    221                  
    222                 if([itemName isEqualToString:name]) 
    223                         return child; 
    224         } 
    225          
    226         return NULL; 
    227 } 
    228  
    229  
    230  
    231 - (NSString *)valueOfTree:(CFXMLTreeRef)tree { 
    232         NSMutableString         *value; 
    233         NSString                        *itemName; 
    234         CFXMLTreeRef            itemTree; 
    235         CFXMLNodeRef            itemNode; 
    236         unsigned int            i, count; 
    237          
    238         value = [NSMutableString string]; 
    239         count = CFTreeGetChildCount (tree); 
    240          
    241         for (i = 0; i < count; i++) { 
    242                 itemTree = CFTreeGetChildAtIndex (tree, i); 
    243                 itemNode = CFXMLTreeGetNode (itemTree); 
    244                 itemName = (NSString *) CFXMLNodeGetString (itemNode); 
    245                  
    246                 if(itemName) { 
    247                         if(CFXMLNodeGetTypeCode(itemNode) == kCFXMLNodeTypeEntityReference) { 
    248                                 if ([itemName isEqualToString:@"lt"]) 
    249                                         itemName = @"<"; 
    250                                 else if ([itemName isEqualToString:@"gt"]) 
    251                                         itemName = @">"; 
    252                                 else if ([itemName isEqualToString:@"quot"]) 
    253                                         itemName = @"\""; 
    254                                 else if ([itemName isEqualToString:@"amp"]) 
    255                                         itemName = @"&"; 
    256                         } 
    257                                                  
    258                         [value appendString:itemName]; 
    259                 } 
    260         } 
    261          
    262         return value; 
    263 } 
    264  
    265179@end 
  • Footagehead/trunk/Footagehead.xcode/project.pbxproj

    r2919 r2925  
    135135                                A5B1F60D067B3A8000111D0A, 
    136136                                A5B1F7B9067B43C300111D0A, 
     137                                A5E7CC4B0848B02B00F1E98C, 
    137138                                A5EE94DA055AA5EE00CC2AD8, 
    138139                                29B97315FDCFA39411CA2CEA, 
     
    15371538                                A5092F57083E7812006646D1, 
    15381539                                77BD99520760B7380007D034, 
     1540                                A5E7CC520848B05300F1E98C, 
     1541                                A5E7CC610848B09000F1E98C, 
    15391542                        ); 
    15401543                        isa = PBXSourcesBuildPhase; 
     
    19041907                        files = ( 
    19051908                                A54D42DD07663AA300227EBE, 
     1909                                A5E7CC510848B05300F1E98C, 
     1910                                A5E7CC620848B09000F1E98C, 
    19061911                        ); 
    19071912                        isa = PBXCopyFilesBuildPhase; 
     
    20022007                                A5B1F7BA067B440E00111D0A, 
    20032008                                A5B1F7BB067B440E00111D0A, 
    2004                                 A5E7CA4C0847CBA000F1E98C, 
    2005                                 A5E7CA4D0847CBA000F1E98C, 
    20062009                                A587DF7B055AA418005D2097, 
    20072010                                A587DF76055AA418005D2097, 
     
    22372240                        isa = PBXFileReference; 
    22382241                        lastKnownFileType = sourcecode.c.objc; 
    2239                         path = FHRSSParser.m; 
     2242                        path = FHRSSStreamParser.m; 
    22402243                        refType = 4; 
    22412244                        sourceTree = "<group>"; 
     
    22452248                        isa = PBXFileReference; 
    22462249                        lastKnownFileType = sourcecode.c.h; 
    2247                         path = FHRSSParser.h; 
     2250                        path = FHRSSStreamParser.h; 
    22482251                        refType = 4; 
    22492252                        sourceTree = "<group>"; 
     
    22642267                A5E7CC3B0847E7C900F1E98C = { 
    22652268                        fileRef = A5E7CC3A0847E7C900F1E98C; 
     2269                        isa = PBXBuildFile; 
     2270                        settings = { 
     2271                        }; 
     2272                }; 
     2273                A5E7CC4B0848B02B00F1E98C = { 
     2274                        children = ( 
     2275                                A5E7CC5F0848B09000F1E98C, 
     2276                                A5E7CC600848B09000F1E98C, 
     2277                                A5E7CC500848B05300F1E98C, 
     2278                                A5E7CC4F0848B05300F1E98C, 
     2279                                A5E7CA4C0847CBA000F1E98C, 
     2280                                A5E7CA4D0847CBA000F1E98C, 
     2281                        ); 
     2282                        isa = PBXGroup; 
     2283                        name = Streams; 
     2284                        refType = 4; 
     2285                        sourceTree = "<group>"; 
     2286                }; 
     2287                A5E7CC4F0848B05300F1E98C = { 
     2288                        fileEncoding = 5; 
     2289                        isa = PBXFileReference; 
     2290                        lastKnownFileType = sourcecode.c.h; 
     2291                        path = FHAtomStreamParser.h; 
     2292                        refType = 4; 
     2293                        sourceTree = "<group>"; 
     2294                }; 
     2295                A5E7CC500848B05300F1E98C = { 
     2296                        fileEncoding = 5; 
     2297                        isa = PBXFileReference; 
     2298                        lastKnownFileType = sourcecode.c.objc; 
     2299                        path = FHAtomStreamParser.m; 
     2300                        refType = 4; 
     2301                        sourceTree = "<group>"; 
     2302                }; 
     2303                A5E7CC510848B05300F1E98C = { 
     2304                        fileRef = A5E7CC4F0848B05300F1E98C; 
     2305                        isa = PBXBuildFile; 
     2306                        settings = { 
     2307                        }; 
     2308                }; 
     2309                A5E7CC520848B05300F1E98C = { 
     2310                        fileRef = A5E7CC500848B05300F1E98C; 
     2311                        isa = PBXBuildFile; 
     2312                        settings = { 
     2313                        }; 
     2314                }; 
     2315                A5E7CC5F0848B09000F1E98C = { 
     2316                        fileEncoding = 5; 
     2317                        isa = PBXFileReference; 
     2318                        lastKnownFileType = sourcecode.c.objc; 
     2319                        path = FHStreamParser.m; 
     2320                        refType = 4; 
     2321                        sourceTree = "<group>"; 
     2322                }; 
     2323                A5E7CC600848B09000F1E98C = { 
     2324                        fileEncoding = 5; 
     2325                        isa = PBXFileReference; 
     2326                        lastKnownFileType = sourcecode.c.h; 
     2327                        path = FHStreamParser.h; 
     2328                        refType = 4; 
     2329                        sourceTree = "<group>"; 
     2330                }; 
     2331                A5E7CC610848B09000F1E98C = { 
     2332                        fileRef = A5E7CC5F0848B09000F1E98C; 
     2333                        isa = PBXBuildFile; 
     2334                        settings = { 
     2335                        }; 
     2336                }; 
     2337                A5E7CC620848B09000F1E98C = { 
     2338                        fileRef = A5E7CC600848B09000F1E98C; 
    22662339                        isa = PBXBuildFile; 
    22672340                        settings = {