diff --git a/HELP.md b/HELP.md index 362e2530..bde6fdca 100644 --- a/HELP.md +++ b/HELP.md @@ -85,7 +85,9 @@ Cloud Commander supports command line parameters: | `--html-dialogs` | use html dialogs | `--open` | open web browser when server started | `--name` | set tab name in web browser -| `--one-panel-mode` | set one panel mode +| `--one-panel-mode` | show one file panel (**deprecated**: use `--one-file-panel` instead) +| `--one-file-panel` | show one file panel +| `--keys-panel` | show keys panel | `--contact` | enable contact | `--config-dialog` | enable config dialog | `--console` | enable console @@ -93,7 +95,6 @@ Cloud Commander supports command line parameters: | `--terminal` | enable terminal | `--terminal-path` | set terminal path | `--vim` | enable vim hot keys -| `--keys-panel` | show keys panel | `--columns` | set visible columns | `--cache` | enable cache | `--no-server` | do not start server @@ -101,7 +102,9 @@ Cloud Commander supports command line parameters: | `--no-online` | load scripts from local server | `--no-open` | do not open web browser when server started | `--no-name` | set empty tab name in web browser -| `--no-one-panel-mode` | unset one panel mode +| `--no-one-file-panel` | show two file panels +| `--no-one-panel-mode` | show two file panels (**deprecated**: use `--no-one-file-panel` instead) +| `--no-keys-panel` | hide keys panel | `--no-progress` | do not show progress of file operations | `--no-confirm-copy` | do not confirm copy | `--no-confirm-move` | do not confirm move @@ -112,7 +115,6 @@ Cloud Commander supports command line parameters: | `--no-sync-console-path` | do not sync console path | `--no-terminal` | disable terminal | `--no-vim` | disable vim hot keys -| `--no-keys-panel` | hide keys panel | `--no-columns` | set visible default columns | `--no-cache` | disable cache @@ -368,6 +370,8 @@ Here is description of options: "online" : true, /* load js files from cdn or local path */ "open" : false /* open web browser when server started */ "cache" : true, /* enable cache */ + "onePanelMode" : false, /* show one file panel (deprecated) */ + "oneFilePanel" : false, /* show one file panel */ "keysPanel" : true, /* show classic panel with buttons of keys */ "port" : 8000, /* http port */ "ip" : null, /* ip or null(default) */ @@ -378,7 +382,6 @@ Here is description of options: "confirmMove" : true, /* confirm move */ "htmlDialogs" : true, /* use html dialogs */ "showConfig" : false, /* show config at startap */ - "onePanelMode" : false, /* set one panel mode */ "contact" : true, /* enable contact */ "configDialog" : true, /* enable config dialog */ "console" : true, /* enable console */ @@ -405,11 +408,12 @@ Some config options can be overridden with `environment variables` such: - `CLOUDCMD_TERMINAL_PATH` - set terminal path - `CLOUDCMD_CONFIG_DIALOG` - enable config dialog - `CLOUDCMD_KEYS_PANEL` - show keys panel +- `CLOUDCMD_ONE_PANEL_MODE` - show one file panel (**deprecated**: use `CLOUDCMD_ONE_FILE_PANEL` instead) +- `CLOUDCMD_ONE_FILE_PANEL` - show one file panel - `CLOUDCMD_AUTH` - enable authentication - `CLOUDCMD_USERNAME` - set username - `CLOUDCMD_PASSWORD` - set password - `CLOUDCMD_ROOT` - set root directory -- `CLOUDCMD_ONE_PANEL_MODE` - set one panel mode - `CLOUDCMD_VIM` - enable vim hot keys - `CLOUDCMD_CONFIRM_COPY` - confirm copy - `CLOUDCMD_CONFIRM_MOVE` - confirm move @@ -445,12 +449,12 @@ Right mouse click button shows context menu with items: | `F9` | open | `Esc` | close -One panel mode +One file panel --------------- -Cloud Commander could work in one panel mode when screen size can not accommodate second panel or via `--one-panel-mode` options flag. +Cloud Commander can work in one panel mode when screen size can not accommodate second panel or via `--one-file-panel` options flag. It could happen when mobile device, tablet or small window size used to work with file manager. -![One panel mode](/img/screen/one-panel-mode.png "One panel mode") +![One file panel](/img/screen/one-file-panel.png "One file panel") Using as Middleware --------------- diff --git a/app.json b/app.json index 3e8db9c4..9fe7b37d 100644 --- a/app.json +++ b/app.json @@ -57,6 +57,11 @@ "value": "false", "required": false }, + "CLOUDCMD_ONE_FILE_PANEL": { + "description": "show one file panel", + "value": "false", + "required": false + }, "CLOUDCMD_KEYS_PANEL": { "description": "show keys panel", "value": "true", @@ -88,6 +93,11 @@ "required": false }, "CLOUDCMD_ONE_PANEL_MODE": { + "description": "set one panel mode (deprecated use CLOUDCMD_ONE_FILE_PANEL)", + "value": "false", + "required": false + }, + "CLOUDCMD_ONE_FILE_PANEL": { "description": "set one panel mode", "value": "false", "required": false diff --git a/bin/cloudcmd.js b/bin/cloudcmd.js index 06464395..36170f8b 100755 --- a/bin/cloudcmd.js +++ b/bin/cloudcmd.js @@ -2,6 +2,9 @@ 'use strict'; +const util = require('util'); +const noop = () => {}; + const Info = require('../package'); const DIR_SERVER = '../server/'; @@ -45,6 +48,7 @@ const args = require('minimist')(argv.slice(2), { 'sync-console-path', 'contact', 'terminal', + 'one-file-panel', 'one-panel-mode', 'confirm-copy', 'confirm-move', @@ -75,7 +79,8 @@ const args = require('minimist')(argv.slice(2), { 'sync-console-path': choose(env.bool('sync_console_path'), config('syncConsolePath')), 'config-dialog': choose(env.bool('config_dialog'), config('configDialog')), 'terminal-path': env('terminal_path') || config('terminalPath'), - 'one-panel-mode': choose(env.bool('one_panel_mode'), config('onePanelMode')), + 'one-file-panel': choose(env.bool('one_file_panel'), config('onePanelMode')), + 'one-panel-mode': '', 'confirm-copy': choose(env.bool('confirm_copy'), config('confirmCopy')), 'confirm-move': choose(env.bool('confirm_move'), config('confirmMove')), 'html-dialogs': config('htmlDialogs'), @@ -133,10 +138,27 @@ function main() { config('htmlDialogs', args['html-dialogs']); config('confirmCopy', args['confirm-copy']); config('confirmMove', args['confirm-move']); - config('onePanelMode', args['one-panel-mode']); + config('onePanelMode', args['one-file-panel']); + config('oneFilePanel', args['one-file-panel']); config('configDialog', args['config-dialog']); config('keysPanel', args['keys-panel']); + if (args['one-panel-mode']) { + util.deprecate(noop, `cloudcmd --one-panel-mode: deprecated, use --one-file-panel instead`, 'DP0001')(); + config('oneFilePanel', true); + config('onePanelMode', true); + } else if (typeof args['one-panel-mode'] === 'boolean') { + util.deprecate(noop, `cloudcmd --no-one-panel-mode: deprecated, use --no-one-file-panel instead`, 'DP0001')(); + config('oneFilePanel', false); + config('onePanelMode', false); + } + + if (typeof env.bool('one_panel_mode') === 'boolean') { + util.deprecate(noop, `CLOUDCMD_ONE_PANEL_MODE deprecated, use CLOUDCMD_ONE_FILE_PANEL instead`, 'DP0001')(); + config('oneFilePanel', env.bool('one_panel_mode')); + config('onePanelMode', env.bool('one_panel_mode')); + } + readConfig(args.config); const options = { diff --git a/img/screen/one-panel-mode.png b/img/screen/one-file-panel.png similarity index 100% rename from img/screen/one-panel-mode.png rename to img/screen/one-file-panel.png diff --git a/json/config.json b/json/config.json index efce05f4..42fc4bca 100644 --- a/json/config.json +++ b/json/config.json @@ -26,6 +26,7 @@ "confirmMove": true, "configDialog": true, "onePanelMode": false, + "oneFilePanel": false, "console": true, "syncConsolePath": false, "terminal": false, diff --git a/json/help.json b/json/help.json index 0e573346..81a481eb 100644 --- a/json/help.json +++ b/json/help.json @@ -19,7 +19,9 @@ "--html-dialogs ": "use html dialogs", "--open ": "open web browser when server started", "--name ": "set tab name in web browser", - "--one-panel-mode ": "set one panel mode", + "--one-panel-mode ": "show one file panel (deprecated use --one-file-panel instead)", + "--one-file-panel ": "show one file panel", + "--keys-panel ": "show keys panel", "--config-dialog ": "enable config dialog", "--console ": "enable console", "--sync-console-path ": "sync console path", @@ -28,14 +30,15 @@ "--terminal-path ": "set terminal path", "--vim ": "enable vim hot keys", "--columns ": "set visible columns", - "--keys-panel ": "show keys panel", "--cache ": "enable cache", "--no-server ": "do not start server", "--no-auth ": "disable authorization", "--no-online ": "load scripts from local server", "--no-open ": "do not open web browser when server started", "--no-name ": "set default tab name in web browser", - "--no-one-panel-mode ": "unset one panel mode", + "--no-one-panel ": "show two file panels", + "--no-keys-panel ": "hide keys panel", + "--no-one-file-panel ": "show two file panels", "--no-progress ": "do not show progress of file operations", "--no-confirm-copy ": "do not confirm copy", "--no-confirm-move ": "do not confirm move", @@ -46,7 +49,6 @@ "--no-contact ": "disable contact", "--no-terminal ": "disable terminal", "--no-vim ": "disable vim hot keys", - "--no-keys-panel ": "hide keys panel", "--no-columns ": "set default visible columns", "--no-cache ": "disable cache" } diff --git a/man/cloudcmd.1 b/man/cloudcmd.1 index e79afee4..94c05dca 100644 --- a/man/cloudcmd.1 +++ b/man/cloudcmd.1 @@ -42,23 +42,25 @@ programs in browser from any computer, mobile or tablet device. --html-dialogs use html dialogs --open open web browser when server started --name set tab name in web browser - --one-panel-mode set one panel mode + --one-panele-mode show one file panel (deprecated use --one-file-panel instead) + --one-file-panele show one file panel + --keys-panel show keys panel --contact enable contact --config-dialog enable config dialog --console enable console - --sync-console-path sync console path + --sync-console-path sync console path --terminal enable terminal --terminal-path set terminal path --vim enable vim hot keys --columns set visible columns - --keys-panel show keys panel --cache enable cache --no-auth disable authorization --no-server do not start server --no-online load scripts from local server --no-open do not open web browser when server started --no-name set default tab name in web browser - --no-one-panel-mode unset one panel mode + --no-one-file-panel show two file panels + --no-keys-panel hide keys panel --no-progress do not show progress of file operations --no-confirm-copy do not confirm copy --no-confirm-move do not confirm move @@ -70,7 +72,6 @@ programs in browser from any computer, mobile or tablet device. --no-terminal disable terminal --no-vim disable vim hot keys --no-columns set visible default columns - --no-keys-panel hide keys panel --no-cache disable cache .SH RESOURCES AND DOCUMENTATION diff --git a/server/cloudcmd.js b/server/cloudcmd.js index 4fea010b..4b88cd64 100644 --- a/server/cloudcmd.js +++ b/server/cloudcmd.js @@ -4,6 +4,8 @@ const DIR = __dirname + '/'; const DIR_ROOT = DIR + '../'; const DIR_COMMON = DIR + '../common/'; +const util = require('util'); + const cloudfunc = require(DIR_COMMON + 'cloudfunc'); const authentication = require(DIR + 'auth'); const config = require(DIR + 'config'); @@ -37,6 +39,14 @@ const clean = (a) => a.filter(notEmpty); const isDev = process.env.NODE_ENV === 'development'; +const deprecateOnePanelMode = (value) => { + const noop = () => {}; + + util.deprecate(noop, 'onePanelMode is deprecated, use oneFilePanel instead', 'DP0001')(); + + config('oneFilePanel', value); +}; + module.exports = (params) => { const p = params || {}; const options = p.config || {}; @@ -50,7 +60,11 @@ module.exports = (params) => { keys.forEach((name) => { const value = options[name]; - if (/root|editor|packer|columns/.test(name)) + if (name === 'onePanelMode') + deprecateOnePanelMode(); + else if (name === 'oneFilePanel') + config('onePanelMode', value); + else if (/root|editor|packer|columns/.test(name)) validate[name](value); config(name, value); diff --git a/server/env.js b/server/env.js index bc6d5eff..27914de1 100644 --- a/server/env.js +++ b/server/env.js @@ -7,6 +7,9 @@ module.exports = parse; module.exports.bool = (name) => { const value = parse(name); + if (value === 'true') + return true; + if (value === 'false') return false; diff --git a/server/route.js b/server/route.js index 5800109e..81ae7c1e 100644 --- a/server/route.js +++ b/server/route.js @@ -41,7 +41,7 @@ module.exports._getIndexPath = getIndexPath; * additional processing of index file */ function indexProcessing(options) { - const isOnePanel = config('onePanelMode'); + const oneFilePanel = config('onePanelMode'); const noContact = !config('contact'); const noConfig = !config('configDialog'); const noConsole = !config('console'); @@ -53,7 +53,7 @@ function indexProcessing(options) { if (!config('keysPanel')) data = hideKeysPanel(data); - if (isOnePanel) + if (oneFilePanel) data = data .replace('icon-move', 'icon-move none') .replace('icon-copy', 'icon-copy none'); @@ -77,11 +77,11 @@ function indexProcessing(options) { const left = rendy(Template.panel, { side : 'left', content : panel, - className : !isOnePanel ? '' : 'panel-single' + className : !oneFilePanel ? '' : 'panel-single' }); let right = ''; - if (!isOnePanel) + if (!oneFilePanel) right = rendy(Template.panel, { side : 'right', content : panel, diff --git a/test/server/env.js b/test/server/env.js index b5e453d7..d5376ab3 100644 --- a/test/server/env.js +++ b/test/server/env.js @@ -19,18 +19,18 @@ test('env: big', (t) => { t.end(); }); -test('env: bool', (t) => { +test('env: bool: false', (t) => { process.env.cloudcmd_terminal = 'false'; - t.notOk(env.bool('terminal'), 'should return false'); + t.equal(env.bool('terminal'), false, 'should return false'); delete process.env.cloudcmd_terminal; t.end(); }); -test('env: bool', (t) => { +test('env: bool: true', (t) => { process.env.cloudcmd_terminal = 'true'; - t.ok(env.bool('terminal'), 'should be true'); + t.equal(env.bool('terminal'), true, 'should be true'); delete process.env.cloudcmd_terminal; t.end(); diff --git a/test/server/route.js b/test/server/route.js index 3735d5c9..6bdb0fe0 100644 --- a/test/server/route.js +++ b/test/server/route.js @@ -113,7 +113,7 @@ test('cloudcmd: route: buttons: no contact', async (t) => { test('cloudcmd: route: buttons: one panel mode: move', async (t) => { const config = { - onePanelMode: true + oneFilePanel: true }; const {port, done} = await connect({config}); @@ -127,7 +127,7 @@ test('cloudcmd: route: buttons: one panel mode: move', async (t) => { test('cloudcmd: route: buttons: one panel mode: move', async (t) => { const config = { - onePanelMode: true + oneFilePanel: true }; const {port, done} = await connect({config}); diff --git a/tmpl/config.hbs b/tmpl/config.hbs index 282ece0a..582e89f4 100644 --- a/tmpl/config.hbs +++ b/tmpl/config.hbs @@ -105,6 +105,12 @@ Cache +
  • + +
  • -
  • - -