We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit ec8dd014 authored by Evan Prodromou's avatar Evan Prodromou

Merge branch '0.7.x' into querybyid

parents aee641ee b12e72ae
......@@ -13,3 +13,6 @@ dataobject.ini
*.rej
.#*
*.swp
.buildpath
.project
.settings
......@@ -59,7 +59,7 @@ class AccesstokenAction extends Action
try {
common_debug('getting request from env variables', __FILE__);
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__);
$server = omb_oauth_server();
common_debug('fetching the access token', __FILE__);
......
......@@ -130,6 +130,7 @@ class ApiAction extends Action
'statuses/friends_timeline',
'statuses/friends',
'statuses/replies',
'statuses/mentions',
'statuses/followers',
'favorites/favorites');
......
......@@ -107,7 +107,7 @@ class FavoritesrssAction extends Rss10Action
$c = array('url' => common_local_url('favoritesrss',
array('nickname' =>
$user->nickname)),
'title' => sprintf(_("%s favorite notices"), $user->nickname),
'title' => sprintf(_("%s's favorite notices"), $user->nickname),
'link' => common_local_url('showfavorites',
array('nickname' =>
$user->nickname)),
......
......@@ -67,8 +67,8 @@ class OpenidsettingsAction extends AccountSettingsAction
function getInstructions()
{
return _('[OpenID](%%doc.openid%%) lets you log into many sites ' .
' with the same user account. '.
return _('[OpenID](%%doc.openid%%) lets you log into many sites' .
' with the same user account.'.
' Manage your associated OpenIDs from here.');
}
......
......@@ -151,11 +151,11 @@ class RecoverpasswordAction extends Action
$this->element('p', null,
_('If you\'ve forgotten or lost your' .
' password, you can get a new one sent to' .
' the email address you have stored ' .
' the email address you have stored' .
' in your account.'));
} else if ($this->mode == 'reset') {
$this->element('p', null,
_('You\'ve been identified. Enter a ' .
_('You\'ve been identified. Enter a' .
' new password below. '));
}
$this->elementEnd('div');
......
......@@ -74,9 +74,9 @@ class ShowfavoritesAction extends Action
function title()
{
if ($this->page == 1) {
return sprintf(_("%s favorite notices"), $this->user->nickname);
return sprintf(_("%s's favorite notices"), $this->user->nickname);
} else {
return sprintf(_("%s favorite notices, page %d"),
return sprintf(_("%s's favorite notices, page %d"),
$this->user->nickname,
$this->page);
}
......
......@@ -144,10 +144,10 @@ class TwitapistatusesAction extends TwitterapiAction
break;
case 'atom':
if (isset($apidata['api_arg'])) {
$selfuri = $selfuri = common_root_url() .
$selfuri = common_root_url() .
'api/statuses/friends_timeline/' . $apidata['api_arg'] . '.atom';
} else {
$selfuri = $selfuri = common_root_url() .
$selfuri = common_root_url() .
'api/statuses/friends_timeline.atom';
}
$this->show_atom_timeline($notice, $title, $id, $link, $subtitle, null, $selfuri);
......@@ -231,10 +231,10 @@ class TwitapistatusesAction extends TwitterapiAction
break;
case 'atom':
if (isset($apidata['api_arg'])) {
$selfuri = $selfuri = common_root_url() .
$selfuri = common_root_url() .
'api/statuses/user_timeline/' . $apidata['api_arg'] . '.atom';
} else {
$selfuri = $selfuri = common_root_url() .
$selfuri = common_root_url() .
'api/statuses/user_timeline.atom';
}
$this->show_atom_timeline($notice, $title, $id, $link, $subtitle, $suplink, $selfuri);
......@@ -344,7 +344,7 @@ class TwitapistatusesAction extends TwitterapiAction
$this->show($args, $apidata);
}
function replies($args, $apidata)
function mentions($args, $apidata)
{
parent::handle($args);
......@@ -360,11 +360,13 @@ class TwitapistatusesAction extends TwitterapiAction
$profile = $user->getProfile();
$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');
$id = "tag:$taguribase:Replies:".$user->id;
$id = "tag:$taguribase:Mentions:".$user->id;
$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) {
$page = 1;
......@@ -385,7 +387,8 @@ class TwitapistatusesAction extends TwitterapiAction
$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();
while ($notice->fetch()) {
......@@ -400,14 +403,10 @@ class TwitapistatusesAction extends TwitterapiAction
$this->show_rss_timeline($notices, $title, $link, $subtitle);
break;
case 'atom':
if (isset($apidata['api_arg'])) {
$selfuri = $selfuri = common_root_url() .
'api/statuses/replies/' . $apidata['api_arg'] . '.atom';
} else {
$selfuri = $selfuri = common_root_url() .
'api/statuses/replies.atom';
}
$this->show_atom_timeline($notices, $title, $id, $link, $subtitle, null, $selfuri);
$selfuri = common_root_url() .
ltrim($_SERVER['QUERY_STRING'], 'p=');
$this->show_atom_timeline($notices, $title, $id, $link, $subtitle,
null, $selfuri);
break;
case 'json':
$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)
{
parent::handle($args);
......
......@@ -128,7 +128,7 @@
var a = document.createElement('A');
a.innerHTML = 'get this';
a.target = '_blank';
a.href = 'http://identica/doc/badge';
a.href = 'http://identi.ca/doc/badge';
$.s.f.appendChild(a);
$.s.appendChild($.s.f);
$.f.getUser();
......
......@@ -231,12 +231,12 @@ class Router
$m->connect('api/statuses/:method',
array('action' => 'api',
'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',
array('action' => 'api',
'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
......
......@@ -45,9 +45,11 @@ class CometPlugin extends Plugin
{
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();
}
......@@ -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->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');
return true;
......@@ -117,7 +133,7 @@ class CometPlugin extends Plugin
$json = $this->noticeAsJson($notice);
// 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) {
$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['url'] = $notice->bestUrl();
$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();
$arr['user']['profile_url'] = $profile->profileurl;
......
......@@ -26,9 +26,12 @@ class Bayeux
private $oCurl = '';
private $nNextId = 0;
private $sUser = '';
private $sPassword = '';
public $sUrl = '';
function __construct($sUrl)
function __construct($sUrl, $sUser='', $sPassword='')
{
$this->sUrl = $sUrl;
......@@ -43,6 +46,10 @@ class Bayeux
curl_setopt($this->oCurl, CURLOPT_POST, 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();
}
......
......@@ -3,14 +3,26 @@
var updater = function()
{
var _server;
var _timeline;
var _userid;
var _replyurl;
var _favorurl;
var _deleteurl;
var _cometd;
return {
init: function(server, timeline)
init: function(server, timeline, userid, replyurl, favorurl, deleteurl)
{
_cometd = $.cometd; // Uses the default Comet object
_cometd.setLogLevel('debug');
_cometd.init(server);
_server = server;
_timeline = timeline;
_userid = userid;
_favorurl = favorurl;
_replyurl = replyurl;
_deleteurl = deleteurl;
_cometd.subscribe(timeline, receive);
$(window).unload(leave);
}
......@@ -34,7 +46,7 @@ var updater = function()
var noticeItem = makeNoticeItem(message.data);
$("#notices_primary .notices").prepend(noticeItem, true);
$("#notices_primary .notice:first").css({display:"none"});
$("#notices_primary .notice:first").fadeIn(2500);
$("#notices_primary .notice:first").fadeIn(1000);
NoticeHover();
NoticeReply();
}
......@@ -42,7 +54,8 @@ var updater = function()
function makeNoticeItem(data)
{
user = data['user'];
html = data['html'].replace(/&amp;/g,'&').replace(/&lt;/g,'<').replace(/&gt;/g,'>');
html = data['html'].replace(/&amp;/g,'&').replace(/&lt;/g,'<').replace(/&gt;/g,'>').replace(/&quot;/g,'"');
source = data['source'].replace(/&amp;/g,'&').replace(/&lt;/g,'<').replace(/&gt;/g,'>').replace(/&quot;/g,'"');
ni = "<li class=\"hentry notice\" id=\"notice-"+data['id']+"\">"+
"<div class=\"entry-title\">"+
......@@ -65,13 +78,77 @@ var updater = function()
"</dl>"+
"<dl class=\"device\">"+
"<dt>From</dt> "+
"<dd>"+data['source']+"</dd>"+
"</dl>"+
"</div>"+
"<div class=\"notice-options\">"+
"</div>"+
"<dd>"+source+"</dd>"+ // may have a link, I think
"</dl>";
if (data['in_reply_to_status_id']) {
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>";
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;
}
}();
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment