Changeset 36 for trunk/VoxAtomApi.m

Show
Ignore:
Timestamp:
06/12/06 04:02:48 (3 years ago)
Author:
ngerakines
Message:

image uploads in Vox work -- this is release 0.8 beta

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/VoxAtomApi.m

    r35 r36  
    1919        NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; 
    2020        NSString *reqtype; 
    21         if ([to isEqualToString:@"weblog"] || [to isEqualToString:@"0"]) { 
    22                 /* NSLog(@"set as weblog post type\n"); */ 
    23                 reqtype = @"POST"; 
    24                 [self setApiurl:[NSString stringWithFormat:@"%@weblog/blog_id=%@",@"http://www.typepad.com/t/atom/", [userDefaults objectForKey:@"selectedweblog"]]]; 
    25                 [self weblog_upload: dataarg]; 
    26         } 
    27         if ([to isEqualToString:@"gallery"] || [to isEqualToString:@"1"]) { 
    28                 /* NSLog(@"set as gallery post type\n"); */ 
    29                 reqtype = @"POST"; 
    30                 [self setApiurl:[NSString stringWithFormat:@"%@gallery/set_id=%@", @"http://www.typepad.com/t/atom/", [userDefaults objectForKey:@"selectedgallery"]]]; 
    31                 [self gallery_upload: dataarg]; 
    32         } 
    33         if ([to isEqualToString:@"quickpost"] || [to isEqualToString:@"2"]) { 
    34                 /* NSLog(@"set as gallery post type\n"); */ 
    35                 reqtype = @"POST"; 
    36                 [self setApiurl:[NSString stringWithFormat:@"%@weblog/blog_id=%@", @"http://www.typepad.com/t/atom/", [userDefaults objectForKey:@"selectedweblog"]]]; 
    37                 [self weblog_newpost:@"Quick Post" content:dataarg]; 
    38         } 
    3921        if ([to isEqualToString:@"weblogdiscovery"] || [to isEqualToString:@"3"]) { 
    4022                /* NSLog(@"set as gallery post type\n"); */ 
     
    4224                [self setApiurl:@"http://www.vox.com/atom/"]; 
    4325                [self weblog_discover]; 
    44         }  
    45         if ([to isEqualToString:@"categorydiscovery"] || [to isEqualToString:@"4"]) { 
    46                 /* NSLog(@"set as gallery post type\n"); */ 
    47                 reqtype = @"GET"; 
    48                 [self setApiurl:[NSString stringWithFormat:@"%@categories/blog_id=%@", @"http://www.typepad.com/t/atom/", [args objectForKey:@"blog_id"] ]]; 
    49                 [self weblog_discover]; 
    5026        } 
    51         if ([to isEqualToString:@"gallerydiscovery"] || [to isEqualToString:@"5"]) { 
    52                 /* NSLog(@"set as gallery post type\n"); */ 
    53                 reqtype = @"GET"; 
    54                 [self setApiurl:[NSString stringWithFormat:@"%@gallery", @"http://www.typepad.com/t/atom/"]]; 
    55                 [self weblog_discover]; 
    56         }  
     27        if ([to isEqualToString:@"collection"] || [to isEqualToString:@"1"]) { 
     28                NSLog(@"set as weblog post type\n"); 
     29                reqtype = @"POST"; 
     30                [self setApiurl:[NSString stringWithFormat:@"http://www.vox.com/atom/svc=post/collection_id=%@", [args objectForKey:@"destinationid"]]]; 
     31                [self weblog_upload: dataarg]; 
     32        } 
     33        if ([to isEqualToString:@"quickpost"] || [to isEqualToString:@"2"]) { 
     34                NSLog(@"set as quickpost post type\n"); 
     35                reqtype = @"POST"; 
     36                [self setApiurl:[NSString stringWithFormat:@"http://www.vox.com/atom/collection_id=%@", [args objectForKey:@"destinationid"]]]; 
     37                [self weblog_newpost:@"Quick Post" content:dataarg]; 
     38        } 
     39        // http://www.vox.com/atom/svc=post/collection_id= 
    5740        /* NSLog(@"Making request with request type %@\n", reqtype); */ 
    5841        [self makerequest:reqtype]; 
    59 } 
    60  
    61 - (NSString *) gallery_upload: (NSString *) file { 
    62         /* NSLog(@"- (NSString *) gallery_newitem - called"); */ 
    63         NSData *data = [NSData dataWithContentsOfFile:file]; 
    64         NSString *encodedFile = [data base64Encoding]; 
    65         atomdata = [NSString stringWithFormat:@"<entry xmlns=\"http://purl.org/atom/ns#\" xmlns:photo=\"http://sixapart.com/atom/photo#\"><title>%@</title><summary></summary><content mode=\"base64\" type=\"image/%@\">%@</content></entry>", [file lastPathComponent], [file pathExtension], encodedFile]; 
    66         return atomdata; 
    67 } 
    68  
    69 - (NSString *) weblog_upload: (NSString *) file { 
    70         /* NSLog(@"- (NSString *) weblog_newitem - called"); */ 
    71         /* NSLog(@"Creating atom feed based on upload file %@\n", uploadfile); */ 
    72         NSData *data = [NSData dataWithContentsOfFile:file]; 
    73         NSString *encodedFile = [data base64Encoding]; 
    74         atomdata = [NSString stringWithFormat:@"<entry xmlns=\"http://purl.org/atom/ns#\" xmlns:photo=\"http://sixapart.com/atom/photo#\"><title>Picture Post</title><summary></summary><photo:filename>%@</photo:filename><content mode=\"base64\" type=\"image/%@\">%@</content></entry>",[file lastPathComponent], [file pathExtension], encodedFile]; 
    75         /* NSLog(@"Atom feed:\n%@\n", atomdata); */ 
    76         return atomdata; 
    77 } 
    78  
    79 - (NSString *) weblog_newpost: (NSString *) title content: (NSString *) content { 
    80         /* NSLog(@"- (NSString *) weblog_newitem - called"); */ 
    81         /* NSLog(@"Creating atom feed based on upload file %@\n", uploadfile); */ 
    82         atomdata = [NSString stringWithFormat:@"<entry xmlns=\"http://purl.org/atom/ns#\"><title>%@</title><summary></summary><content mode=\"xml\"><div xmlns=\"http://www.w3.org/1999/xhtml\">%@</div></content>%@</entry>", title, content, [self weblog_postcategories]]; 
    83         /* NSLog(@"Atom feed:\n%@\n", atomdata); */ 
    84         return atomdata; 
    8542} 
    8643 
     
    9451} 
    9552 
    96 - (NSString *) weblog_postcategories { 
    97         NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; 
    98         NSArray *lines = [[userDefaults objectForKey:@"blogcategories"] componentsSeparatedByString:@","]; 
    99         int i, count = [lines count]; 
    100         NSString *output = @""; 
    101         for (i = 0; i < count; i++) { 
    102                 [output stringByAppendingString:[NSString stringWithFormat:@"<category scheme=\"http://sixapart.com/ns/category#\" term\"%@\" />", [lines objectAtIndex:i]]]; 
    103         } 
    104         return output; 
     53- (NSString *) weblog_upload: (NSString *) file { 
     54        NSLog(@"- (NSString *) weblog_upload - called"); 
     55        NSData *data = [NSData dataWithContentsOfFile:file]; 
     56        NSString *encodedFile = [data base64Encoding]; 
     57        // TODO: enable standalone mode - <standalone xmlns=\"http://sixapart.com/atom/typepad#\">1</standalone> 
     58        atomdata = [NSString stringWithFormat:@"<entry xmlns=\"http://purl.org/atom/ns#\" xmlns:photo=\"http://sixapart.com/atom/photo#\"><title>%@</title><summary></summary><photo:filename>%@</photo:filename><content mode=\"base64\" type=\"image/%@\">%@</content><standalone xmlns=\"http://sixapart.com/atom/typepad#\">1</standalone></entry>",[file lastPathComponent],[file lastPathComponent], [file pathExtension], encodedFile]; 
     59        return atomdata; 
     60} 
     61 
     62- (NSString *) weblog_newpost: (NSString *) title content: (NSString *) content { 
     63        NSLog(@"- (NSString *) weblog_newpost - called"); 
     64        atomdata = [NSString stringWithFormat:@"<entry xmlns=\"http://purl.org/atom/ns#\"><title>%@</title><summary></summary><content mode=\"xml\"><div xmlns=\"http://www.w3.org/1999/xhtml\">%@</div></content></entry>", title, content]; 
     65        return atomdata; 
    10566} 
    10667