Use secure drive as default drive

This commit is contained in:
yflory
2017-09-27 10:31:35 +02:00
parent b4de31c827
commit e02a779c14
14 changed files with 3809 additions and 3809 deletions

View File

@@ -1,99 +1,125 @@
@import "/customize/src/less/variables.less";
@import "/customize/src/less/mixins.less";
@import (once) "/customize/src/less2/include/tools.less";
@import (once) "../../customize/src/less2/include/browser.less";
@import (once) "../../customize/src/less2/include/toolbar.less";
@import (once) "../../customize/src/less2/include/markdown.less";
@import (once) '../../customize/src/less2/include/fileupload.less';
@import (once) '../../customize/src/less2/include/alertify.less';
@import (once) '../../customize/src/less2/include/leftside-menu.less';
@import (once) "../../customize/src/less2/include/tools.less";
@import (once) "../../customize/src/less2/include/limit-bar.less";
@tree-bg: #eee;
@tree-fg: #000;
@tree-lines-col: #888;
.toolbar_main();
.fileupload_main();
.alertify_main();
.limit-bar_main();
@drive-hover: #eee;
@drive-hover-light: lighten(@drive-hover, 20%);
@drive_hover: #eee;
@drive_hover-light: lighten(@drive_hover, 20%);
@drive_info-box-bg: #d2e1f2;
@drive_info-box-border: #bbb;
@drive_table-header-fg: #555;
@drive_table-header-bg: #e8e8e8;
@drive_mobile-tree-border-col: #ccc;
@content-bg: #fff;
@content-bg-ro: darken(@content-bg, 10%);
@content-fg: @tree-fg;
@info-box-bg: #d2e1f2;
@info-box-border: #bbb;
@table-header-fg: #555;
@table-header-bg: #e8e8e8;
@drive_content-fg: @colortheme_sidebar-right-fg;
@drive_content-bg: @colortheme_sidebar-right-bg;
@drive_content-bg-ro: darken(@drive_content-bg, 10%);
@toolbar-bg: #ddd;
@toolbar-fg: #555;
@toolbar-border-col: #ccc;
@toolbar-button-bg: #888;
@toolbar-button-border: #888;
@toolbar-button-bg-hover: #777;
@toolbar-button-fg: #eee;
@toolbar-path-bg: #fff;
@toolbar-path-border: #888;
@size-mobile: 600px;
/* PAGE */
html, body {
width: 100%;
height: 100%;
box-sizing: border-box;
padding: 0;
margin: 0;
position: relative;
font-size: @main-font-size;
overflow: auto;
display: flex;
flex-flow: column;
max-height: 100%;
min-height: auto;
.cp-unselectable {
.tools_unselectable();
}
body {
display: flex;
flex-flow: column;
}
img.icon {
max-width: 20px;
max-height: 16px;
}
/* local mixins */
.drive_fileIcon {
li {
display: inline-block;
margin: 10px 10px;
width: 140px;
height: 140px;
text-align: center;
vertical-align: top;
overflow: hidden;
text-overflow: ellipsis;
padding-top: 5px;
padding-bottom: 5px;
.unselectable {
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.app-container {
flex: 1;
overflow: auto;
width: 100%;
display: flex;
flex-flow: row;
@media screen and (max-width: @size-mobile) {
display: block;
#driveToolbar {
.path .element {
display: none;
}
&:not(.cp-app-drive-element-selected):not(.cp-app-drive-element-selected-tmp) {
border: 1px solid #CCC;
}
#tree {
resize: none;
.cp-app-drive-element-name {
width: 100%;
max-width: unset;
max-height: unset;
border-bottom: 1px solid @toolbar-border-col;
.category {
margin-top: 0.5em;
height: 48px;
margin: 8px 0;
display: inline-block;
//align-items: center;
//justify-content: center;
overflow: hidden;
//text-overflow: ellipsis;
word-wrap: break-word;
}
.cp-app-drive-element-truncated {
display: block;
position: absolute;
bottom: 0px;
left: 0; right: 0;
text-align: center;
}
img.cp-app-drive-content-icon {
height: 48px;
max-height: none;
max-width: none;
margin: 8px 0;
}
.fa {
display: block;
margin: auto;
font-size: 48px;
margin: 8px 0;
text-align: center;
&.listonly {
display: none;
}
}
}
}
.padColor { color: @toolbar-pad-bg; }
.codeColor { color: @toolbar-code-bg; }
.slideColor { color: @toolbar-slide-bg; }
.pollColor { color: @toolbar-poll-bg; }
.fileColor { color: @toolbar-file-bg; }
.whiteboardColor { color: @toolbar-whiteboard-bg; }
.driveColor { color: @toolbar-drive-bg; }
.defaultColor { color: @toolbar-default-bg; }
img.cp-app-drive-icon {
max-width: 20px;
max-height: 16px;
}
.cp-app-drive-container {
flex: 1;
overflow: auto;
width: 100%;
display: flex;
flex-flow: row;
@media screen and (max-width: @browser_media-medium-screen) {
display: block;
#cp-app-drive-toolbar {
.path .element {
display: none;
}
}
#cp-app-drive-tree {
resize: none;
width: 100%;
max-width: unset;
max-height: unset;
border-bottom: 1px solid @drive_mobile-tree-border-col;
.cp-app-drive-tree-category {
margin-top: 0.5em;
}
}
}
}
div:focus {
outline: none;
@@ -116,40 +142,40 @@ li {
user-select: none;
}
.contextMenu {
.cp-app-drive-context {
display: none;
position: absolute;
z-index: 500;
li {
padding: 0;
font-size: @main-font-size;
font-size: @colortheme_app-font-size;
a {
cursor: pointer;
}
}
}
.droppable {
.cp-app-drive-element-droppable {
background-color: #FE9A2E;
color: #222;
}
.selected {
.cp-app-drive-element-selected {
background: #666 !important;
color: #eee;
margin: -1px;
.fa-minus-square-o, .fa-plus-square-o {
color: @tree-fg;
color: @colortheme_sidebar-left-fg;
}
}
.selectedTmp {
.cp-app-drive-element-selected-tmp {
border: 1px dotted #bbb;
background: #AAA;
color: #ddd;
margin: -1px;
.fa-minus-square-o, .fa-plus-square-o {
color: @tree-fg;
color: @colortheme_sidebar-left-fg;
}
}
@@ -163,11 +189,11 @@ span {
/* TREE */
#tree {
font-size: @main-font-size;
#cp-app-drive-tree {
font-size: @colortheme_app-font-size;
//border-right: 1px solid #ccc;
box-sizing: border-box;
background: @tree-bg;
background: @colortheme_sidebar-left-bg;
overflow: auto;
resize: horizontal;
width: auto;
@@ -175,40 +201,40 @@ span {
max-width: 500px;
min-width: 200px;
padding: 0px;
color: @tree-fg;
color: @colortheme_sidebar-left-fg;
display: flex;
flex-flow: column;
max-height: 100%;
.categories-container {
.cp-app-drive-tree-categories-container {
flex: 1;
max-width: 500px;
overflow: auto;
}
img.icon {
img.cp-app-drive-icon {
margin-bottom: 3px;
margin-left: -2px;
}
.docTree {
.cp-app-drive-tree-docs {
margin-top: 20px;
//padding: 0 0 0 20px;
padding: 0;
cursor: auto;
&li, li {
padding: 0;
&.collapsed ul {
&.cp-app-drive-element-collapsed ul {
display: none;
}
input {
width: ~"calc(100% - 30px)";
padding: 0 10px;
border: 0;
color: lighten(@tree-fg, 40%);
color: lighten(@colortheme_sidebar-left-fg, 40%);
}
& > span.element-row {
& > span.cp-app-drive-element-row {
overflow: hidden;
text-overflow: ellipsis;
//min-width: ~"calc(100% + 5px)";
.leftsideCategory();
.leftside-menu-category_main();
width: ~"calc(100% + 5px)";
margin: 0;
margin-bottom: -6px;
@@ -217,23 +243,17 @@ span {
margin-left: -5px;
padding-left: 5px;
}
& > span.element-row:not(.selected):not(.active):hover {
//background-color: @drive-hover;
& > span.cp-app-drive-element-row:not(.cp-app-drive-element-selected):not(.cp-app-drive-element-active):hover {
}
}
}
span.element {
span.cp-app-drive-element {
cursor: pointer;
}
/*.active {
&:not(.selected):not(.droppable) {
background-color: darken(@drive-hover, 15%);
}
}*/
.category {
.cp-app-drive-tree-category {
margin: 0;
margin-top: 15px;
.root {
.cp-app-drive-tree-root {
&> .fa {
min-width: 30px;
cursor: pointer;
@@ -241,10 +261,10 @@ span {
}
li {
padding: 0;
.element-row {
.cp-app-drive-element-row {
display: block;
padding-left: 20px;
.leftsideCategory();
.leftside-menu-category_main();
margin: 0;
.fa {
width: 25px;
@@ -252,45 +272,42 @@ span {
}
}
}
.category:last-child {
.cp-app-drive-tree-category:last-child {
margin-bottom: 20px;
}
#allfilesTree {
margin-top: 0;
}
.limit-container {
margin-top: 0;
}
#searchContainer {
#cp-app-drive-tree-search {
text-align: center;
padding: 0;
position: relative;
input {
background: lighten(@toolbar-drive-bg, 8%);
color: @toolbar-drive-color;
.tools_placeholder-color(@toolbar-drive-color);
background: lighten(@colortheme_drive-bg, 8%);
color: @colortheme_drive-color;
.tools_placeholder-color(@colortheme_drive-color);
outline-width: 0px;
border-radius: 0;
width: 100%;
//border: 1px solid #ccc;
border: 0;
border-right: 1px solid lighten(@toolbar-drive-bg, 16%);
border-right: 1px solid lighten(@colortheme_drive-bg, 16%);
//border-right: 0;
height: @toolbar-line-height;
height: @variables_bar-height;
padding: 0 5px;
padding-left: 45px;
&:focus {
outline-width: 0px;
}
}
.searchIcon {
color: @toolbar-drive-color;
.cp-app-drive-tree-search-con {
color: @colortheme_drive-color;
position: absolute;
left: 20px; // TODO align with drive categories
top: 8px;
}
}
.fa.expcol {
.fa.cp-app-drive-icon-expcol {
margin-left: -10px;
font-size: 14px;
position: absolute;
@@ -308,17 +325,17 @@ span {
top: -1px;
}
}
.docTree {
.root > .element-row > .expcol {
.cp-app-drive-tree-docs {
.cp-app-drive-tree-root > .cp-app-drive-element-row > .cp-app-drive-icon-expcol {
position: relative;
top:0;
left: -10px;
}
.root > .element-row > .folder {
.cp-app-drive-tree-root > .cp-app-drive-element-row > .cp-app-drive-icon-folder {
margin-left: -5px;
}
.root {
&> .element-row {
.cp-app-drive-tree-root {
&> .cp-app-drive-element-row {
padding-left: 20px;
}
&> ul {
@@ -328,7 +345,7 @@ span {
}
// Expand/collapse lines
.docTree ul {
.cp-app-drive-tree-docs ul {
margin: 0px 0px 0px 10px;
list-style: none;
padding-left: 10px;
@@ -340,9 +357,9 @@ span {
top: -11px;
content: '';
display: block;
border-left: 1px solid @tree-lines-col;
border-left: 1px solid @colortheme_sidebar-left-branch;
height: ~"calc(1em + 11px)";
border-bottom: 1px solid @tree-lines-col;
border-bottom: 1px solid @colortheme_sidebar-left-branch;
width: 15px;
}
&:after {
@@ -351,10 +368,10 @@ span {
bottom: -7px;
content: '';
display: block;
border-left: 1px solid @tree-lines-col;
border-left: 1px solid @colortheme_sidebar-left-branch;
height: 100%;
}
&.root {
&.cp-app-drive-tree-root {
margin: 0px 0px 0px -10px;
&:before {
display: none;
@@ -371,7 +388,7 @@ span {
}
/* CONTENT */
#rightCol {
#cp-app-drive-content-container {
display: flex;
flex-flow: column;
flex: 1;
@@ -379,74 +396,66 @@ span {
// https://stackoverflow.com/questions/38223879/white-space-nowrap-breaks-flexbox-layout
min-width: 0;
}
#content {
#cp-app-drive-content {
box-sizing: border-box;
background: @content-bg;
color: @content-fg;
background: @drive_content-bg;
color: @drive_content-fg;
overflow: auto;
flex: 1;
display: flex;
flex-flow: column;
position: relative;
.selectBox {
.cp-app-drive-content-select-box {
display: none;
background-color: rgba(100, 100, 100, 0.7);
position: absolute;
z-index: 50;
}
&.readonly {
background: @content-bg-ro;
&.cp-app-drive-readonly {
background: @drive_content-bg-ro;
}
h1 {
padding-left: 10px;
margin-top: 10px;
}
.info-box {
.cp-app-drive-content-info-box {
line-height: 2em;
padding: 0.25em 0.75em;
margin: 1em;
background: @info-box-bg;
background: @drive_info-box-bg;
span {
cursor: pointer;
float: right;
margin-top: 0.5em;
}
&.noclose {
}
}
li {
cursor: default;
&:not(.header) {
*:not(input) {
/*pointer-events: none;*/
}
&:not(.cp-app-drive-element-header) {
&:hover {
&:not(.selected, .selectedTmp) {
background-color: @drive-hover;
}
.name {
/*text-decoration: underline;*/
&:not(.-cp-app-drive-element-selected, .cp-app-drive-element-selected-tmp) {
background-color: @drive_hover;
}
}
}
}
#folderContent {
#cp-app-drive-content-folder {
li {
&.searchResult {
border-bottom: 1px solid @info-box-border;
&.cp-app-drive-search-result {
border-bottom: 1px solid @drive_info-box-border;
display: block;
&:hover {
background-color: initial;
}
table {
width: 100%;
.label2 {
.cp-app-drive-search-label2 {
width: 150px;
font-size: 15px;
text-align: right;
padding-right: 15px;
}
.openDir {
.cp-app-drive-search-opendir {
a {
cursor: pointer;
color: #41b7d8;
@@ -456,25 +465,25 @@ span {
}
}
}
.path {
.cp-app-drive-search-path {
font-style: italic;
direction: rtl;
.element {
.cp-app-drive-path-element {
display: inline-block;
margin-right: 5px;
}
}
.title {
.cp-app-drive-search-title {
font-weight: bold;
cursor: pointer;
&:hover {
background-color: @drive-hover;
background-color: @drive_hover;
}
}
.col2 {
.cp-app-drive-search-col2 {
width: 250px;
}
td.icon {
td.cp-app-drive-search-icon {
width: 50px;
font-size: 40px;
}
@@ -482,21 +491,21 @@ span {
}
}
}
.element {
.truncated { display: none; }
.cp-app-drive-element {
.cp-app-drive-element-truncated { display: none; }
}
div.grid {
div.cp-app-drive-content-grid {
padding: 20px;
.fileIcon;
.drive_fileIcon;
li {
&.element {
&.cp-app-drive-element {
position: relative;
}
input {
width: 100%;
margin-top: 5px;
}
.state {
.cp-app-drive-element-state {
position: absolute;
top: 3px;
right: 3px;
@@ -506,10 +515,10 @@ span {
}
}
}
.listElement {
.cp-app-drive-element-list {
display: none;
}
.addpad {
.cp-app-drive-new-ghost {
cursor: pointer;
opacity: 0.5;
padding: 0;
@@ -525,8 +534,8 @@ span {
}
}
.list {
.grid-element {
.cp-app-drive-content-list {
.cp-app-drive-element-grid {
display: none;
}
// Make it act as a table!
@@ -542,13 +551,13 @@ span {
padding: 0 5px;
display: table-cell;
}
&:not(.header) {
height: @toolbar-line-height;
line-height: @toolbar-line-height;
&:not(.cp-app-drive-element-header) {
height: @variables_bar-height;
line-height: @variables_bar-height;
}
&.header {
&.cp-app-drive-element-header {
cursor: default;
color: @table-header-fg;
color: @drive_table-header-fg;
span {
&:not(.fa) {
text-align: left;
@@ -559,41 +568,41 @@ span {
}
&> span {
padding: 15px 5px;
&.active {
&.cp-app-drive-sort-active {
font-weight: bold;
}
&.clickable {
&.cp-app-drive-sort-clickable {
cursor: pointer;
&:hover {
background: @table-header-bg;
background: @drive_table-header-bg;
}
}
}
}
}
.element {
.cp-app-drive-element {
span {
overflow: hidden;
white-space: nowrap;
box-sizing: border-box;
&.state {
&.cp-app-drive-element-state {
.fa:not(:last-child) {
margin-right: 5px;
}
}
&.icon, &.state {
&.cp-app-drive-content-icon, &.cp-app-drive-element-state {
width: 30px;
}
&.type, &.atime, &.ctime {
&.cp-app-drive-element-type, &.cp-app-drive-element-atime, &.cp-app-drive-element-ctime {
width: 175px;
}
&.title {
&.cp-app-drive-element-title {
width: 250px;
@media screen and (max-width: 1200px) {
display: none;
}
}
&.folders, &.files {
&.cp-app-drive-element-folders, &.cp-app-drive-element-files {
width: 150px;
}
}
@@ -601,23 +610,15 @@ span {
}
}
.parentFolder {
cursor: pointer;
margin-left: 10px;
&:hover {
text-decoration: underline;
}
}
#folderContent {
#cp-app-drive-content-folder {
padding-right: 10px;
flex: 1;
}
#addPadDialog.cp-modal-container {
.fileIcon;
#cp-app-drive-new-ghost-dialog.cp-modal-container {
.drive_fileIcon;
li:not(.selected):hover {
li:not(.cp-app-drive-element-selected):hover {
border: 1px solid white;
}
.cp-modal {
@@ -635,7 +636,7 @@ span {
justify-content: center;
align-content: center;
overflow-y: auto;
.uploadFile {
.cp-app-drive-new-upload {
break-after: always;
page-break-after: always;
}
@@ -657,7 +658,7 @@ span {
.fa {
font-size: 32px;
}
.name {
.cp-app-drive-new-name {
height: auto;
}
}
@@ -669,15 +670,15 @@ span {
/* Toolbar */
#driveToolbar {
background: lighten(@toolbar-drive-bg, 8%);
color: @toolbar-drive-color;
#cp-app-drive-toolbar {
background: lighten(@colortheme_drive-bg, 8%);
color: @colortheme_drive-color;
//height: 30px;
//display: flex;
//flex-flow: row;
z-index: 100;
box-sizing: border-box;
height: @toolbar-line-height;
height: @variables_bar-height;
padding: 0;
display: flex;
flex-flow: row;
@@ -689,16 +690,14 @@ span {
}
}
.newPadContainer {
display: inline-block;
height: 100%;
}
.history {
float: right;
.cp-toolbar-drawer-element {
display: none;
}
}
.rightside, .leftside {
.cp-app-drive-toolbar-rightside, .cp-app-drive-toolbar-leftside {
display: inline-block;
margin: 0;
padding: 0;
@@ -706,41 +705,41 @@ span {
margin: 0;
}
button {
height: @toolbar-line-height;
height: @variables_bar-height;
padding: 0 10px;
border: none;
border-radius: 0;
box-sizing: border-box;
background: transparent;
font-size: @main-font-size;
color: @toolbar-drive-color;
font-size: @colortheme_app-font-size;
color: @colortheme_drive-color;
transition: all 0.15s;
.drawer {
display: none;
}
.fa, span {
font-size: @main-font-size;
font-size: @colortheme_app-font-size;
}
&:hover {
background: @toolbar-drive-bg;
background: @colortheme_drive-bg;
}
&.active {
&.cp-app-drive-toolbar-active {
display: none;
}
}
}
.rightside {
.cp-app-drive-toolbar-rightside {
float: right;
& > * {
float: right;
}
#contextButtonsContainer {
#cp-app-drive-toolbar-contextbuttons {
display: inline-block;
height: 100%;
}
padding-left: 10px;
}
.leftside {
.cp-app-drive-toolbar-leftside {
& > span {
height: 100%;
margin: 0;
@@ -752,7 +751,7 @@ span {
}
.cp-dropdown-button-title {
display: inline-flex;
height: @toolbar-line-height;
height: @variables_bar-height;
align-items: center;
span:not(.fa) {
line-height: 23px;
@@ -762,9 +761,9 @@ span {
}
button {
font: @toolbar-button-font;
font: @colortheme_app-font;
span {
font: @toolbar-button-font;
font: @colortheme_app-font;
}
.fa, &.fa {
font-family: FontAwesome;
@@ -781,11 +780,11 @@ span {
margin-right: 2px;
}
.path {
.cp-app-drive-path {
flex: 1;
width: 100%;
height: @toolbar-line-height;
line-height: @toolbar-line-height;
height: @variables_bar-height;
line-height: @variables_bar-height;
cursor: default;
width: auto;
overflow: hidden;
@@ -793,24 +792,24 @@ span {
direction: rtl;
max-width: 100%;
text-align: left;
.element {
.cp-app-drive-path-element {
display: inline-block;
height: @toolbar-line-height;
line-height: @toolbar-line-height;
font-size: @main-font-size;
height: @variables_bar-height;
line-height: @variables_bar-height;
font-size: @colortheme_app-font-size;
padding: 0 5px;
border: 0;
background: darken(@toolbar-drive-bg, 10%);
color: @toolbar-drive-color;
background: darken(@colortheme_drive-bg, 10%);
color: @colortheme_drive-color;
box-sizing: border-box;
transition: all 0.15s;
&.separator {
&.cp-app-drive-path-separator {
color: #ccc;
}
&.clickable {
&.cp-app-drive-path-lickable {
cursor: pointer;
&:hover {
background: darken(@toolbar-drive-bg, 15%);
background: darken(@colortheme_drive-bg, 15%);
}
}
}

View File

@@ -1,18 +1,19 @@
<!DOCTYPE html>
<html class="cp">
<html>
<head>
<title>CryptDrive</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CryptPad</title>
<meta content="text/html; charset=utf-8" http-equiv="content-type"/>
<script async data-bootload="/customize/template.js" data-main="/common/boot.js?ver=1.0" src="/bower_components/requirejs/require.js?ver=2.3.5"></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="referrer" content="no-referrer" />
<script async data-bootload="main.js" data-main="/common/boot.js?ver=1.0" src="/bower_components/requirejs/require.js?ver=2.3.5"></script>
<style>
html, body {
margin: 0px;
padding: 0px;
}
#pad-iframe {
#sbox-iframe {
position:fixed;
top:0;
top:0px;
left:0px;
bottom:0px;
right:0px;
@@ -23,7 +24,15 @@
padding:0;
overflow:hidden;
}
#sbox-filePicker-iframe {
position: fixed;
top:0; left:0;
bottom:0; right:0;
width:100%;
height: 100%;
border: 0;
}
</style>
</head>
<body>
<iframe id="pad-iframe"></iframe><script src="/common/noscriptfix.js"></script>
<iframe id="sbox-iframe">

View File

@@ -1,57 +1,60 @@
<!DOCTYPE html>
<html>
<html class="cp-app-noscroll">
<head>
<meta content="text/html; charset=utf-8" http-equiv="content-type"/>
<script src="/bower_components/jquery/dist/jquery.min.js"></script>
<script async data-bootload="/drive/inner.js" data-main="/common/boot.js?ver=1.0" src="/bower_components/requirejs/require.js?ver=2.3.5"></script>
<script async data-bootload="/drive/inner.js" data-main="/common/sframe-boot.js?ver=1.6" src="/bower_components/requirejs/require.js?ver=2.3.5"></script>
<style>
.loading-hidden { display: none; }
#editor1 { display: none; }
</style>
</head>
<body style="display: none;">
<div id="toolbar" class="toolbar-container"></div>
<div class="app-container" tabindex="0">
<div id="tree">
<body class="cp-app-drive">
<div id="cp-toolbar" class="cp-toolbar-container"></div>
<div class="cp-app-drive-container" tabindex="0">
<div id="cp-app-drive-tree">
</div>
<div id="rightCol">
<div id="driveToolbar"></div>
<div id="content" tabindex="2"></div>
<div id="cp-app-drive-content-container">
<div id="cp-app-drive-toolbar"></div>
<div id="cp-app-drive-content" tabindex="2"></div>
</div>
<div id="treeContextMenu" class="contextMenu dropdown clearfix unselectable">
<div id="cp-app-drive-context-tree" class="cp-app-drive-context dropdown cp-unselectable">
<ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu" style="display:block;position:static;margin-bottom:5px;">
<li><a tabindex="-1" data-icon="fa-folder-open" class="open dropdown-item" data-localization="fc_open">Open</a></li>
<li><a tabindex="-1" data-icon="fa-eye" class="open_ro dropdown-item" data-localization="fc_open_ro">Open (read-only)</a></li>
<li><a tabindex="-1" data-icon="fa-pencil" class="rename editable dropdown-item" data-localization="fc_rename">Rename</a></li>
<li><a tabindex="-1" data-icon="fa-trash" class="delete editable dropdown-item" data-localization="fc_delete">Delete</a></li>
<li><a tabindex="-1" data-icon="fa-folder" class="newfolder editable dropdown-item" data-localization="fc_newfolder">New folder</a></li>
<li><a tabindex="-1" data-icon="fa-database" class="properties dropdown-item" data-localization="fc_prop">Properties</a></li>
<li><a tabindex="-1" data-icon="fa-folder-open" class="cp-app-drive-context-open dropdown-item" data-localization="fc_open">Open</a></li>
<li><a tabindex="-1" data-icon="fa-eye" class="cp-app-drive-context-openro dropdown-item" data-localization="fc_open_ro">Open (read-only)</a></li>
<li><a tabindex="-1" data-icon="fa-pencil" class="cp-app-drive-context-rename cp-app-drive-context-editable dropdown-item" data-localization="fc_rename">Rename</a></li>
<li><a tabindex="-1" data-icon="fa-trash" class="cp-app-drive-context-delete cp-app-drive-context-editable dropdown-item" data-localization="fc_delete">Delete</a></li>
<li><a tabindex="-1" data-icon="fa-folder" class="cp-app-drive-context-newfolder cp-app-drive-context-editable dropdown-item" data-localization="fc_newfolder">New folder</a></li>
<li><a tabindex="-1" data-icon="fa-database" class="cp-app-drive-context-properties dropdown-item" data-localization="fc_prop">Properties</a></li>
</ul>
</div>
<div id="contentContextMenu" class="contextMenu dropdown clearfix unselectable">
<div id="cp-app-drive-context-content" class="cp-app-drive-context dropdown cp-unselectable">
<ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu" style="display:block;position:static;margin-bottom:5px;">
<li><a tabindex="-1" data-icon="fa-folder" class="newfolder editable dropdown-item" data-localization="fc_newfolder">New folder</a></li>
<li><a tabindex="-1" data-icon="fa-file-word-o" class="newdoc own editable dropdown-item" data-type="pad" data-localization="button_newpad">New pad</a></li>
<li><a tabindex="-1" data-icon="fa-file-code-o" class="newdoc own editable dropdown-item" data-type="code" data-localization="button_newcode">New code</a></li>
<li><a tabindex="-1" data-icon="fa-file-powerpoint-o" class="newdoc own editable dropdown-item" data-type="slide" data-localization="button_newslide">New slide</a></li>
<li><a tabindex="-1" data-icon="fa-calendar" class="newdoc own editable dropdown-item" data-type="poll" data-localization="button_newpoll">New poll</a></li>
<li><a tabindex="-1" data-icon="fa-paint-brush" class="newdoc own editable dropdown-item" data-type="whiteboard" data-localization="button_newwhiteboard">New whiteboard</a></li>
<li><a tabindex="-1" data-icon="fa-folder" class="cp-app-drive-context-newfolder cp-app-drive-context-editable dropdown-item" data-localization="fc_newfolder">New folder</a></li>
<li><a tabindex="-1" data-icon="fa-file-word-o" class="cp-app-drive-context-newdoc cp-app-drive-context-own cp-app-drive-context-editable dropdown-item" data-type="pad" data-localization="button_newpad">New pad</a></li>
<li><a tabindex="-1" data-icon="fa-file-code-o" class="cp-app-drive-context-newdoc cp-app-drive-context-own cp-app-drive-context-editable dropdown-item" data-type="code" data-localization="button_newcode">New code</a></li>
<li><a tabindex="-1" data-icon="fa-file-powerpoint-o" class="cp-app-drive-context-newdoc cp-app-drive-context-own cp-app-drive-context-editable dropdown-item" data-type="slide" data-localization="button_newslide">New slide</a></li>
<li><a tabindex="-1" data-icon="fa-calendar" class="cp-app-drive-context-newdoc cp-app-drive-context-own cp-app-drive-context-editable dropdown-item" data-type="poll" data-localization="button_newpoll">New poll</a></li>
<li><a tabindex="-1" data-icon="fa-paint-brush" class="cp-app-drive-context-newdoc cp-app-drive-context-own cp-app-drive-context-editable dropdown-item" data-type="whiteboard" data-localization="button_newwhiteboard">New whiteboard</a></li>
</ul>
</div>
<div id="defaultContextMenu" class="contextMenu dropdown clearfix unselectable">
<div id="cp-app-drive-context-default" class="cp-app-drive-context dropdown cp-unselectable">
<ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu" style="display:block;position:static;margin-bottom:5px;">
<li><a tabindex="-1" data-icon="fa-folder-open" class="open dropdown-item" data-localization="fc_open">Open</a></li>
<li><a tabindex="-1" data-icon="fa-eye" class="open_ro dropdown-item" data-localization="fc_open_ro">Open (read-only)</a></li>
<li><a tabindex="-1" data-icon="fa-trash" class="delete dropdown-item" data-localization="fc_delete">Delete</a></li>
<li><a tabindex="-1" data-icon="fa-database" class="properties dropdown-item" data-localization="fc_prop">Properties</a></li>
<li><a tabindex="-1" data-icon="fa-folder-open" class="cp-app-drive-context-open dropdown-item" data-localization="fc_open">Open</a></li>
<li><a tabindex="-1" data-icon="fa-eye" class="cp-app-drive-context-openro dropdown-item" data-localization="fc_open_ro">Open (read-only)</a></li>
<li><a tabindex="-1" data-icon="fa-trash" class="cp-app-drive-context-delete dropdown-item" data-localization="fc_delete">Delete</a></li>
<li><a tabindex="-1" data-icon="fa-database" class="cp-app-drive-context-properties dropdown-item" data-localization="fc_prop">Properties</a></li>
</ul>
</div>
<div id="trashTreeContextMenu" class="contextMenu dropdown clearfix unselectable">
<div id="cp-app-drive-context-trashtree" class="cp-app-drive-context dropdown cp-unselectable">
<ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu" style="display:block;position:static;margin-bottom:5px;">
<li><a tabindex="-1" data-icon="fa-trash-o" class="empty editable dropdown-item" data-localization="fc_empty">Empty the trash</a></li>
<li><a tabindex="-1" data-icon="fa-trash-o" class="cp-app-drive-context-empty cp-app-drive-context-editable dropdown-item" data-localization="fc_empty">Empty the trash</a></li>
</ul>
</div>
<div id="trashContextMenu" class="contextMenu dropdown clearfix unselectable">
<div id="cp-app-drive-context-trash" class="cp-app-drive-context dropdown cp-unselectable">
<ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu" style="display:block;position:static;margin-bottom:5px;">
<li><a tabindex="-1" data-icon="fa-eraser" class="remove editable dropdown-item" data-localization="fc_remove">Delete permanently</a></li>
<li><a tabindex="-1" data-icon="fa-repeat" class="restore editable dropdown-item" data-localization="fc_restore">Restore</a></li>
<li><a tabindex="-1" data-icon="fa-database" class="properties dropdown-item" data-localization="fc_prop">Properties</a></li>
<li><a tabindex="-1" data-icon="fa-eraser" class="cp-app-drive-context-remove cp-app-drive-context-editable dropdown-item" data-localization="fc_remove">Delete permanently</a></li>
<li><a tabindex="-1" data-icon="fa-repeat" class="cp-app-drive-context-restore cp-app-drive-context-editable dropdown-item" data-localization="fc_restore">Restore</a></li>
<li><a tabindex="-1" data-icon="fa-database" class="cp-app-drive-context-properties dropdown-item" data-localization="fc_prop">Properties</a></li>
</ul>
</div>
</div>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,396 +0,0 @@
define([
'/common/cryptpad-common.js',
'/common/userObject.js',
],function (Cryptpad, FO) {
var module = {};
var href1 = "/pad/#/1/edit/a798u+miu2tg5b-QaP9SvA/UIPoGUPewZscBUFhNIi+eBBM/";
var href2 = "/poll/#/1/edit/uFJTXjQUEwV2bl-y3cKVpP/LJ-4qPnpR5iY0HVdwLcnjLsx/";
var href3 = "/code/#/1/view/eRS+YPTTASNqjRbgrznAdQ/2OyNsvfYw7ZwLg6wkJuCaGBzOZvxNLra9n7GN848Zic/";
var href4 = "/slide/#/1/edit/R2bZC1mY9khSsrLCyJT+CA/mlQrCxbTiqQJ4HyUxbFBnmG8/";
var href5 = "/whiteboard/#/1/edit/k8bZC1mY9khSsrLCyJT+CA/moQrCxbTiqQJ4HyUxbFBnmG8/";
var id1 = 1000000000001;
var id2 = 1000000000002;
var id3 = 1000000000003;
var id4 = 1000000000004;
var example = {
"root": {
"Folder": {
"Sub": {}
},
"Folder2": {
"rdmStrFile1": id1
}
},
"template": [id2],
"trash": {
"DeletedF": [{
"path": ["root"],
"element": {}
},{
"path": ["root"],
"element": {
"rdmStrFile3": id3
}
}],
"Title4": [{
"path": ["root", "Folder"],
"element": id4
}]
},
"filesData": {
"1000000000004": {
"atime": 23456783489,
"ctime": 12345678999,
"href": href4,
"title": "Title4"
},
"1000000000003": {
"atime": 23456783456,
"ctime": 12345678901,
"href": href3,
"title": "Title3"
},
"1000000000002": {
"atime": 23456789012,
"ctime": 12345789235,
"href": href2,
"title": "Title2"
},
"1000000000001": {
"atime": 23456789012,
"ctime": 12345789235,
"href": href1,
"title": "Title1",
"filename": "FileName1"
}
}
};
module.test = function (assert) {
var config = {Cryptpad: Cryptpad, workgroup: false, testMode: true};
// MIGRATION FROM HREF TO ID
assert(function (cb) {
console.log('START DRIVE1');
var files = {
"root": {
"Folder": {},
"Folder2": {
"FileName": href1
}
},
"template": [href3],
"trash": {
"DeletedF": [{
"path": ["root"],
"element": {}
}, {
"path": ["root", "Folder"],
"element": href2
}]
},
"CryptPad_RECENTPADS": [{
"atime": 23456783456,
"ctime": 12345678901,
"href": href3,
"title": "pewcode"
}, {
"atime": 23456789012,
"ctime": 12345789235,
"href": href2,
"title": "pewpoll"
}, {
"atime": 23456789012,
"ctime": 12345789235,
"href": href1,
"title": "pewpad"
}]
};
var fo = FO.init(files, config);
var todo = function () {
fo.fixFiles();
if (files['CryptPad_RECENTPADS'] || !files.filesData) {
console.log("DRIVE1: migration from RECENTPADS to filesData failed");
return cb();
}
var fileKey = Object.keys(files.root.Folder2)[0];
if (!fileKey) { return cb(); }
var fileId = files.root.Folder2[fileKey];
var res = typeof fileId === "number"
&& typeof files.filesData[fileId] === "object"
&& files.filesData[fileId].filename === "FileName"
&& typeof files.trash.DeletedF[1].element === "number"
&& typeof files.filesData[files.trash.DeletedF[1].element] === "object"
&& files.filesData[files.trash.DeletedF[1].element].filename === "DeletedF"
&& typeof files.template[0] === "number"
&& typeof files.filesData[files.template[0]] === "object"
&& !files.filesData[files.template[0]].filename;
return cb(res);
};
fo.migrate(todo);
}, "DRIVE1: migration and fixFiles without unsorted");
assert(function (cb) {
console.log('START DRIVE2');
var files = {
"root": {
"Folder": {},
"Folder2": {
"FileName": "/pad/#/1/edit/a798u+miu2tg5b-QaP9SvA/UIPoGUPewZscBUFhNIi+eBBM/"
}
},
"unsorted": ["/code/#/1/edit/R1kZC1mY9khSsrLCyJT+CA/jtQrCxbTiqQJ4HyUxbFBnmG8/"],
"trash": {},
"CryptPad_RECENTPADS": [{
"atime": 23456783456,
"ctime": 12345678901,
"href": "/code/#/1/edit/R1kZC1mY9khSsrLCyJT+CA/jtQrCxbTiqQJ4HyUxbFBnmG8/",
"title": "pewcode"
}, {
"atime": 23456789012,
"ctime": 12345789235,
"href": "/pad/#/1/edit/a798u+miu2tg5b-QaP9SvA/UIPoGUPewZscBUFhNIi+eBBM/",
"title": "pewpad"
}]
};
var fo = FO.init(files, config);
var todo = function () {
fo.fixFiles();
if (files['CryptPad_RECENTPADS'] || !files.filesData) {
console.log("DRIVE2: migration from RECENTPADS to filesData failed");
return cb();
}
if (!files.template) {
console.log("DRIVE2: template is missing");
return cb();
}
if (files.unsorted) {
console.log("DRIVE2: unsorted not removed");
return cb();
}
var fileKey = Object.keys(files.root.Folder2)[0];
var fileKey2 = Object.keys(files.root).filter(function (x) {
return typeof files.root[x] === "number";
})[0];
if (!fileKey || !fileKey2) { return cb(); }
var fileId = files.root.Folder2[fileKey];
var fileId2 = files.root[fileKey2];
var res = typeof fileId === "number"
&& typeof files.filesData[fileId] === "object"
&& files.filesData[fileId].filename === "FileName"
&& typeof fileId2 === "number"
&& typeof files.filesData[fileId2] === "object"
&& !files.filesData[fileId2].filename;
return cb(res);
};
fo.migrate(todo);
}, "DRIVE2: migration and fixFiles with unsorted");
assert(function (cb) {
console.log('START DRIVE3');
var files = {
"root": {
"Folder": {},
"Folder2": {
"FileName": href1
}
},
"template": [href3],
"trash": {
"DeletedF": [{
"path": ["root"],
"element": { "Trash": href4 }
}, {
"path": ["root", "Folder"],
"element": href2
}]
},
"CryptPad_RECENTPADS": []
};
var fo = FO.init(files, config);
var todo = function () {
fo.fixFiles();
if (files['CryptPad_RECENTPADS'] || !files.filesData) {
console.log("DRIVE2: migration from RECENTPADS to filesData failed");
return cb();
}
var fileKey = Object.keys(files.root.Folder2)[0];
var fileKey2 = Object.keys(files.trash.DeletedF[0].element)[0];
if (!fileKey || !fileKey2) { return cb(); }
var fileId = files.root.Folder2[fileKey];
var fileId2 = files.trash.DeletedF[0].element[fileKey2];
var res = typeof fileId === "number"
&& typeof files.filesData[fileId] === "object"
&& files.filesData[fileId].filename === "FileName"
&& files.filesData[fileId].href === href1
&& typeof files.trash.DeletedF[1].element === "number"
&& typeof files.filesData[files.trash.DeletedF[1].element] === "object"
&& files.filesData[files.trash.DeletedF[1].element].filename === "DeletedF"
&& files.filesData[files.trash.DeletedF[1].element].href === href2
&& typeof files.template[0] === "number"
&& typeof files.filesData[files.template[0]] === "object"
&& !files.filesData[files.template[0]].filename
&& files.filesData[files.template[0]].href === href3
&& typeof fileId2 === "number"
&& typeof files.filesData[fileId2] === "object"
&& files.filesData[fileId2].filename === "Trash"
&& files.filesData[fileId2].href === href4;
return cb(res);
};
fo.migrate(todo);
}, "DRIVE4: migration and fixFiles with a pad in trash not root");
// Pad attributes migration
/*
assert(function (cb) {
console.log('START PAD ATTRIBUTES');
var files = JSON.parse(JSON.stringify(example));
files[href1.slice(6) + '.userid'] = 'value';
files[href1.slice(6) + '.previewMode'] = true;
var fo = FO.init(files, config);
fo.fixFiles();
return cb(files.filesData[id1].userid === 'value'
&& files.filesData[id1].previewMode);
}, "PAD ATTRIBUTES");
*/
// userObject Tests
// UTILS
assert(function (cb) {
console.log('START DRIVE utils');
var files = JSON.parse(JSON.stringify(example));
var fo = FO.init(files, config);
fo.fixFiles();
if (fo.isFile({}) || fo.isFile(href1) || !fo.isFile(href1, true) || !fo.isFile(id1)) {
console.log("DRIVE utils: isFile returns an incorrect value");
return cb();
}
if (fo.isReadOnlyFile(id1)) {
console.log("DRIVE utils: isReadOnlyFile returns true for an 'edit' file");
return cb();
}
if (!fo.isReadOnlyFile(id3)) {
console.log("DRIVE utils: isReadOnlyFile returns false for a 'view' file");
return cb();
}
if (!fo.hasSubfolder(files.root.Folder) || fo.hasSubfolder(files.root.Folder2)) {
console.log("DRIVE utils: hasSubfolder returns an incorrect value");
return cb();
}
if (fo.hasFile(files.root.Folder) || !fo.hasFile(files.root.Folder2)) {
console.log("DRIVE utils: hasFile returns an incorrect value");
return cb();
}
if (JSON.stringify(fo.getFileData(id1)) !== JSON.stringify(files.filesData[id1])) {
console.log("DRIVE utils: getFileData returns an incorrect value");
return cb();
}
if (fo.getTitle(id4) !== "Title4" || fo.getTitle(id1) !== "FileName1") {
console.log("DRIVE utils: getTitle returns an incorrect value");
return cb();
}
if (fo.find(["root", "Folder2", "rdmStrFile1"]) !== id1) {
console.log("DRIVE utils: 'find' returns an incorrect value");
return cb();
}
if (fo.getFiles().length !== 4 || fo.getFiles(['trash']).length !== 2) {
console.log("DRIVE utils: getFiles returns an incorrect value");
return cb();
}
if (fo.findFile(id4).length !== 1 || fo.findFile(id4)[0].length !== 4) {
console.log("DRIVE utils: findFile returns an incorrect value");
return cb();
}
if (fo.search('tle2').length !== 1 || fo.search('tle2')[0].data.href !== href2 || fo.search('tle2')[0].paths[0][0] !== 'template') {
console.log("DRIVE utils: search returns an incorrect value");
return cb();
}
return cb(true);
}, "DRIVE utils");
// OPERATIONS
assert(function (cb) {
console.log('START DRIVE operations');
var files = JSON.parse(JSON.stringify(example));
var fo = FO.init(files, config);
fo.fixFiles();
var data = Cryptpad.makePad(href5, 'Title5');
var res;
var id5;
// pushData is synchronous in test mode (no pinning)
fo.pushData(data, function (e, id) {
fo.add(id, ["root", "Folder"]);
id5 = id;
res = JSON.stringify(data) === JSON.stringify(fo.getFileData(id)) &&
fo.getFiles(["root"]).indexOf(id) !== -1;
});
if (!res) {
console.log("DRIVE operations: pushData");
return cb();
}
fo.move([["root", "Folder"], ["template", 0]], ["trash"]);
if (fo.getFiles(["template"]).indexOf(id2) !== -1 ||
fo.getFiles(["trash"]).indexOf(id5) === -1) {
console.log("DRIVE operations: move");
return cb();
}
fo.restore(["trash", "Title2", 0, "element"]);
if (files["template"][0] !== id2 || fo.getFiles(['trash']).indexOf(id2) !== -1) {
console.log("DRIVE operations: restore");
return cb();
}
files["template"] = [];
fo.add(id2, ["template"]);
if (fo.getFiles(['template']).indexOf(id2) === -1) {
console.log("DRIVE operations");
return cb();
}
var path;
fo.addFolder(["root", "Folder2"], "subsub", function (e, o) { path = o.newPath; });
if (!files.root.Folder2.subsub || path.length !== 3) {
console.log("DRIVE operations: add folder");
return cb();
}
fo.forget(href2);
if (files["template"].length !== 0 || fo.getFiles(['trash']).indexOf(id2) === -1) {
console.log("DRIVE operations: forget");
return cb();
}
fo.restore(["trash", "Title2", 0, "element"]);
fo.delete([["root", "Folder2", "subsub"],["template",0]]);
if (files.root.Folder2.subsub || fo.getFiles().indexOf(id2) !== -1) {
console.log("DRIVE operations: delete");
return cb();
}
fo.emptyTrash();
if (JSON.stringify(files.trash) !== "{}" || fo.getFiles().indexOf(id5) !== -1 ||
files.filesData[id5]) {
console.log("DRIVE operations: emptyTrash");
return cb();
}
fo.rename(["root", "Folder2"], "FolderNew");
fo.rename(["root", "FolderNew", "rdmStrFile1"], "NewFileName1");
if (files.root.Folder2 || !files.root.FolderNew ||
fo.getFileData(id1).filename !== "NewFileName1" ||
fo.getTitle(id1) !== "NewFileName1") {
console.log("DRIVE operations: rename");
return cb();
}
fo.replace(href1, href2);
if (fo.getFileData(id1).href !== href2) {
console.log("DRIVE operations: replace");
return cb();
}
cb(true);
}, "DRIVE operations");
};
return module;
});