Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
246 lines (199 sloc) 9.28 KB
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="en">
<head>
<meta name="google-signin-scope" content="https://picasaweb.google.com/data/">
<meta name="google-signin-client_id" content="992551522822-7nstfoq17gn0u27kmcfcgnnfbp13ndl3.apps.googleusercontent.com">
<script src="https://apis.google.com/js/platform.js" async defer></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css" />
<link href="https://fonts.googleapis.com/css?family=Roboto+Condensed" rel="stylesheet">
<style>
* { font-family: 'Roboto Condensed', sans-serif; }
.btn {
padding: 1px 5px;
}
</style>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-39069349-9', 'auto');
ga('send', 'pageview');
// statistics
ga('send', 'event', 'pageview', 'pageview');
</script>
<title>nanoGPVisibility</title>
<meta name="description" content="Manage the visibility of your photo albums on Google Photos">
</head>
<body>
<div class="container">
<h2>nanoGPVisibility - Manage the visibility of your photo albums on Google Photos</h2>
<hr>
<h4 style="color:#d00;">
IMPORTANT NOTE: <b>Google changed it's API</b>. Since the 9th february 2017, it's no more possible to change the visibility of your albums.
<br><br>
For users of nanoGALLERY: please upgrade to <a href="http://nanogallery2.nanostudio.org/">nanogallery2</a> to display photos stored on Google Photos.
<br><br>
This tool stays online for historical reasons.
</h4>
<hr>
<p>
<p id="pleaseSignIn"><b>To use this tool, please sign-in to Google</b><br>By signing-in you agree that some data can be used for statistical purposes.</p>
<a style="display:none; float: left; margin-right: 10px; height: 36px;" class="btn btn-warning" id="sign-out" href="#">Sign out</a>
<div class="g-signin2" data-onsuccess="onSignIn" data-theme="dark"></div>
<div style="clear: both;"></div>
</p>
<script>
var tableEntries;
function onSignIn(googleUser) {
// Useful data for your client-side scripts:
var profile = googleUser.getBasicProfile(),
id_token = googleUser.getAuthResponse().id_token,
access_token = googleUser.getAuthResponse().access_token;
//console.log("ID: " + profile.getId()); // Don't send this directly to your server!
//console.log("Name: " + profile.getName());
//console.log("Image URL: " + profile.getImageUrl());
//console.log("Email: " + profile.getEmail());
// The ID token you need to pass to your backend:
//console.log("ID Token: " + id_token);
// statistics
ga('send', 'event', 'login', profile.getName()+' - '+ profile.getId() +' - '+ profile.getEmail());
jQuery('#sign-out').show();
jQuery('#pleaseSignIn').hide();
jQuery('#userID').text('hello, ' + profile.getName() + '. Your userID is: '+ profile.getId());
jQuery.ajax( {
url: 'https://picasaweb.google.com/data/feed/api/user/' + profile.getId() + '?alt=json&access=all&access_token=' + access_token,
dataType: 'json',
method:'GET',
success: function(data){
var i, j;
tableEntries = [];
for(var i=0; i<data.feed.entry.length; i++) {
var entry = data.feed.entry[i],
title = entry.title.$t,
userid = entry.gphoto$user.$t,
albumid = entry.gphoto$id.$t,
link,
authKeyMatchResult,
tableEntry = {};
for(var j=0; j<entry.link.length; j++) {
if (entry.link[j].rel === "alternate") {
tableEntry.link = entry.link[j].href;
break;
}
}
tableEntry.userid = userid;
tableEntry.title = title;
tableEntry.albumid = albumid;
tableEntry.rights = entry.rights.$t;
tableEntry.authKey = '';
tableEntry.access_token = access_token;
authKeyMatchResult = tableEntry.link.match(/authkey=([^&]*)/);
if (null !== authKeyMatchResult && authKeyMatchResult.length > 1) {
tableEntry.authKey = authKeyMatchResult[1];
}
tableEntries.push(tableEntry);
}
// sort on title
tableEntries.sort(function (a, b) {
return( (a.title.toUpperCase() < b.title.toUpperCase()) ? -1 : ((a.title.toUpperCase() > b.title.toUpperCase()) ? 1 : 0) );
});
// render the table
for(var i=0; i<tableEntries.length; i++) {
var tableEntry=tableEntries[i];
var btVisibility = '<div class="btn-group">';
btVisibility +='<button data-permission="protected" class="btn btn-danger change-permission '+(tableEntry.rights=='protected' ? "disabled": "" )+'" href=""><i class="fa fa-ban"></i> Hidden</button>';
btVisibility +='<button data-permission="private" class="btn btn-warning change-permission '+(tableEntry.rights=='private' ? "disabled": "" )+'" href=""><i class="fa fa-user"></i> Private</button>';
btVisibility +='<button data-permission="public" class="btn btn-success change-permission '+(tableEntry.rights=='public' ? "disabled": "" )+'" href=""><i class="fa fa-cloud"></i> Public</button>';
btVisibility +='</div>';
var aLink='<a class="albumlink" href="' + tableEntry.link + '" target="_blank">'+tableEntry.title+'</a>';
var s=(tableEntry.authKey != '' ? "<br>authkey="+tableEntry.authKey : "");
var r=tableEntry.rights;
var c='';
var ic='';
switch( tableEntry.rights ) {
case 'protected':
c='danger';
r='hidden';
ic='<i class="fa fa-ban">';
break;
case 'private':
c='warning';c
ic='<i class="fa fa-user">';
break;
case 'public':
c='success';
ic='<i class="fa fa-cloud">';
break;
}
$('#lstAlbums > tbody:last-child').append('<tr data-index="'+i+'" class=""><td class="'+c+'">'+ic+' '+aLink+'</td><td>'+btVisibility+'</td><td>'+tableEntry.albumid + s + '</td></tr>');
}
}
});
};
jQuery( document ).ready(function() {
jQuery(document).on('click', '#sign-out', function(e){
var auth2 = gapi.auth2.getAuthInstance();
auth2.signOut().then(function () {
location.reload();
});
});
jQuery(document).on('click', '.change-permission', function(e){
e.preventDefault();
var $btn=jQuery(e.target);
if( $btn.hasClass('disabled') ) { return; }
var index = $btn.parents('tr').attr('data-index'),
tableEntry = tableEntries[index],
url = 'nanogpvisibility.php',
new_access = jQuery(e.target).attr('data-permission');
jQuery("body").css("cursor", "progress");
jQuery.ajax({
url: url,
dataType: 'json',
method:'POST',
data: {
'userid': tableEntry.userid,
'albumid': tableEntry.albumid,
'access_token': tableEntry.access_token,
'new_access': new_access
}
})
.done(function( msg ) {
jQuery("body").css("cursor", "default");
console.log( "Data Saved: " + msg );
location.reload();
})
.fail( function( data ) {
jQuery("body").css("cursor", "default");
console.dir(data);
if ( data.responseCode )
console.log( data.responseCode );
});
});
});
</script>
<br>
<h4 id="userID"></h4>
<br>
<div class="table-responsive">
<table id="lstAlbums" class="table table-striped table-hover table-condensed">
<thead>
<tr>
<th>Album title</th>
<!-- <th>Visibility</th> -->
<th>Change visibility</th>
<th>albumID</th>
<!-- <th>Private key</th> -->
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
<p>nanoGPVisibility by Christophe Brisbois - original code by Sven Bluege</p>
</div>
</body>
</html>