Wed, 19 Apr 2010 0:30:00 +0000
+
+ sparkle:dsaSignature="MC4CFQCt/VPAkzibXLQRI9W6Zx/NZ6yKWwIVALAz3/n9uMD1v9XtVpORobhmPUtr" />
\ No newline at end of file
diff --git a/Controller.h b/Controller.h
index 00d71e6..8691ed1 100644
--- a/Controller.h
+++ b/Controller.h
@@ -24,6 +24,7 @@
- (void)initWebView;
- (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 53c3594..63dddc3 100644
--- a/Controller.m
+++ b/Controller.m
@@ -45,7 +45,7 @@
name:@"sendTweet"
object:nil];
- NSAppleEventManager *appleEventManager = [NSAppleEventManager sharedAppleEventManager];// 1
+ NSAppleEventManager *appleEventManager = [NSAppleEventManager sharedAppleEventManager];
[appleEventManager setEventHandler:self andSelector:@selector(handleGetURLEvent:withReplyEvent:) forEventClass:kInternetEventClass andEventID:kAEGetURL];
}
@@ -53,7 +53,7 @@
NSString *path = [[NSBundle mainBundle] resourcePath];
NSURL *url = [NSURL fileURLWithPath:path];
NSString *index_string = [NSString stringWithContentsOfFile:[NSString stringWithFormat:@"%@/index.html", path] encoding:NSUTF8StringEncoding error:nil];
- [[webView mainFrame] loadHTMLString:index_string baseURL:url];
+ [[webView mainFrame] loadHTMLString:index_string baseURL:url];
viewDelegate = [[ViewDelegate alloc] initWithWebView:webView];
[webView setFrameLoadDelegate:viewDelegate];
@@ -67,6 +67,7 @@
return NO;
}
+
#pragma mark Notifications
- (IBAction)openNewTweetWindow:(id)sender {
@@ -93,6 +94,23 @@
[self openNewTweetWindowWithString:[text substringFromIndex:8]];
}
+- (IBAction)sendTweet:(id)sender {
+ NSString *encodedString = [[[sender object] objectAtIndex:0] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
+ [webView stringByEvaluatingJavaScriptFromString:
+ [NSString stringWithFormat:@"twittia_instance.sendNewTweet(\"%@\", \"%@\")",
+ [encodedString stringByReplacingOccurrencesOfString:@"\"" withString:@"\\\""],
+ [[sender object] objectAtIndex:1]]];
+}
+
+- (NSString *)pluginURL {
+ NSFileManager *fileManager = [NSFileManager defaultManager];
+ NSString *pathToPlugin = [@"~/Library/Application Support/Twittia/Plugin.js" stringByExpandingTildeInPath];
+ if([fileManager fileExistsAtPath:pathToPlugin]) {
+ return [NSString stringWithFormat:@"%@", [NSURL fileURLWithPath:pathToPlugin]];
+ }
+ return nil;
+}
+
/* CARBON */
diff --git a/README.markdown b/README.markdown
index e4f1cd5..16b803d 100644
--- a/README.markdown
+++ b/README.markdown
@@ -26,6 +26,9 @@ FAQ:s
4. Yes there is a twittia: url scheme, try it out:
[twittia:Twittia is the shit](http://twittia.istheshit.net/)
+
+5. Yes, there is a JavaScript-plugin-API. Create this file:
+ ~/Library/Application Support/Twittia/Plugin.js
Nice to know
diff --git a/ReleaseNotes.html b/ReleaseNotes.html
index 93cc750..80bbfb1 100644
--- a/ReleaseNotes.html
+++ b/ReleaseNotes.html
@@ -15,6 +15,7 @@
Twittia 2.0.2
Added the twittia:
URL scheme.
+Added a JavaScript-plugin API.
Twittia 2.0.1
Added Sparcle so the updates will be less efford for the user.
diff --git a/index.html b/index.html
index 13f9263..b7e1e34 100644
--- a/index.html
+++ b/index.html
@@ -243,6 +243,13 @@ function replyTo(username, status_id) {
controller.openNewTweetWindowInReplyTo_statusId_(username, status_id);
}
+function loadPlugin(url) {
+ var plugin = document.createElement("script");
+ plugin.type = "text/javascript";
+ plugin.src = url;
+ document.getElementsByTagName("head")[0].appendChild(plugin);
+}
+