mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
feature(cloudcmd) --columns: add ability to set visible columns (#146)
This commit is contained in:
parent
6c9913e5f1
commit
b5f98be162
18 changed files with 115 additions and 30 deletions
5
HELP.md
5
HELP.md
|
|
@ -92,6 +92,7 @@ Cloud Commander supports command line parameters:
|
||||||
| `--terminal` | enable terminal
|
| `--terminal` | enable terminal
|
||||||
| `--terminal-path` | set terminal path
|
| `--terminal-path` | set terminal path
|
||||||
| `--vim` | enable vim hot keys
|
| `--vim` | enable vim hot keys
|
||||||
|
| `--columns` | set visible columns
|
||||||
| `--no-server` | do not start server
|
| `--no-server` | do not start server
|
||||||
| `--no-auth` | disable authorization
|
| `--no-auth` | disable authorization
|
||||||
| `--no-online` | load scripts from local server
|
| `--no-online` | load scripts from local server
|
||||||
|
|
@ -107,7 +108,7 @@ Cloud Commander supports command line parameters:
|
||||||
| `--no-console` | disable console
|
| `--no-console` | disable console
|
||||||
| `--no-terminal` | disable terminal
|
| `--no-terminal` | disable terminal
|
||||||
| `--no-vim` | disable vim hot keys
|
| `--no-vim` | disable vim hot keys
|
||||||
|
| `--no-columns` | set visible default columns
|
||||||
|
|
||||||
If no parameters given Cloud Commander reads information from `~/.cloudcmd.json` and use
|
If no parameters given Cloud Commander reads information from `~/.cloudcmd.json` and use
|
||||||
port from it (`8000` default). if port variables `PORT` or `VCAP_APP_PORT` isn't exist.
|
port from it (`8000` default). if port variables `PORT` or `VCAP_APP_PORT` isn't exist.
|
||||||
|
|
@ -378,6 +379,7 @@ Here is description of options:
|
||||||
"terminal" : false, /* disable terminal */
|
"terminal" : false, /* disable terminal */
|
||||||
"terminalPath" : '', /* path of a terminal */
|
"terminalPath" : '', /* path of a terminal */
|
||||||
"vim" : false, /* disable vim hot keys */
|
"vim" : false, /* disable vim hot keys */
|
||||||
|
"columns" : "name-size-date-owner-mode", /* set visible columns */
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
@ -387,6 +389,7 @@ Some config options can be overridden with `environment variables` such:
|
||||||
|
|
||||||
- `CLOUDCMD_NAME` - set tab name in web browser
|
- `CLOUDCMD_NAME` - set tab name in web browser
|
||||||
- `CLOUDCMD_EDITOR` - set editor
|
- `CLOUDCMD_EDITOR` - set editor
|
||||||
|
- `CLOUDCMD_COLUMNS` - set visible columns
|
||||||
- `CLOUDCMD_CONTACT` - enable contact
|
- `CLOUDCMD_CONTACT` - enable contact
|
||||||
- `CLOUDCMD_CONFIG_DIALOG` - enable config dialog
|
- `CLOUDCMD_CONFIG_DIALOG` - enable config dialog
|
||||||
- `CLOUDCMD_CONSOLE` - enable console
|
- `CLOUDCMD_CONSOLE` - enable console
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ const args = require('minimist')(argv.slice(2), {
|
||||||
'root',
|
'root',
|
||||||
'prefix',
|
'prefix',
|
||||||
'terminal-path',
|
'terminal-path',
|
||||||
|
'columns',
|
||||||
],
|
],
|
||||||
boolean: [
|
boolean: [
|
||||||
'auth',
|
'auth',
|
||||||
|
|
@ -74,6 +75,7 @@ const args = require('minimist')(argv.slice(2), {
|
||||||
'confirm-move': choose(env.bool('confirm_move'), config('confirmMove')),
|
'confirm-move': choose(env.bool('confirm_move'), config('confirmMove')),
|
||||||
'html-dialogs': config('htmlDialogs'),
|
'html-dialogs': config('htmlDialogs'),
|
||||||
'vim': choose(env.bool('vim'), config('vim')),
|
'vim': choose(env.bool('vim'), config('vim')),
|
||||||
|
'columns': env('columns') || config('columns') || '',
|
||||||
},
|
},
|
||||||
alias: {
|
alias: {
|
||||||
v: 'version',
|
v: 'version',
|
||||||
|
|
@ -119,6 +121,7 @@ function main() {
|
||||||
config('prefix', args.prefix);
|
config('prefix', args.prefix);
|
||||||
config('root', args.root);
|
config('root', args.root);
|
||||||
config('vim', args.vim);
|
config('vim', args.vim);
|
||||||
|
config('columns', args.columns);
|
||||||
config('htmlDialogs', args['html-dialogs']);
|
config('htmlDialogs', args['html-dialogs']);
|
||||||
config('confirmCopy', args['confirm-copy']);
|
config('confirmCopy', args['confirm-copy']);
|
||||||
config('confirmMove', args['confirm-move']);
|
config('confirmMove', args['confirm-move']);
|
||||||
|
|
@ -131,7 +134,8 @@ function main() {
|
||||||
root: args.root || '/', /* --no-root */
|
root: args.root || '/', /* --no-root */
|
||||||
editor: args.editor,
|
editor: args.editor,
|
||||||
packer: args.packer,
|
packer: args.packer,
|
||||||
prefix: args.prefix
|
prefix: args.prefix,
|
||||||
|
columns: args.columns,
|
||||||
};
|
};
|
||||||
|
|
||||||
const password = env('password') || args.password;
|
const password = env('password') || args.password;
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
require('../css/main.css');
|
require('../css/main.css');
|
||||||
require('../css/nojs.css');
|
require('../css/nojs.css');
|
||||||
|
require('../css/columns/name-size-date.css');
|
||||||
|
|
||||||
// prevent additional loading of exec by spero, remedy, ishtar, salam, omnes
|
// prevent additional loading of exec by spero, remedy, ishtar, salam, omnes
|
||||||
window.exec = require('execon');
|
window.exec = require('execon');
|
||||||
|
|
|
||||||
|
|
@ -358,3 +358,4 @@ load.style = (params) => {
|
||||||
element,
|
element,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -165,6 +165,9 @@ function fillTemplate(error, template) {
|
||||||
obj[obj.packer + '-selected'] = 'selected';
|
obj[obj.packer + '-selected'] = 'selected';
|
||||||
delete obj.packer;
|
delete obj.packer;
|
||||||
|
|
||||||
|
obj[obj.columns + '-selected'] = 'selected';
|
||||||
|
delete obj.columns;
|
||||||
|
|
||||||
const inner = rendy(Template, obj);
|
const inner = rendy(Template, obj);
|
||||||
|
|
||||||
Element = DOM.load({
|
Element = DOM.load({
|
||||||
|
|
|
||||||
12
css/columns/name-size-date.css
Normal file
12
css/columns/name-size-date.css
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
.name {
|
||||||
|
width: 59%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.owner {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mode {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -7,12 +7,14 @@
|
||||||
<!-- mobile first design -->
|
<!-- mobile first design -->
|
||||||
<meta content="width=device-width,initial-scale=1" name="viewport">
|
<meta content="width=device-width,initial-scale=1" name="viewport">
|
||||||
<link rel="icon" href="{{ prefix }}/favicon.ico">
|
<link rel="icon" href="{{ prefix }}/favicon.ico">
|
||||||
<title>{{ title }}</title>
|
|
||||||
|
|
||||||
<link rel=stylesheet href="{{ prefix }}/dist/cloudcmd.css">
|
<link rel=stylesheet href="{{ prefix }}/dist/cloudcmd.css">
|
||||||
<noscript>
|
<noscript>
|
||||||
<link rel=stylesheet href="{{ prefix }}/dist/nojs.css">
|
<link rel=stylesheet href="{{ prefix }}/dist/nojs.css">
|
||||||
</noscript>
|
</noscript>
|
||||||
|
<style data-name="columns">
|
||||||
|
{{ columns }}
|
||||||
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class=fm>{{ fm }}</div>
|
<div class=fm>{{ fm }}</div>
|
||||||
|
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 198 KiB After Width: | Height: | Size: 165 KiB |
|
|
@ -30,6 +30,7 @@
|
||||||
"terminal": false,
|
"terminal": false,
|
||||||
"terminalPath": "",
|
"terminalPath": "",
|
||||||
"showConfig": false,
|
"showConfig": false,
|
||||||
"vim": false
|
"vim": false,
|
||||||
|
"columns": "name-size-date-owner-mode"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@
|
||||||
"--terminal ": "enable terminal",
|
"--terminal ": "enable terminal",
|
||||||
"--terminal-path ": "set terminal path",
|
"--terminal-path ": "set terminal path",
|
||||||
"--vim ": "enable vim hot keys",
|
"--vim ": "enable vim hot keys",
|
||||||
|
"--columns ": "set visible columns",
|
||||||
"--no-server ": "do not start server",
|
"--no-server ": "do not start server",
|
||||||
"--no-auth ": "disable authorization",
|
"--no-auth ": "disable authorization",
|
||||||
"--no-online ": "load scripts from local server",
|
"--no-online ": "load scripts from local server",
|
||||||
|
|
@ -40,5 +41,6 @@
|
||||||
"--no-console ": "disable console",
|
"--no-console ": "disable console",
|
||||||
"--no-contact ": "disable contact",
|
"--no-contact ": "disable contact",
|
||||||
"--no-terminal ": "disable terminal",
|
"--no-terminal ": "disable terminal",
|
||||||
"--no-vim ": "disable vim hot keys"
|
"--no-vim ": "disable vim hot keys",
|
||||||
|
"--no-columns ": "set default visible columns"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,7 @@ programs in browser from any computer, mobile or tablet device.
|
||||||
--terminal enable terminal
|
--terminal enable terminal
|
||||||
--terminal-path set terminal path
|
--terminal-path set terminal path
|
||||||
--vim enable vim hot keys
|
--vim enable vim hot keys
|
||||||
|
--columns` set visible columns
|
||||||
--no-auth disable authorization
|
--no-auth disable authorization
|
||||||
--no-server do not start server
|
--no-server do not start server
|
||||||
--no-online load scripts from local server
|
--no-online load scripts from local server
|
||||||
|
|
@ -64,6 +65,7 @@ programs in browser from any computer, mobile or tablet device.
|
||||||
--no-console disable console
|
--no-console disable console
|
||||||
--no-terminal disable terminal
|
--no-terminal disable terminal
|
||||||
--no-vim disable vim hot keys
|
--no-vim disable vim hot keys
|
||||||
|
--no-columns set visible default columns
|
||||||
|
|
||||||
.SH RESOURCES AND DOCUMENTATION
|
.SH RESOURCES AND DOCUMENTATION
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -54,19 +54,8 @@ module.exports = (params) => {
|
||||||
keys.forEach((name) => {
|
keys.forEach((name) => {
|
||||||
const value = options[name];
|
const value = options[name];
|
||||||
|
|
||||||
switch(name) {
|
if (/root|editor|packer|columns/.test(name))
|
||||||
case 'root':
|
validate[name](value);
|
||||||
validate.root(value);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'editor':
|
|
||||||
validate.editor(value);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'packer':
|
|
||||||
validate.packer(value);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
config(name, value);
|
config(name, value);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
17
server/columns.js
Normal file
17
server/columns.js
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const fs = require('fs');
|
||||||
|
const isDev = process.NODE_ENV === 'development';
|
||||||
|
const dir = getDirPath(isDev);
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
'': '',
|
||||||
|
'name-size-date': fs.readFileSync(`${dir}/name-size-date.css`, 'utf8'),
|
||||||
|
'name-size-date-owner-mode': '',
|
||||||
|
};
|
||||||
|
|
||||||
|
function getDirPath (isDev) {
|
||||||
|
const dist = isDev ? 'dist-dev' : 'dist';
|
||||||
|
return `${__dirname}/../${dist}/columns`;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -14,6 +14,7 @@ const format = require('format-io');
|
||||||
const squad = require('squad/legacy');
|
const squad = require('squad/legacy');
|
||||||
const apart = require('apart');
|
const apart = require('apart');
|
||||||
|
|
||||||
|
const columns = require(DIR_SERVER + 'columns');
|
||||||
const config = require(DIR_SERVER + 'config');
|
const config = require(DIR_SERVER + 'config');
|
||||||
const root = require(DIR_SERVER + 'root');
|
const root = require(DIR_SERVER + 'root');
|
||||||
const prefixer = require(DIR_SERVER + 'prefixer');
|
const prefixer = require(DIR_SERVER + 'prefixer');
|
||||||
|
|
@ -99,6 +100,7 @@ function indexProcessing(options) {
|
||||||
fm: left + right,
|
fm: left + right,
|
||||||
prefix: prefix(),
|
prefix: prefix(),
|
||||||
config: JSON.stringify(config('*')),
|
config: JSON.stringify(config('*')),
|
||||||
|
columns: columns[config('columns')],
|
||||||
});
|
});
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,9 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const exit = require('./exit');
|
const exit = require('./exit');
|
||||||
|
const columns = require('./columns');
|
||||||
|
|
||||||
module.exports.root = root;
|
module.exports.root = (dir, fn) => {
|
||||||
module.exports.editor = editor;
|
|
||||||
module.exports.packer = packer;
|
|
||||||
|
|
||||||
function root(dir, fn) {
|
|
||||||
if (typeof dir !== 'string')
|
if (typeof dir !== 'string')
|
||||||
throw Error('dir should be a string');
|
throw Error('dir should be a string');
|
||||||
|
|
||||||
|
|
@ -22,19 +19,28 @@ function root(dir, fn) {
|
||||||
if (typeof fn === 'function')
|
if (typeof fn === 'function')
|
||||||
fn('root:', dir);
|
fn('root:', dir);
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
function editor(name) {
|
module.exports.editor = (name) => {
|
||||||
const reg = /^(dword|edward|deepword)$/;
|
const reg = /^(dword|edward|deepword)$/;
|
||||||
|
|
||||||
if (!reg.test(name))
|
if (!reg.test(name))
|
||||||
exit('cloudcmd --editor: could be "dword", "edward" or "deepword" only');
|
exit('cloudcmd --editor: could be "dword", "edward" or "deepword" only');
|
||||||
}
|
};
|
||||||
|
|
||||||
function packer(name) {
|
module.exports.packer = (name) => {
|
||||||
const reg = /^(tar|zip)$/;
|
const reg = /^(tar|zip)$/;
|
||||||
|
|
||||||
if (!reg.test(name))
|
if (!reg.test(name))
|
||||||
exit('cloudcmd --packer: could be "tar" or "zip" only');
|
exit('cloudcmd --packer: could be "tar" or "zip" only');
|
||||||
}
|
};
|
||||||
|
|
||||||
|
module.exports.columns = (type) => {
|
||||||
|
const all = Object
|
||||||
|
.keys(columns)
|
||||||
|
.concat('');
|
||||||
|
|
||||||
|
if (!~all.indexOf(type))
|
||||||
|
exit('cloudcmd --columns: could be "name-size-date" or "name-size-date-owner-mode"');
|
||||||
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -107,6 +107,37 @@ test('validate: editor: not valid', (t) => {
|
||||||
t.end();
|
t.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('validate: columns', (t) => {
|
||||||
|
const fn = sinon.stub();
|
||||||
|
|
||||||
|
clean();
|
||||||
|
require(exitPath);
|
||||||
|
stub(exitPath, fn);
|
||||||
|
|
||||||
|
const {columns} = require(validatePath);
|
||||||
|
|
||||||
|
columns('name-size-date');
|
||||||
|
|
||||||
|
t.notOk(fn.called, 'should not call exit');
|
||||||
|
t.end();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('validate: columns: wrong', (t) => {
|
||||||
|
const fn = sinon.stub();
|
||||||
|
|
||||||
|
clean();
|
||||||
|
require(exitPath);
|
||||||
|
stub(exitPath, fn);
|
||||||
|
|
||||||
|
const {columns} = require(validatePath);
|
||||||
|
const msg = 'cloudcmd --columns: could be "name-size-date" or "name-size-date-owner-mode"';
|
||||||
|
|
||||||
|
columns('hello');
|
||||||
|
|
||||||
|
t.ok(fn.calledWith(msg), 'should call exit');
|
||||||
|
t.end();
|
||||||
|
});
|
||||||
|
|
||||||
function clean() {
|
function clean() {
|
||||||
clear(validatePath);
|
clear(validatePath);
|
||||||
clear(exitPath);
|
clear(exitPath);
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,12 @@
|
||||||
Zip
|
Zip
|
||||||
</label>
|
</label>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<select data-name="js-columns" class="form-control full-width" title="Columns">
|
||||||
|
<option {{ name-size-date-owner-mode-selected }}>name-size-date-owner-mode</option>
|
||||||
|
<option {{ name-size-date-selected }}>name-size-date</option>
|
||||||
|
</select>
|
||||||
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<select data-name="js-editor" class="form-control full-width" title="Editor">
|
<select data-name="js-editor" class="form-control full-width" title="Editor">
|
||||||
<option {{ edward-selected }}>edward</option>
|
<option {{ edward-selected }}>edward</option>
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ const extractNojs = new ExtractTextPlugin('nojs.css');
|
||||||
|
|
||||||
const extractView = new ExtractTextPlugin('view.css');
|
const extractView = new ExtractTextPlugin('view.css');
|
||||||
const extractConfig = new ExtractTextPlugin('config.css');
|
const extractConfig = new ExtractTextPlugin('config.css');
|
||||||
|
const extractNameSizeDate = new ExtractTextPlugin('columns/name-size-date.css');
|
||||||
|
|
||||||
const plugins = [
|
const plugins = [
|
||||||
new HtmlWebpackPlugin({
|
new HtmlWebpackPlugin({
|
||||||
|
|
@ -34,6 +35,7 @@ const plugins = [
|
||||||
extractNojs,
|
extractNojs,
|
||||||
extractView,
|
extractView,
|
||||||
extractConfig,
|
extractConfig,
|
||||||
|
extractNameSizeDate,
|
||||||
];
|
];
|
||||||
|
|
||||||
const rules = clean([
|
const rules = clean([
|
||||||
|
|
@ -43,7 +45,7 @@ const rules = clean([
|
||||||
loader: 'babel-loader',
|
loader: 'babel-loader',
|
||||||
}, {
|
}, {
|
||||||
test: /\.css$/,
|
test: /\.css$/,
|
||||||
exclude: /css\/(nojs|view|config)\.css/,
|
exclude: /css\/(nojs|view|config|columns.*)\.css/,
|
||||||
use: extractMain.extract([
|
use: extractMain.extract([
|
||||||
'css-loader?minimize',
|
'css-loader?minimize',
|
||||||
]),
|
]),
|
||||||
|
|
@ -51,6 +53,7 @@ const rules = clean([
|
||||||
extract('nojs', extractNojs),
|
extract('nojs', extractNojs),
|
||||||
extract('view', extractView),
|
extract('view', extractView),
|
||||||
extract('config', extractConfig),
|
extract('config', extractConfig),
|
||||||
|
extract('columns/name-size-date', extractNameSizeDate),
|
||||||
{
|
{
|
||||||
test: /\.(png|gif|svg|woff|woff2|eot|ttf)$/,
|
test: /\.(png|gif|svg|woff|woff2|eot|ttf)$/,
|
||||||
loader: 'url-loader?limit=50000',
|
loader: 'url-loader?limit=50000',
|
||||||
|
|
@ -154,7 +157,7 @@ function getMinifyHtmlOptions() {
|
||||||
removeStyleLinkTypeAttributes: true,
|
removeStyleLinkTypeAttributes: true,
|
||||||
|
|
||||||
minifyJS: true,
|
minifyJS: true,
|
||||||
minifyCSS: true
|
minifyCSS: false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue