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>
|
<sparkle:releaseNotesLink>
|
||||||
http://github.com/downloads/jeena/Twittia/ReleaseNotes.html
|
http://github.com/downloads/jeena/Twittia/ReleaseNotes.html
|
||||||
</sparkle:releaseNotesLink>
|
</sparkle:releaseNotesLink>
|
||||||
<pubDate>Wed, 19 Apr 2010 02:00:00 +0000</pubDate>
|
<pubDate>Wed, 19 Apr 2010 0:30:00 +0000</pubDate>
|
||||||
<enclosure url="http://github.com/downloads/jeena/Twittia/Twittia.zip"
|
<enclosure url="http://github.com/downloads/jeena/Twittia/Twittia.app.zip"
|
||||||
sparkle:version="2.0.2"
|
sparkle:version="2.0.2"
|
||||||
length="486608"
|
length="490687"
|
||||||
type="application/octet-stream"
|
type="application/octet-stream"
|
||||||
sparkle:dsaSignature="MCwCFC6RsmU3oU+QvFvFar2EarAhxsq1AhRFXyHYUgKToJUQTv4JVwoJWQZkhw==" />
|
sparkle:dsaSignature="MC4CFQCt/VPAkzibXLQRI9W6Zx/NZ6yKWwIVALAz3/n9uMD1v9XtVpORobhmPUtr" />
|
||||||
</item>
|
</item>
|
||||||
</channel>
|
</channel>
|
||||||
</rss>
|
</rss>
|
|
@ -24,6 +24,7 @@
|
||||||
|
|
||||||
- (void)initWebView;
|
- (void)initWebView;
|
||||||
- (void)openNewTweetWindowInReplyTo:(NSString *)userName statusId:(NSString *)statusId;
|
- (void)openNewTweetWindowInReplyTo:(NSString *)userName statusId:(NSString *)statusId;
|
||||||
|
- (NSString *)pluginURL;
|
||||||
OSStatus handler(EventHandlerCallRef nextHandler, EventRef theEvent, void* userData);
|
OSStatus handler(EventHandlerCallRef nextHandler, EventRef theEvent, void* userData);
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
20
Controller.m
20
Controller.m
|
@ -45,7 +45,7 @@
|
||||||
name:@"sendTweet"
|
name:@"sendTweet"
|
||||||
object:nil];
|
object:nil];
|
||||||
|
|
||||||
NSAppleEventManager *appleEventManager = [NSAppleEventManager sharedAppleEventManager];// 1
|
NSAppleEventManager *appleEventManager = [NSAppleEventManager sharedAppleEventManager];
|
||||||
[appleEventManager setEventHandler:self andSelector:@selector(handleGetURLEvent:withReplyEvent:) forEventClass:kInternetEventClass andEventID:kAEGetURL];
|
[appleEventManager setEventHandler:self andSelector:@selector(handleGetURLEvent:withReplyEvent:) forEventClass:kInternetEventClass andEventID:kAEGetURL];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,6 +67,7 @@
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#pragma mark Notifications
|
#pragma mark Notifications
|
||||||
|
|
||||||
- (IBAction)openNewTweetWindow:(id)sender {
|
- (IBAction)openNewTweetWindow:(id)sender {
|
||||||
|
@ -93,6 +94,23 @@
|
||||||
[self openNewTweetWindowWithString:[text substringFromIndex:8]];
|
[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 */
|
/* CARBON */
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,9 @@ FAQ:s
|
||||||
4. Yes there is a twittia: url scheme, try it out:
|
4. Yes there is a twittia: url scheme, try it out:
|
||||||
[twittia:Twittia is the shit](http://twittia.istheshit.net/)
|
[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
|
Nice to know
|
||||||
------------
|
------------
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
<h2>Twittia 2.0.2</h2>
|
<h2>Twittia 2.0.2</h2>
|
||||||
<p>Added the <code>twittia:</code> URL scheme.</p>
|
<p>Added the <code>twittia:</code> URL scheme.</p>
|
||||||
|
<p>Added a JavaScript-plugin API.</p>
|
||||||
|
|
||||||
<h2>Twittia 2.0.1</h2>
|
<h2>Twittia 2.0.1</h2>
|
||||||
<p>Added Sparcle so the updates will be less efford for the user.</p>
|
<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);
|
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>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
@ -738,6 +745,7 @@ $(document).ready(function() {
|
||||||
<ol id="body" class="messages"></ol>
|
<ol id="body" class="messages"></ol>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var twittia_instance = new Twittia();
|
var twittia_instance = new Twittia();
|
||||||
|
loadPlugin(controller.pluginURL());
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
Reference in a new issue