Browse Source

Merge pull request #129 from digital-dreamer/guest-mode

Guest mode – browse without registration
master
miguelfreitas 11 years ago
parent
commit
2c4027bb7a
  1. 6
      home.html
  2. 36
      js/interface_common.js
  3. 43
      js/interface_home.js
  4. 11
      js/interface_localization.js
  5. 2
      js/interface_profile-edit.js
  6. 10
      js/twister_directmsg.js
  7. 6
      js/twister_following.js
  8. 7
      js/twister_formatpost.js
  9. 5
      js/twister_network.js
  10. 2
      js/twister_timeline.js

6
home.html

@ -53,7 +53,7 @@
</div> </div>
<a class="dropdown-menu-item" href="options.html">Options</a> <a class="dropdown-menu-item" href="options.html">Options</a>
<a class="dropdown-menu-item" href="profile-edit.html">Setup account</a> <a class="dropdown-menu-item" href="profile-edit.html">Setup account</a>
<a class="dropdown-menu-item" href="following.html">Following users</a> <a class="dropdown-menu-item dropdown-menu-following" href="following.html">Following users</a>
<a class="dropdown-menu-item" href="network.html">Network config</a> <a class="dropdown-menu-item" href="network.html">Network config</a>
<a class="dropdown-menu-item" href="login.html">Change user</a> <a class="dropdown-menu-item" href="login.html">Change user</a>
<a class="dropdown-menu-item promoted-posts-only" href="#">Switch to Promoted posts</a> <a class="dropdown-menu-item promoted-posts-only" href="#">Switch to Promoted posts</a>
@ -118,8 +118,8 @@
</div> </div>
<ul class="module profile-data"> <ul class="module profile-data">
<li><a href="#" class="open-profile-modal"><span class="posts-count">&nbsp;</span><span class="label">Posts</span></a></li> <li><a href="#" class="open-profile-modal"><span class="posts-count">&nbsp;</span><span class="label">Posts</span></a></li>
<li><a href="following.html"><span class="following-count">&nbsp;</span><span class="label">Following</span></a></li> <li><a href="following.html" class="open-following-page"><span class="following-count">&nbsp;</span><span class="label">Following</span></a></li>
<li><a href="#"><span class="followers-count">&nbsp;</span><span class="label">Followers</span> *</a></li> <li><a href="#" class="open-followers"><span class="followers-count">&nbsp;</span><span class="label">Followers</span> *</a></li>
</ul> </ul>
<div class="post-area"> <div class="post-area">

36
js/interface_common.js

