mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
feature(cloudcmd) --name: add ability to set tab name in web browser
This commit is contained in:
parent
9ef0dd02dd
commit
9cdca9efe5
12 changed files with 93 additions and 20 deletions
15
HELP.md
15
HELP.md
|
|
@ -80,11 +80,12 @@ Cloud Commander supports command line parameters:
|
|||
| `--progress` | show progress of file operations
|
||||
| `--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
|
||||
`--config-dialog` | enable config dialog
|
||||
`--console` | enable console
|
||||
`--terminal` | enable terminal
|
||||
`--terminal-path` | set terminal path
|
||||
| `--config-dialog` | enable config dialog
|
||||
| `--console` | enable console
|
||||
| `--terminal` | enable terminal
|
||||
| `--terminal-path` | set terminal path
|
||||
| `--no-server` | do not start server
|
||||
| `--no-auth` | disable authorization
|
||||
| `--no-online` | load scripts from local server
|
||||
|
|
@ -95,6 +96,8 @@ Cloud Commander supports command line parameters:
|
|||
| `--no-config-dialog` | disable config dialog
|
||||
| `--no-console` | disable console
|
||||
| `--no-terminal` | disable terminal
|
||||
| `--no-name` | set empty tab name in web browser
|
||||
|
||||
|
||||
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.
|
||||
|
|
@ -296,9 +299,10 @@ Here is description of options:
|
|||
|
||||
```js
|
||||
{
|
||||
"name" : "", /* set tab name in web browser */
|
||||
"auth" : false, /* enable http authentication */
|
||||
"username" : "root", /* username for authentication */
|
||||
"password" : "toor", /* password hash for authentication*/
|
||||
"password" : "toor", /* password hash for authentication */
|
||||
"algo" : "sha512WithRSAEncryption", /* cryptographic algorithm */
|
||||
"editor" : "edward", /* default, could be "dword" or "edward" */
|
||||
"packer" : "tar", /* default, could be "tar" or "zip" */
|
||||
|
|
@ -329,6 +333,7 @@ Here is description of options:
|
|||
|
||||
Some config options can be overridden with `environment variables` such:
|
||||
|
||||
- `CLOUDCMD_NAME` - set tab name in web browser
|
||||
- `CLOUDCMD_EDITOR` - set editor
|
||||
- `CLOUDCMD_TERMINAL` - enable terminal
|
||||
- `CLOUDCMD_TERMINAL_PATH` - set terminal path
|
||||
|
|
|
|||
5
app.json
5
app.json
|
|
@ -37,6 +37,11 @@
|
|||
"value": "false",
|
||||
"required": false
|
||||
},
|
||||
"CLOUDCMD_NAME": {
|
||||
"description": "set tab name in web browser",
|
||||
"value": "",
|
||||
"required": false
|
||||
},
|
||||
"CLOUDCMD_AUTH": {
|
||||
"description": "enable authorization",
|
||||
"value": "false",
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ const choose = (a, b) => {
|
|||
const argv = process.argv;
|
||||
const args = require('minimist')(argv.slice(2), {
|
||||
string: [
|
||||
'name',
|
||||
'port',
|
||||
'password',
|
||||
'username',
|
||||
|
|
@ -46,6 +47,7 @@ const args = require('minimist')(argv.slice(2), {
|
|||
],
|
||||
default: {
|
||||
server : true,
|
||||
name : env('name') || config('name'),
|
||||
auth : choose(env('auth'), config('auth')),
|
||||
port : config('port'),
|
||||
online : config('online'),
|
||||
|
|
@ -95,6 +97,7 @@ function main() {
|
|||
|
||||
port(args.port);
|
||||
|
||||
config('name', args.name);
|
||||
config('auth', args.auth);
|
||||
config('online', args.online);
|
||||
config('open', args.open);
|
||||
|
|
|
|||
|
|
@ -461,8 +461,12 @@ function CmdProto() {
|
|||
|
||||
let path = DOM.getCurrentDirPath();
|
||||
|
||||
const name = CloudCmd.config('name');
|
||||
if (path !== pathWas) {
|
||||
DOM.setTitle(getTitle(path));
|
||||
DOM.setTitle(getTitle({
|
||||
name,
|
||||
path,
|
||||
}));
|
||||
|
||||
/* history could be present
|
||||
* but it should be false
|
||||
|
|
|
|||
|
|
@ -13,7 +13,9 @@ const Images = require('../dom/images');
|
|||
const Events = require('../dom/events');
|
||||
const Files = require('../dom/files');
|
||||
|
||||
const {Dialog} = DOM;
|
||||
const {getTitle} = require('../../common/cloudfunc');
|
||||
|
||||
const {Dialog, setTitle} = DOM;
|
||||
|
||||
const TITLE = 'Config';
|
||||
const alert = currify(Dialog.alert, TITLE);
|
||||
|
|
@ -200,7 +202,9 @@ function onChange(el) {
|
|||
const data = input.getValue(name, Element);
|
||||
const type = el.type;
|
||||
|
||||
if (type === 'checkbox')
|
||||
if (name === 'name')
|
||||
onNameChange(data);
|
||||
else if (type === 'checkbox')
|
||||
if (/^(diff|buffer|dirStorage)$/.test(name))
|
||||
onLSChange(name, data);
|
||||
else if (name === 'localStorage')
|
||||
|
|
@ -287,6 +291,12 @@ function onAuthChange(checked) {
|
|||
elPassword.disabled = !checked;
|
||||
}
|
||||
|
||||
function onNameChange(name) {
|
||||
setTitle(getTitle({
|
||||
name
|
||||
}));
|
||||
}
|
||||
|
||||
function onKey({keyCode, target}) {
|
||||
switch (keyCode) {
|
||||
case Key.ESC:
|
||||
|
|
|
|||
|
|
@ -33,8 +33,20 @@ module.exports.formatMsg = (msg, name, status) => {
|
|||
* Функция возвращает заголовок веб страницы
|
||||
* @path
|
||||
*/
|
||||
module.exports.getTitle = (path) => {
|
||||
return NAME + ' - ' + (path || Path());
|
||||
module.exports.getTitle = (options) => {
|
||||
options = options || {};
|
||||
|
||||
const path = options.path || Path();
|
||||
const name = options.name;
|
||||
|
||||
const array = [
|
||||
name || NAME,
|
||||
path,
|
||||
];
|
||||
|
||||
return array
|
||||
.filter(Boolean)
|
||||
.join(' - ');
|
||||
};
|
||||
|
||||
/** Функция получает адреса каждого каталога в пути
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"name": "",
|
||||
"auth": false,
|
||||
"username": "root",
|
||||
"password": "2b64f2e3f9fee1942af9ff60d40aa5a719db33b8ba8dd4864bb4f11e25ca2bee00907de32a59429602336cac832c8f2eeff5177cc14c864dd116c8bf6ca5d9a9",
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
"--terminal ": "enable terminal",
|
||||
"--terminal-path ": "set terminal path",
|
||||
"--open ": "open web browser when server started",
|
||||
"--name ": "set tab name in web browser",
|
||||
"--no-server ": "do not start server",
|
||||
"--no-auth ": "disable authorization",
|
||||
"--no-online ": "load scripts from local server",
|
||||
|
|
@ -30,5 +31,6 @@
|
|||
"--no-one-panel-mode ": "unset one panel mode",
|
||||
"--no-config-dialog ": "disable config dialog",
|
||||
"--no-console ": "disable console",
|
||||
"--no-terminal ": "disable terminal"
|
||||
"--no-terminal ": "disable terminal",
|
||||
"--no-name ": "set default tab name in web browser"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,12 +38,13 @@ programs in browser from any computer, mobile or tablet device.
|
|||
--port set port number
|
||||
--progress show progress of file operations
|
||||
--html-dialogs use html dialogs
|
||||
--open open web browser when server started
|
||||
--one-panel-mode set one panel mode
|
||||
--config-dialog enable config dialog
|
||||
--console enable console
|
||||
--terminal enable terminal
|
||||
--terminal-path set terminal path
|
||||
--open open web browser when server started
|
||||
--name set tab name in web browser
|
||||
--no-auth disable authorization
|
||||
--no-server do not start server
|
||||
--no-online load scripts from local server
|
||||
|
|
@ -54,6 +55,7 @@ programs in browser from any computer, mobile or tablet device.
|
|||
--no-config-dialog disable config dialog
|
||||
--no-console disable console
|
||||
--no-terminal disable terminal
|
||||
--no-name set default tab name in web browser
|
||||
|
||||
.SH RESOURCES AND DOCUMENTATION
|
||||
|
||||
|
|
|
|||
|
|
@ -107,8 +107,12 @@ function indexProcessing(options) {
|
|||
className : ''
|
||||
});
|
||||
|
||||
const name = config('name');
|
||||
|
||||
data = rendy(data, {
|
||||
title: CloudFunc.getTitle(),
|
||||
title: CloudFunc.getTitle({
|
||||
name,
|
||||
}),
|
||||
fm: left + right,
|
||||
prefix: prefix(),
|
||||
config: JSON.stringify(config('*')),
|
||||
|
|
|
|||
|
|
@ -5,7 +5,9 @@ const COMMONDIR = DIR + 'common/';
|
|||
const TMPLDIR = DIR + 'tmpl/';
|
||||
|
||||
const Util = require(COMMONDIR + 'util');
|
||||
const CloudFunc = require(COMMONDIR + 'cloudfunc');
|
||||
const CloudFuncPath = COMMONDIR + 'cloudfunc';
|
||||
|
||||
const CloudFunc = require(CloudFuncPath);
|
||||
|
||||
const files = require('files-io');
|
||||
const currify = require('currify');
|
||||
|
|
@ -151,22 +153,37 @@ test('cloudfunc: formatMsg', (t) => {
|
|||
});
|
||||
|
||||
test('cloudfunc: getTitle', (t) => {
|
||||
const name = COMMONDIR + 'cloudfunc';
|
||||
const CloudFunc = fresh(CloudFuncPath);
|
||||
|
||||
const CloudFunc = fresh(name);
|
||||
const result = CloudFunc.getTitle();
|
||||
|
||||
t.equal(result, 'Cloud Commander - /');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('cloudfunc: getTitle', (t) => {
|
||||
const name = COMMONDIR + 'cloudfunc';
|
||||
test('cloudfunc: getTitle: no name', (t) => {
|
||||
const CloudFunc = fresh(CloudFuncPath);
|
||||
const path = '/hello/world';
|
||||
|
||||
const CloudFunc = fresh(name);
|
||||
const result = CloudFunc.getTitle('/hello/world');
|
||||
const result = CloudFunc.getTitle({
|
||||
path
|
||||
});
|
||||
|
||||
t.equal(result, 'Cloud Commander - /hello/world');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('cloudfunc: getTitle: name, path', (t) => {
|
||||
const CloudFunc = fresh(CloudFuncPath);
|
||||
const name = 'hello';
|
||||
const path = '/hello/world';
|
||||
|
||||
const result = CloudFunc.getTitle({
|
||||
name,
|
||||
path,
|
||||
});
|
||||
|
||||
t.equal(result, 'hello - /hello/world');
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -93,6 +93,14 @@
|
|||
<input data-name="js-showKeysPanel" type="checkbox" {{ showKeysPanel }}>
|
||||
Show keys panel
|
||||
</label>
|
||||
</li>
|
||||
<li>
|
||||
<input
|
||||
data-name="js-name"
|
||||
title="Name"
|
||||
value="{{ name }}"
|
||||
placeholder="name"
|
||||
class="form-control">
|
||||
</li>
|
||||
<li>
|
||||
<input
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue