]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Merge remote branch 'gitorious/0.9.x' into 0.9.x
authorEvan Prodromou <evan@status.net>
Tue, 21 Sep 2010 18:07:48 +0000 (14:07 -0400)
committerEvan Prodromou <evan@status.net>
Tue, 21 Sep 2010 18:07:48 +0000 (14:07 -0400)
plugins/Comet/README
plugins/TwitterBridge/daemons/twitterstatusfetcher.php
scripts/commandline.inc
scripts/importtwitteratom.php

index 4abd40af7ae18bbb3e350559ac7d2ab1fd888e46..f6e840b6afde2777188b3d70eec6b73ef5a89d06 100644 (file)
@@ -6,7 +6,10 @@ NOTE: this is an insecure version; don't roll it out on a production
 server.
 
 It requires a cometd server. I've only had the cometd-java server work
-correctly; something's wiggy with the Twisted-based server.
+correctly; something's wiggy with the Twisted-based server. See here
+for help setting up a comet server:
+
+    http://cometd.org/
 
 After you have a cometd server installed, just add this code to your
 config.php:
index 31129b96d9e452ce63d9e21d7299457dd688a6dc..590fa2954d1ac467c65d2f23a97917a9b1ef59e6 100755 (executable)
@@ -692,6 +692,10 @@ class TwitterStatusFetcher extends ParallelizingDaemon
         $text = $status->text;
 
         if (empty($status->entities)) {
+            common_log(LOG_WARNING, "No entities data for {$status->id}; trying to fake up links ourselves.");
+            $text = common_replace_urls_callback($text, 'common_linkify');
+            $text = preg_replace('/(^|\&quot\;|\'|\(|\[|\{|\s+)#([\pL\pN_\-\.]{1,64})/e', "'\\1#'.TwitterStatusFetcher::tagLink('\\2')", $text);
+            $text = preg_replace('/(^|\s+)@([a-z0-9A-Z_]{1,64})/e', "'\\1@'.TwitterStatusFetcher::atLink('\\2')", $text);
             return $text;
         }
 
@@ -750,12 +754,26 @@ class TwitterStatusFetcher extends ParallelizingDaemon
 
     function makeHashtagLink($object)
     {
-        return "#<a href='https://twitter.com/search?q=%23{$object->text}' class='hashtag'>{$object->text}</a>";
+        return "#" . self::tagLink($object->text);
     }
 
     function makeMentionLink($object)
     {
-        return "@<a href='http://twitter.com/{$object->screen_name}' title='{$object->name}'>{$object->screen_name}</a>";
+        return "@".self::atLink($object->screen_name, $object->name);
+    }
+
+    static function tagLink($tag)
+    {
+        return "<a href='https://twitter.com/search?q=%23{$tag}' class='hashtag'>{$tag}</a>";
+    }
+
+    static function atLink($screenName, $fullName=null)
+    {
+        if (!empty($fullName)) {
+            return "<a href='http://twitter.com/{$screenName}' title='{$fullName}'>{$screenName}</a>";
+        } else {
+            return "<a href='http://twitter.com/{$screenName}'>{$screenName}</a>";
+        }
     }
 
     function saveStatusMentions($notice, $status)
index a475e11d01abba19ba7fb9ba8126f00f312388c7..a29f588448db88f7d048be2d5475ebe9f786874e 100644 (file)
@@ -177,3 +177,27 @@ function get_option_value($opt, $alt=null)
 
     return null;
 }
+
+function getUser()
+{
+    $user = null;
+
+    if (have_option('i', 'id')) {
+        $id = get_option_value('i', 'id');
+        $user = User::staticGet('id', $id);
+        if (empty($user)) {
+            throw new Exception("Can't find user with id '$id'.");
+        }
+    } else if (have_option('n', 'nickname')) {
+        $nickname = get_option_value('n', 'nickname');
+        $user = User::staticGet('nickname', $nickname);
+        if (empty($user)) {
+            throw new Exception("Can't find user with nickname '$nickname'");
+        }
+    } else {
+        show_help();
+        exit(1);
+    }
+
+    return $user;
+}
index c12e3b91a8f3a920ce9fc9c4f21e08fded44b83d..261dfb1d02b7af595d628632eec97f1af2947cb4 100644 (file)
@@ -36,30 +36,6 @@ END_OF_IMPORTTWITTERATOM_HELP;
 require_once INSTALLDIR.'/scripts/commandline.inc';
 require_once INSTALLDIR.'/extlib/htmLawed/htmLawed.php';
 
-function getUser()
-{
-    $user = null;
-
-    if (have_option('i', 'id')) {
-        $id = get_option_value('i', 'id');
-        $user = User::staticGet('id', $id);
-        if (empty($user)) {
-            throw new Exception("Can't find user with id '$id'.");
-        }
-    } else if (have_option('n', 'nickname')) {
-        $nickname = get_option_value('n', 'nickname');
-        $user = User::staticGet('nickname', $nickname);
-        if (empty($user)) {
-            throw new Exception("Can't find user with nickname '$nickname'");
-        }
-    } else {
-        show_help();
-        exit(1);
-    }
-
-    return $user;
-}
-
 function getAtomFeedDocument()
 {
     $filename = get_option_value('f', 'file');