@ -5,6 +5,8 @@
// Profile, mentions and hashtag modal // Profile, mentions and hashtag modal
// Post actions: submit, count characters // Post actions: submit, count characters
var preventSlide = false;
//dispara o modal genérico //dispara o modal genérico
//o modalClass me permite fazer tratamentos específicos de CSS para cada modal //o modalClass me permite fazer tratamentos específicos de CSS para cada modal
function openModal( modalClass ) function openModal( modalClass )
@ -104,6 +106,12 @@ function openProfileModal(e)
var $this = $( this ); var $this = $( this );
var username = $.MAL.urlToUser( $this.attr("href") ); var username = $.MAL.urlToUser( $this.attr("href") );
if(!username)
{
alert(polyglot.t("You don't have any profile because you are not logged in."));
return;
}
var profileModalClass = "profile-modal"; var profileModalClass = "profile-modal";
openModal( profileModalClass ); openModal( profileModalClass );
@ -169,6 +177,11 @@ function openMentionsModal(e)
e.stopPropagation(); e.stopPropagation();
e.preventDefault(); e.preventDefault();
if(!defaultScreenName)
{
alert(polyglot.t("No one can mention you because you are not logged in."));
return;
}
// reuse the same hashtag modal to show mentions // reuse the same hashtag modal to show mentions
var hashtagModalClass = "hashtag-modal"; var hashtagModalClass = "hashtag-modal";
openModal( hashtagModalClass ); openModal( hashtagModalClass );
@ -224,6 +237,13 @@ function openFollowingModal(e)
//dispara o modal de retweet //dispara o modal de retweet
var reTwistPopup = function( e ) var reTwistPopup = function( e )
{ {
if(!defaultScreenName)
{
preventSlide=true;
alert(polyglot.t("You have to log in to retransmit messages."));
return;
}
var reTwistClass = "reTwist"; var reTwistClass = "reTwist";
openModal( reTwistClass ); openModal( reTwistClass );
@ -296,7 +316,15 @@ var postExpandFunction = function( e, postLi )
var $postsRelated = postLi.find(".related"); var $postsRelated = postLi.find(".related");
var openClass = "open"; var openClass = "open";
if( !postLi.hasClass( openClass ) ) {
//This is used in "guest mode", when user gets an alert that he can't reply or retransmit
//when not logged in. Otherwise, this click would also be understood as a command to open/close
//the post, which would look weird.
if(preventSlide)
{
preventSlide=false;
}
else if( !postLi.hasClass( openClass ) ) {
originalPost.detach(); originalPost.detach();
postLi.empty(); postLi.empty();
postLi.addClass( openClass ); postLi.addClass( openClass );
@ -347,6 +375,12 @@ var postExpandFunction = function( e, postLi )
var postReplyClick = function( e ) var postReplyClick = function( e )
{ {
if(!defaultScreenName)
{
preventSlide=true;
alert(polyglot.t("You have to log in to post replies."));
return;
}
var post = $(this).closest(".post"); var post = $(this).closest(".post");
if( !post.hasClass( "original" ) ) { if( !post.hasClass( "original" ) ) {
replyInitPopup(e, post); replyInitPopup(e, post);

43
js/interface_home.js

@ -31,15 +31,47 @@ var InterfaceFunctions = function()
} }
function initHome(cbFunc, cbArg) { function initHome(cbFunc, cbArg) {
if( !defaultScreenName ) {
alert(polyglot.t("username_undefined"));
$.MAL.goLogin();
return;
}
checkNetworkStatusAndAskRedirect(); checkNetworkStatusAndAskRedirect();
//$("span.screen-name").text('@' + user); //$("span.screen-name").text('@' + user);
var $miniProfile = $(".mini-profile"); var $miniProfile = $(".mini-profile");
if(!defaultScreenName)
{
$(".userMenu-profile > a").text(polyglot.t("Login"));
$(".userMenu-profile > a").attr("href","login.html");
$(".post-area-new > textarea").attr("placeholder",polyglot.t("You have to log in to post messages."));
$(".post-area-new > textarea").attr("disabled","true");
$miniProfile.find(".mini-profile-name").text("guest");
$miniProfile.find(".posts-count").text("0");
$miniProfile.find(".following-count").text("0");
$miniProfile.find(".followers-count").text("0");
$miniProfile.find("a.open-following-page").attr("href","#");
$miniProfile.find("a.open-following-page").bind("click", function()
{ alert(polyglot.t("You are not following anyone because you are not logged in."))} );
$miniProfile.find("a.open-followers").bind("click", function()
{ alert(polyglot.t("You don't have any followers because you are not logged in."))} );
$(".dropdown-menu-following").attr("href","#");
$(".dropdown-menu-following").bind("click", function()
{ alert(polyglot.t("You are not following anyone because you are not logged in."))} );
twisterRpc("gettrendinghashtags", [10],
function(args, ret) {
for( var i = 0; i < ret.length; i++ ) {
var $li = $("<li>");
var hashtagLinkTemplate = $("#hashtag-link-template").clone(true);
hashtagLinkTemplate.removeAttr("id");
hashtagLinkTemplate.attr("href",$.MAL.hashtagUrl(ret[i]));
hashtagLinkTemplate.text("#"+ret[i]);
$li.append(hashtagLinkTemplate);
$(".toptrends-list").append($li);
}
}, {},
function(args, ret) {
console.log("Error with gettrendinghashtags. Older twister daemon?");
}, {});
}
else
{
$miniProfile.find("a.mini-profile-name").attr("href",$.MAL.userUrl(defaultScreenName)); $miniProfile.find("a.mini-profile-name").attr("href",$.MAL.userUrl(defaultScreenName));
$miniProfile.find("a.open-profile-modal").attr("href",$.MAL.userUrl(defaultScreenName)); $miniProfile.find("a.open-profile-modal").attr("href",$.MAL.userUrl(defaultScreenName));
$miniProfile.find(".mini-profile-name").text(defaultScreenName); $miniProfile.find(".mini-profile-name").text(defaultScreenName);
@ -90,6 +122,7 @@ var InterfaceFunctions = function()
args.cbFunc(args.cbArg); args.cbFunc(args.cbArg);
}, {cbFunc:cbFunc, cbArg:cbArg}); }, {cbFunc:cbFunc, cbArg:cbArg});
} }
}
} }
//*********************************************** //***********************************************

11
js/interface_localization.js

