set logged in user data server side

This commit is contained in:
Hannes Mannerheim 2015-11-05 12:34:12 +01:00
parent e4cf072027
commit b12bad0ebd
2 changed files with 121 additions and 133 deletions

View File

@ -344,13 +344,18 @@ class QvitterAction extends ApiAction
print $instanceurl.'main/public'; print $instanceurl.'main/public';
} }
?>"><div id="logo"></div></a> ?>"><div id="logo"></div></a><?php
<a id="settingslink">
<div class="dropdown-toggle"> // menu for logged in users
<div class="nav-session"></div> if($logged_in_user) { ?>
</div> <a id="settingslink">
</a> <div class="dropdown-toggle">
<div id="top-compose" class="hidden"></div> <div class="nav-session" style="background-image:url('<?php print $logged_in_user_obj['profile_image_url_profile_size'] ?>')"></div>
</div>
</a><?php
}
?><div id="top-compose" class="hidden"></div>
<ul class="quitter-settings dropdown-menu"> <ul class="quitter-settings dropdown-menu">
<li class="dropdown-caret right"> <li class="dropdown-caret right">
<span class="caret-outer"></span> <span class="caret-outer"></span>
@ -463,38 +468,43 @@ class QvitterAction extends ApiAction
<button id="signup-btn-step1" class="signup-btn" type="submit"></button> <button id="signup-btn-step1" class="signup-btn" type="submit"></button>
<div id="other-servers-link"></div> <div id="other-servers-link"></div>
<div id="qvitter-notice-logged-out"><?php print common_config('site', 'qvitternoticeloggedout'); ?></div> <div id="qvitter-notice-logged-out"><?php print common_config('site', 'qvitternoticeloggedout'); ?></div>
</div><?php } ?> </div><?php }
<div id="user-header">
<div id="mini-edit-profile-button"></div> // box containing the logged in users queet count and compose form
<div class="profile-header-inner-overlay"></div> if($logged_in_user) { ?>
<div id="user-avatar-container"><img id="user-avatar" src="" /></div> <div id="user-header" style="background-image:url('<?php print $logged_in_user_obj['cover_photo'] ?>')">
<div id="user-name"></div> <div id="mini-edit-profile-button"></div>
<div id="user-screen-name"></div> <div class="profile-header-inner-overlay"></div>
</div> <div id="user-avatar-container"><img id="user-avatar" src="<?php print $logged_in_user_obj['profile_image_url_profile_size'] ?>" /></div>
<ul id="user-body"> <div id="user-name"><?php print $logged_in_user_obj['name'] ?></div>
<li><a id="user-queets"><span class="label"></span><strong></strong></a></li> <div id="user-screen-name"><?php print $logged_in_user_obj['screen_name'] ?></div>
<li><a id="user-following"><span class="label"></span><strong></strong></a></li> </div>
<li><a id="user-groups"><span class="label"></span><strong></strong></a></li> <ul id="user-body">
</ul> <li><a href="<?php print $instanceurl.$logged_in_user->nickname ?>" id="user-queets"><span class="label"></span><strong><?php print $logged_in_user_obj['statuses_count'] ?></strong></a></li>
<div id="user-footer"> <li><a href="<?php print $instanceurl.$logged_in_user->nickname ?>/subscriptions" id="user-following"><span class="label"></span><strong><?php print $logged_in_user_obj['friends_count'] ?></strong></a></li>
<div id="user-footer-inner"> <li><a href="<?php print $instanceurl.$logged_in_user->nickname ?>/groups" id="user-groups"><span class="label"></span><strong><?php print $logged_in_user_obj['groups_count'] ?></strong></a></li>
<div id="queet-box" class="queet-box queet-box-syntax" data-start-text=""></div> </ul>
<div class="syntax-middle"></div> <div id="user-footer">
<div class="syntax-two" contenteditable="true"></div> <div id="user-footer-inner">
<div class="mentions-suggestions"></div> <div id="queet-box" class="queet-box queet-box-syntax" data-start-text=""></div>
<div class="queet-toolbar"> <div class="syntax-middle"></div>
<div class="queet-box-extras"> <div class="syntax-two" contenteditable="true"></div>
<button class="upload-image"></button> <div class="mentions-suggestions"></div>
<button class="shorten disabled">URL</button> <div class="queet-toolbar">
</div> <div class="queet-box-extras">
<div class="queet-button"> <button class="upload-image"></button>
<span class="queet-counter"></span> <button class="shorten disabled">URL</button>
<button></button> </div>
</div> <div class="queet-button">
</div> <span class="queet-counter"></span>
</div> <button></button>
</div> </div>
<div id="main-menu" class="menu-container"><?php </div>
</div>
</div><?php
}
?><div id="main-menu" class="menu-container"><?php
if($logged_in_user) { if($logged_in_user) {
?><a href="<?php print $instanceurl.$logged_in_user->nickname ?>/all" class="stream-selection friends-timeline"><i class="chev-right"></i></a> ?><a href="<?php print $instanceurl.$logged_in_user->nickname ?>/all" class="stream-selection friends-timeline"><i class="chev-right"></i></a>

View File

@ -826,7 +826,6 @@ function proceedToSetLanguageAndLogin(data){
} }
else { else {
display_spinner(); display_spinner();
window.currentStream = ''; // force reload stream
setNewCurrentStream(getStreamFromUrl(),true,false,function(){ setNewCurrentStream(getStreamFromUrl(),true,false,function(){
logoutWithoutReload(false); logoutWithoutReload(false);
remove_spinner(); remove_spinner();
@ -855,106 +854,85 @@ function doLogin(streamObjectToSet) {
$('#submit-login').focus(); // prevents submit on enter to close alert-popup on wrong credentials $('#submit-login').focus(); // prevents submit on enter to close alert-popup on wrong credentials
display_spinner(); display_spinner();
// add user data to DOM, show search form, remeber user id, show the feed // add user data to DOM, show search form, remeber user id, show the feed
$('#user-container').css('z-index','1000'); $('#user-container').css('z-index','1000');
$('#top-compose').removeClass('hidden'); $('#top-compose').removeClass('hidden');
$('#qvitter-notice').show(); $('#qvitter-notice').show();
$('#user-avatar').attr('src', window.loggedIn.profile_image_url_profile_size); $('#user-screen-name, #user-avatar, #user-name').attr('data-tooltip', window.sL.viewMyProfilePage);
$('#settingslink .nav-session').css('background-image', 'url(\'' + window.loggedIn.profile_image_url_profile_size + '\')');
$('#user-screen-name, #user-avatar, #user-name').attr('data-tooltip', window.sL.viewMyProfilePage); // get all users i'm following for autosuggestion
$('#user-name').append(window.loggedIn.name); window.following = new Object();
$('#user-screen-name').append(window.loggedIn.screen_name); window.groupMemberships = new Object();
$('#user-queets strong').html(window.loggedIn.statuses_count); window.groupNicknamesAndLocalAliases = new Array();
$('#user-following strong').html(window.loggedIn.friends_count);
$('#user-followers strong').html(window.loggedIn.followers_count); getFromAPI('qvitter/allfollowing/' + window.loggedIn.screen_name + '.json',function(data){
$('#user-groups strong').html(window.loggedIn.groups_count);
$('.stream-selection.friends-timeline').attr('href', window.loggedIn.statusnet_profile_url + '/all'); if(data.users) {
$('.stream-selection.mentions').attr('href', window.loggedIn.statusnet_profile_url + '/replies'); $.each(data.users,function(k,v){
$('.stream-selection.notifications').attr('href', window.loggedIn.statusnet_profile_url + '/notifications'); if(v[2] === false) { var avatar = window.defaultAvatarStreamSize; }
$('.stream-selection.my-timeline').attr('href', window.loggedIn.statusnet_profile_url); else { var avatar = v[2]; }
$('.stream-selection.favorites').attr('href', window.loggedIn.statusnet_profile_url + '/favorites'); if(v[3]) {
$('#user-queets').attr('href',window.loggedIn.statusnet_profile_url); // extract server base url
$('#user-following').attr('href',window.loggedIn.statusnet_profile_url + '/subscriptions'); v[3] = v[3].substring(v[3].indexOf('://')+3,v[3].lastIndexOf(v[1])-1);
$('#user-groups').attr('href',window.loggedIn.statusnet_profile_url + '/groups'); }
window.myUserID = window.loggedIn.id; v[0] = v[0] || v[1]; // if name is null we go with username there too
if(window.loggedIn.cover_photo !== false) { window.following[k] = { 'id': k,'name': v[0], 'username': v[1],'avatar': avatar, 'url':v[3] };
$('#user-header').css('background-image','url(\'' + window.loggedIn.cover_photo + '\')'); });
} }
// get all users i'm following for autosuggestion if(data.groups) {
window.following = new Object(); $.each(data.groups,function(k,v){
window.groupMemberships = new Object(); if(v[2] === false || v[2] === null) { var avatar = window.defaultAvatarStreamSize; }
window.groupNicknamesAndLocalAliases = new Array(); else { var avatar = v[2]; }
if(v[3]) {
// extract server base url
v[3] = v[3].substring(v[3].indexOf('://')+3);
v[3] = v[3].substring(0, v[3].indexOf('/'));
}
v[0] = v[0] || v[1]; // if name is null we go with username there too
window.groupMemberships[k] = { 'id': k,'name': v[0], 'username': v[1],'avatar': avatar, 'url':v[3] };
window.groupNicknamesAndLocalAliases[k] = v[1];
});
}
getFromAPI('qvitter/allfollowing/' + window.loggedIn.screen_name + '.json',function(data){ // do this now not to stall slow computers, also we know of group memberships to highlight now
cacheSyntaxHighlighting();
cacheSyntaxHighlightingGroups();
if(data.users) { // we might have cached text for the queet box
$.each(data.users,function(k,v){ // (we need to get the mentions suggestions and cache the syntax highlighting before doing this)
if(v[2] === false) { var avatar = window.defaultAvatarStreamSize; } var cachedQueetBoxData = localStorageObjectCache_GET('queetBoxInput','queet-box');
else { var avatar = v[2]; } var cachedQueetBoxDataText = $('<div/>').html(cachedQueetBoxData).text();
if(v[3]) { if(cachedQueetBoxData) {
// extract server base url queetBox = $('#queet-box');
v[3] = v[3].substring(v[3].indexOf('://')+3,v[3].lastIndexOf(v[1])-1); queetBox.click();
} queetBox.html(cachedQueetBoxData);
v[0] = v[0] || v[1]; // if name is null we go with username there too setSelectionRange(queetBox[0], cachedQueetBoxDataText.length, cachedQueetBoxDataText.length);
window.following[k] = { 'id': k,'name': v[0], 'username': v[1],'avatar': avatar, 'url':v[3] }; queetBox.trigger('input');
}); }
} });
if(data.groups) { // load history
$.each(data.groups,function(k,v){ loadHistoryFromLocalStorage();
if(v[2] === false || v[2] === null) { var avatar = window.defaultAvatarStreamSize; }
else { var avatar = v[2]; }
if(v[3]) {
// extract server base url
v[3] = v[3].substring(v[3].indexOf('://')+3);
v[3] = v[3].substring(0, v[3].indexOf('/'));
}
v[0] = v[0] || v[1]; // if name is null we go with username there too
window.groupMemberships[k] = { 'id': k,'name': v[0], 'username': v[1],'avatar': avatar, 'url':v[3] };
window.groupNicknamesAndLocalAliases[k] = v[1];
});
}
// do this now not to stall slow computers, also we know of group memberships to highlight now // show bookmarks
cacheSyntaxHighlighting(); appendAllBookmarks(window.allBookmarks);
cacheSyntaxHighlightingGroups();
// we might have cached text for the queet box // set stream
// (we need to get the mentions suggestions and cache the syntax highlighting before doing this) setNewCurrentStream(streamObjectToSet,true,false,function(){
var cachedQueetBoxData = localStorageObjectCache_GET('queetBoxInput','queet-box'); $('.language-dropdown').css('display','none');
var cachedQueetBoxDataText = $('<div/>').html(cachedQueetBoxData).text(); $('#user-header').animate({opacity:'1'},800);
if(cachedQueetBoxData) { $('#user-body').animate({opacity:'1'},800);
queetBox = $('#queet-box'); $('#user-footer').animate({opacity:'1'},800);
queetBox.click(); $('.menu-container').animate({opacity:'1'},800);
queetBox.html(cachedQueetBoxData); $('#page-container').animate({opacity:'1'},200);
setSelectionRange(queetBox[0], cachedQueetBoxDataText.length, cachedQueetBoxDataText.length); $('#search').fadeIn('slow');
queetBox.trigger('input'); $('#login-content').css('display','none');
} $('.front-signup').css('display','none');
}); $('#settingslink .dropdown-toggle').fadeIn('slow');
$('#top-compose').fadeIn('slow');
// load history $('input#nickname').blur();
loadHistoryFromLocalStorage(); });
// show bookmarks
appendAllBookmarks(window.allBookmarks);
// set stream
window.currentStream = ''; // always reload stream on login
setNewCurrentStream(streamObjectToSet,true,false,function(){
$('.language-dropdown').css('display','none');
$('#user-header').animate({opacity:'1'},800);
$('#user-body').animate({opacity:'1'},800);
$('#user-footer').animate({opacity:'1'},800);
$('.menu-container').animate({opacity:'1'},800);
$('#page-container').animate({opacity:'1'},200);
$('#search').fadeIn('slow');
$('#login-content').css('display','none');
$('.front-signup').css('display','none');
$('#settingslink .dropdown-toggle').fadeIn('slow');
$('#top-compose').fadeIn('slow');
$('input#nickname').blur();
});
} }