This repository has been archived by the owner on Sep 25, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created initial codebase, need to view some live data to figure out w…
…hat to store.
- Loading branch information
0 parents
commit e6ad8c3
Showing
9 changed files
with
268 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<feed xmlns="http://www.w3.org/2005/Atom" | ||
xmlns:thr="http://purl.org/syndication/thread/1.0" | ||
xmlns:media="http://search.yahoo.com/mrss" | ||
xmlns:activity="http://activitystrea.ms/spec/1.0/"> | ||
<link rel="self" | ||
type="application/atom+xml" | ||
href="http://buzz.googleapis.com/feeds/117377434815709898403/public/posted"/> | ||
<link rel="hub" href="http://pubsubhubbub.appspot.com/"/> | ||
<title type="text">Google Buzz</title> | ||
<updated>2009-12-14T20:04:39.977Z</updated> | ||
<id>tag:google.com,2009:buzz-feed/public/posted/117377434815709898403</id> | ||
<generator>Google - Google Buzz</generator> | ||
<entry> | ||
<title type="html">Buzz by A. Googler from Mobile</title> | ||
<published>2009-12-14T20:04:39.000Z</published> | ||
<updated>2009-12-14T20:04:39.977Z</updated> | ||
<id>tag:google.com,2009:buzz/z12bx5v5hljywtfug23wtrrpklnhf3gd3</id> | ||
<link rel="alternate" | ||
type="text/html" | ||
href="http://www.google.com/buzz/117377434815709898403/DmuNZHSfZ7t/buzz-buzz"/> | ||
<author> | ||
<name>A. Googler</name> | ||
<uri>http://www.google.com/profiles/a.googler</uri> | ||
</author> | ||
<content type="html">Bzz! Bzz!</content> | ||
<activity:verb>http://activitystrea.ms/schema/1.0/post</activity:verb> | ||
<activity:object> | ||
<activity:object-type>http://activitystrea.ms/schema/1.0/note</activity:object-type> | ||
<id>webupdates:a.googler@gmail.com.1258ecae5db</id> | ||
<title>Buzz by A. Googler from Mobile</title> | ||
<content type="html">Bzz! Bzz!</content> | ||
</activity:object> | ||
<link rel="replies" | ||
type="application/atom+xml" | ||
href="http://buzz.googleapis.com/feeds/117377434815709898403/comments/z12bx5v5hljywtfug23wtrrpklnhf3gd3" | ||
thr:count="0"/> | ||
<thr:total>0</thr:total> | ||
</entry> | ||
</feed> |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
/* | ||
* Copyright 2008-2009 Laurent Eschenauer and Alard Weisscher | ||
* Copyright 2010 John Hobbs | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
class GooglebuzzItem extends SourceItem { | ||
|
||
protected $_prefix = 'github'; | ||
|
||
protected $_preamble = 'Buzz activity: '; | ||
|
||
public function getContent() { return s$this->_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; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
<?php | ||
/* | ||
* Copyright 2008-2009 Laurent Eschenauer and Alard Weisscher | ||
* Copyright 2010 John Hobbs | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
class GooglebuzzModel extends SourceModel { | ||
|
||
protected $_name = 'googlebuzz_data'; | ||
|
||
protected $_prefix = 'googlebuzz'; | ||
|
||
protected $_search = 'content'; | ||
|
||
protected $_update_tweet = "Did %d things on Google Buzz on my lifestream %s"; | ||
|
||
public function getServiceName() { | ||
return "Google Buzz"; | ||
} | ||
|
||
public function isStoryElement() { | ||
return true; | ||
} | ||
|
||
public function getServiceURL() { | ||
return 'http://github.com/' . $this->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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<div class="googlebuzz"> | ||
<div class="content"><a href="<?= $this->item->getLink() ?>" target="_blank"><?= $this->item->getTitle() ?></a></div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<div class="googlebuzz"> | ||
<table cellspacing=0> | ||
<tr> | ||
<td style="background: url('../images/bg-googlebuzz.jpg') no-repeat"> | ||
<div class="title"><a href="<?= $this->item->getLink() ?>" target="_blank"><?= $this->item->getTitle() ?></a></div> | ||
</td> | ||
</tr> | ||
</table> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<div class="googlebuzz"> | ||
<div class="title"><?= $this->item->getTitle(); ?></div> | ||
<div class="content"><?= $this->item->getContent(); ?></div> | ||
</div> |