I found some bugs in the Twitter plugin:
- When using the linktrimmer::create function unnecessary shorturls are created. Using lookup solves the problem
- for the tweetback lookup: the raw short url format cuts urls at 140 chars, and therefore leads to bad results. twitter can use the full url to search so I created another "reallyraw" shorturl and use it when looking for tweetbacks
This is the patch. I would love to see it in the official tree so I do not have to repatch with every new version.
Code: Select all
diff -rNu Downloads/serendipity_plugin_twitter/classes/UrlShortener.php Desktop/serendipity_plugin_twitter/classes/UrlShortener.php
--- Downloads/serendipity_plugin_twitter/classes/UrlShortener.php 2011-06-22 23:45:16.000000000 +0200
+++ Desktop/serendipity_plugin_twitter/classes/UrlShortener.php 2011-07-07 18:04:55.000000000 +0200
@@ -31,9 +31,9 @@
if (empty($lt_prefix)) $lt_prefix = '/s/';
if ($lt_domain == $serendipity['baseURL']) {
- $shorturls['linktrimmer'] = $lt_domain . $lt_prefix .trim(serendipity_event_linktrimmer::create($url));
+ $shorturls['linktrimmer'] = $lt_domain. $lt_prefix .trim(serendipity_event_linktrimmer::lookup($url));
} else {
- $shorturls['linktrimmer'] = $lt_domain . trim(serendipity_event_linktrimmer::create($url));
+ $shorturls['linktrimmer'] = $lt_domain . trim(serendipity_event_linktrimmer::lookup($url));
}
}
break;
@@ -42,6 +42,9 @@
$shorturls['raw'] = $url;
}
break;
+ case 'reallyraw';
+ $shorturls['reallyraw'] = $url;
+ break;
case 'tinyurl';
UrlShortener::shorten_via_tinyurl( $url, $shorturls );
break;
diff -rNu Downloads/serendipity_plugin_twitter/serendipity_event_twitter.php Desktop/serendipity_plugin_twitter/serendipity_event_twitter.php
--- Downloads/serendipity_plugin_twitter/serendipity_event_twitter.php 2011-06-12 12:31:54.000000000 +0200
+++ Desktop/serendipity_plugin_twitter/serendipity_event_twitter.php 2011-07-07 18:05:48.000000000 +0200
@@ -1685,7 +1685,7 @@
}
// Always look up 'raw'
- UrlShortener::put_shorturl('raw', $article_url, $shorturls);
+ UrlShortener::put_shorturl('reallyraw', $article_url, $shorturls);
TwitterPluginDbAccess::save_short_urls( $article_url, $shorturls, $loaded_shorturls );
return $shorturls;
@@ -2044,4 +2044,4 @@
$return = true;
}
}
-}
\ No newline at end of file
+}