Skip to content

Commit

Permalink
realtime fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Hendrickson committed Nov 9, 2009
1 parent 7fe6e8a commit cdf1db7
Show file tree
Hide file tree
Showing 27 changed files with 395 additions and 73 deletions.
2 changes: 2 additions & 0 deletions app/config/config.yml
Expand Up @@ -84,6 +84,7 @@ env:
- flickr
- rsscloud
- wiki
- shortener

installed:
- twitter
Expand All @@ -95,6 +96,7 @@ env:
- flickr
- rsscloud
- wiki
- shortener

boot: omb

Expand Down
6 changes: 4 additions & 2 deletions app/facebook/views/facebook_users/_edit.html
Expand Up @@ -7,7 +7,7 @@
// <![CDATA[


$(document).ready(function() {
function show_jeditable(){

var submit_to = "<?php echo $staturl; ?>";

Expand Down Expand Up @@ -40,7 +40,9 @@



});
}
show_jeditable();


// ]]>
</script>
Expand Down
6 changes: 4 additions & 2 deletions app/flickr/views/flickr_users/_edit.html
Expand Up @@ -7,7 +7,7 @@
// <![CDATA[


$(document).ready(function() {
function show_jeditable(){

var submit_to = "<?php echo $staturl; ?>";

Expand Down Expand Up @@ -40,7 +40,9 @@



});
}
show_jeditable();


// ]]>
</script>
Expand Down
6 changes: 4 additions & 2 deletions app/identica/views/dents/_edit.html
Expand Up @@ -10,7 +10,7 @@



$(document).ready(function() {
function show_jeditable(){

var submit_to = "<?php echo $userurl; ?>";

Expand Down Expand Up @@ -106,7 +106,9 @@
});
});

});
}
show_jeditable();


<?php setting_widget_text_post_helper('server',$serverurl); ?>

Expand Down
65 changes: 65 additions & 0 deletions app/omb/controllers/posts.php
Expand Up @@ -15,9 +15,74 @@ function get( &$vars ) {
}


function handle_twitter_cmdline(&$request){
$commands = array(
'follow ',
'unfollow ',
'addtolist '
);
$parts = explode(" ",$request->params['post']['title']);
$c = $parts[0]." ";
$result = false;
if (in_array($c,$commands)){
$c = trim($c)."_cmdfunc";
if (function_exists($c))
$result = $c($parts);
}
return $result;
}

function follow_cmdfunc($parts){
if (isset($parts[1])){
$to = get_twitter_oauth();
if ($to){
$content = $to->OAuthRequest('https://twitter.com/friendships/create/'.$parts[1].'.xml', array(), 'POST');
return true;
}
}
return false;
}

function unfollow_cmdfunc($parts){
if (isset($parts[1])){
$to = get_twitter_oauth();
if ($to){
$content = $to->OAuthRequest('https://twitter.com/friendships/destroy/'.$parts[1].'.xml', array(), 'POST');
return true;
}
}
return false;
}

function addtolist_cmdfunc($parts){
if (isset($parts[1])&&isset($parts[2])){
$to = get_twitter_oauth();
if ($to){
$content = $to->OAuthRequest('https://twitter.com/users/show/'.$parts[1].'.json', array(), 'GET');
if (!(class_exists('Services_JSON')))
lib_include('json');
$json = new Services_JSON();
$data = $json->decode($content);
if ($content && $data && $json)
$content = $to->OAuthRequest('https://api.twitter.com/1/'.get_twitter_screen_name().'/'.$parts[2].'/members.xml', array('id'=>$data->id), 'POST');
if (isset($parts[3]))
if ($parts[3] == '-u')
$content = $to->OAuthRequest('https://twitter.com/friendships/destroy/'.$parts[1].'.xml', array(), 'POST');
return true;
}
}
return false;
}

