From 7f9b21405b59b6cfcb268da975f21c011f86efe1 Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 31 Oct 2017 10:27:41 +0100 Subject: [PATCH] Add missing files for profile --- .../src/less2/include/sidebar-layout.less | 97 ++++ www/oldprofile/index.html | 20 + www/oldprofile/main.js | 532 ++++++++++++++++++ www/oldprofile/main.less | 143 +++++ www/profile/app-profile.less | 160 ++++++ www/profile/inner.html | 18 + www/profile/inner.js | 476 ++++++++++++++++ 7 files changed, 1446 insertions(+) create mode 100644 customize.dist/src/less2/include/sidebar-layout.less create mode 100644 www/oldprofile/index.html create mode 100644 www/oldprofile/main.js create mode 100644 www/oldprofile/main.less create mode 100644 www/profile/app-profile.less create mode 100644 www/profile/inner.html create mode 100644 www/profile/inner.js diff --git a/customize.dist/src/less2/include/sidebar-layout.less b/customize.dist/src/less2/include/sidebar-layout.less new file mode 100644 index 000000000..86f0b3a75 --- /dev/null +++ b/customize.dist/src/less2/include/sidebar-layout.less @@ -0,0 +1,97 @@ +@import (once) "/customize/src/less2/include/colortheme.less"; +@import (once) "/customize/src/less2/include/leftside-menu.less"; + +@leftside-bg: @colortheme_sidebar-left-bg; +@leftside-color: @colortheme_sidebar-left-fg; +@rightside-color: @colortheme_sidebar-right-fg; +@description-color: @colortheme_sidebar-description; + +@button-width: 400px; + + +.sidebar-layout_main() { + input[type="text"] { + padding-left: 10px; + } + #container { + font-size: 16px; + display: flex; + flex: 1; + min-height: 0; + #leftSide { + color: @leftside-color; + width: 250px; + background: @leftside-bg; + display: flex; + flex-flow: column; + .categories { + flex: 1; + .category { + .leftside-menu-category_main(); + } + } + } + #rightSide { + flex: 1; + padding: 5px 20px; + color: @rightside-color; + overflow: auto; + .element { + label:not(.noTitle), .label { + display: block; + font-weight: bold; + margin-bottom: 0; + } + .description { + display: block; + color: @description-color; + margin-bottom: 5px; + } + margin-bottom: 20px; + } + [type="text"], button { + vertical-align: middle; + height: 40px; + box-sizing: border-box; + } + .inputBlock { + display: inline-flex; + width: @button-width; + input { + flex: 1; + border-radius: 0.25em 0 0 0.25em; + border: 1px solid #adadad; + border-right: 0px; + } + button { + border-radius: 0 0.25em 0.25em 0; + //border: 1px solid #adadad; + border-left: 0px; + } + } + &>div { + margin: 10px 0; + } + button.btn { + @button-bg: #3066e5; + @button-red-bg: #e54e4e; + background-color: @button-bg; + border-color: darken(@button-bg, 10%); + color: white; + &:hover { + background-color: darken(@button-bg, 10%); + } + &.btn-danger { + background-color: @button-red-bg; + border-color: darken(@button-red-bg, 10%); + color: white; + &:hover { + background-color: darken(@button-red-bg, 10%); + } + } + } + } + } +} + + diff --git a/www/oldprofile/index.html b/www/oldprofile/index.html new file mode 100644 index 000000000..5200564ce --- /dev/null +++ b/www/oldprofile/index.html @@ -0,0 +1,20 @@ + + + + + CryptPad: Zero Knowledge, Collaborative Real Time Editing + + + + + + + + + + + + diff --git a/www/oldprofile/main.js b/www/oldprofile/main.js new file mode 100644 index 000000000..ef2ac9a81 --- /dev/null +++ b/www/oldprofile/main.js @@ -0,0 +1,532 @@ +require.config({ + paths: { + cm: '/bower_components/codemirror' + } +}); +define([ + 'jquery', + '/common/cryptpad-common.js', + '/bower_components/chainpad-listmap/chainpad-listmap.js', + '/bower_components/chainpad-crypto/crypto.js', + '/bower_components/marked/marked.min.js', + '/common/toolbar2.js', + 'cm/lib/codemirror', + 'cm/mode/markdown/markdown', + 'less!/profile/main.less', + 'less!/customize/src/less/toolbar.less', + 'less!/customize/src/less/cryptpad.less', + 'css!/bower_components/bootstrap/dist/css/bootstrap.min.css', +], function ($, Cryptpad, Listmap, Crypto, Marked, Toolbar, CodeMirror) { + + var APP = window.APP = { + Cryptpad: Cryptpad, + _onRefresh: [] + }; + + $(window.document).on('decryption', function (e) { + var decrypted = e.originalEvent; + if (decrypted.callback) { decrypted.callback(); } + }) + .on('decryptionError', function (e) { + var error = e.originalEvent; + Cryptpad.alert(error.message); + }); + + // Marked + var renderer = new Marked.Renderer(); + Marked.setOptions({ + renderer: renderer, + sanitize: true + }); + // Tasks list + var checkedTaskItemPtn = /^\s*\[x\]\s*/; + var uncheckedTaskItemPtn = /^\s*\[ \]\s*/; + renderer.listitem = function (text) { + var isCheckedTaskItem = checkedTaskItemPtn.test(text); + var isUncheckedTaskItem = uncheckedTaskItemPtn.test(text); + if (isCheckedTaskItem) { + text = text.replace(checkedTaskItemPtn, + ' ') + '\n'; + } + if (isUncheckedTaskItem) { + text = text.replace(uncheckedTaskItemPtn, + ' ') + '\n'; + } + var cls = (isCheckedTaskItem || isUncheckedTaskItem) ? ' class="todo-list-item"' : ''; + return '' + text + '\n'; + }; + /*renderer.image = function (href, title, text) { + if (href.slice(0,6) === '/file/') { + var parsed = Cryptpad.parsePadUrl(href); + var hexFileName = Cryptpad.base64ToHex(parsed.hashData.channel); + var src = '/blob/' + hexFileName.slice(0,2) + '/' + hexFileName; + var mt = ''; + mt += ''; + return mt; + } + var out = '' + text + '' : '>'; + return out; + };*/ + + var Messages = Cryptpad.Messages; + + var DISPLAYNAME_ID = "displayName"; + var LINK_ID = "link"; + var AVATAR_ID = "avatar"; + var DESCRIPTION_ID = "description"; + var PUBKEY_ID = "pubKey"; + var CREATE_ID = "createProfile"; + var HEADER_ID = "header"; + var HEADER_RIGHT_ID = "rightside"; + var CREATE_INVITE_BUTTON = 'inviteButton'; /* jshint ignore: line */ + var VIEW_PROFILE_BUTTON = 'viewProfileButton'; + + var createEditableInput = function ($block, name, ph, getValue, setValue, realtime, fallbackValue) { + fallbackValue = fallbackValue || ''; // don't ever display 'null' or 'undefined' + var lastVal; + getValue(function (value) { + lastVal = value; + var $input = $('', { + 'id': name+'Input', + placeholder: ph + }).val(value); + var $icon = $('', {'class': 'fa fa-pencil edit'}); + var editing = false; + var todo = function () { + if (editing) { return; } + editing = true; + + var newVal = $input.val().trim(); + + if (newVal === lastVal) { + editing = false; + return; + } + + setValue(newVal, function (err) { + if (err) { return void console.error(err); } + Cryptpad.whenRealtimeSyncs(realtime, function () { + lastVal = newVal; + Cryptpad.log(Messages._getKey('profile_fieldSaved', [newVal || fallbackValue])); + editing = false; + }); + }); + }; + $input.on('keyup', function (e) { + if (e.which === 13) { return void todo(); } + if (e.which === 27) { + $input.val(lastVal); + } + }); + $icon.click(function () { $input.focus(); }); + $input.focus(function () { + $input.width(''); + }); + $input.focusout(todo); + $block.append($input).append($icon); + }); + }; + +/* jshint ignore:start */ + var isFriend = function (proxy, edKey) { + var friends = Cryptpad.find(proxy, ['friends']); + return typeof(edKey) === 'string' && friends && (edKey in friends); + }; + + var addCreateInviteLinkButton = function ($container) { + return; + var obj = APP.lm.proxy; + + var proxy = Cryptpad.getProxy(); + var userViewHash = Cryptpad.find(proxy, ['profile', 'view']); + + var edKey = obj.edKey; + var curveKey = obj.curveKey; + + if (!APP.readOnly || !curveKey || !edKey || userViewHash === window.location.hash.slice(1) || isFriend(proxy, edKey)) { + //console.log("edit mode or missing curve key, or you're viewing your own profile"); + return; + } + + // sanitize user inputs + + var unsafeName = obj.name || ''; + console.log(unsafeName); + var name = Cryptpad.fixHTML(unsafeName) || Messages.anonymous; + console.log(name); + + console.log("Creating invite button"); + $("