Permalink
Browse files

Update API to 1.0, add support for videos and embeds, and add iPhone …

…5 support.
  • Loading branch information...
1 parent a9fdc48 commit a82c008e4d987f391949e31b7eb4b20847a27449 @dmpatierno dmpatierno committed Nov 17, 2012
View
BIN .DS_Store
Binary file not shown.
@@ -51,14 +51,14 @@ - (void)refreshHierarchy {
NSArray *allBookmarks = [[GuideBookmarks sharedBookmarks].guides allValues];
for (NSDictionary *guideData in allBookmarks) {
Guide *guide = [Guide guideWithDictionary:guideData];
- NSMutableArray *guides = [b objectForKey:guide.device];
+ NSMutableArray *guides = [b objectForKey:guide.topic];
if (guides) {
[guides addObject:guide];
}
else {
guides = [NSMutableArray arrayWithObject:guide];
- [b setObject:guides forKey:guide.device];
+ [b setObject:guides forKey:guide.topic];
}
}
@@ -1,5 +1,5 @@
//
-// AreasViewController.h
+// CategoriesViewController.h
// iFixit
//
// Created by David Patierno on 8/6/10.
@@ -8,7 +8,7 @@
@class DetailViewController;
-@interface AreasViewController : UITableViewController <UISearchBarDelegate, UIAlertViewDelegate, UITextFieldDelegate>
+@interface CategoriesViewController : UITableViewController <UISearchBarDelegate, UIAlertViewDelegate, UITextFieldDelegate>
@property (nonatomic, assign) id delegate;
@property (nonatomic, retain) IBOutlet UISearchBar *searchBar;
@@ -1,5 +1,5 @@
//
-// AreasViewController.m
+// CategoriesViewController.m
// iFixit
//
// Created by David Patierno on 8/6/10.
@@ -8,17 +8,17 @@
#import "iFixitAppDelegate.h"
#import "Config.h"
-#import "AreasViewController.h"
+#import "CategoriesViewController.h"
#import "DetailViewController.h"
#import "iPhoneDeviceViewController.h"
#import "DetailGridViewController.h"
-@implementation AreasViewController
+@implementation CategoriesViewController
@synthesize delegate, searchBar, searching, searchResults, detailViewController, data, tree, keys, leafs, noResults, inPopover;
- (id)init {
- if ((self = [super initWithNibName:@"AreasViewController" bundle:nil])) {
+ if ((self = [super initWithNibName:nil bundle:nil])) {
self.tree = nil;
searching = NO;
self.searchResults = [NSArray array];
@@ -46,6 +46,7 @@ - (void)viewDidLoad {
else {
UIImage *titleImage = [UIImage imageNamed:@"titleImage.png"];
UIImageView *imageTitle = [[UIImageView alloc] initWithImage:titleImage];
+ imageTitle.contentMode = UIViewContentModeScaleAspectFit;
self.navigationItem.titleView = imageTitle;
[imageTitle release];
}
@@ -94,7 +95,7 @@ - (void)showRefreshButton {
}
- (void)getAreas {
[self showLoading];
- [[iFixitAPI sharedInstance] getAreas:nil forObject:self withSelector:@selector(gotAreas:)];
+ [[iFixitAPI sharedInstance] getCategories:nil forObject:self withSelector:@selector(gotAreas:)];
}
- (void)gotAreas:(NSDictionary *)areas {
@@ -107,7 +108,7 @@ - (void)gotAreas:(NSDictionary *)areas {
else {
// If there is no area hierarchy, show a guide list instead
if ([areas isKindOfClass:[NSArray class]] && ![areas count]) {
- iPhoneDeviceViewController *dvc = [[iPhoneDeviceViewController alloc] initWithDevice:nil];
+ iPhoneDeviceViewController *dvc = [[iPhoneDeviceViewController alloc] initWithTopic:nil];
[self.navigationController pushViewController:dvc animated:YES];
[dvc release];
}
@@ -247,7 +248,7 @@ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interface
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
if (inPopover)
return;
-
+
// Make room for the toolbar
if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad || UIInterfaceOrientationIsPortrait(toInterfaceOrientation)) {
self.tableView.contentInset = UIEdgeInsetsMake(0, 0, 44, 0);
@@ -276,8 +277,8 @@ - (void)setData:(NSDictionary *)dict {
// Separate the leafs.
self.tree = [NSMutableDictionary dictionaryWithDictionary:dict];
- self.leafs = [[tree objectForKey:@"DEVICES"] sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
- [tree removeObjectForKey:@"DEVICES"];
+ self.leafs = [[tree objectForKey:@"TOPICS"] sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
+ [tree removeObjectForKey:@"TOPICS"];
self.keys = [[tree allKeys] sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
}
@@ -424,7 +425,7 @@ - (void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath
}
}
else if (indexPath.section == 1 - base && [keys count] && !searching) {
- AreasViewController *vc = [[AreasViewController alloc] init];
+ CategoriesViewController *vc = [[CategoriesViewController alloc] init];
vc.inPopover = inPopover;
vc.detailViewController = detailViewController;
@@ -467,7 +468,7 @@ - (void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath
// iPhone: Push a webView onto the stack.
if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone) {
- iPhoneDeviceViewController *vc = [[iPhoneDeviceViewController alloc] initWithDevice:title];
+ iPhoneDeviceViewController *vc = [[iPhoneDeviceViewController alloc] initWithTopic:title];
vc.title = display_title;
[self.navigationController pushViewController:vc animated:YES];
[vc release];
@@ -51,7 +51,7 @@ - (void)showLoading {
- (void)loadDevice {
[self showLoading];
- [[iFixitAPI sharedInstance] getDevice:_device forObject:self withSelector:@selector(gotDevice:)];
+ [[iFixitAPI sharedInstance] getTopic:_device forObject:self withSelector:@selector(gotDevice:)];
}
- (void)gotDevice:(NSDictionary *)data {
@@ -9,7 +9,7 @@
#import "iFixitAppDelegate.h"
#import "Config.h"
#import "DetailViewController.h"
-#import "AreasViewController.h"
+#import "CategoriesViewController.h"
#import "ListViewController.h"
#import "GuideCatchingWebView.h"
#import "WBProgressHUD.h"
@@ -32,7 +32,7 @@ - (id)init {
gridViewController.gridDelegate = self;
// Initialize the Browse button.
- AreasViewController *avc = [[AreasViewController alloc] init];
+ CategoriesViewController *avc = [[CategoriesViewController alloc] init];
avc.inPopover = YES;
ListViewController *lvc = [[ListViewController alloc] initWithRootViewController:avc];
avc.detailViewController = self;
View
@@ -15,7 +15,7 @@
@property (nonatomic, retain) NSDictionary *data;
@property (nonatomic) NSInteger guideid;
@property (nonatomic, retain) NSString *title;
-@property (nonatomic, retain) NSString *device;
+@property (nonatomic, retain) NSString *topic;
@property (nonatomic, retain) NSString *subject;
@property (nonatomic, retain) NSString *author;
@property (nonatomic, retain) NSString *timeRequired;
View
@@ -11,7 +11,7 @@
@implementation Guide
-@synthesize data, guideid, device, subject, title, author, timeRequired, difficulty, introduction, introduction_rendered, summary, image;
+@synthesize data, guideid, topic, subject, title, author, timeRequired, difficulty, introduction, introduction_rendered, summary, image;
@synthesize documents, parts, tools, flags;
@synthesize prereqs, steps;
@@ -37,7 +37,7 @@ + (Guide *)guideWithDictionary:(NSDictionary *)dict {
// Meta information
guide.title = [guideData valueForKey:@"title"];
- guide.device = [dict valueForKey:@"device"];
+ guide.topic = [dict valueForKey:@"topic"];
guide.subject = [guideData valueForKey:@"subject"];
guide.author = [guideData valueForKey:@"author"];
guide.timeRequired = [guideData valueForKey:@"time"];
@@ -70,7 +70,7 @@ + (Guide *)guideWithDictionary:(NSDictionary *)dict {
- (void)dealloc {
[data release];
[title release];
- [device release];
+ [topic release];
[subject release];
[author release];
[timeRequired release];
View
@@ -0,0 +1,19 @@
+//
+// GuideEmbed.h
+// iFixit
+//
+// Created by David Patierno on 11/16/12.
+// Copyright 2012 iFixit. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+@interface GuideEmbed : NSObject
+
+@property (nonatomic, copy) NSString *url;
+@property (nonatomic, copy) NSString *type;
+@property (nonatomic, assign) CGSize size;
+
++ (GuideEmbed *)guideEmbedWithDictionary:(NSDictionary *)dict;
+
+@end
View
@@ -0,0 +1,34 @@
+//
+// GuideEmbed.m
+// iFixit
+//
+// Created by David Patierno on 11/16/12.
+// Copyright 2012 iFixit. All rights reserved.
+//
+
+#import "GuideEmbed.h"
+
+@implementation GuideEmbed
+
+@synthesize url = _url,
+ size = _size,
+ type = _type;
+
++ (GuideEmbed *)guideEmbedWithDictionary:(NSDictionary *)dict {
+ GuideEmbed *guideEmbed = [[GuideEmbed alloc] init];
+ NSString *url = [dict valueForKey:@"url"];
+ guideEmbed.url = [NSString stringWithFormat:@"%@&format=json", url, nil];
+ guideEmbed.type = [dict valueForKey:@"type"];
+ guideEmbed.size = CGSizeMake([[dict valueForKey:@"width"] floatValue],
+ [[dict valueForKey:@"height"] floatValue]);
+ return [guideEmbed autorelease];
+}
+
+- (void)dealloc {
+ [_url release];
+ [_type release];
+
+ [super dealloc];
+}
+
+@end
@@ -24,7 +24,7 @@ @implementation GuideIntroViewController
// Load the view nib and initialize the guide.
- (id)initWithGuide:(Guide *)guide {
- if ((self = [super initWithNibName:@"GuideIntroView" bundle:nil])) {
+ if ((self = [super initWithNibName:nil bundle:nil])) {
self.guide = guide;
self.huge = nil;
}
@@ -88,24 +88,24 @@ - (void)viewDidLoad {
self.view.backgroundColor = bgColor;
webView.modalDelegate = delegate;
- webView.backgroundColor = bgColor;
+ webView.backgroundColor = bgColor;
webView.opaque = NO;
- // Load the intro contents as HTML.
- NSString *header = [NSString stringWithFormat:@"<html><head><style type=\"text/css\"> %@ </style></head><body class=\"%@\">",
- [Config currentConfig].introCSS,
- ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) ? @"big" : @"small"];
- NSString *footer = @"</body></html>";
+ // Load the intro contents as HTML.
+ NSString *header = [NSString stringWithFormat:@"<html><head><style type=\"text/css\"> %@ </style></head><body class=\"%@\">",
+ [Config currentConfig].introCSS,
+ ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) ? @"big" : @"small"];
+ NSString *footer = @"</body></html>";
- NSString *body = self.guide.introduction_rendered;
+ NSString *body = self.guide.introduction_rendered;
//NSString *body = guide.introduction;
self.html = [NSString stringWithFormat:@"%@%@%@", header, body, footer];
- [webView loadHTMLString:html baseURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://%@", [Config host]]]];
+ [webView loadHTMLString:html baseURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://%@", [Config host]]]];
[self removeWebViewShadows];
- [device setText:self.guide.device];
+ [device setText:self.guide.topic];
// Add a shadow to the image
[self addViewShadow:mainImage];
@@ -116,10 +116,10 @@ - (void)viewDidLoad {
// Because the web view has a white background, it starts hidden.
// After the content is loaded, we wait a small amount of time before showing it to prevent flicker.
- (void)webViewDidFinishLoad:(UIWebView *)webView {
- [self performSelector:@selector(showWebView:) withObject:nil afterDelay:0.2];
+ [self performSelector:@selector(showWebView:) withObject:nil afterDelay:0.2];
}
- (void)showWebView:(id)sender {
- webView.hidden = NO;
+ webView.hidden = NO;
}
- (IBAction)zoomImage:(id)sender {
@@ -147,6 +147,8 @@ - (void)layoutLandscape {
}
}
- (void)layoutPortrait {
+ CGSize screenSize = [UIScreen mainScreen].bounds.size;
+
// iPad
if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) {
swipeLabel.frame = CGRectMake(340.0, 790.0, 375.0, 84.0);
@@ -155,8 +157,10 @@ - (void)layoutPortrait {
// iPhone
else {
CGRect frame = webView.frame;
- frame.size.height = 305;
+ frame.size.height = screenSize.height - 175;// 305;
webView.frame = frame;
+
+ swipeLabel.frame = CGRectMake(0.0, screenSize.height - 20.0, 320.0, 45.0);
}
}
@@ -172,14 +176,6 @@ - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrie
[webView loadHTMLString:html baseURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://%@", [Config host]]]];
}
-- (void)didReceiveMemoryWarning {
- // Releases the view if it doesn't have a superview.
- [super didReceiveMemoryWarning];
-
- // Release any cached data, images, etc that aren't in use.
-}
-
-
- (void)viewDidUnload {
[self setOverlayView:nil];
[self setHeaderTextDozuki:nil];
Oops, something went wrong.

0 comments on commit a82c008

Please sign in to comment.