diff --git a/README.markdown b/README.markdown new file mode 100644 index 0000000..1f67eba --- /dev/null +++ b/README.markdown @@ -0,0 +1,16 @@ +# THIS PLUGIN DOES NOT WORK # + +It is in development, it does not work right now. + +# What is this? # + +This is a plugin for the Storytlr application. It allows you to integrate your actions on Google Buzz into the Storytlr lifestream. + +# Installation # + +1. Clone this repo into your storytlr/protected/application/plugins/ directory +2. Rename the directory from "storytlr-plugin-googlebuzz" to "googlebuzz" +3. Load database.sql into your database +4. Copy googlebuzz.png into storytlr/images/ +5. Go on the admin side and add your account +6. You were done at number 5, you can stop reading now diff --git a/database.sql b/database.sql new file mode 100644 index 0000000..3ca5a44 --- /dev/null +++ b/database.sql @@ -0,0 +1,16 @@ +DROP TABLE IF EXISTS `googlebuzz_data`; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `googlebuzz_data` ( + `id` int(10) unsigned NOT NULL auto_increment, + `source_id` int(10) unsigned NOT NULL, + `buzz_id` varchar(255) NOT NULL, + `title` text NOT NULL, + `content` text, + `link` varchar(255) NOT NULL, + `published` varchar(45) NOT NULL, + PRIMARY KEY USING BTREE (`id`), + UNIQUE KEY `DUPLICATES` USING BTREE (`source_id`, `buzz_id`), + FULLTEXT KEY `SEARCH` (`content`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +SET character_set_client = @saved_cs_client; \ No newline at end of file diff --git a/example.atom b/example.atom new file mode 100644 index 0000000..1e991b7 --- /dev/null +++ b/example.atom @@ -0,0 +1,40 @@ + + + + + Google Buzz + 2009-12-14T20:04:39.977Z + tag:google.com,2009:buzz-feed/public/posted/117377434815709898403 + Google - Google Buzz + + Buzz by A. Googler from Mobile + 2009-12-14T20:04:39.000Z + 2009-12-14T20:04:39.977Z + tag:google.com,2009:buzz/z12bx5v5hljywtfug23wtrrpklnhf3gd3 + + + A. Googler + http://www.google.com/profiles/a.googler + + Bzz! Bzz! + http://activitystrea.ms/schema/1.0/post + + http://activitystrea.ms/schema/1.0/note + webupdates:a.googler@gmail.com.1258ecae5db + Buzz by A. Googler from Mobile + Bzz! Bzz! + + + 0 + + \ No newline at end of file diff --git a/googlebuzz.png b/googlebuzz.png new file mode 100644 index 0000000..e9d99e4 Binary files /dev/null and b/googlebuzz.png differ diff --git a/models/GooglebuzzItem.php b/models/GooglebuzzItem.php new file mode 100644 index 0000000..dd78564 --- /dev/null +++ b/models/GooglebuzzItem.php @@ -0,0 +1,43 @@ +_data['content']; } + + public function getTitle () { return $this->_data['title']; } + + public function getLink() { return $this->_data['link']; } + + public function getType() { return SourceItem::LINK_TYPE; } + + public function getBackup() { + $item = array(); + $item['SourceID'] = $this->_data['source_id']; + $item['Title'] = $this->_data['title']; + $item['Content'] = $this->_data['content']; + $item['Link'] = $this->_data['link']; + $item['Published'] = $this->_data['published']; + return $item; + } + +} \ No newline at end of file diff --git a/models/GooglebuzzModel.php b/models/GooglebuzzModel.php new file mode 100644 index 0000000..dbac59d --- /dev/null +++ b/models/GooglebuzzModel.php @@ -0,0 +1,137 @@ +getProperty('username'); + } + + public function getServiceDescription() { + return "Google Buzz is Google's social sharing network."; + } + + public function getAccountName() { + if( $name = $this->getProperty( 'username' ) ) { + return $name; + } + else { + return false; + } + } + + public function getTitle() { + return $this->getServiceName(); + } + + public function importData() { + $items = $this->updateData(); + $this->setImported( true ); + return $items; + } + + public function updateData() { + $url = ' http://buzz.googleapis.com/feeds/' . $this->getProperty( 'username' ) . '/public/posted'; + + $curl = curl_init(); + curl_setopt($curl, CURLOPT_URL, $url); + curl_setopt($curl, CURLOPT_HEADER, false); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); + curl_setopt($curl, CURLOPT_USERAGENT,'Storytlr/1.0'); + + $response = curl_exec($curl); + $http_code = curl_getinfo($curl, CURLINFO_HTTP_CODE); + curl_close ($curl); + + if ($http_code != 200) { + throw new Stuffpress_Exception( "Google Buzz returned http status $http_code for url: $url", $http_code ); + } + + if (!($items = simplexml_load_string($response))) { + throw new Stuffpress_Exception( "Google Buzz did not return any result", 0 ); + } + + if ( count( $items->entry ) == 0 ) { return; } + + $items = $this->processItems( $items->entry ); + $this->markUpdated(); + return $items; + } + + //! \todo + private function processItems( $items ) { + $result = array(); + foreach ($items as $item) { + $data = array(); + $data['title'] = $item->title; + $data['repository'] = substr( $item->title, strrpos( $item->title, ' ' ) + 1 ); + $data['published'] = strtotime( $item->published ); + $data['content'] = $item->content; + $data['link'] = $item->link['href']; + $data['github_id'] = $item->id; + $id = $this->addItem( $data, $data['published'], SourceItem::LINK_TYPE, false, false, false, $data['title'] ); + if ($id) $result[] = $id; + } + return $result; + } + + public function getConfigForm($populate=false) { + $form = new Stuffpress_Form(); + + // Add the username element + $element = $form->createElement('text', 'username', array('label' => 'Username', 'decorators' => $form->elementDecorators)); + $element->setRequired(true); + $form->addElement($element); + + // Populate + if($populate) { + $values = $this->getProperties(); + $form->populate($values); + } + + return $form; + } + + public function processConfigForm($form) { + $values = $form->getValues(); + $update = false; + + if($values['username'] != $this->getProperty('username')) { + $this->_properties->setProperty('username', $values['username']); + $update = true; + } + + return $update; + } +} diff --git a/views/scripts/rss.phtml b/views/scripts/rss.phtml new file mode 100755 index 0000000..dd13dac --- /dev/null +++ b/views/scripts/rss.phtml @@ -0,0 +1,3 @@ +
+
item->getTitle() ?>
+
\ No newline at end of file diff --git a/views/scripts/story.phtml b/views/scripts/story.phtml new file mode 100755 index 0000000..c0ac58d --- /dev/null +++ b/views/scripts/story.phtml @@ -0,0 +1,9 @@ +
+ + + + +
+ +
+
\ No newline at end of file diff --git a/views/scripts/timeline.phtml b/views/scripts/timeline.phtml new file mode 100644 index 0000000..8db5dc5 --- /dev/null +++ b/views/scripts/timeline.phtml @@ -0,0 +1,4 @@ +
+
item->getTitle(); ?>
+
item->getContent(); ?>
+
\ No newline at end of file