Issues with Tweetbacks & multiple shortend urls

Found a bug? Tell us!!
Post Reply
danst0
Regular
Posts: 197
Joined: Tue Jul 13, 2004 10:50 am

Issues with Tweetbacks & multiple shortend urls

Post by danst0 »

Hi,

I just recently had two issues with the Twitter plugin regarding
1) tweetbacks: Twitter is searched but not correctly if the full article url is longer than 140 chars (this limitation does not matter for urls in the search function)

2) Double entries are created when using the internal url shortener so it is better to use the lookup function instead of create

Ergo, I wrote a patch and it would be cool if someone could check it and check it in.

Code: Select all

diff -urN old_serendipity_plugin_twitter/classes/UrlShortener.php new_serendipity_plugin_twitter/classes/UrlShortener.php
--- old_serendipity_plugin_twitter/classes/UrlShortener.php	2011-05-04 15:55:02.000000000 +0200
+++ new_serendipity_plugin_twitter/classes/UrlShortener.php	2011-06-01 17:34:00.000000000 +0200
@@ -27,13 +27,10 @@
                     if (is_array($res) && !empty($res['value'])) {
                         $lt_domain = trim($res['value']);
                     }
-                    if (empty($lt_domain)) $lt_domain = $serendipity['baseURL'];
-                    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 +39,9 @@
                     $shorturls['raw'] = $url;
                 }
                 break;
+            case 'reallyraw';
+                $shorturls['reallyraw'] = $url;
+                break;
             case 'tinyurl';
                 UrlShortener::shorten_via_tinyurl( $url, $shorturls );
                 break;
diff -urN old_serendipity_plugin_twitter/serendipity_event_twitter.php new_serendipity_plugin_twitter/serendipity_event_twitter.php
--- old_serendipity_plugin_twitter/serendipity_event_twitter.php	2011-05-02 13:48:20.000000000 +0200
+++ new_serendipity_plugin_twitter/serendipity_event_twitter.php	2011-06-01 17:39:00.000000000 +0200
@@ -1414,7 +1414,6 @@
         $title = $entry['title'];
         $tags_marker = '#tags#';
         $announce_format_notags = trim(str_replace($tags_marker,'',$announce_format));
-
         // Check for tags:
         $tagsnotused = array();
         if (serendipity_db_bool($this->get_config('announce_with_tags',false)) && !empty($serendipity['POST']['properties']) && !(empty($serendipity['POST']['properties']['freetag_tagList']) && empty($serendipity['POST']['properties']['microblogging_tagList'])) && strlen($announce_format_notags)<140) {
@@ -1685,7 +1684,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;
Daniel
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Issues with Tweetbacks & multiple shortend urls

Post by garvinhicking »

Hi!

Okay, sounds interesting! Can you tell me why those two lines were removed:

Code: Select all

-                    if (empty($lt_domain)) $lt_domain = $serendipity['baseURL'];
-                    if (empty($lt_prefix)) $lt_prefix = '/s/';
?

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Post Reply