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

View File

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