From e006ed70761a3084a58487fb627a3b3789e97afc Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 17 Jan 2017 11:52:44 +0100 Subject: [PATCH] Ability to log in from the main page --- customize.dist/about.html | 12 ++--- customize.dist/contact.html | 12 ++--- customize.dist/index.html | 20 ++++----- customize.dist/main.css | 51 +++++++++++----------- customize.dist/main.js | 38 +++++++++++++++- customize.dist/privacy.html | 10 ++--- customize.dist/src/fragments/about.html | 2 +- customize.dist/src/fragments/contact.html | 2 +- customize.dist/src/fragments/fork.html | 2 +- customize.dist/src/fragments/index.html | 10 ++--- customize.dist/src/fragments/topbar.html | 8 ++-- customize.dist/src/less/cryptpad.less | 1 + customize.dist/src/less/variables.less | 4 +- customize.dist/terms.html | 10 ++--- customize.dist/translations/messages.fr.js | 8 ++++ customize.dist/translations/messages.js | 6 +++ www/common/cryptpad-common.js | 5 +++ www/user/main.js | 17 +++++++- 18 files changed, 144 insertions(+), 74 deletions(-) diff --git a/customize.dist/about.html b/customize.dist/about.html index eab8b7b32..682422a80 100644 --- a/customize.dist/about.html +++ b/customize.dist/about.html @@ -25,21 +25,21 @@ - About + About - Privacy + Privacy - ToS + ToS - Contact + Contact - + @@ -61,7 +61,7 @@
-

About

+

About

diff --git a/customize.dist/contact.html b/customize.dist/contact.html index bd9df834b..1c7885c25 100644 --- a/customize.dist/contact.html +++ b/customize.dist/contact.html @@ -25,21 +25,21 @@ - About + About - Privacy + Privacy - ToS + ToS - Contact + Contact
- + @@ -61,7 +61,7 @@
-

Contact

+

Contact

diff --git a/customize.dist/index.html b/customize.dist/index.html index 2947a56cc..9a874b38f 100644 --- a/customize.dist/index.html +++ b/customize.dist/index.html @@ -25,21 +25,21 @@ - About + About - Privacy + Privacy - ToS + ToS - Contact + Contact
- + @@ -79,15 +79,15 @@

Join Us!


-
+

-
+
-
+

