diff --git a/HELP.md b/HELP.md index ee18c39a..fa3eae4b 100644 --- a/HELP.md +++ b/HELP.md @@ -59,78 +59,79 @@ cloudcmd Cloud Commander supports the following command-line parameters: -|Parameter |Operation -|:------------------------------|:------------------------------ -| `-h, --help` | display help and exit -| `-v, --version` | display version and exit -| `-s, --save` | save configuration -| `-o, --online` | load scripts from remote servers -| `-a, --auth` | enable authorization -| `-u, --username` | set username -| `-p, --password` | set password -| `-c, --config` | configuration file path -| `--show-config` | show config values -| `--show-file-name` | show file name in view and edit -| `--editor` | set editor: "dword", "edward" or "deepword" -| `--packer` | set packer: "tar" or "zip" -| `--root` | set root directory -| `--prefix` | set url prefix -| `--prefix-socket` | set prefix for url connection -| `--port` | set port number -| `--confirm-copy` | confirm copy -| `--confirm-move` | confirm move -| `--open` | open web browser when server starts -| `--name` | set tab name in web browser -| `--one-file-panel` | show one file panel -| `--keys-panel` | show keys panel -| `--contact` | enable contact -| `--config-dialog` | enable config dialog -| `--config-auth` | enable auth change in config dialog -| `--console` | enable console -| `--sync-console-path` | sync console path -| `--terminal` | enable terminal -| `--terminal-path` | set terminal path -| `--terminal-command` | set command to run in terminal (shell by default) -| `--terminal-auto-restart` | restart command on exit -| `--vim` | enable vim hot keys -| `--columns` | set visible columns -| `--theme` | set theme 'light' or 'dark'" -| `--export` | enable export of config through a server -| `--export-token` | authorization token used by export server -| `--import` | enable import of config -| `--import-token` | authorization token used to connect to export server -| `--import-url` | url of an import server -| `--import-listen` | enable listen on config updates from import server -| `--dropbox` | enable dropbox integration -| `--dropbox-token` | set dropbox token -| `--log` | enable logging -| `--no-show-config` | do not show config values -| `--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-keys-panel` | hide keys panel -| `--no-one-file-panel` | show two file panels -| `--no-confirm-copy` | do not confirm copy -| `--no-confirm-move` | do not confirm move -| `--no-config-dialog` | disable config dialog -| `--no-config-auth` | disable auth change in config dialog -| `--no-console` | disable console -| `--no-sync-console-path` | do not sync console path -| `--no-contact` | disable contact -| `--no-terminal` | disable terminal -| `--no-terminal-command` | set default shell to run in terminal -| `--no-terminal-auto-restart` | do not restart command on exit -| `--no-vim` | disable vim hot keys +| Parameter |Operation +|:-----------------------------|:------------------------------ +| `-h, --help` | display help and exit +| `-v, --version` | display version and exit +| `-s, --save` | save configuration +| `-o, --online` | load scripts from remote servers +| `-a, --auth` | enable authorization +| `-u, --username` | set username +| `-p, --password` | set password +| `-c, --config` | configuration file path +| `--show-config` | show config values +| `--show-dot-files` | show dot files +| `--show-file-name` | show file name in view and edit +| `--editor` | set editor: "dword", "edward" or "deepword" +| `--packer` | set packer: "tar" or "zip" +| `--root` | set root directory +| `--prefix` | set url prefix +| `--prefix-socket` | set prefix for url connection +| `--port` | set port number +| `--confirm-copy` | confirm copy +| `--confirm-move` | confirm move +| `--open` | open web browser when server starts +| `--name` | set tab name in web browser +| `--one-file-panel` | show one file panel +| `--keys-panel` | show keys panel +| `--contact` | enable contact +| `--config-dialog` | enable config dialog +| `--config-auth` | enable auth change in config dialog +| `--console` | enable console +| `--sync-console-path` | sync console path +| `--terminal` | enable terminal +| `--terminal-path` | set terminal path +| `--terminal-command` | set command to run in terminal (shell by default) +| `--terminal-auto-restart` | restart command on exit +| `--vim` | enable vim hot keys +| `--columns` | set visible columns +| `--theme` | set theme 'light' or 'dark'" +| `--export` | enable export of config through a server +| `--export-token` | authorization token used by export server +| `--import` | enable import of config +| `--import-token` | authorization token used to connect to export server +| `--import-url` | url of an import server +| `--import-listen` | enable listen on config updates from import server +| `--dropbox` | enable dropbox integration +| `--dropbox-token` | set dropbox token +| `--log` | enable logging +| `--no-show-config` | do not show config values +| `--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-keys-panel` | hide keys panel +| `--no-one-file-panel` | show two file panels +| `--no-confirm-copy` | do not confirm copy +| `--no-confirm-move` | do not confirm move +| `--no-config-dialog` | disable config dialog +| `--no-config-auth` | disable auth change in config dialog +| `--no-console` | disable console +| `--no-sync-console-path` | do not sync console path +| `--no-contact` | disable contact +| `--no-terminal` | disable terminal +| `--no-terminal-command` | set default shell to run in terminal +| `--no-terminal-auto-restart` | do not restart command on exit +| `--no-vim` | disable vim hot keys | `--no-themes` | set default visible themes -| `--no-export` | disable export config through a server -| `--no-import` | disable import of config -| `--no-import-listen` | disable listen on config updates from import server -| `--no-show-file-name` | do not show file name in view and edit -| `--no-dropbox` | disable dropbox integration -| `--no-dropbox-token` | unset dropbox token -| `--no-log` | disable logging +| `--no-export` | disable export config through a server +| `--no-import` | disable import of config +| `--no-import-listen` | disable listen on config updates from import server +| `--no-show-file-name` | do not show file name in view and edit +| `--no-dropbox` | disable dropbox integration +| `--no-dropbox-token` | unset dropbox token +| `--no-log` | disable logging For options not specified by command-line parameters, Cloud Commander then reads configuration data from `~/.cloudcmd.json`. It uses port `8000` by default. @@ -152,56 +153,57 @@ Then, start the server again with `cloudcmd` and reload the page. ## Hot keys -|Key |Operation -|:----------------------|:-------------------------------------------- -| `F1` | help -| `F2` | show `user menu` -| `F3` | view, change directory -| `Shift + F3` | view raw file, change directory -| `F4` | edit -| `F5` | copy -| `Alt` + `F5` | pack -| `F6` | rename/move -| `Shift` + `F6` | rename current file -| `F7` | new directory -| `Shift + F7` | new file -| `F8`, `Delete` | remove -| `Shift + Delete` | remove without prompt -| `F9` | menu -| `Alt` + `F9` | extract -| `F10` | config -| `*` | select/unselect all -| `+` | expand selection -| `-` | shrink selection -| `:` | open Command Line -| `Ctrl + X` | cut to buffer -| `Ctrl + C` | copy to buffer -| `Ctrl + V` | paste from buffer -| `Ctrl + Z` | clear buffer -| `Ctrl + P` | copy path -| `Ctrl + R` | refresh -| `Ctrl + D` | clear local storage -| `Ctrl + A` | select all files in a panel -| `Ctrl + M` | [rename selected files](https://github.com/coderaiser/cloudcmd/releases/tag/v12.1.0) in editor -| `Ctrl + U` | swap panels -| `Ctrl + F3` | sort by name -| `Ctrl + F5` | sort by date -| `Ctrl + F6` | sort by size -| `Up`, `Down` | file system navigation -| `Enter` | change directory/view file -| `Alt + Left/Right` | show content of directory under cursor in target panel -| `Alt + G` | go to directory -| `Ctrl + \` | go to the root directory -| `Tab` | move via panels -| `Page Up` | up on one page -| `Page Down` | down on one page -| `Home` | to begin of list -| `End` | to end of list -| `Space` | select current file (and get size of directory) -| `Insert` | select current file (and move to next) -| `F9` | context menu -| `~` | console -| `Esc` | toggle vim hotkeys (`file manager`, `editor`) +| Key |Operation +|:---------------------|:-------------------------------------------- +| `F1` | help +| `F2` | show `user menu` +| `F3` | view, change directory +| `Shift + F3` | view raw file, change directory +| `F4` | edit +| `F5` | copy +| `Alt` + `F5` | pack +| `F6` | rename/move +| `Shift` + `F6` | rename current file +| `F7` | new directory +| `Shift + F7` | new file +| `F8`, `Delete` | remove +| `Shift + Delete` | remove without prompt +| `F9` | menu +| `Alt` + `F9` | extract +| `F10` | config +| `*` | select/unselect all +| `+` | expand selection +| `-` | shrink selection +| `:` | open Command Line +| `Ctrl + X` | cut to buffer +| `Ctrl + C` | copy to buffer +| `Ctrl + V` | paste from buffer +| `Ctrl + Z` | clear buffer +| `Ctrl + P` | copy path +| `Ctrl + R` | refresh +| `Ctrl + D` | clear local storage +| `Ctrl + A` | select all files in a panel +| `Ctrl + M` | [rename selected files](https://github.com/coderaiser/cloudcmd/releases/tag/v12.1.0) in editor +| `Ctrl + U` | swap panels +| `Ctrl + F3` | sort by name +| `Ctrl + F5` | sort by date +| `Ctrl + F6` | sort by size +| `Ctrl + Command + .` | show/hide dot files +| `Up`, `Down` | file system navigation +| `Enter` | change directory/view file +| `Alt + Left/Right` | show content of directory under cursor in target panel +| `Alt + G` | go to directory +| `Ctrl + \` | go to the root directory +| `Tab` | move via panels +| `Page Up` | up on one page +| `Page Down` | down on one page +| `Home` | to begin of list +| `End` | to end of list +| `Space` | select current file (and get size of directory) +| `Insert` | select current file (and move to next) +| `F9` | context menu +| `~` | console +| `Esc` | toggle vim hotkeys (`file manager`, `editor`) ### Vim @@ -398,6 +400,7 @@ Here's a description of all options: "confirmCopy": true, // confirm copy "confirmMove": true, // confirm move "showConfig": false, // show config at startup + "showDotFiles": true, // show dot files "showFileName": false, // do not show file name in view and edit "contact": true, // enable contact "configDialog": true, // enable config dialog diff --git a/bin/cloudcmd.mjs b/bin/cloudcmd.mjs index 6551c50b..0a7ec042 100755 --- a/bin/cloudcmd.mjs +++ b/bin/cloudcmd.mjs @@ -86,6 +86,7 @@ const yargsOptions = { 'confirm-copy', 'confirm-move', 'show-config', + 'show-dot-files', 'show-file-name', 'vim', 'keys-panel', @@ -124,6 +125,7 @@ const yargsOptions = { 'export': choose(env.bool('export'), config('export')), 'prefix-socket': config('prefixSocket'), + 'show-dot-files': choose(env.bool('show_dot_files'), config('showDotFiles')), 'show-file-name': choose(env.bool('show_file_name'), config('showFileName')), 'sync-console-path': choose(env.bool('sync_console_path'), config('syncConsolePath')), 'config-dialog': choose(env.bool('config_dialog'), config('configDialog')), @@ -189,6 +191,7 @@ async function main() { config('username', args.username); config('console', args.console); config('syncConsolePath', args.syncConsolePath); + config('showDotFiles', args.showDotFiles); config('showFileName', args.showFileName); config('contact', args.contact); config('terminal', args.terminal); diff --git a/client/client.js b/client/client.js index 4c4555ff..139dd002 100644 --- a/client/client.js +++ b/client/client.js @@ -103,6 +103,7 @@ function CloudCmdProto(DOM) { history, noCurrent, currentName, + showDotFiles: CloudCmd.config('showDotFiles'), }, panel); }; @@ -300,7 +301,6 @@ function CloudCmdProto(DOM) { * @param options * { refresh, history } - необходимость обновить данные о каталоге * @param panel - * @param callback * */ async function ajaxLoad(path, options = {}, panel) { @@ -348,13 +348,16 @@ function CloudCmdProto(DOM) { /** * Функция строит файловую таблицу - * @param json - данные о файлах + * @param data - данные о файлах * @param panelParam - * @param history - * @param callback + * @param options - history, noCurrent, showDotFiles */ async function createFileTable(data, panelParam, options) { - const {history, noCurrent} = options; + const { + history, + noCurrent, + showDotFiles, + } = options; const names = [ 'file', @@ -385,6 +388,7 @@ function CloudCmdProto(DOM) { data, id: panel.id, prefix, + showDotFiles, template: { file, path, diff --git a/client/key/index.js b/client/key/index.js index d7d455af..b0678601 100644 --- a/client/key/index.js +++ b/client/key/index.js @@ -509,6 +509,19 @@ async function switchKey(event) { event.preventDefault(); } + break; + + case KEY.DOT: + if (meta && shift) { + const showDotFiles = !CloudCmd.config('showDotFiles'); + CloudCmd._config('showDotFiles', showDotFiles); + CloudCmd.refresh(); + await DOM.RESTful.Config.write({ + showDotFiles, + }); + } + break; } } + diff --git a/common/cloudfunc.js b/common/cloudfunc.js index 39e422e7..4e4e09d7 100644 --- a/common/cloudfunc.js +++ b/common/cloudfunc.js @@ -16,6 +16,13 @@ const Path = store(); Path('/'); +const filterOutDotFiles = ({showDotFiles}) => ({name}) => { + if (showDotFiles) + return true; + + return !name.startsWith('.'); +}; + module.exports.FS = FS; module.exports.apiURL = '/api/v1'; module.exports.MAX_FILE_SIZE = 500 * 1024; @@ -118,6 +125,7 @@ module.exports.buildFromJSON = (params) => { template, sort = 'name', order = 'asc', + showDotFiles, } = params; const templateFile = template.file; @@ -195,6 +203,7 @@ module.exports.buildFromJSON = (params) => { } fileTable += files + .filter(filterOutDotFiles({showDotFiles})) .map(updateField) .map((file) => { const name = encode(file.name); diff --git a/common/cloudfunc.spec.js b/common/cloudfunc.spec.js index b5aceb7b..e4e06dd7 100644 --- a/common/cloudfunc.spec.js +++ b/common/cloudfunc.spec.js @@ -142,3 +142,36 @@ test('cloudfunc: getSize: file', (t) => { t.equal(result, expected); t.end(); }); + +test('cloudfunc: buildFromJSON: showDotFiles: false', (t) => { + const data = { + path: '/media/', + files: [{ + date: '30.08.2016', + mode: 'rwx rwx rwx', + name: '.floppy', + owner: 'root', + size: '7b', + type: 'directory-link', + }], + }; + + const html = buildFromJSON({ + prefix: '', + template, + data, + showDotFiles: false, + }); + + const $ = cheerio.load(html); + const el = $('[data-name="js-file-LmZsb3BweQ=="]'); + + const result = el + .find('[data-name="js-name"]') + .text(); + + const expected = ''; + + t.equal(result, expected); + t.end(); +}); diff --git a/json/config.json b/json/config.json index fd66580f..e65f41ee 100644 --- a/json/config.json +++ b/json/config.json @@ -30,6 +30,7 @@ "terminalPath": "", "terminalCommand": "", "terminalAutoRestart": true, + "showDotFiles": true, "showConfig": false, "showFileName": false, "vim": false, diff --git a/json/help.json b/json/help.json index 056713ff..6289a2d2 100644 --- a/json/help.json +++ b/json/help.json @@ -8,6 +8,7 @@ "-p, --password ": "set password", "-c, --config ": "configuration file path", "--show-config ": "show config values", + "--show-dot-files ": "show dot files", "--show-file-name ": "show file name in view and edit", "--editor ": "set editor: \"dword\", \"edward\" or \"deepword\"", "--packer ": "set packer: \"tar\" or \"zip\"", @@ -65,6 +66,7 @@ "--no-export ": "disable export config through a server", "--no-import ": "disable import of config", "--no-import-listen ": "disable listen on config updates from import server", + "--no-show-dot-files ": "do not show dot files", "--no-show-file-name ": "do not show file name in view and edit", "--no-dropbox ": "disable dropbox integration", "--no-dropbox-token ": "unset dropbox token", diff --git a/man/cloudcmd.1 b/man/cloudcmd.1 index 9ce86c60..607ff241 100644 --- a/man/cloudcmd.1 +++ b/man/cloudcmd.1 @@ -31,6 +31,7 @@ programs in browser from any computer, mobile or tablet device. -p, --password set password -c, --config configuration file path --show-config show config values + --show-dot-files show dot files --show-file-name show file name in view and edit modes --editor set editor: "dword", "edward" or "deepword" --packer set packer: "tar" or "zip" @@ -66,6 +67,7 @@ programs in browser from any computer, mobile or tablet device. --dropbox-token set dropbox token --log enable logging --no-show-config do not show config values + --no-show-dot-files do not show dot files --no-server do not start server --no-auth disable authorization --no-online load scripts from local server diff --git a/server/route.mjs b/server/route.mjs index d6917ec5..675a0b7a 100644 --- a/server/route.mjs +++ b/server/route.mjs @@ -180,6 +180,7 @@ function buildIndex(config, html, data) { data, prefix: getPrefix(config), template: Template, + showDotFiles: config('showDotFiles'), }); return indexProcessing(config, { diff --git a/tmpl/config.hbs b/tmpl/config.hbs index dfcc4c09..a05db1e6 100644 --- a/tmpl/config.hbs +++ b/tmpl/config.hbs @@ -135,6 +135,12 @@ placeholder="Port" class="form-control"> +
  • + +