From dc09453a77f33c4dfdff306321ce93cf5fbd2d57 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Mon, 8 Feb 2010 11:06:03 -0800 Subject: First steps on converting FeedSub into the pub/sub basis for OStatus communications: * renamed FeedSub plugin to OStatus * now setting avatar on subscriptions * general fixes for subscription * integrated PuSH hub to handle only user timelines on canonical ID url; sends updates directly * set $config['feedsub']['nohub'] = true to test w/ foreign feeds that don't have hubs (won't actually receive updates though) * a few bits of code documentation * HMAC support for verified distributions (safest if sub setup is on HTTPS) And a couple core changes: * minimizing HTML output for exceptions in API requests to aid in debugging * fix for rel=self link in apitimelineuser when id given This does not not yet include any of the individual subscription management (Salmon notifications for sub/unsub, etc) nor a nice UI for user subscriptions. Needs some further cleanup to treat posts as status updates instead of link references. --- plugins/OStatus/tests/FeedMungerTest.php | 147 +++++++++++++++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100644 plugins/OStatus/tests/FeedMungerTest.php (limited to 'plugins/OStatus/tests/FeedMungerTest.php') diff --git a/plugins/OStatus/tests/FeedMungerTest.php b/plugins/OStatus/tests/FeedMungerTest.php new file mode 100644 index 000000000..0ce24c9fb --- /dev/null +++ b/plugins/OStatus/tests/FeedMungerTest.php @@ -0,0 +1,147 @@ +profile(); + + foreach ($expected as $field => $val) { + $this->assertEquals($expected[$field], $profile->$field, "profile->$field"); + } + } + + static public function profileProvider() + { + return array( + array(self::samplefeed(), + array('nickname' => 'leŭksman', // @todo does this need to be asciified? + 'fullname' => 'leŭksman', + 'bio' => 'reticula, electronica, & oddities', + 'homepage' => 'http://leuksman.com/log'))); + } + + /** + * @dataProvider noticeProvider + * + */ + public function testNotices($xml, $entryIndex, $expected) + { + $feed = new XML_Feed_Parser($xml, false, false, true); + $entry = $feed->getEntryByOffset($entryIndex); + + $munger = new FeedMunger($feed); + $notice = $munger->noticeFromEntry($entry); + + $this->assertTrue(mb_strlen($notice) <= Notice::maxContent()); + $this->assertEquals($expected, $notice); + } + + static public function noticeProvider() + { + return array( + array('A fairly short titlehttp://example.com/short/link', 0, + 'New post: "A fairly short title" http://example.com/short/link'), + // Requires URL shortening ... + array('A fairly short titlehttp://example.com/but/a/very/long/link/indeed/this/is/far/too/long/for/mere/humans/to/comprehend/oh/my/gosh', 0, + 'New post: "A fairly short title" http://ur1.ca/g2o1'), + array('A fairly long title in this case, which will have to get cut down at some point alongside its very long link. Really who even makes titles this long? It\'s just ridiculous imo...http://example.com/but/a/very/long/link/indeed/this/is/far/too/long/for/mere/humans/to/comprehend/oh/my/gosh', 0, + 'New post: "A fairly long title in this case, which will have to get cut down at some point alongside its very long li…" http://ur1.ca/g2o1'), + // Some real sample feeds + array(self::samplefeed(), 0, + 'New post: "Compiling PHP on Snow Leopard" http://leuksman.com/log/2009/11/12/compiling-php-on-snow-leopard/'), + array(self::samplefeedBlogspot(), 0, + 'New post: "I love posting" http://briontest.blogspot.com/2009/11/i-love-posting.html'), + array(self::samplefeedBlogspot(), 1, + 'New post: "Hey dude" http://briontest.blogspot.com/2009/11/hey-dude.html'), + ); + } + + static protected function samplefeed() + { + $xml = '<' . '?xml version="1.0" encoding="UTF-8"?' . ">\n"; + $samplefeed = $xml . << + + + leŭksman + + http://leuksman.com/log + reticula, electronica, & oddities + + Thu, 12 Nov 2009 17:44:42 +0000 + http://wordpress.org/?v=2.8.6 + en + hourly + 1 + + + Compiling PHP on Snow Leopard + http://leuksman.com/log/2009/11/12/compiling-php-on-snow-leopard/ + http://leuksman.com/log/2009/11/12/compiling-php-on-snow-leopard/#comments + Thu, 12 Nov 2009 17:44:42 +0000 + brion + + + + + http://leuksman.com/log/?p=649 + + If you’ve been having trouble compiling your own PHP installations on Mac OS X 10.6, here’s the secret to making it not suck! After running the configure script, edit the generated Makefile and make these fixes:

+
    +
  • Find the EXTRA_LIBS definition and add -lresolv to the end
  • +
  • Find the EXE_EXT definition and remove .dSYM
  • +
+

Standard make and make install should work from here…

+

For reference, here’s the whole configure line I currently use; MySQL is installed from the downloadable installer; other deps from MacPorts:

+

‘./configure’ ‘–prefix=/opt/php52′ ‘–with-mysql=/usr/local/mysql’ ‘–with-zlib’ ‘–with-bz2′ ‘–enable-mbstring’ ‘–enable-exif’ ‘–enable-fastcgi’ ‘–with-xmlrpc’ ‘–with-xsl’ ‘–with-readline=/opt/local’ –without-iconv –with-gd –with-png-dir=/opt/local –with-jpeg-dir=/opt/local –with-curl –with-gettext=/opt/local –with-mysqli=/usr/local/mysql/bin/mysql_config –with-tidy=/opt/local –enable-pcntl –with-openssl

+]]>
+ http://leuksman.com/log/2009/11/12/compiling-php-on-snow-leopard/feed/ + 0 +
+
+ +END; + return $samplefeed; + } + + static protected function samplefeedBlogspot() + { + return <<tag:blogger.com,1999:blog-77800835085316971672009-11-19T12:56:11.233-08:00Brion's Cool Test Blogbrionhttp://www.blogger.com/profile/12932299467049762017noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-7780083508531697167.post-84566718790002906772009-11-19T12:55:00.000-08:002009-11-19T12:56:11.241-08:00I love postingIt's pretty awesome, if you like that sort of thing.<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7780083508531697167-8456671879000290677?l=briontest.blogspot.com' alt='' /></div>brionhttp://www.blogger.com/profile/12932299467049762017noreply@blogger.com0tag:blogger.com,1999:blog-7780083508531697167.post-82022969178973466332009-11-18T13:52:00.001-08:002009-11-18T13:52:48.444-08:00Hey dudetestingggggggggg<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7780083508531697167-8202296917897346633?l=briontest.blogspot.com' alt='' /></div>brionhttp://www.blogger.com/profile/12932299467049762017noreply@blogger.com0 +END; + } +} -- cgit v1.2.3-54-g00ecf