Merge branch '0.7.x' into querybyid
This commit is contained in:
commit
ec8dd014e3
3
.gitignore
vendored
3
.gitignore
vendored
@ -13,3 +13,6 @@ dataobject.ini
|
|||||||
*.rej
|
*.rej
|
||||||
.#*
|
.#*
|
||||||
*.swp
|
*.swp
|
||||||
|
.buildpath
|
||||||
|
.project
|
||||||
|
.settings
|
||||||
|
@ -59,7 +59,7 @@ class AccesstokenAction extends Action
|
|||||||
try {
|
try {
|
||||||
common_debug('getting request from env variables', __FILE__);
|
common_debug('getting request from env variables', __FILE__);
|
||||||
common_remove_magic_from_request();
|
common_remove_magic_from_request();
|
||||||
$req = OAuthRequest::from_request('POST', common_locale_url('accesstoken'));
|
$req = OAuthRequest::from_request('POST', common_local_url('accesstoken'));
|
||||||
common_debug('getting a server', __FILE__);
|
common_debug('getting a server', __FILE__);
|
||||||
$server = omb_oauth_server();
|
$server = omb_oauth_server();
|
||||||
common_debug('fetching the access token', __FILE__);
|
common_debug('fetching the access token', __FILE__);
|
||||||
|
@ -130,6 +130,7 @@ class ApiAction extends Action
|
|||||||
'statuses/friends_timeline',
|
'statuses/friends_timeline',
|
||||||
'statuses/friends',
|
'statuses/friends',
|
||||||
'statuses/replies',
|
'statuses/replies',
|
||||||
|
'statuses/mentions',
|
||||||
'statuses/followers',
|
'statuses/followers',
|
||||||
'favorites/favorites');
|
'favorites/favorites');
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ class FavoritesrssAction extends Rss10Action
|
|||||||
$c = array('url' => common_local_url('favoritesrss',
|
$c = array('url' => common_local_url('favoritesrss',
|
||||||
array('nickname' =>
|
array('nickname' =>
|
||||||
$user->nickname)),
|
$user->nickname)),
|
||||||
'title' => sprintf(_("%s favorite notices"), $user->nickname),
|
'title' => sprintf(_("%s's favorite notices"), $user->nickname),
|
||||||
'link' => common_local_url('showfavorites',
|
'link' => common_local_url('showfavorites',
|
||||||
array('nickname' =>
|
array('nickname' =>
|
||||||
$user->nickname)),
|
$user->nickname)),
|
||||||
|
@ -74,9 +74,9 @@ class ShowfavoritesAction extends Action
|
|||||||
function title()
|
function title()
|
||||||
{
|
{
|
||||||
if ($this->page == 1) {
|
if ($this->page == 1) {
|
||||||
return sprintf(_("%s favorite notices"), $this->user->nickname);
|
return sprintf(_("%s's favorite notices"), $this->user->nickname);
|
||||||
} else {
|
} else {
|
||||||
return sprintf(_("%s favorite notices, page %d"),
|
return sprintf(_("%s's favorite notices, page %d"),
|
||||||
$this->user->nickname,
|
$this->user->nickname,
|
||||||
$this->page);
|
$this->page);
|
||||||
}
|
}
|
||||||
|
@ -144,10 +144,10 @@ class TwitapistatusesAction extends TwitterapiAction
|
|||||||
break;
|
break;
|
||||||
case 'atom':
|
case 'atom':
|
||||||
if (isset($apidata['api_arg'])) {
|
if (isset($apidata['api_arg'])) {
|
||||||
$selfuri = $selfuri = common_root_url() .
|
$selfuri = common_root_url() .
|
||||||
'api/statuses/friends_timeline/' . $apidata['api_arg'] . '.atom';
|
'api/statuses/friends_timeline/' . $apidata['api_arg'] . '.atom';
|
||||||
} else {
|
} else {
|
||||||
$selfuri = $selfuri = common_root_url() .
|
$selfuri = common_root_url() .
|
||||||
'api/statuses/friends_timeline.atom';
|
'api/statuses/friends_timeline.atom';
|
||||||
}
|
}
|
||||||
$this->show_atom_timeline($notice, $title, $id, $link, $subtitle, null, $selfuri);
|
$this->show_atom_timeline($notice, $title, $id, $link, $subtitle, null, $selfuri);
|
||||||
@ -231,10 +231,10 @@ class TwitapistatusesAction extends TwitterapiAction
|
|||||||
break;
|
break;
|
||||||
case 'atom':
|
case 'atom':
|
||||||
if (isset($apidata['api_arg'])) {
|
if (isset($apidata['api_arg'])) {
|
||||||
$selfuri = $selfuri = common_root_url() .
|
$selfuri = common_root_url() .
|
||||||
'api/statuses/user_timeline/' . $apidata['api_arg'] . '.atom';
|
'api/statuses/user_timeline/' . $apidata['api_arg'] . '.atom';
|
||||||
} else {
|
} else {
|
||||||
$selfuri = $selfuri = common_root_url() .
|
$selfuri = common_root_url() .
|
||||||
'api/statuses/user_timeline.atom';
|
'api/statuses/user_timeline.atom';
|
||||||
}
|
}
|
||||||
$this->show_atom_timeline($notice, $title, $id, $link, $subtitle, $suplink, $selfuri);
|
$this->show_atom_timeline($notice, $title, $id, $link, $subtitle, $suplink, $selfuri);
|
||||||
@ -344,7 +344,7 @@ class TwitapistatusesAction extends TwitterapiAction
|
|||||||
$this->show($args, $apidata);
|
$this->show($args, $apidata);
|
||||||
}
|
}
|
||||||
|
|
||||||
function replies($args, $apidata)
|
function mentions($args, $apidata)
|
||||||
{
|
{
|
||||||
|
|
||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
@ -360,11 +360,13 @@ class TwitapistatusesAction extends TwitterapiAction
|
|||||||
$profile = $user->getProfile();
|
$profile = $user->getProfile();
|
||||||
|
|
||||||
$sitename = common_config('site', 'name');
|
$sitename = common_config('site', 'name');
|
||||||
$title = sprintf(_('%1$s / Updates replying to %2$s'), $sitename, $user->nickname);
|
$title = sprintf(_('%1$s / Updates mentioning %2$s'),
|
||||||
|
$sitename, $user->nickname);
|
||||||
$taguribase = common_config('integration', 'taguri');
|
$taguribase = common_config('integration', 'taguri');
|
||||||
$id = "tag:$taguribase:Replies:".$user->id;
|
$id = "tag:$taguribase:Mentions:".$user->id;
|
||||||
$link = common_local_url('replies', array('nickname' => $user->nickname));
|
$link = common_local_url('replies', array('nickname' => $user->nickname));
|
||||||
$subtitle = sprintf(_('%1$s updates that reply to updates from %2$s / %3$s.'), $sitename, $user->nickname, $profile->getBestName());
|
$subtitle = sprintf(_('%1$s updates that reply to updates from %2$s / %3$s.'),
|
||||||
|
$sitename, $user->nickname, $profile->getBestName());
|
||||||
|
|
||||||
if (!$page) {
|
if (!$page) {
|
||||||
$page = 1;
|
$page = 1;
|
||||||
@ -385,7 +387,8 @@ class TwitapistatusesAction extends TwitterapiAction
|
|||||||
|
|
||||||
$since = strtotime($this->arg('since'));
|
$since = strtotime($this->arg('since'));
|
||||||
|
|
||||||
$notice = $user->getReplies((($page-1)*20), $count, $since_id, $before_id, $since);
|
$notice = $user->getReplies((($page-1)*20),
|
||||||
|
$count, $since_id, $before_id, $since);
|
||||||
$notices = array();
|
$notices = array();
|
||||||
|
|
||||||
while ($notice->fetch()) {
|
while ($notice->fetch()) {
|
||||||
@ -400,14 +403,10 @@ class TwitapistatusesAction extends TwitterapiAction
|
|||||||
$this->show_rss_timeline($notices, $title, $link, $subtitle);
|
$this->show_rss_timeline($notices, $title, $link, $subtitle);
|
||||||
break;
|
break;
|
||||||
case 'atom':
|
case 'atom':
|
||||||
if (isset($apidata['api_arg'])) {
|
$selfuri = common_root_url() .
|
||||||
$selfuri = $selfuri = common_root_url() .
|
ltrim($_SERVER['QUERY_STRING'], 'p=');
|
||||||
'api/statuses/replies/' . $apidata['api_arg'] . '.atom';
|
$this->show_atom_timeline($notices, $title, $id, $link, $subtitle,
|
||||||
} else {
|
null, $selfuri);
|
||||||
$selfuri = $selfuri = common_root_url() .
|
|
||||||
'api/statuses/replies.atom';
|
|
||||||
}
|
|
||||||
$this->show_atom_timeline($notices, $title, $id, $link, $subtitle, null, $selfuri);
|
|
||||||
break;
|
break;
|
||||||
case 'json':
|
case 'json':
|
||||||
$this->show_json_timeline($notices);
|
$this->show_json_timeline($notices);
|
||||||
@ -418,6 +417,11 @@ class TwitapistatusesAction extends TwitterapiAction
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function replies($args, $apidata)
|
||||||
|
{
|
||||||
|
call_user_func(array($this, 'mentions'), $args, $apidata);
|
||||||
|
}
|
||||||
|
|
||||||
function show($args, $apidata)
|
function show($args, $apidata)
|
||||||
{
|
{
|
||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
|
@ -128,7 +128,7 @@
|
|||||||
var a = document.createElement('A');
|
var a = document.createElement('A');
|
||||||
a.innerHTML = 'get this';
|
a.innerHTML = 'get this';
|
||||||
a.target = '_blank';
|
a.target = '_blank';
|
||||||
a.href = 'http://identica/doc/badge';
|
a.href = 'http://identi.ca/doc/badge';
|
||||||
$.s.f.appendChild(a);
|
$.s.f.appendChild(a);
|
||||||
$.s.appendChild($.s.f);
|
$.s.appendChild($.s.f);
|
||||||
$.f.getUser();
|
$.f.getUser();
|
||||||
|
@ -231,12 +231,12 @@ class Router
|
|||||||
$m->connect('api/statuses/:method',
|
$m->connect('api/statuses/:method',
|
||||||
array('action' => 'api',
|
array('action' => 'api',
|
||||||
'apiaction' => 'statuses'),
|
'apiaction' => 'statuses'),
|
||||||
array('method' => '(public_timeline|friends_timeline|user_timeline|update|replies|friends|followers|featured)(\.(atom|rss|xml|json))?'));
|
array('method' => '(public_timeline|friends_timeline|user_timeline|update|replies|mentions|friends|followers|featured)(\.(atom|rss|xml|json))?'));
|
||||||
|
|
||||||
$m->connect('api/statuses/:method/:argument',
|
$m->connect('api/statuses/:method/:argument',
|
||||||
array('action' => 'api',
|
array('action' => 'api',
|
||||||
'apiaction' => 'statuses'),
|
'apiaction' => 'statuses'),
|
||||||
array('method' => '(user_timeline|friends_timeline|replies|show|destroy|friends|followers)'));
|
array('method' => '(user_timeline|friends_timeline|replies|mentions|show|destroy|friends|followers)'));
|
||||||
|
|
||||||
// users
|
// users
|
||||||
|
|
||||||
|
@ -45,9 +45,11 @@ class CometPlugin extends Plugin
|
|||||||
{
|
{
|
||||||
var $server = null;
|
var $server = null;
|
||||||
|
|
||||||
function __construct($server=null)
|
function __construct($server=null, $username=null, $password=null)
|
||||||
{
|
{
|
||||||
$this->server = $server;
|
$this->server = $server;
|
||||||
|
$this->username = $username;
|
||||||
|
$this->password = $password;
|
||||||
|
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
@ -82,8 +84,22 @@ class CometPlugin extends Plugin
|
|||||||
' ');
|
' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$user = common_current_user();
|
||||||
|
|
||||||
|
if (!empty($user->id)) {
|
||||||
|
$user_id = $user->id;
|
||||||
|
} else {
|
||||||
|
$user_id = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$replyurl = common_local_url('newnotice');
|
||||||
|
$favorurl = common_local_url('favor');
|
||||||
|
// FIXME: need to find a better way to pass this pattern in
|
||||||
|
$deleteurl = common_local_url('deletenotice',
|
||||||
|
array('notice' => '0000000000'));
|
||||||
|
|
||||||
$action->elementStart('script', array('type' => 'text/javascript'));
|
$action->elementStart('script', array('type' => 'text/javascript'));
|
||||||
$action->raw("$(document).ready(function() { updater.init(\"$this->server\", \"$timeline\");});");
|
$action->raw("$(document).ready(function() { updater.init(\"$this->server\", \"$timeline\", $user_id, \"$replyurl\", \"$favorurl\", \"$deleteurl\"); });");
|
||||||
$action->elementEnd('script');
|
$action->elementEnd('script');
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -117,7 +133,7 @@ class CometPlugin extends Plugin
|
|||||||
$json = $this->noticeAsJson($notice);
|
$json = $this->noticeAsJson($notice);
|
||||||
|
|
||||||
// Bayeux? Comet? Huh? These terms confuse me
|
// Bayeux? Comet? Huh? These terms confuse me
|
||||||
$bay = new Bayeux($this->server);
|
$bay = new Bayeux($this->server, $this->user, $this->password);
|
||||||
|
|
||||||
foreach ($timelines as $timeline) {
|
foreach ($timelines as $timeline) {
|
||||||
$this->log(LOG_INFO, "Posting notice $notice->id to '$timeline'.");
|
$this->log(LOG_INFO, "Posting notice $notice->id to '$timeline'.");
|
||||||
@ -144,6 +160,15 @@ class CometPlugin extends Plugin
|
|||||||
$arr = $act->twitter_status_array($notice, true);
|
$arr = $act->twitter_status_array($notice, true);
|
||||||
$arr['url'] = $notice->bestUrl();
|
$arr['url'] = $notice->bestUrl();
|
||||||
$arr['html'] = htmlspecialchars($notice->rendered);
|
$arr['html'] = htmlspecialchars($notice->rendered);
|
||||||
|
$arr['source'] = htmlspecialchars($arr['source']);
|
||||||
|
|
||||||
|
if (!empty($notice->reply_to)) {
|
||||||
|
$reply_to = Notice::staticGet('id', $notice->reply_to);
|
||||||
|
if (!empty($reply_to)) {
|
||||||
|
$arr['in_reply_to_status_url'] = $reply_to->bestUrl();
|
||||||
|
}
|
||||||
|
$reply_to = null;
|
||||||
|
}
|
||||||
|
|
||||||
$profile = $notice->getProfile();
|
$profile = $notice->getProfile();
|
||||||
$arr['user']['profile_url'] = $profile->profileurl;
|
$arr['user']['profile_url'] = $profile->profileurl;
|
||||||
|
@ -26,9 +26,12 @@ class Bayeux
|
|||||||
private $oCurl = '';
|
private $oCurl = '';
|
||||||
private $nNextId = 0;
|
private $nNextId = 0;
|
||||||
|
|
||||||
|
private $sUser = '';
|
||||||
|
private $sPassword = '';
|
||||||
|
|
||||||
public $sUrl = '';
|
public $sUrl = '';
|
||||||
|
|
||||||
function __construct($sUrl)
|
function __construct($sUrl, $sUser='', $sPassword='')
|
||||||
{
|
{
|
||||||
$this->sUrl = $sUrl;
|
$this->sUrl = $sUrl;
|
||||||
|
|
||||||
@ -43,6 +46,10 @@ class Bayeux
|
|||||||
curl_setopt($this->oCurl, CURLOPT_POST, 1);
|
curl_setopt($this->oCurl, CURLOPT_POST, 1);
|
||||||
curl_setopt($this->oCurl, CURLOPT_RETURNTRANSFER,1);
|
curl_setopt($this->oCurl, CURLOPT_RETURNTRANSFER,1);
|
||||||
|
|
||||||
|
if (!is_null($sUser) && mb_strlen($sUser) > 0) {
|
||||||
|
curl_setopt($this->oCurl, CURLOPT_USERPWD,"$sUser:$sPassword");
|
||||||
|
}
|
||||||
|
|
||||||
$this->handShake();
|
$this->handShake();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,14 +3,26 @@
|
|||||||
|
|
||||||
var updater = function()
|
var updater = function()
|
||||||
{
|
{
|
||||||
|
var _server;
|
||||||
|
var _timeline;
|
||||||
|
var _userid;
|
||||||
|
var _replyurl;
|
||||||
|
var _favorurl;
|
||||||
|
var _deleteurl;
|
||||||
var _cometd;
|
var _cometd;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
init: function(server, timeline)
|
init: function(server, timeline, userid, replyurl, favorurl, deleteurl)
|
||||||
{
|
{
|
||||||
_cometd = $.cometd; // Uses the default Comet object
|
_cometd = $.cometd; // Uses the default Comet object
|
||||||
_cometd.setLogLevel('debug');
|
_cometd.setLogLevel('debug');
|
||||||
_cometd.init(server);
|
_cometd.init(server);
|
||||||
|
_server = server;
|
||||||
|
_timeline = timeline;
|
||||||
|
_userid = userid;
|
||||||
|
_favorurl = favorurl;
|
||||||
|
_replyurl = replyurl;
|
||||||
|
_deleteurl = deleteurl;
|
||||||
_cometd.subscribe(timeline, receive);
|
_cometd.subscribe(timeline, receive);
|
||||||
$(window).unload(leave);
|
$(window).unload(leave);
|
||||||
}
|
}
|
||||||
@ -34,7 +46,7 @@ var updater = function()
|
|||||||
var noticeItem = makeNoticeItem(message.data);
|
var noticeItem = makeNoticeItem(message.data);
|
||||||
$("#notices_primary .notices").prepend(noticeItem, true);
|
$("#notices_primary .notices").prepend(noticeItem, true);
|
||||||
$("#notices_primary .notice:first").css({display:"none"});
|
$("#notices_primary .notice:first").css({display:"none"});
|
||||||
$("#notices_primary .notice:first").fadeIn(2500);
|
$("#notices_primary .notice:first").fadeIn(1000);
|
||||||
NoticeHover();
|
NoticeHover();
|
||||||
NoticeReply();
|
NoticeReply();
|
||||||
}
|
}
|
||||||
@ -42,7 +54,8 @@ var updater = function()
|
|||||||
function makeNoticeItem(data)
|
function makeNoticeItem(data)
|
||||||
{
|
{
|
||||||
user = data['user'];
|
user = data['user'];
|
||||||
html = data['html'].replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>');
|
html = data['html'].replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"');
|
||||||
|
source = data['source'].replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"');
|
||||||
|
|
||||||
ni = "<li class=\"hentry notice\" id=\"notice-"+data['id']+"\">"+
|
ni = "<li class=\"hentry notice\" id=\"notice-"+data['id']+"\">"+
|
||||||
"<div class=\"entry-title\">"+
|
"<div class=\"entry-title\">"+
|
||||||
@ -65,13 +78,77 @@ var updater = function()
|
|||||||
"</dl>"+
|
"</dl>"+
|
||||||
"<dl class=\"device\">"+
|
"<dl class=\"device\">"+
|
||||||
"<dt>From</dt> "+
|
"<dt>From</dt> "+
|
||||||
"<dd>"+data['source']+"</dd>"+
|
"<dd>"+source+"</dd>"+ // may have a link, I think
|
||||||
"</dl>"+
|
"</dl>";
|
||||||
"</div>"+
|
|
||||||
"<div class=\"notice-options\">"+
|
if (data['in_reply_to_status_id']) {
|
||||||
"</div>"+
|
ni = ni+" <dl class=\"response\">"+
|
||||||
|
"<dt>To</dt>"+
|
||||||
|
"<dd>"+
|
||||||
|
"<a href=\""+data['in_reply_to_status_url']+"\" rel=\"in-reply-to\">in reply to</a>"+
|
||||||
|
"</dd>"+
|
||||||
|
"</dl>";
|
||||||
|
}
|
||||||
|
|
||||||
|
ni = ni+"</div>"+
|
||||||
|
"<div class=\"notice-options\">";
|
||||||
|
|
||||||
|
if (_userid != 0) {
|
||||||
|
var input = $("form#form_notice fieldset input#token");
|
||||||
|
var session_key = input.val();
|
||||||
|
ni = ni+makeFavoriteForm(data['id'], session_key);
|
||||||
|
ni = ni+makeReplyLink(data['id'], data['user']['screen_name']);
|
||||||
|
if (_userid == data['user']['id']) {
|
||||||
|
ni = ni+makeDeleteLink(data['id']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ni = ni+"</div>"+
|
||||||
"</li>";
|
"</li>";
|
||||||
return ni;
|
return ni;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function makeFavoriteForm(id, session_key)
|
||||||
|
{
|
||||||
|
var ff;
|
||||||
|
|
||||||
|
ff = "<form id=\"favor-"+id+"\" class=\"form_favor\" method=\"post\" action=\""+_favorurl+"\">"+
|
||||||
|
"<fieldset>"+
|
||||||
|
"<legend>Favor this notice</legend>"+ // XXX: i18n
|
||||||
|
"<input name=\"token-"+id+"\" type=\"hidden\" id=\"token-"+id+"\" value=\""+session_key+"\"/>"+
|
||||||
|
"<input name=\"notice\" type=\"hidden\" id=\"notice-n"+id+"\" value=\""+id+"\"/>"+
|
||||||
|
"<input type=\"submit\" id=\"favor-submit-"+id+"\" name=\"favor-submit-"+id+"\" class=\"submit\" value=\"Favor\" title=\"Favor this notice\"/>"+
|
||||||
|
"</fieldset>"+
|
||||||
|
"</form>";
|
||||||
|
return ff;
|
||||||
|
}
|
||||||
|
|
||||||
|
function makeReplyLink(id, nickname)
|
||||||
|
{
|
||||||
|
var rl;
|
||||||
|
rl = "<dl class=\"notice_reply\">"+
|
||||||
|
"<dt>Reply to this notice</dt>"+
|
||||||
|
"<dd>"+
|
||||||
|
"<a href=\""+_replyurl+"?replyto="+nickname+"\" title=\"Reply to this notice\">Reply <span class=\"notice_id\">"+id+"</span>"+
|
||||||
|
"</a>"+
|
||||||
|
"</dd>"+
|
||||||
|
"</dl>";
|
||||||
|
return rl;
|
||||||
|
}
|
||||||
|
|
||||||
|
function makeDeleteLink(id)
|
||||||
|
{
|
||||||
|
var dl, delurl;
|
||||||
|
delurl = _deleteurl.replace("0000000000", id);
|
||||||
|
|
||||||
|
dl = "<dl class=\"notice_delete\">"+
|
||||||
|
"<dt>Delete this notice</dt>"+
|
||||||
|
"<dd>"+
|
||||||
|
"<a href=\""+delurl+"\" title=\"Delete this notice\">Delete</a>"+
|
||||||
|
"</dd>"+
|
||||||
|
"</dl>";
|
||||||
|
|
||||||
|
return dl;
|
||||||
|
}
|
||||||
}();
|
}();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user