Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Public server mode #135

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -1595,3 +1595,25 @@ ul.dropdown-menu > li > a {
-o-transition: all 200ms;
transition: all 200ms;
}
/*******************************************************
****************** PUBLIC SERVER MODE PAGE *************
*******************************************************/
.announcement-title
{
font-size: 32px;
text-align: center;
margin-top: 40px;
margin-bottom: 40px;
}

.announcement-line
{
text-align: center;
margin-top: 20px;
}

.download-page-link
{
font-size: 16px;
margin-top: 5px;
}
6 changes: 3 additions & 3 deletions home.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@
<span class="mini-profile-view">View</span>
</div>
<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 dropdown-menu-profile" href="profile-edit.html">Setup account</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="login.html">Change user</a>
<a class="dropdown-menu-item dropdown-menu-network" href="network.html">Network config</a>
<a class="dropdown-menu-item dropdown-menu-change-user" href="login.html">Change user</a>
<a class="dropdown-menu-item promoted-posts-only" href="#">Switch to Promoted posts</a>
<a class="direct-messages dropdown-menu-item" href="#">Direct Messages</a>
</div>
Expand Down
13 changes: 13 additions & 0 deletions js/interface_common.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ function checkNetworkStatusAndAskRedirect(cbFunc, cbArg) {
}, {cbFunc:cbFunc,cbArg:cbArg});
}

