adium 3010:b4927f4a7ea8: Support both retweeting and quoting a t...
commits at adium.im
commits at adium.im
Tue Dec 1 14:58:01 UTC 2009
details: http://hg.adium.im/adium/rev/b4927f4a7ea8
revision: 3010:b4927f4a7ea8
author: Zachary West <zacw at adium.im>
date: Tue Dec 01 09:57:55 2009 -0500
Support both retweeting and quoting a tweet. For StatusNet, this means only quoting (since there is no retweet yet).
This removes the hidden preference for forcing RT->quote style, and implements the "/via @user" syntax some random guy on the internet said was the best idea. Random people are smart!
diffs (136 lines):
diff -r 6b150c193234 -r b4927f4a7ea8 Plugins/Twitter Plugin/AILaconicaAccount.m
--- a/Plugins/Twitter Plugin/AILaconicaAccount.m Mon Nov 30 22:13:22 2009 -0500
+++ b/Plugins/Twitter Plugin/AILaconicaAccount.m Tue Dec 01 09:57:55 2009 -0500
@@ -135,6 +135,8 @@
address = [NSString stringWithFormat:@"http://%@/tag/%@", fullAddress, context];
} else if (linkType == AITwitterLinkGroup) {
address = [NSString stringWithFormat:@"http://%@/group/%@", fullAddress, context];
+ } else if (linkType == AITwitterLinkRetweet) {
+ address = nil;
}
return address;
diff -r 6b150c193234 -r b4927f4a7ea8 Plugins/Twitter Plugin/AITwitterAccount.h
--- a/Plugins/Twitter Plugin/AITwitterAccount.h Mon Nov 30 22:13:22 2009 -0500
+++ b/Plugins/Twitter Plugin/AITwitterAccount.h Tue Dec 01 09:57:55 2009 -0500
@@ -56,6 +56,7 @@
typedef enum {
AITwitterLinkReply = 0,
AITwitterLinkRetweet,
+ AITwitterLinkQuote,
AITwitterLinkFavorite,
AITwitterLinkStatus,
AITwitterLinkFriends,
@@ -69,6 +70,7 @@
// HTML class names
#define AITwitterInReplyToClassName @"twitter_inReplyTo"
+#define AITwitterQuoteClassName @"twitter_quote"
#define AITwitterRetweetClassName @"twitter_reTweet"
#define AITwitterReplyClassName @"twitter_reply"
#define AITwitterDeleteClassName @"twitter_delete"
diff -r 6b150c193234 -r b4927f4a7ea8 Plugins/Twitter Plugin/AITwitterAccount.m
--- a/Plugins/Twitter Plugin/AITwitterAccount.m Mon Nov 30 22:13:22 2009 -0500
+++ b/Plugins/Twitter Plugin/AITwitterAccount.m Tue Dec 01 09:57:55 2009 -0500
@@ -1192,13 +1192,15 @@
} else if (linkType == AITwitterLinkReply) {
address = [NSString stringWithFormat:@"twitterreply://%@@%@?action=reply&status=%@", self.internalObjectID, userID, statusID];
} else if (linkType == AITwitterLinkRetweet) {
- address = [NSString stringWithFormat:@"twitterreply://%@@%@?action=retweet&status=%@&message=%@", self.internalObjectID, userID, statusID, context];
+ address = [NSString stringWithFormat:@"twitterreply://%@@%@?action=retweet&status=%@", self.internalObjectID, userID, statusID];
} else if (linkType == AITwitterLinkFavorite) {
address = [NSString stringWithFormat:@"twitterreply://%@@%@?action=favorite&status=%@", self.internalObjectID, userID, statusID];
} else if (linkType == AITwitterLinkDestroyStatus) {
address = [NSString stringWithFormat:@"twitterreply://%@@%@?action=destroy&status=%@&message=%@", self.internalObjectID, userID, statusID, context];
} else if (linkType == AITwitterLinkDestroyDM) {
address = [NSString stringWithFormat:@"twitterreply://%@@%@?action=destroy&dm=%@&message=%@", self.internalObjectID, userID, statusID, context];
+ } else if (linkType == AITwitterLinkQuote) {
+ address = [NSString stringWithFormat:@"twitterreply://%@@%@?action=quote&message=%@", self.internalObjectID, userID, context];
}
return address;
@@ -1419,11 +1421,28 @@
linkAddress = [self addressForLinkType:AITwitterLinkRetweet
userID:userID
statusID:tweetID
+ context:nil];
+
+ // If the account doesn't support retweets, it returns nil.
+ if (linkAddress) {
+ [mutableMessage appendAttributedString:[self attributedStringWithLinkLabel:@"RT"
+ linkDestination:linkAddress
+ linkClass:AITwitterRetweetClassName]];
+
+ [mutableMessage appendString:@", " withAttributes:nil];
+ }
+
+ linkAddress = [self addressForLinkType:AITwitterLinkQuote
+ userID:userID
+ statusID:tweetID
context:[inMessage stringByAddingPercentEscapesForAllCharacters]];
- [mutableMessage appendAttributedString:[self attributedStringWithLinkLabel:@"RT"
+#define PILCROW_SIGN @"\u00B6"
+
+ [mutableMessage appendAttributedString:[self attributedStringWithLinkLabel:PILCROW_SIGN
linkDestination:linkAddress
- linkClass:AITwitterRetweetClassName]];
+ linkClass:AITwitterQuoteClassName]];
+
commaNeeded = YES;
}
diff -r 6b150c193234 -r b4927f4a7ea8 Plugins/Twitter Plugin/AITwitterURLHandler.m
--- a/Plugins/Twitter Plugin/AITwitterURLHandler.m Mon Nov 30 22:13:22 2009 -0500
+++ b/Plugins/Twitter Plugin/AITwitterURLHandler.m Tue Dec 01 09:57:55 2009 -0500
@@ -104,13 +104,13 @@
return;
}
- BOOL retweetAsReply = [[NSUserDefaults standardUserDefaults] boolForKey:@"AITwitterUseNonstandardRetweet"];
+ BOOL treatAsQuote = [inAction isEqualToString:@"quote"];
- if (!retweetAsReply && [inAction isEqualToString:@"retweet"]) {
- retweetAsReply = ![account retweetTweet:inTweet];
+ if (!treatAsQuote && [inAction isEqualToString:@"retweet"]) {
+ treatAsQuote = ![account retweetTweet:inTweet];
}
- if (retweetAsReply || [inAction isEqualToString:@"reply"]) {
+ if (treatAsQuote || [inAction isEqualToString:@"reply"]) {
AIChat *timelineChat = [adium.chatController existingChatWithName:account.timelineChatName
onAccount:account];
@@ -131,7 +131,7 @@
AIMessageEntryTextView *textView = ((AIMessageTabViewItem *)[timelineChat valueForProperty:@"MessageTabViewItem"]).messageViewController.textEntryView;
// Insert the @reply text
- NSString *prefix = retweetAsReply ? [NSString stringWithFormat:@"RT @%@: %@", inUser, [inMessage stringByDecodingURLEscapes]] : [NSString stringWithFormat:@"@%@ ", inUser];
+ NSString *prefix = treatAsQuote ? [NSString stringWithFormat:@"%@ /via @%@ ", [inMessage stringByDecodingURLEscapes], inUser] : [NSString stringWithFormat:@"@%@ ", inUser];
if (![textView.string hasPrefix:prefix]) {
NSMutableAttributedString *newString;
@@ -153,15 +153,17 @@
// Make the text view have focus
[[adium.interfaceController windowForChat:timelineChat] makeFirstResponder:textView];
- [timelineChat setValue:inTweet forProperty:@"TweetInReplyToStatusID" notify:NotifyNow];
- [timelineChat setValue:inUser forProperty:@"TweetInReplyToUserID" notify:NotifyNow];
- [timelineChat setValue:@"@" forProperty:@"Character Counter Prefix" notify:NotifyNow];
+ if (!treatAsQuote) {
+ [timelineChat setValue:inTweet forProperty:@"TweetInReplyToStatusID" notify:NotifyNow];
+ [timelineChat setValue:inUser forProperty:@"TweetInReplyToUserID" notify:NotifyNow];
+ [timelineChat setValue:@"@" forProperty:@"Character Counter Prefix" notify:NotifyNow];
- AILogWithSignature(@"Flagging chat %@ to in_reply_to_status_id = %@", timelineChat, inTweet);
+ AILogWithSignature(@"Flagging chat %@ to in_reply_to_status_id = %@", timelineChat, inTweet);
- [[NSNotificationCenter defaultCenter] removeObserver:self name:NSTextDidChangeNotification object:textView];
+ [[NSNotificationCenter defaultCenter] removeObserver:self name:NSTextDidChangeNotification object:textView];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textDidChange:) name:NSTextDidChangeNotification object:textView];
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textDidChange:) name:NSTextDidChangeNotification object:textView];
+ }
} else if ([inAction isEqualToString:@"favorite"]) {
[account toggleFavoriteTweet:inTweet];
} else if ([inAction isEqualToString:@"destroy"] && exactMatchForInternalID) {
More information about the commits
mailing list