diff --git a/Controller.h b/Controller.h index 8691ed1..f0f25dc 100644 --- a/Controller.h +++ b/Controller.h @@ -8,23 +8,23 @@ #import #import -#import "StatusView.h" #import "ViewDelegate.h" #import @interface Controller : NSObject { - IBOutlet WebView *webView; - id viewDelegate; - NSString *username; - NSString *password; + IBOutlet WebView *timelineView; + IBOutlet WebView *mentionsView; + ViewDelegate *viewDelegate; } -@property (retain, nonatomic) IBOutlet WebView *webView; -@property (retain, nonatomic) IBOutlet id viewDelegate; +@property (retain, nonatomic) IBOutlet WebView *timelineView; +@property (retain, nonatomic) IBOutlet WebView *mentionsView; +@property (retain, nonatomic) IBOutlet ViewDelegate *viewDelegate; -- (void)initWebView; +- (void)initWebViews; - (void)openNewTweetWindowInReplyTo:(NSString *)userName statusId:(NSString *)statusId; - (NSString *)pluginURL; + OSStatus handler(EventHandlerCallRef nextHandler, EventRef theEvent, void* userData); @end diff --git a/Controller.m b/Controller.m index c1272fd..431ff08 100644 --- a/Controller.m +++ b/Controller.m @@ -12,10 +12,10 @@ @implementation Controller -@synthesize webView, viewDelegate; +@synthesize timelineView, mentionsView, viewDelegate; - (void)awakeFromNib { - [self initWebView]; + [self initWebViews]; /* CARBON from http://github.com/Xjs/drama-button/blob/carbon/Drama_ButtonAppDelegate.m */ @@ -49,19 +49,27 @@ [appleEventManager setEventHandler:self andSelector:@selector(handleGetURLEvent:withReplyEvent:) forEventClass:kInternetEventClass andEventID:kAEGetURL]; } -- (void)initWebView { +- (void)initWebViews { + NSString *path = [[NSBundle mainBundle] resourcePath]; NSURL *url = [NSURL fileURLWithPath:path]; NSString *index_string = [NSString stringWithContentsOfFile:[NSString stringWithFormat:@"%@/index.html", path] encoding:NSUTF8StringEncoding error:nil]; - NSLog(@"%@", url); - [[webView mainFrame] loadHTMLString:index_string baseURL:url]; - viewDelegate = [[ViewDelegate alloc] initWithWebView:webView]; - [webView setFrameLoadDelegate:viewDelegate]; - [webView setPolicyDelegate:viewDelegate]; - [webView setUIDelegate:viewDelegate]; - - [[webView windowScriptObject] setValue:self forKey:@"controller"]; + viewDelegate = [[ViewDelegate alloc] init]; + + viewDelegate.timelineView = timelineView; + [[timelineView mainFrame] loadHTMLString:index_string baseURL:url]; + [timelineView setFrameLoadDelegate:viewDelegate]; + [timelineView setPolicyDelegate:viewDelegate]; + [timelineView setUIDelegate:viewDelegate]; + [[timelineView windowScriptObject] setValue:self forKey:@"controller"]; + + viewDelegate.mentionsView = mentionsView; + [[mentionsView mainFrame] loadHTMLString:index_string baseURL:url]; + [mentionsView setFrameLoadDelegate:viewDelegate]; + [mentionsView setPolicyDelegate:viewDelegate]; + [mentionsView setUIDelegate:viewDelegate]; + [[mentionsView windowScriptObject] setValue:self forKey:@"controller"]; } + (BOOL)isSelectorExcludedFromWebScript:(SEL)aSelector { @@ -97,7 +105,7 @@ - (IBAction)sendTweet:(id)sender { NSString *encodedString = [[[sender object] objectAtIndex:0] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; - [webView stringByEvaluatingJavaScriptFromString: + [timelineView stringByEvaluatingJavaScriptFromString: [NSString stringWithFormat:@"twittia_instance.sendNewTweet(\"%@\", \"%@\")", [encodedString stringByReplacingOccurrencesOfString:@"\"" withString:@"\\\""], [[sender object] objectAtIndex:1]]]; diff --git a/English.lproj/MainMenu.xib b/English.lproj/MainMenu.xib index df643b3..baa9c48 100644 --- a/English.lproj/MainMenu.xib +++ b/English.lproj/MainMenu.xib @@ -21,8 +21,9 @@ YES - - + + + YES @@ -229,6 +230,15 @@ + + + Mentions + m + 1048576 + 2147483647 + + + Close @@ -806,24 +816,16 @@ - + 13 YES - - YES - WebKitDefaultFixedFontSize - WebKitDefaultFontSize - WebKitMinimumFontSize - + YES - - - - YES + NO YES @@ -837,6 +839,70 @@ SUUpdater + + 15 + 2 + {{235, -22}, {376, 581}} + 1685586944 + Mentions + NSWindow + + {1.79769e+308, 1.79769e+308} + + + 256 + + YES + + + 274 + + YES + + YES + Apple HTML pasteboard type + Apple PDF pasteboard type + Apple PICT pasteboard type + Apple URL pasteboard type + Apple Web Archive pasteboard type + NSColor pasteboard type + NSFilenamesPboardType + NSStringPboardType + NeXT RTFD pasteboard type + NeXT Rich Text Format v1.0 pasteboard type + NeXT TIFF v4.0 pasteboard type + WebURLsWithTitlesPboardType + public.png + public.url + public.url-name + + + {376, 581} + + + + + + 12 + + YES + + + YES + + + + NO + YES + + + {376, 581} + + + {{0, 0}, {1920, 1178}} + {1.79769e+308, 1.79769e+308} + mentions + @@ -1177,14 +1243,6 @@ 494 - - - webView - - - - 538 - newDocument: @@ -1209,6 +1267,30 @@ 547 + + + timelineView + + + + 553 + + + + mentionsView + + + + 562 + + + + makeKeyAndOrderFront: + + + + 563 + @@ -1297,6 +1379,7 @@ + @@ -1804,6 +1887,7 @@ 537 + timeline 541 @@ -1820,6 +1904,35 @@ + + 551 + + + + + 559 + + + YES + + + + Mentions + + + 560 + + + YES + + + + + + 561 + + + @@ -1970,8 +2083,15 @@ 537.IBPluginDependency 542.IBPluginDependency 544.IBPluginDependency + 551.IBPluginDependency + 559.IBEditorWindowLastContentRect + 559.IBPluginDependency + 559.IBWindowTemplateEditedContentRect + 559.NSWindowTemplate.visibleAtLaunch 56.IBPluginDependency 56.ImportedFromIB2 + 560.IBPluginDependency + 561.IBPluginDependency 57.IBEditorWindowLastContentRect 57.IBPluginDependency 57.ImportedFromIB2 @@ -2133,16 +2253,23 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{907, 115}, {397, 581}} + {{42, 357}, {397, 581}} com.apple.InterfaceBuilder.CocoaPlugin - {{907, 115}, {397, 581}} + {{42, 357}, {397, 581}} com.apple.InterfaceBuilder.CocoaPlugin com.apple.WebKitIBPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + {{460, 356}, {376, 581}} + com.apple.InterfaceBuilder.CocoaPlugin + {{460, 356}, {376, 581}} + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.WebKitIBPlugin {{1089, 312}, {229, 173}} com.apple.InterfaceBuilder.CocoaPlugin @@ -2155,7 +2282,7 @@ com.apple.InterfaceBuilder.CocoaPlugin - {{771, 861}, {181, 93}} + {{771, 841}, {182, 113}} com.apple.InterfaceBuilder.CocoaPlugin {{155, 774}, {199, 203}} @@ -2183,7 +2310,7 @@ - 547 + 563 @@ -2195,13 +2322,17 @@ YES YES + mentionsView + timelineView viewDelegate - webView + viewDelegate2 YES - id WebView + WebView + id + id diff --git a/StatusView.h b/StatusView.h deleted file mode 100644 index 9efd4bb..0000000 --- a/StatusView.h +++ /dev/null @@ -1,16 +0,0 @@ -// -// Viewer.h -// Twittia 2 -// -// Created by Jeena on 15.04.10. -// Licence: BSD (see attached LICENCE.txt file). -// - -#import -#import - -@protocol StatusView - --(id)initWithWebView:(WebView *) webView; - -@end diff --git a/Twittia 2.xcodeproj/project.pbxproj b/Twittia 2.xcodeproj/project.pbxproj index 3ad0152..8d57c36 100644 --- a/Twittia 2.xcodeproj/project.pbxproj +++ b/Twittia 2.xcodeproj/project.pbxproj @@ -72,7 +72,6 @@ 1FFA36D31177D879006C8562 /* Controller.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Controller.m; sourceTree = ""; }; 1FFA36D41177D879006C8562 /* ViewDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewDelegate.h; sourceTree = ""; }; 1FFA36D51177D879006C8562 /* ViewDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ViewDelegate.m; sourceTree = ""; }; - 1FFA36D61177D879006C8562 /* StatusView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StatusView.h; sourceTree = ""; }; 1FFA37061177DAF4006C8562 /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = System/Library/Frameworks/WebKit.framework; sourceTree = SDKROOT; }; 2564AD2C0F5327BB00F57823 /* Twittia_2_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Twittia_2_Prefix.pch; sourceTree = ""; }; 2A37F4ACFDCFA73011CA2CEA /* MyDocument.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MyDocument.m; sourceTree = ""; }; @@ -165,7 +164,6 @@ 1FFA36D31177D879006C8562 /* Controller.m */, 1FFA36D41177D879006C8562 /* ViewDelegate.h */, 1FFA36D51177D879006C8562 /* ViewDelegate.m */, - 1FFA36D61177D879006C8562 /* StatusView.h */, 2A37F4AEFDCFA73011CA2CEA /* MyDocument.h */, 2A37F4ACFDCFA73011CA2CEA /* MyDocument.m */, ); diff --git a/TwittiaCore.js b/TwittiaCore.js index 34c1f10..86d5330 100644 --- a/TwittiaCore.js +++ b/TwittiaCore.js @@ -1,11 +1,16 @@ -function Twittia() { +function Twittia(action, oauth_key, oauth_secret) { this.body = document.getElementById("body"); this.max_length = 100; this.since_id; - this.getNewData(); this.timeout = 2 * 60 * 1000; + this.action = action; + this.oauth_key = oauth_key; + this.oauth_secret = oauth_secret; + this.getNewData(); + setTimeout(function() { loadPlugin(controller.pluginURL()) }, 1); } + Twittia.prototype.newStatus = function(status, supress_new_with_timeout) { if(status != null) { for(var i = status.length-1, c=0; i>=c; --i) { @@ -161,7 +166,8 @@ Twittia.prototype.getTemplate = function() { Twittia.prototype.getNewData = function(supress_new_with_timeout) { - var url = "http://api.twitter.com/1/statuses/home_timeline.json?count=100"; + var url = "http://api.twitter.com/1/statuses/" + this.action + ".json" + url += "?count=" + this.max_length; if(this.since_id) url += "&since_id=" + this.since_id; var _this = this; @@ -241,3 +247,5 @@ function loadPlugin(url) { plugin.src = url; document.getElementsByTagName("head")[0].appendChild(plugin); } + +var twittia_instance; \ No newline at end of file diff --git a/ViewDelegate.h b/ViewDelegate.h index 084151e..0bf414e 100644 --- a/ViewDelegate.h +++ b/ViewDelegate.h @@ -8,12 +8,13 @@ #import #import -#import "StatusView.h" -@interface ViewDelegate : NSObject { - WebView *webView; +@interface ViewDelegate : NSObject { + WebView *timelineView; + WebView *mentionsView; } --(id)initWithWebView:(WebView *) webView; +@property (nonatomic, assign) WebView *timelineView; +@property (nonatomic, assign) WebView *mentionsView; @end diff --git a/ViewDelegate.m b/ViewDelegate.m index 3340e88..1973d51 100644 --- a/ViewDelegate.m +++ b/ViewDelegate.m @@ -11,17 +11,9 @@ @implementation ViewDelegate --(id)initWithWebView:(WebView *) view { - - if ( self = [super init] ) { - webView = view; - } - - return self; -} +@synthesize timelineView, mentionsView; - -- (void)webView:(WebView *)_webView addMessageToConsole:(NSDictionary *)message;{ +- (void)webView:(WebView *)sender addMessageToConsole:(NSDictionary *)message;{ if (![message isKindOfClass:[NSDictionary class]]) return; @@ -41,4 +33,15 @@ [[NSWorkspace sharedWorkspace] openURL:[request URL]]; } +- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame { + NSString *action = @"home_timeline"; + + if (sender == mentionsView) { + action = @"mentions"; + } + + [sender stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat: + @"setTimeout(function(){ twittia_instance = new Twittia('%@'); }, 1);", action]]; +} + @end diff --git a/index.html b/index.html index 557a982..e2c171f 100644 --- a/index.html +++ b/index.html @@ -10,12 +10,5 @@
    - \ No newline at end of file