new more compact api json format for some streams
This commit is contained in:
parent
cdc48502e2
commit
b2f4209780
|
@ -77,16 +77,22 @@ class QvitterPlugin extends Plugin {
|
|||
$m->connect('api/statuses/public_and_external_timeline.:format',
|
||||
array('action' => 'ApiTimelinePublicAndExternal',
|
||||
'format' => '(xml|json|rss|atom|as)'));
|
||||
|
||||
$m->connect('api/qvitter/update_link_color.json',
|
||||
array('action' => 'apiqvitterupdatelinkcolor'));
|
||||
|
||||
$m->connect('api/qvitter/update_background_color.json',
|
||||
array('action' => 'apiqvitterupdatebackgroundcolor'));
|
||||
|
||||
$m->connect('api/qvitter/checklogin.json',
|
||||
array('action' => 'apiqvitterchecklogin'));
|
||||
|
||||
$m->connect('api/qvitter/statuses/friends_timeline.json',
|
||||
array('action' => 'apiqvitterfriends'));
|
||||
$m->connect('api/qvitter/statuses/friends_timeline/:id.json',
|
||||
array('action' => 'apiqvitterfriends',
|
||||
'id' => Nickname::INPUT_FMT));
|
||||
$m->connect('api/qvitter/statuses/mentions/:id.json',
|
||||
array('action' => 'apiqvittermentions',
|
||||
'id' => Nickname::INPUT_FMT));
|
||||
$m->connect('api/qvitter/statuses/mentions.:format',
|
||||
array('action' => 'apiqvittermentions'));
|
||||
$m->connect('settings/qvitter',
|
||||
array('action' => 'qvittersettings'));
|
||||
$m->connect('main/qlogin',
|
||||
|
|
46
actions/apiqvitterfriends.php
Normal file
46
actions/apiqvitterfriends.php
Normal file
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
/* · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · ·
|
||||
· ·
|
||||
· ·
|
||||
· Q V I T T E R ·
|
||||
· ·
|
||||
· http://github.com/hannesmannerheim/qvitter ·
|
||||
· ·
|
||||
· ·
|
||||
· <o) ·
|
||||
· /_//// ·
|
||||
· (____/ ·
|
||||
· (o< ·
|
||||
· o> \\\\_\ ·
|
||||
· \\) \____) ·
|
||||
· ·
|
||||
· ·
|
||||
· ·
|
||||
· Qvitter is free software: you can redistribute it and / or modify it ·
|
||||
· under the terms of the GNU Affero General Public License as published by ·
|
||||
· the Free Software Foundation, either version three of the License or (at ·
|
||||
· your option) any later version. ·
|
||||
· ·
|
||||
· Qvitter is distributed in hope that it will be useful but WITHOUT ANY ·
|
||||
· WARRANTY; without even the implied warranty of MERCHANTABILTY or FITNESS ·
|
||||
· FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for ·
|
||||
· more details. ·
|
||||
· ·
|
||||
· You should have received a copy of the GNU Affero General Public License ·
|
||||
· along with Qvitter. If not, see <http://www.gnu.org/licenses/>. ·
|
||||
· ·
|
||||
· Contact h@nnesmannerhe.im if you have any questions. ·
|
||||
· ·
|
||||
· · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · */
|
||||
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
class ApiQvitterFriendsAction extends ApiTimelineFriendsAction
|
||||
{
|
||||
function showTimeline()
|
||||
{
|
||||
ApiQvitterAction::showQvitterJsonTimeline($this->notices);
|
||||
}
|
||||
}
|
||||
|
||||
|
44
actions/apiqvittermentions.php
Normal file
44
actions/apiqvittermentions.php
Normal file
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
/* · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · ·
|
||||
· ·
|
||||
· ·
|
||||
· Q V I T T E R ·
|
||||
· ·
|
||||
· http://github.com/hannesmannerheim/qvitter ·
|
||||
· ·
|
||||
· ·
|
||||
· <o) ·
|
||||
· /_//// ·
|
||||
· (____/ ·
|
||||
· (o< ·
|
||||
· o> \\\\_\ ·
|
||||
· \\) \____) ·
|
||||
· ·
|
||||
· ·
|
||||
· ·
|
||||
· Qvitter is free software: you can redistribute it and / or modify it ·
|
||||
· under the terms of the GNU Affero General Public License as published by ·
|
||||
· the Free Software Foundation, either version three of the License or (at ·
|
||||
· your option) any later version. ·
|
||||
· ·
|
||||
· Qvitter is distributed in hope that it will be useful but WITHOUT ANY ·
|
||||
· WARRANTY; without even the implied warranty of MERCHANTABILTY or FITNESS ·
|
||||
· FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for ·
|
||||
· more details. ·
|
||||
· ·
|
||||
· You should have received a copy of the GNU Affero General Public License ·
|
||||
· along with Qvitter. If not, see <http://www.gnu.org/licenses/>. ·
|
||||
· ·
|
||||
· Contact h@nnesmannerhe.im if you have any questions. ·
|
||||
· ·
|
||||
· · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · */
|
||||
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
class ApiQvitterMentionsAction extends ApiTimelineMentionsAction
|
||||
{
|
||||
function showTimeline()
|
||||
{
|
||||
ApiQvitterAction::showQvitterJsonTimeline($this->notices);
|
||||
}
|
||||
}
|
|
@ -230,7 +230,7 @@ class ApiTimelinePublicAndExternalAction extends ApiPrivateAuthAction
|
|||
|
||||
break;
|
||||
case 'json':
|
||||
$this->showJsonTimeline($this->notices);
|
||||
ApiQvitterAction::showQvitterJsonTimeline($this->notices);
|
||||
break;
|
||||
case 'as':
|
||||
header('Content-Type: ' . ActivityStreamJSONDocument::CONTENT_TYPE);
|
||||
|
|
|
@ -322,8 +322,8 @@ class QvitterAction extends ApiAction
|
|||
</div>
|
||||
</div>
|
||||
<div class="menu-container">
|
||||
<a class="stream-selection friends-timeline" data-stream-header="" data-stream-name="statuses/friends_timeline.json"><i class="chev-right"></i></a>
|
||||
<a class="stream-selection mentions" data-stream-header="" data-stream-name="statuses/mentions.json"><i class="chev-right"></i></a>
|
||||
<a class="stream-selection friends-timeline" data-stream-header="" data-stream-name="qvitter/statuses/friends_timeline.json"><i class="chev-right"></i></a>
|
||||
<a class="stream-selection mentions" data-stream-header="" data-stream-name="qvitter/statuses/mentions.json"><i class="chev-right"></i></a>
|
||||
<a class="stream-selection my-timeline" data-stream-header="@statuses/user_timeline.json" data-stream-name="statuses/user_timeline.json"><i class="chev-right"></i></a>
|
||||
<a class="stream-selection favorites" data-stream-header="" data-stream-name="favorites.json"><i class="chev-right"></i></a>
|
||||
<a href="<?php print $instanceurl ?>" class="stream-selection public-timeline" data-stream-header="" data-stream-name="statuses/public_timeline.json"><i class="chev-right"></i></a>
|
||||
|
|
127
classes/apiqvitteraction.php
Normal file
127
classes/apiqvitteraction.php
Normal file
|
@ -0,0 +1,127 @@
|
|||
<?php
|
||||
|
||||
/* · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · ·
|
||||
· ·
|
||||
· ·
|
||||
· Q V I T T E R ·
|
||||
· ·
|
||||
· http://github.com/hannesmannerheim/qvitter ·
|
||||
· ·
|
||||
· ·
|
||||
· <o) ·
|
||||
· /_//// ·
|
||||
· (____/ ·
|
||||
· (o< ·
|
||||
· o> \\\\_\ ·
|
||||
· \\) \____) ·
|
||||
· ·
|
||||
· ·
|
||||
· ·
|
||||
· Qvitter is free software: you can redistribute it and / or modify it ·
|
||||
· under the terms of the GNU Affero General Public License as published by ·
|
||||
· the Free Software Foundation, either version three of the License or (at ·
|
||||
· your option) any later version. ·
|
||||
· ·
|
||||
· Qvitter is distributed in hope that it will be useful but WITHOUT ANY ·
|
||||
· WARRANTY; without even the implied warranty of MERCHANTABILTY or FITNESS ·
|
||||
· FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for ·
|
||||
· more details. ·
|
||||
· ·
|
||||
· You should have received a copy of the GNU Affero General Public License ·
|
||||
· along with Qvitter. If not, see <http://www.gnu.org/licenses/>. ·
|
||||
· ·
|
||||
· Contact h@nnesmannerhe.im if you have any questions. ·
|
||||
· ·
|
||||
· · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · */
|
||||
|
||||
if (!defined('GNUSOCIAL')) { exit(1); }
|
||||
|
||||
class ApiQvitterAction extends ApiAction
|
||||
{
|
||||
function showQvitterJsonTimeline($notice)
|
||||
{
|
||||
$this->initDocument('json');
|
||||
|
||||
$statuses = array();
|
||||
|
||||
if (is_array($notice)) {
|
||||
$notice = new ArrayWrapper($notice);
|
||||
}
|
||||
|
||||
while ($notice->fetch()) {
|
||||
try {
|
||||
$twitter_status = $this->twitterStatusArray($notice);
|
||||
array_push($statuses, $twitter_status);
|
||||
} catch (Exception $e) {
|
||||
common_log(LOG_ERR, $e->getMessage());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$simplified_statuses = new stdClass();
|
||||
|
||||
$i=0;
|
||||
foreach($statuses as &$s) {
|
||||
|
||||
foreach($s as &$ss) {
|
||||
if($ss === false || $ss === null) {
|
||||
$ss=0;
|
||||
}
|
||||
elseif($ss === true) {
|
||||
$ss=1;
|
||||
}
|
||||
}
|
||||
foreach($s['user'] as &$su) {
|
||||
if($su === false || $su === null) {
|
||||
$su=0;
|
||||
}
|
||||
elseif($su === true) {
|
||||
$su=1;
|
||||
}
|
||||
}
|
||||
|
||||
$simplified_statuses->s[$i][0] = $s['id'];
|
||||
$simplified_statuses->s[$i][1] = strtotime($s['created_at']);
|
||||
$simplified_statuses->s[$i][2] = $s['text'];
|
||||
$simplified_statuses->s[$i][3] = $s['statusnet_html'];
|
||||
$simplified_statuses->s[$i][4] = $s['in_reply_to_status_id'];
|
||||
$simplified_statuses->s[$i][5] = $s['in_reply_to_user_id'];
|
||||
$simplified_statuses->s[$i][6] = $s['in_reply_to_screen_name'];
|
||||
$simplified_statuses->s[$i][7] = $s['favorited'];
|
||||
$simplified_statuses->s[$i][8] = $s['repeated'];
|
||||
$simplified_statuses->s[$i][9] = $s['statusnet_in_groups'];
|
||||
$simplified_statuses->s[$i][10] = $s['user']['id'];
|
||||
$simplified_statuses->s[$i][11] = $s['statusnet_conversation_id'];
|
||||
$simplified_statuses->s[$i][12] = $s['source'];
|
||||
|
||||
$simplified_statuses->u[$s['user']['id']][0] = $s['user']['screen_name'];
|
||||
$simplified_statuses->u[$s['user']['id']][1] = $s['user']['name'];
|
||||
$simplified_statuses->u[$s['user']['id']][2] = $s['user']['location'];
|
||||
$simplified_statuses->u[$s['user']['id']][3] = $s['user']['description'];
|
||||
$simplified_statuses->u[$s['user']['id']][4] = $s['user']['profile_image_url_profile_size'];
|
||||
$simplified_statuses->u[$s['user']['id']][5] = $s['user']['profile_image_url_original'];
|
||||
$simplified_statuses->u[$s['user']['id']][6] = $s['user']['groups_count'];
|
||||
$simplified_statuses->u[$s['user']['id']][7] = $s['user']['linkcolor'];
|
||||
$simplified_statuses->u[$s['user']['id']][8] = $s['user']['backgroundcolor'];
|
||||
$simplified_statuses->u[$s['user']['id']][9] = $s['user']['url'];
|
||||
$simplified_statuses->u[$s['user']['id']][10] = $s['user']['followers_count'];
|
||||
$simplified_statuses->u[$s['user']['id']][11] = $s['user']['friends_count'];
|
||||
$simplified_statuses->u[$s['user']['id']][12] = $s['user']['favourites_count'];
|
||||
$simplified_statuses->u[$s['user']['id']][13] = $s['user']['statuses_count'];
|
||||
$simplified_statuses->u[$s['user']['id']][14] = $s['user']['following'];
|
||||
$simplified_statuses->u[$s['user']['id']][15] = $s['user']['statusnet_blocking'];
|
||||
$simplified_statuses->u[$s['user']['id']][16] = $s['user']['statusnet_profile_url'];
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
// print_r($simplified_statuses);
|
||||
// print_r($statuses);
|
||||
//
|
||||
|
||||
$this->showJsonObjects($simplified_statuses);
|
||||
|
||||
$this->endDocument('json');
|
||||
}
|
||||
}
|
|
@ -93,6 +93,10 @@ function getFromAPI(stream, actionOnSuccess) {
|
|||
type: "GET",
|
||||
dataType: 'json',
|
||||
success: function(data) {
|
||||
|
||||
// decode if we have a qvitter compact stream
|
||||
data = decodeQvitterCompactFormat(data);
|
||||
|
||||
actionOnSuccess(data);
|
||||
},
|
||||
error: function(data) {
|
||||
|
@ -123,7 +127,9 @@ function postQueetToAPI(queetText_txt, actionOnSuccess) {
|
|||
},
|
||||
dataType: "json",
|
||||
error: function(data){ actionOnSuccess(false); console.log(data); },
|
||||
success: function(data) { actionOnSuccess(data);}
|
||||
success: function(data) {
|
||||
actionOnSuccess(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -274,7 +280,13 @@ function postActionToAPI(action, actionOnSuccess) {
|
|||
},
|
||||
dataType:"json",
|
||||
error: function(data){ actionOnSuccess(false); console.log(data); },
|
||||
success: function(data) { actionOnSuccess(data);}
|
||||
success: function(data) {
|
||||
|
||||
// decode if we have a qvitter compact stream
|
||||
data = decodeQvitterCompactFormat(data);
|
||||
|
||||
actionOnSuccess(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -322,9 +322,9 @@ function setNewCurrentStream(stream,actionOnSuccess,setLocation) {
|
|||
if(stream.substring(0,45) == 'statuses/followers.json?count=20&screen_name='
|
||||
|| stream.substring(0,43) == 'statuses/friends.json?count=20&screen_name='
|
||||
|| stream.substring(0,48) == 'statusnet/groups/list.json?count=10&screen_name='
|
||||
|| stream.substring(0,43) == 'statuses/friends_timeline.json?screen_name='
|
||||
|| stream.substring(0,51) == 'qvitter/statuses/friends_timeline.json?screen_name='
|
||||
|| stream.substring(0,27) == 'favorites.json?screen_name='
|
||||
|| stream.substring(0,35) == 'statuses/mentions.json?screen_name='
|
||||
|| stream.substring(0,43) == 'qvitter/statuses/mentions.json?screen_name='
|
||||
|| stream.substring(0,27) == 'statuses/user_timeline.json') {
|
||||
var defaultStreamName = 'statuses/user_timeline.json?' + stream.substring(stream.indexOf('screen_name='));
|
||||
var streamHeader = '@' + stream.substring(stream.lastIndexOf('=')+1);
|
||||
|
@ -337,8 +337,8 @@ function setNewCurrentStream(stream,actionOnSuccess,setLocation) {
|
|||
var streamHeader = '@' + window.loggedIn.screen_name;
|
||||
}
|
||||
// if this is one of the default streams, get header from DOM
|
||||
else if(stream == 'statuses/friends_timeline.json'
|
||||
|| stream == 'statuses/mentions.json'
|
||||
else if(stream == 'qvitter/statuses/friends_timeline.json'
|
||||
|| stream == 'qvitter/statuses/mentions.json'
|
||||
|| stream == 'favorites.json'
|
||||
|| stream == 'statuses/public_timeline.json'
|
||||
|| stream == 'statuses/public_and_external_timeline.json') {
|
||||
|
@ -374,7 +374,7 @@ function setNewCurrentStream(stream,actionOnSuccess,setLocation) {
|
|||
else if(stream.substring(0,40) == 'statuses/user_timeline.json?screen_name=') {
|
||||
var h2FeedHeader = window.sL.notices + '<div class="queet-streams">/ <a class="queet-stream mentions">' + window.sL.mentions + '</a> / <a class="queet-stream favorites">' + window.sL.favoritesNoun +'</a></div>';
|
||||
}
|
||||
else if(stream.substring(0,35) == 'statuses/mentions.json?screen_name=') {
|
||||
else if(stream.substring(0,43) == 'qvitter/statuses/mentions.json?screen_name=') {
|
||||
var h2FeedHeader = '<div class="queet-streams"><a class="queet-stream queets">' + window.sL.notices + '</a> /</div>' + window.sL.mentions + '<div class="queet-streams">/ <a class="queet-stream favorites">' + window.sL.favoritesNoun + '</a></div>';
|
||||
}
|
||||
else if(stream.substring(0,27) == 'favorites.json?screen_name=') {
|
||||
|
@ -389,7 +389,7 @@ function setNewCurrentStream(stream,actionOnSuccess,setLocation) {
|
|||
else if(stream.substring(0,24) == 'statusnet/groups/admins/') {
|
||||
var h2FeedHeader = window.sL.adminCount;
|
||||
}
|
||||
else if(stream.substring(0,43) == 'statuses/friends_timeline.json?screen_name=') {
|
||||
else if(stream.substring(0,51) == 'qvitter/statuses/friends_timeline.json?screen_name=') {
|
||||
var h2FeedHeader = '<span style="unicode-bidi:bidi-override;direction:ltr;">' + streamHeader + '/all</span>'; // ugly rtl fix, sry, we should have translations for this stream header
|
||||
}
|
||||
else {
|
||||
|
@ -434,9 +434,9 @@ function setNewCurrentStream(stream,actionOnSuccess,setLocation) {
|
|||
if(stream.substring(0,23) == 'statuses/followers.json'
|
||||
|| stream.substring(0,21) == 'statuses/friends.json'
|
||||
|| stream.substring(0,26) == 'statusnet/groups/list.json'
|
||||
|| stream.substring(0,35) == 'statuses/mentions.json?screen_name='
|
||||
|| stream.substring(0,43) == 'qvitter/statuses/mentions.json?screen_name='
|
||||
|| stream.substring(0,27) == 'favorites.json?screen_name='
|
||||
|| stream.substring(0,43) == 'statuses/friends_timeline.json?screen_name=') {
|
||||
|| stream.substring(0,51) == 'qvitter/statuses/friends_timeline.json?screen_name=') {
|
||||
getFromAPI(defaultStreamName + '&count=1', function(profile_data){
|
||||
if(profile_data) {
|
||||
getFromAPI(stream, function(user_data){
|
||||
|
@ -528,7 +528,7 @@ function convertStreamToPath(stream) {
|
|||
var screenName = stream.substring(stream.lastIndexOf('=')+1);
|
||||
return screenName + '/subscriptions';
|
||||
}
|
||||
else if(stream.substring(0,35) == 'statuses/mentions.json?screen_name=') {
|
||||
else if(stream.substring(0,43) == 'qvitter/statuses/mentions.json?screen_name=') {
|
||||
var screenName = stream.substring(stream.indexOf('=')+1);
|
||||
return screenName + '/replies';
|
||||
}
|
||||
|
@ -546,7 +546,7 @@ function convertStreamToPath(stream) {
|
|||
else if(stream == 'statuses/friends.json?count=20') {
|
||||
return window.loggedIn.screen_name + '/subscriptions';
|
||||
}
|
||||
else if(stream == 'statuses/mentions.json') {
|
||||
else if(stream == 'qvitter/statuses/mentions.json') {
|
||||
return window.loggedIn.screen_name + '/replies';
|
||||
}
|
||||
else if(stream == 'favorites.json') {
|
||||
|
@ -559,14 +559,14 @@ function convertStreamToPath(stream) {
|
|||
var screenName = stream.substring(stream.indexOf('=')+1);
|
||||
return screenName;
|
||||
}
|
||||
else if(stream == 'statuses/friends_timeline.json') {
|
||||
else if(stream == 'qvitter/statuses/friends_timeline.json') {
|
||||
return window.loggedIn.screen_name + '/all';
|
||||
}
|
||||
else if(stream.substring(0,43) == 'statuses/friends_timeline.json?screen_name=') {
|
||||
else if(stream.substring(0,51) == 'qvitter/statuses/friends_timeline.json?screen_name=') {
|
||||
var screenName = stream.substring(stream.indexOf('=')+1);
|
||||
return screenName + '/all';
|
||||
}
|
||||
else if (stream == 'statuses/mentions.json') {
|
||||
else if (stream == 'qvitter/statuses/mentions.json') {
|
||||
return window.loggedIn.screen_name + '/replies';
|
||||
}
|
||||
else if(stream == 'statuses/public_timeline.json') {
|
||||
|
@ -644,10 +644,10 @@ function getStreamFromUrl() {
|
|||
var userToStream = loc.replace('/','').replace('/all','');
|
||||
if(userToStream.length>0) {
|
||||
if(window.loggedIn.screen_name == userToStream) {
|
||||
streamToSet = 'statuses/friends_timeline.json';
|
||||
streamToSet = 'qvitter/statuses/friends_timeline.json';
|
||||
}
|
||||
else {
|
||||
streamToSet = 'statuses/friends_timeline.json?screen_name=' + userToStream;
|
||||
streamToSet = 'qvitter/statuses/friends_timeline.json?screen_name=' + userToStream;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -657,10 +657,10 @@ function getStreamFromUrl() {
|
|||
var userToStream = loc.replace('/','').replace('/replies','');
|
||||
if(userToStream.length>0) {
|
||||
if(window.loggedIn.screen_name == userToStream) {
|
||||
streamToSet = 'statuses/mentions.json';
|
||||
streamToSet = 'qvitter/statuses/mentions.json';
|
||||
}
|
||||
else {
|
||||
streamToSet = 'statuses/mentions.json?screen_name=' + userToStream;
|
||||
streamToSet = 'qvitter/statuses/mentions.json?screen_name=' + userToStream;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1117,10 +1117,10 @@ $('#settings').html(window.sL.settings);
|
|||
$('#other-servers-link').html(window.sL.otherServers);
|
||||
$('.language-dropdown .dropdown-toggle small').html(window.sL.languageSelected);
|
||||
$('.language-dropdown .current-language').html(window.sL.languageName);
|
||||
$('.stream-selection[data-stream-name="statuses/friends_timeline.json"]').prepend(window.sL.timeline);
|
||||
$('.stream-selection[data-stream-name="statuses/friends_timeline.json"]').attr('data-stream-header',window.sL.timeline);
|
||||
$('.stream-selection[data-stream-name="statuses/mentions.json"]').prepend(window.sL.mentions);
|
||||
$('.stream-selection[data-stream-name="statuses/mentions.json"]').attr('data-stream-header',window.sL.mentions);
|
||||
$('.stream-selection[data-stream-name="qvitter/statuses/friends_timeline.json"]').prepend(window.sL.timeline);
|
||||
$('.stream-selection[data-stream-name="qvitter/statuses/friends_timeline.json"]').attr('data-stream-header',window.sL.timeline);
|
||||
$('.stream-selection[data-stream-name="qvitter/statuses/mentions.json"]').prepend(window.sL.mentions);
|
||||
$('.stream-selection[data-stream-name="qvitter/statuses/mentions.json"]').attr('data-stream-header',window.sL.mentions);
|
||||
$('.stream-selection[data-stream-name="favorites.json"]').prepend(window.sL.favoritesNoun);
|
||||
$('.stream-selection[data-stream-name="favorites.json"]').attr('data-stream-header',window.sL.favoritesNoun);
|
||||
$('.stream-selection[data-stream-name="statuses/public_timeline.json"]').prepend(window.sL.publicTimeline);
|
||||
|
|
|
@ -284,6 +284,89 @@ function parseTwitterLongDate(tdate) {
|
|||
else { time12hours = window.sL.time12pm.replace('{time}',time12hours + ':' + minutes); }
|
||||
return window.sL.longDateFormat.replace('{time24}',time24hours).replace('{hours}',hours).replace('{minutes}',minutes).replace('{time12}',time12hours).replace('{day}',system_date.getDate()).replace('{month}',month_names[system_date.getMonth()]).replace('{year}',system_date.getFullYear());
|
||||
}
|
||||
function timestampToTwitterDate(timestamp) {
|
||||
var a = new Date(timestamp*1000);
|
||||
var months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
|
||||
var days = ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'];
|
||||
var day = days[a.getUTCDay()];
|
||||
var year = a.getUTCFullYear();
|
||||
var month = months[a.getUTCMonth()];
|
||||
var date = (a.getUTCDate()<10?'0':'')+a.getUTCDate();
|
||||
var hour = (a.getUTCHours()<10?'0':'')+a.getUTCHours();
|
||||
var min = (a.getUTCMinutes()<10?'0':'')+a.getUTCMinutes();
|
||||
var sec = (a.getUTCSeconds()<10?'0':'')+a.getUTCSeconds();
|
||||
return day+' '+month+' '+date+' '+hour+':'+min+':'+sec+' +0000 '+year;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* ·
|
||||
·
|
||||
· Decode Qvitter's compact API reponse
|
||||
·
|
||||
· @param data: the data returned from qvitter's compact api response
|
||||
·
|
||||
· @return data formatted as the non-compact "[old] twitter style" api response
|
||||
·
|
||||
· · · · · · · · · · */
|
||||
|
||||
function decodeQvitterCompactFormat(data) {
|
||||
|
||||
// leave data unchanged if we don't recognize it
|
||||
if(typeof data.s == 'undefined') {
|
||||
return data;
|
||||
}
|
||||
// decode
|
||||
else {
|
||||
var users = new Object();
|
||||
var i = 0;
|
||||
$.each(data.u, function(k,v){
|
||||
users[k] = new Object;
|
||||
users[k].screen_name = v[0];
|
||||
users[k].name = (v[1]==0?null:v[1]);
|
||||
users[k].location = (v[2]==0?null:v[2]);
|
||||
users[k].description = (v[3]==0?null:v[3]);
|
||||
users[k].profile_image_url_profile_size = v[4];
|
||||
users[k].profile_image_url_original = v[5];
|
||||
users[k].groups_count = v[6];
|
||||
users[k].linkcolor = (v[7]==0?false:v[7]);
|
||||
users[k].backgroundcolor = (v[8]==0?false:v[8]);
|
||||
users[k].url = (v[9]==0?null:v[9]);
|
||||
users[k].followers_count = v[10];
|
||||
users[k].friends_count = v[11];
|
||||
users[k].favourites_count = v[12];
|
||||
users[k].statuses_count = v[13];
|
||||
users[k].following = (v[14]==0?false:v[14]);
|
||||
users[k].statusnet_blocking = (v[15]==0?false:v[15]);
|
||||
users[k].statusnet_profile_url = v[16];
|
||||
i++;
|
||||
});
|
||||
var unqvitter = Array();
|
||||
var i = 0;
|
||||
$.each(data.s, function(k,v){
|
||||
unqvitter[i] = new Object;
|
||||
unqvitter[i].id = v[0];
|
||||
unqvitter[i].created_at = timestampToTwitterDate(v[1]);
|
||||
unqvitter[i].text = v[2];
|
||||
unqvitter[i].statusnet_html = v[3];
|
||||
unqvitter[i].in_reply_to_status_id = (v[4]==0?null:v[4]);
|
||||
unqvitter[i].in_reply_to_user_id = (v[5]==0?null:v[5]);
|
||||
unqvitter[i].in_reply_to_screen_name = (v[6]==0?null:v[6]);
|
||||
unqvitter[i].favorited = (v[7]==0?false:v[7]);
|
||||
unqvitter[i].repeated = (v[8]==0?false:v[8]);
|
||||
unqvitter[i].statusnet_in_groups = (v[9]==0?false:v[9]);
|
||||
unqvitter[i].user = users[v[10]];
|
||||
unqvitter[i].statusnet_conversation_id = v[11];
|
||||
unqvitter[i].uri = window.siteInstanceURL + 'notice/' + v[0];
|
||||
unqvitter[i].source = (v[12]==0?null:v[12]);
|
||||
i++;
|
||||
});
|
||||
return unqvitter;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* ·
|
||||
|
|
|
@ -649,7 +649,7 @@ $('body').on('click','.profile-banner-footer .stats li a, .queet-stream',functio
|
|||
setNewCurrentStream('statuses/user_timeline.json?screen_name=' + screenName,function(){},true);
|
||||
}
|
||||
else if($(this).hasClass('mentions')) {
|
||||
setNewCurrentStream('statuses/mentions.json?screen_name=' + screenName,function(){},true);
|
||||
setNewCurrentStream('qvitter/statuses/mentions.json?screen_name=' + screenName,function(){},true);
|
||||
}
|
||||
else if($(this).hasClass('favorites')) {
|
||||
setNewCurrentStream('favorites.json?screen_name=' + screenName,function(){},true);
|
||||
|
@ -717,16 +717,12 @@ $(document).on('click','a', function(e) {
|
|||
// logged in users streams
|
||||
else if ($(this).attr('href').replace('http://','').replace('https://','').replace(window.siteRootDomain + '/' + window.loggedIn.screen_name,'') == '/all') {
|
||||
e.preventDefault();
|
||||
setNewCurrentStream('statuses/friends_timeline.json',function(){},true);
|
||||
setNewCurrentStream('qvitter/statuses/friends_timeline.json',function(){},true);
|
||||
}
|
||||
else if ($(this).attr('href').replace('http://','').replace('https://','').replace(window.siteRootDomain + '/' + window.loggedIn.screen_name,'') == '/replies') {
|
||||
e.preventDefault();
|
||||
setNewCurrentStream('statuses/mentions.json',function(){},true);
|
||||
setNewCurrentStream('qvitter/statuses/mentions.json',function(){},true);
|
||||
}
|
||||
// else if ($(this).attr('href').replace('http://','').replace('https://','').replace(window.siteRootDomain + '/','') == window.loggedIn.screen_name) {
|
||||
// e.preventDefault();
|
||||
// setNewCurrentStream('statuses/user_timeline.json',function(){},true);
|
||||
// }
|
||||
else if ($(this).attr('href').replace('http://','').replace('https://','').replace(window.siteRootDomain + '/' + window.loggedIn.screen_name,'') == '/favorites') {
|
||||
e.preventDefault();
|
||||
setNewCurrentStream('favorites.json',function(){},true);
|
||||
|
|
Loading…
Reference in New Issue
Block a user