added plugin api
This commit is contained in:
parent
f23314b925
commit
16052b4fdf
6 changed files with 37 additions and 6 deletions
|
@ -11,12 +11,12 @@
|
|||
<sparkle:releaseNotesLink>
|
||||
http://github.com/downloads/jeena/Twittia/ReleaseNotes.html
|
||||
</sparkle:releaseNotesLink>
|
||||
<pubDate>Wed, 19 Apr 2010 02:00:00 +0000</pubDate>
|
||||
<enclosure url="http://github.com/downloads/jeena/Twittia/Twittia.zip"
|
||||
<pubDate>Wed, 19 Apr 2010 0:30:00 +0000</pubDate>
|
||||
<enclosure url="http://github.com/downloads/jeena/Twittia/Twittia.app.zip"
|
||||
sparkle:version="2.0.2"
|
||||
length="486608"
|
||||
length="490687"
|
||||
type="application/octet-stream"
|
||||
sparkle:dsaSignature="MCwCFC6RsmU3oU+QvFvFar2EarAhxsq1AhRFXyHYUgKToJUQTv4JVwoJWQZkhw==" />
|
||||
sparkle:dsaSignature="MC4CFQCt/VPAkzibXLQRI9W6Zx/NZ6yKWwIVALAz3/n9uMD1v9XtVpORobhmPUtr" />
|
||||
</item>
|
||||
</channel>
|
||||
</rss>
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
- (void)initWebView;
|
||||
- (void)openNewTweetWindowInReplyTo:(NSString *)userName statusId:(NSString *)statusId;
|
||||
- (NSString *)pluginURL;
|
||||
OSStatus handler(EventHandlerCallRef nextHandler, EventRef theEvent, void* userData);
|
||||
|
||||
@end
|
||||
|
|
22
Controller.m
22
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 */
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
<h2>Twittia 2.0.2</h2>
|
||||
<p>Added the <code>twittia:</code> URL scheme.</p>
|
||||
<p>Added a JavaScript-plugin API.</p>
|
||||
|
||||
<h2>Twittia 2.0.1</h2>
|
||||
<p>Added Sparcle so the updates will be less efford for the user.</p>
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
@ -738,6 +745,7 @@ $(document).ready(function() {
|
|||
<ol id="body" class="messages"></ol>
|
||||
<script type="text/javascript">
|
||||
var twittia_instance = new Twittia();
|
||||
loadPlugin(controller.pluginURL());
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Reference in a new issue