function checkNetworkStatusAndShowAlert(cbFunc, cbArg) {
networkUpdate(function(args)
{
if(!twisterdConnectedAndUptodate)
alert(polyglot.t("Server was not able to connect to the network.\nSome functions may not work properly."));
else if(args.cbFunc)
args.cbFunc(args.cbArg);
}, {cbFunc:cbFunc,cbArg:cbArg});
}
function timeGmtToText(t) {
var d = new Date(0);
d.setUTCSeconds(t);
Expand Down Expand Up @@ -399,6 +408,10 @@ var postReplyClick = function( e )
var composeNewPost = function( e, postAreaNew )
{
e.stopPropagation();

if(!defaultScreenName)
return;

if( !postAreaNew.hasClass("open") ) {
postAreaNew.addClass( "open" );
//se o usuário clicar fora é pra fechar
Expand Down
23 changes: 19 additions & 4 deletions js/interface_home.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,31 @@ var InterfaceFunctions = function()
}

function initHome(cbFunc, cbArg) {
checkNetworkStatusAndAskRedirect();
if(publicServerMode)
checkNetworkStatusAndShowAlert();
else
checkNetworkStatusAndAskRedirect();

//$("span.screen-name").text('@' + user);
var $miniProfile = $(".mini-profile");
if(!defaultScreenName)
{
if(publicServerMode)
{
$(".userMenu-network").remove();
$(".userMenu-connections").remove();
$(".userMenu-messages").remove();
$(".who-to-follow").remove();
$(".dropdown-menu-network").remove();
$(".dropdown-menu-profile").attr("href","public-server.html");
$(".dropdown-menu-change-user").attr("href","public-server.html");
$(".userMenu-profile > a").attr("href","public-server.html");
}
else
$(".userMenu-profile > a").attr("href","login.html");
$(".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");
$(".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");
Expand Down
5 changes: 5 additions & 0 deletions js/interface_localization.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,11 @@ if(preferredLanguage == "en"){
"none": "none",
"Custom": "Custom",
"Mentions": "Mentions",
"This is a read-only server": "This is a read-only server",
"The website you are now viewing is a public, read-only server.":"The website you are now viewing is a public, read-only server.",
"If you want to be active on the network, download and run your own Twister.":"If you want to be active on the network, download and run your own Twister.",
"Click here to start":"Click here to start",
"Server was not able to connect to the network.\nSome functions may not work properly.": "Server was not able to connect to the network.\nSome functions may not work properly.",
};
}
if(preferredLanguage == "es"){
Expand Down
5 changes: 4 additions & 1 deletion js/interface_login.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ function loginCreatedUser() {
}

function initInterfaceLogin() {
initUser();
initUser(function()
{ if(publicServerMode)
window.location.href = "public-server.html";
});
initInterfaceCommon();
checkNetworkStatusAndAskRedirect();

Expand Down
4 changes: 3 additions & 1 deletion js/interface_profile-edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ function initProfileEdit() {
$(".cancel-changes").click( $.MAL.goHome );

initUser( function() {
if( !defaultScreenName ) {
if(publicServerMode)
window.location.href = "public-server.html";
else if( !defaultScreenName ) {
alert(polyglot.t("username_undefined"));
$.MAL.goLogin();
return;
Expand Down
9 changes: 9 additions & 0 deletions js/interface_public_server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// interface_public_server.js

function initInterfaceLogin() {
$(".announcement-title").text(polyglot.t("This is a read-only server"));
$(".public-sercer-line-1 > p").text(polyglot.t("The website you are now viewing is a public, read-only server."));
$(".public-sercer-line-2 > p").text(polyglot.t("If you want to be active on the network, download and run your own Twister."));
$(".download-page-link").text(polyglot.t("Click here to start"));
$(".download-page-link").bind( "click", function() {window.location.href = "http://twister.net.co/?page_id=23";} );
}
21 changes: 21 additions & 0 deletions js/twister_io.js
Original file line number Diff line number Diff line change
Expand Up @@ -366,3 +366,24 @@ function dumpPrivkey(username, cbFunc, cbArg) {
}, {cbFunc:cbFunc, cbArg:cbArg});
}

function getInfo(cbFunc, cbArg) {
twisterRpc("getinfo", [],
function(args, ret) {
args.cbFunc(args.cbArg, ret);
}, {cbFunc:cbFunc, cbArg:cbArg},
function(args, ret) {
alert(polyglot.t("error_connecting_to_daemon"));
}, {cbFunc:cbFunc, cbArg:cbArg});
}

function getPublicServerMode(cbFunc, cbArg) {
getInfo(
function(args, info) {
publicServerMode=info["public_server_mode"];
if(publicServerMode)
defaultScreenName=undefined;
if(cbFunc)
cbFunc(cbArg);
}, {cbFunc:cbFunc, cbArg:cbArg}
)
}
7 changes: 6 additions & 1 deletion js/twister_network.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,8 @@ function interfaceNetworkHandlers() {
function initInterfaceNetwork() {
initInterfaceCommon();
initUser( function () {
if(publicServerMode)
window.location.href = "public-server.html";
getSpamMsg();

if( defaultScreenName ) {
Expand All @@ -268,7 +270,10 @@ function initInterfaceNetwork() {
else
{
$(".userMenu-profile > a").text(polyglot.t("Login"));
$(".userMenu-profile > a").attr("href","login.html");
if(publicServerMode)
$(".userMenu-profile > a").attr("href","public-server.html");
else
$(".userMenu-profile > a").attr("href","login.html");
}
});
networkUpdate();
Expand Down
4 changes: 2 additions & 2 deletions js/twister_user.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
var defaultScreenName = undefined;
var localUsernames = [];
var lastPostId = undefined;
var publicServerMode = false;

// basic user functions
// -------------------------------
Expand Down Expand Up @@ -44,8 +45,7 @@ function initUser(cbFunc, cbArg) {
}
}
lastPostId = undefined;
if( cbFunc )
cbFunc(cbArg);
getPublicServerMode(cbFunc,cbArg);
});
}

Expand Down
59 changes: 59 additions & 0 deletions public-server.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>twister login</title>
<link id="stylecss" rel="stylesheet" href="css/style.css" type="text/css"/>
<script src="js/jquery.min.js"></script>
<script src="js/jQueryPlugins.js"></script>
<script src="js/jquery.json-2.4.js"></script>
<script src="js/jquery.jsonrpcclient.js"></script>
<script src="js/jquery.storageapi.js"></script>
<script src="js/options.js"></script>
<script src="js/mobile_abstract.js"></script>
<script src="js/twister_io.js"></script>
<script src="js/twister_network.js"></script>
<script src="js/twister_user.js"></script>
<script src="js/interface_common.js"></script>
<script src="js/interface_public_server.js"></script>
<script src="js/polyglot.min.js"></script>
<script src="js/interface_localization.js"></script>
<script src="js/calm.js"></script>

<script>
$(document).ready(function()
{
initInterfaceLogin();
});
changeStyle();
</script>

<link rel="icon" type="image/png" href="img/twister_mini.png" />
</head>

<body>

<!-- MENU SUPERIOR INIT -->
<nav class="userMenu">
<ul>
<li class="userMenu-home"><a href="home.html">Home</a></li>
<li class="userMenu-profile current"><a href="public-server.html">Login</a></li>
</ul>
</nav>
<!-- MENU SUPERIOR END -->

<div class="wrapper">
<h1 class="announcement-title">This is a read-only server</h1>
<div class="announcement-line public-sercer-line-1">
<p>The website you are now viewing is a public, read-only server.</p>
</div>
<div class="announcement-line public-sercer-line-2">
<p>If you want to be active on the network, download and run your own Twister.</p>
</div>
<div class="announcement-line">
<button class="download-page-link">Click here to start</button>
</div>
</div>

</body>
</html>
21 changes: 20 additions & 1 deletion theme_calm/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -2006,4 +2006,23 @@ ul.dropdown-menu img {
p.post-text img {
width: 20px;
height: 20px;
}
}
.announcement-title
{
font-size: 32px;
text-align: center;
margin-top: 40px;
margin-bottom: 40px;
}

.announcement-line
{
text-align: center;
margin-top: 20px;
}

.download-page-link
{
font-size: 16px;
margin-top: 5px;
}