-
- +
+ diff --git a/customize.dist/main.css b/customize.dist/main.css index bb34f4e28..c31dc4408 100644 --- a/customize.dist/main.css +++ b/customize.dist/main.css @@ -3,7 +3,7 @@ */ .alertify-logs > * { padding: 12px 48px; - color: #111; + color: #fafafa; font-weight: bold; font-size: large; box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.2); @@ -18,7 +18,7 @@ } .alertify-logs > *.success { background: #46E981; - color: #ddd; + color: #302B28; } .alertify { position: fixed; @@ -79,8 +79,8 @@ } .alertify .dialog input:not(.form-control), .alertify .alert input:not(.form-control) { - background-color: #ddd; - color: #111; + background-color: #302B28; + color: #fafafa; border: 0px; border-radius: 5px; margin-bottom: 15px; @@ -112,8 +112,8 @@ font-size: 14px; text-decoration: none; cursor: pointer; - color: #111; - border: 1px solid #ddd; + color: #fafafa; + border: 1px solid #302B28; border-radius: 5px; } .alertify .dialog nav button:not(.btn):not(.pure-button):not(.md-button):not(.mdl-button):hover, @@ -124,7 +124,7 @@ } .alertify .dialog nav button:not(.btn):not(.pure-button):not(.md-button):not(.mdl-button):focus, .alertify .alert nav button:not(.btn):not(.pure-button):not(.md-button):not(.mdl-button):focus { - border: 1px dotted #ddd; + border: 1px dotted #302B28; } .alertify .dialog nav button:not(.btn):not(.pure-button):not(.md-button):not(.mdl-button)::-moz-focus-inner, .alertify .alert nav button:not(.btn):not(.pure-button):not(.md-button):not(.mdl-button)::-moz-focus-inner { @@ -210,7 +210,7 @@ height: 2.5em; display: inline-block; width: 100%; - background: #ddd; + background: #302B28; border-top: 1px solid #444; } .top-bar a, @@ -226,7 +226,7 @@ display: block; margin-left: 10px; padding-top: 3px; - color: #111; + color: #fafafa; } .top-bar img, .bottom-bar img { @@ -305,7 +305,7 @@ bottom: 0px; left: 0px; right: 0px; - background: #ddd; + background: #302B28; text-align: center; font-size: 1.5em; } @@ -450,8 +450,8 @@ html.cp, .cp body { font-size: .875em; - background-color: #ddd; - color: #111; + background-color: #302B28; + color: #fafafa; font-family: Georgia,Cambria,serif; height: 100%; } @@ -460,6 +460,7 @@ html.cp, top: 80px; right: 0px; display: inline-block; + z-index: 2; } .cp { /* buttons */ @@ -475,7 +476,7 @@ html.cp, } .cp a.github-corner > svg { fill: #00ADEE; - color: #ddd; + color: #302B28; } .cp .lato { font-family: lato, Helvetica, sans-serif; @@ -487,7 +488,7 @@ html.cp, .cp h4, .cp h5, .cp h6 { - color: #111; + color: #fafafa; font-family: "Source Sans Pro", "Helvetica Neue", Helvetica, Arial, sans-serif; -webkit-font-feature-settings: 'dlig' 1, 'liga' 1, 'lnum' 1, 'kern' 1; -moz-font-feature-settings: 'dlig' 1, 'liga' 1, 'lnum' 1, 'kern' 1; @@ -711,7 +712,7 @@ html.cp, cursor: pointer; } .cp tbody tr:nth-child(odd) { - background-color: #ffffff; + background-color: #685d56; } .cp tbody tr th:first-of-type { border-left: 0px; @@ -722,7 +723,7 @@ html.cp, } .cp tbody tr th, .cp tbody tr td { - color: #111; + color: #fafafa; } .cp tbody tr th.remove, .cp tbody tr td.remove { @@ -793,7 +794,7 @@ html.cp, .cp form.realtime table tr td div.text-cell input[disabled], .cp div.realtime table tr td div.text-cell input[disabled] { background-color: transparent; - color: #111; + color: #fafafa; font-weight: bold; } .cp form.realtime table tr td.checkbox-cell, @@ -828,7 +829,7 @@ html.cp, .cp div.realtime table tr td.checkbox-cell div.checkbox-contain input[type="checkbox"]:not(.editable) ~ .cover { font-weight: bold; background-color: #FF0073; - color: #ddd; + color: #302B28; display: block; } .cp form.realtime table tr td.checkbox-cell div.checkbox-contain input[type="checkbox"]:not(.editable) ~ .cover:after, @@ -858,13 +859,13 @@ html.cp, .cp form.realtime table input[type="text"], .cp div.realtime table input[type="text"] { height: auto; - border: 1px solid #ddd; + border: 1px solid #302B28; width: 80%; } .cp form.realtime table thead td, .cp div.realtime table thead td { padding: 0px 5px; - background: #f7f7f7; + background: #4c443f; border-radius: 20px 20px 0 0; text-align: center; } @@ -881,7 +882,7 @@ html.cp, } .cp form.realtime table tbody .text-cell, .cp div.realtime table tbody .text-cell { - background: #f7f7f7; + background: #4c443f; } .cp form.realtime table tbody .text-cell input[type="text"], .cp div.realtime table tbody .text-cell input[type="text"] { @@ -914,7 +915,7 @@ html.cp, .cp form.realtime table thead tr th input[type="text"][disabled], .cp div.realtime table thead tr th input[type="text"][disabled] { background-color: transparent; - color: #111; + color: #fafafa; font-weight: bold; } .cp form.realtime table thead tr th .remove, @@ -977,7 +978,7 @@ html.cp, width: 100%; height: 100vh; display: none; - background-color: #ddd; + background-color: #302B28; } .cp div.modal #content, .cp div#modal #content { @@ -1068,7 +1069,7 @@ html.cp, width: 80%; height: 80%; margin: auto; - border: 1px solid #ffffff; + border: 1px solid #685d56; text-align: center; } .cp div.modal.shown, @@ -1084,7 +1085,7 @@ html.cp, .cp div#modal table input { height: 100%; width: 90%; - border: 3px solid #ddd; + border: 3px solid #302B28; } .cp div.modal table tfoot tr td, .cp div#modal table tfoot tr td { diff --git a/customize.dist/main.js b/customize.dist/main.js index a14f56d7c..1af9761e1 100644 --- a/customize.dist/main.js +++ b/customize.dist/main.js @@ -156,10 +156,42 @@ define([ }); }; + var addButtonHandlers = function () { + $('button.login').click(function (e) { + var username = $('#name').val(); + var passwd = $('#password').val(); + var remember = $('#rememberme').is(':checked'); + sessionStorage.login_user = username; + sessionStorage.login_pass = passwd; + sessionStorage.login_rmb = remember; + sessionStorage.login = 1; + document.location.href = '/user'; + }); + $('button.register').click(function (e) { + var username = $('#name').val(); + var passwd = $('#password').val(); + var remember = $('#rememberme').is(':checked'); + sessionStorage.login_user = username; + sessionStorage.login_pass = passwd; + sessionStorage.login_rmb = remember; + sessionStorage.register = 1; + document.location.href = '/user'; + }); + $('button.nologin').click(function (e) { + document.location.href = '/drive'; + }); + }; + displayCreateButtons(); - Cryptpad.ready(function () { + //Cryptpad.ready(function () { console.log("ready"); + if (Cryptpad.isLoggedIn()) { + document.location.href = '/drive'; + } + + addButtonHandlers(); + $table = $('table.scroll'); $tbody = $table.find('tbody'); $tryit = $('#tryit'); @@ -167,6 +199,7 @@ define([ Cryptpad.styleAlerts(); //refreshTable(); + /* if (Cryptpad.store && Cryptpad.store.change) { Cryptpad.store.change(function (data) { if (data.key === 'CryptPad_RECENTPADS') { @@ -174,6 +207,7 @@ define([ } }); } - }); + */ + //}); }); diff --git a/customize.dist/privacy.html b/customize.dist/privacy.html index 96ed6325f..244c382ee 100644 --- a/customize.dist/privacy.html +++ b/customize.dist/privacy.html @@ -25,21 +25,21 @@ - About + About - Privacy + Privacy - ToS + ToS - Contact + Contact - + diff --git a/customize.dist/src/fragments/about.html b/customize.dist/src/fragments/about.html index 878c50009..5956b69ac 100644 --- a/customize.dist/src/fragments/about.html +++ b/customize.dist/src/fragments/about.html @@ -1,6 +1,6 @@
-

About

+

About

diff --git a/customize.dist/src/fragments/contact.html b/customize.dist/src/fragments/contact.html index 30415ef0e..340a26e83 100644 --- a/customize.dist/src/fragments/contact.html +++ b/customize.dist/src/fragments/contact.html @@ -1,6 +1,6 @@
-

Contact

+

Contact

diff --git a/customize.dist/src/fragments/fork.html b/customize.dist/src/fragments/fork.html index b4f459923..3c6773783 100644 --- a/customize.dist/src/fragments/fork.html +++ b/customize.dist/src/fragments/fork.html @@ -1,3 +1,3 @@ - + diff --git a/customize.dist/src/fragments/index.html b/customize.dist/src/fragments/index.html index de381bfa3..e9190eae6 100644 --- a/customize.dist/src/fragments/index.html +++ b/customize.dist/src/fragments/index.html @@ -18,15 +18,15 @@

Join Us!


-
+

-
+
-
+

-
- +
+
diff --git a/customize.dist/src/fragments/topbar.html b/customize.dist/src/fragments/topbar.html index 1516073e0..a3544c051 100644 --- a/customize.dist/src/fragments/topbar.html +++ b/customize.dist/src/fragments/topbar.html @@ -8,15 +8,15 @@ - About + About - Privacy + Privacy - ToS + ToS - Contact + Contact diff --git a/customize.dist/src/less/cryptpad.less b/customize.dist/src/less/cryptpad.less index 44b248438..dbed153d3 100644 --- a/customize.dist/src/less/cryptpad.less +++ b/customize.dist/src/less/cryptpad.less @@ -22,6 +22,7 @@ html.cp, .cp body { top: 80px; right: 0px; display: inline-block; + z-index: 2; } } diff --git a/customize.dist/src/less/variables.less b/customize.dist/src/less/variables.less index 1d2230326..c79834a62 100644 --- a/customize.dist/src/less/variables.less +++ b/customize.dist/src/less/variables.less @@ -1,7 +1,7 @@ -@base: #ddd; +@base: #302B28; @light-base: lighten(@base, 20%); @less-light-base: lighten(@base, 10%); -@fore: #111; +@fore: #fafafa; @cp-green: #46E981; @cp-accent: lighten(@cp-green, 20%); diff --git a/customize.dist/terms.html b/customize.dist/terms.html index 6722e3586..abb25586c 100644 --- a/customize.dist/terms.html +++ b/customize.dist/terms.html @@ -25,21 +25,21 @@ - About + About - Privacy + Privacy - ToS + ToS - Contact + Contact - + diff --git a/customize.dist/translations/messages.fr.js b/customize.dist/translations/messages.fr.js index 19e752e05..e3e73dd3b 100644 --- a/customize.dist/translations/messages.fr.js +++ b/customize.dist/translations/messages.fr.js @@ -255,6 +255,14 @@ define(function () { out.button_newpoll = 'NOUVEAU SONDAGE'; out.button_newslide = 'NOUVELLE PRÉSENTATION'; + out.form_username = "Nom d'utilisateur"; + out.form_password = "Mot de passe"; + + out.about = "À propos"; + out.privacy = "Vie privée"; + out.contact = "Contact"; + out.terms = "Conditions"; + // privacy.html out.policy_title = 'Politique de confidentialité de Cryptpad'; diff --git a/customize.dist/translations/messages.js b/customize.dist/translations/messages.js index 0bf478e03..7a22e6107 100644 --- a/customize.dist/translations/messages.js +++ b/customize.dist/translations/messages.js @@ -238,6 +238,7 @@ define(function () { // login out.login_login = "log in"; + out.login_nologin = "use cryptpad without account"; out.login_register = "register"; out.logoutButton = "log out"; @@ -301,6 +302,11 @@ define(function () { out.form_username = "Username"; out.form_password = "Password"; + out.about = "About"; + out.privacy = "Privacy"; + out.contact = "Contact"; + out.terms = "ToS"; + // privacy.html out.policy_title = 'Cryptpad Privacy Policy'; diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index 9ae31a238..c0fe4498f 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -101,6 +101,11 @@ define([ return hash; }; + var isLoggedIn = common.isLoggedIn = function () { + //return typeof getStore().getLoginName() === "string"; + return typeof getUserHash() === "string"; + }; + // var isArray = function (o) { return Object.prototype.toString.call(o) === '[object Array]'; }; var isArray = common.isArray = $.isArray; diff --git a/www/user/main.js b/www/user/main.js index fc159e314..2da1aaebc 100644 --- a/www/user/main.js +++ b/www/user/main.js @@ -287,7 +287,6 @@ define([ }; var rt = APP.rt = Listmap.create(config); - rt.proxy.on('create', function (info) { APP.realtime = info.realtime; }) @@ -350,5 +349,21 @@ define([ }, 75); }); }); + + if (sessionStorage.login) { + $username.val(sessionStorage.login_user); + $password.val(sessionStorage.login_pass); + $remember.attr('checked', sessionStorage.login_rmb === "true"); + $login.click(); + } + if (sessionStorage.register) { + $username.val(sessionStorage.login_user); + $password.val(sessionStorage.login_pass); + $remember.attr('checked', sessionStorage.login_rmb === "true"); + } + ['login', 'register', 'login_user', 'login_pass', 'login_rmb'].forEach(function (k) { + delete sessionStorage[k]; + }); + }); });