function post( &$vars ) {
extract( $vars );
global $request;

$twittercmd = handle_twitter_cmdline($request);

if ($twittercmd)
redirect_to($request->base);

$modelvar = classify($request->resource);
trigger_before( 'insert_from_post', $$modelvar, $request );
$table = $request->resource;
Expand Down
6 changes: 6 additions & 0 deletions app/omb/plugins/omb.php
Expand Up @@ -36,6 +36,12 @@
foreach ($omb_routes as $func)
$request->connect( $func );

$request->connect( 'status', array(
'resource'=>'posts',
'action'=>'index'
));


$request->connect(
'email/:ident',
array(
Expand Down
32 changes: 32 additions & 0 deletions app/omb/plugins/security.php
Expand Up @@ -1324,3 +1324,35 @@ function security_uninstall() {
}


function get_twitter_oauth(){
global $db,$prefix,$request;
$sql = "SELECT oauth_key,oauth_secret FROM ".$prefix."twitter_users WHERE profile_id = ".get_profile_id();
$result = $db->get_result( $sql );
if ($db->num_rows($result) == 1) {
// http://abrah.am
lib_include('twitteroauth');
$key = $db->result_value($result,0,'oauth_key');
$secret = $db->result_value($result,0,'oauth_secret');
$consumer_key = environment( 'twitterKey' );
$consumer_secret = environment( 'twitterSecret' );
$to = new TwitterOAuth(
$consumer_key,
$consumer_secret,
$key,
$secret
);
return $to;
}
return false;
}

function get_twitter_screen_name(){
global $db,$prefix,$request;
$sql = "SELECT screen_name FROM ".$prefix."twitter_users WHERE profile_id = ".get_profile_id();
$result = $db->get_result( $sql );
if ($db->num_rows($result) == 1)
return $db->result_value($result,0,'screen_name');
return false;
}


@@ -1,5 +1,6 @@
<?php

if (!(class_exists('oauthexception')))
require_once dirname(__FILE__).'/OAuth.php';

//Assumes a Wordpress context ($wpdb especially)
Expand Down
@@ -1,4 +1,5 @@
<?php
if (!(class_exists('oauthexception')))
require_once dirname(__FILE__).'/OAuth.php';
require_once dirname(__FILE__).'/OAuthWordpressStore.php';
require_once dirname(__FILE__).'/../../../wp-config.php';
Expand Down
2 changes: 2 additions & 0 deletions app/omb/plugins/wp.php
Expand Up @@ -982,6 +982,8 @@ function wp_head() {
else
echo '<script type="text/javascript" src="'.base_path(true).'resource/jquery-1.2.6.min.js"></script>';

echo '<script src="'.base_path(true).'resource/jquery.charcounter.js" type="text/javascript"></script>';

if (environment('longurl'))
echo '
<script type="text/javascript" src="'.base_path(true).'resource/jquery.longurl.js"></script>
Expand Down
12 changes: 5 additions & 7 deletions app/omb/views/admin/index.html
Expand Up @@ -13,12 +13,6 @@
<script type="text/javascript">
$(function() {
$("#tabs").tabs();
$("#tabs").click(function() {

var b = $("#tabs").tabs('option', 'selected');
if (b == 6) location.href='<?php base_url(); ?>';

});
});
</script>

Expand Down Expand Up @@ -60,7 +54,7 @@
<?php else : ?>
<li><a href="#tabs-4">&nbsp;</a></li>
<?php endif; ?>
<li><a href="JavaScript:top.location.href('<?php base_url(); ?>');">Return To Site</a></li>
<li><a onclick="go_home()" href="#tabs-5">Return To Site</a></li>
</ul>


Expand All @@ -74,6 +68,10 @@
<script type="text/javascript">
// <![CDATA[

function go_home(){
location.href='<?php base_url(); ?>';
}

$(document).ready(function() {

var submit_to = "<?php url_for(array(
Expand Down
6 changes: 4 additions & 2 deletions app/omb/views/identities/_apps.html
Expand Up @@ -42,7 +42,7 @@
}


$(document).ready(function() {
function show_jeditable(){

var submit_to = "<?php url_for(array(
'resource'=>'settings'
Expand Down Expand Up @@ -129,7 +129,9 @@
}
});

});
}
show_jeditable();

// ]]>
</script>
<p class="editable_select_installer" id="editable_select_installer"></p>
Expand Down
6 changes: 4 additions & 2 deletions app/omb/views/identities/_background.html
Expand Up @@ -9,7 +9,7 @@
<script type="text/javascript">
// <![CDATA[

$(document).ready(function() {
function show_jeditable(){

var submit_to = "<?php echo $settingurl; ?>";

Expand Down Expand Up @@ -39,7 +39,9 @@

<?php setting_widget_helper('tile',$setting_mode,$setting_url,$setting_entry,$setting_list); ?>

});
}
show_jeditable();



// ]]>
Expand Down
6 changes: 4 additions & 2 deletions app/omb/views/identities/_edit.html
Expand Up @@ -9,7 +9,7 @@
<script type="text/javascript">
// <![CDATA[

$(document).ready(function() {
function show_jeditable(){

<?php setting_widget_helper('tz',$n2mode,$n2url,$n2entry,$n2list); ?>

Expand Down Expand Up @@ -41,7 +41,9 @@

<?php setting_widget_helper('tile',$setting_mode,$setting_url,$setting_entry,$setting_list); ?>

});
}
show_jeditable();

// ]]>
</script>

Expand Down
20 changes: 13 additions & 7 deletions app/omb/views/posts/_entry.html
Expand Up @@ -27,8 +27,14 @@
data = data.substring(0,(data.length - 10));
eval( "data = " + data );
if (data['in_reply_to']) {
var selectr = data['in_reply_to'];
$(selectr).append(data['html']);
if (lasttweet == data['html']){

}else{
var selectr = data['in_reply_to'];
$("#aftercomments").append(render_a_tweet(data));
//$(selectr).append(data['html']);
lasttweet = data['html'];
}
} else {
$("#postlist").prepend(data['html']);
}
Expand Down Expand Up @@ -122,11 +128,9 @@
<br />


<div id="commentcontent-<?php echo $Member->id; ?>" class="commentlist"></div>

<?php $ccrurl = 'JavaScript:inline_comment('.$Member->id.','.$Member->id.');'; ?>

<a rel=\'nofollow\' class=\'comment-reply-link\' href="<?php echo $ccrurl; ?>">Comment</a>

<br />

Expand Down Expand Up @@ -155,8 +159,10 @@
?>

<?php endwhile; ?>
<div class="entry-clear"></div>
<div class="entry-clear" id="aftercomments"></div>
<div id="commentcontent-<?php echo $Member->id; ?>" class="commentlist"></div>

<a rel=\'nofollow\' class=\'comment-reply-link\' href="<?php echo $ccrurl; ?>"><?php echo $txt['entry_reply']; ?></a>


<?php if (environment('showpostmeta')) : ?>
Expand Down Expand Up @@ -196,7 +202,7 @@
$ident = $Identity->base();
?>


<?php if (environment('old_reply_form')) : ?>
<div>
<br />
<h3><?php echo $txt['entry_reply']; ?>:</h3>
Expand All @@ -211,7 +217,7 @@ <h3><?php echo $txt['entry_reply']; ?>:</h3>
</form>
<br />
</div>

<?php endif; ?>
<?php if (environment('showpostmeta')) : ?>
<h3><?php echo $txt['entry_rating']; ?>:</h3>
<form name="reviewpost" method="post" action="<?php url_for(array('resource'=>'reviews')); ?>">
Expand Down

0 comments on commit cdf1db7

Please sign in to comment.