@ -165,7 +165,16 @@ if(preferredLanguage == "en"){
"Terminate Daemon:": "Terminate Daemon:", "Terminate Daemon:": "Terminate Daemon:",
"Exit": "Exit", "Exit": "Exit",
"Save Changes": "Save Changes", "Save Changes": "Save Changes",
"Secret key:": "Secret key:" "Secret key:": "Secret key:",
"You have to log in to post messages.": "You have to log in to post messages.",
"You have to log in to post replies.": "You have to log in to post replies.",
"You have to log in to retransmit messages.": "You have to log in to retransmit messages.",
"You have to log in to use direct messages.": "You have to log in to use direct messages.",
"You have to log in to follow users.": "You have to log in to follow users.",
"You are not following anyone because you are not logged in.": "You are not following anyone because you are not logged in.",
"You don't have any followers because you are not logged in.": "You don't have any followers because you are not logged in.",
"No one can mention you because you are not logged in.": "No one can mention you because you are not logged in.",
"You don't have any profile because you are not logged in.": "You don't have any profile because you are not logged in."
}; };
} }
if(preferredLanguage == "es"){ if(preferredLanguage == "es"){

2
js/interface_profile-edit.js

@ -22,7 +22,7 @@ function initProfileEdit() {
initUser( function() { initUser( function() {
if( !defaultScreenName ) { if( !defaultScreenName ) {
alert("Username undefined, login required."); alert(polyglot.t("username_undefined"));
$.MAL.goLogin(); $.MAL.goLogin();
return; return;
} }

10
js/twister_directmsg.js

@ -110,6 +110,11 @@ function newDirectMsg(msg, dm_screenname) {
//dispara o modal de direct messages //dispara o modal de direct messages
function directMessagesPopup() function directMessagesPopup()
{ {
if(!defaultScreenName)
{
alert(polyglot.t("You have to log in to use direct messages."));
return;
}
var directMessagesClass = "directMessages"; var directMessagesClass = "directMessages";
openModal( directMessagesClass ); openModal( directMessagesClass );
@ -140,6 +145,11 @@ function hideDmSnippetShowDmThread()
function directMessagesWithUserPopup() function directMessagesWithUserPopup()
{ {
if(!defaultScreenName)
{
alert(polyglot.t("You have to log in to use direct messages."));
return;
}
var $userInfo = $(this).closest("[data-screen-name]"); var $userInfo = $(this).closest("[data-screen-name]");
var dm_screenname = $userInfo.attr("data-screen-name"); var dm_screenname = $userInfo.attr("data-screen-name");
openDmWithUserModal( dm_screenname ); openDmWithUserModal( dm_screenname );

6
js/twister_following.js

@ -438,6 +438,12 @@ function userClickFollow(e) {
var $userInfo = $this.closest("[data-screen-name]"); var $userInfo = $this.closest("[data-screen-name]");
var username = $userInfo.attr("data-screen-name"); var username = $userInfo.attr("data-screen-name");
if(!defaultScreenName)
{
alert(polyglot.t("You have to log in to follow users."));
return;
}
follow(username, true, function() { follow(username, true, function() {
// delay reload so dhtput may do it's job // delay reload so dhtput may do it's job
window.setTimeout("location.reload();",500); window.setTimeout("location.reload();",500);

7
js/twister_formatpost.js

@ -90,7 +90,14 @@ function postToElem( post, kind ) {
replyTo += "@" + mentions[i] + " "; replyTo += "@" + mentions[i] + " ";
} }
} }
if(!defaultScreenName)
{
elem.find(".post-area-new textarea").attr("placeholder", polyglot.t("You have to log in to post replies."));
}
else
{
elem.find(".post-area-new textarea").attr("placeholder", polyglot.t("reply_to", { fullname: replyTo })+ "..."); elem.find(".post-area-new textarea").attr("placeholder", polyglot.t("reply_to", { fullname: replyTo })+ "...");
}
elem.find(".post-area-new textarea").attr("data-reply-to",replyTo); elem.find(".post-area-new textarea").attr("data-reply-to",replyTo);
postData.attr("data-reply-to",replyTo); postData.attr("data-reply-to",replyTo);

5
js/twister_network.js

@ -265,6 +265,11 @@ function initInterfaceNetwork() {
initDMsCount(); initDMsCount();
}); });
} }
else
{
$(".userMenu-profile > a").text(polyglot.t("Login"));
$(".userMenu-profile > a").attr("href","login.html");
}
}); });
networkUpdate(); networkUpdate();
setInterval("networkUpdate()", 2000); setInterval("networkUpdate()", 2000);

2
js/twister_timeline.js

@ -204,7 +204,7 @@ function processReceivedPosts(req, posts)
// request timeline update for a given list of users // request timeline update for a given list of users
function requestTimelineUpdate(mode, count, timelineUsers, getspam) function requestTimelineUpdate(mode, count, timelineUsers, getspam)
{ {
if( _refreshInProgress ) if( _refreshInProgress || !defaultScreenName)
return; return;
$.MAL.postboardLoading(); $.MAL.postboardLoading();
_refreshInProgress = true; _refreshInProgress = true;

Loading…
Cancel
Save