feat: add fontFamily, letterSpacing, lineHeight
This commit is contained in:
parent
140e1e24b1
commit
97f3088780
5 changed files with 76 additions and 10 deletions
24
README.md
24
README.md
|
@ -107,7 +107,13 @@ docker run --name webssh2 -d -p 2222:2222 -v `pwd`/app/config.json:/usr/src/conf
|
||||||
|
|
||||||
* **bellStyle** - _string_ - Style of terminal bell: ("sound"|"none"). **Default:** "sound". **Enforced Values:** "sound", "none"
|
* **bellStyle** - _string_ - Style of terminal bell: ("sound"|"none"). **Default:** "sound". **Enforced Values:** "sound", "none"
|
||||||
|
|
||||||
* **fontSize** - _integer_ - Size of terminal font. **Default:** "12".
|
* **fontSize** - _number_ - Size of terminal font. **Default:** 12
|
||||||
|
|
||||||
|
* **fontFamily** - _string_ - Font family
|
||||||
|
|
||||||
|
* **letterSpacing** - _number_ - Letter spacing
|
||||||
|
|
||||||
|
* **lineHeight** - _number_ - Line height
|
||||||
|
|
||||||
## GET request vars
|
## GET request vars
|
||||||
|
|
||||||
|
@ -129,7 +135,13 @@ docker run --name webssh2 -d -p 2222:2222 -v `pwd`/app/config.json:/usr/src/conf
|
||||||
|
|
||||||
* **bellStyle** - _string_ - Style of terminal bell: ("sound"|"none"). **Default:** "sound". **Enforced Values:** "sound", "none"
|
* **bellStyle** - _string_ - Style of terminal bell: ("sound"|"none"). **Default:** "sound". **Enforced Values:** "sound", "none"
|
||||||
|
|
||||||
* **fontSize** - _integer_ - Size of terminal font. **Default:** "12".
|
* **fontSize** - _number_ - Size of terminal font. **Default:** "12"
|
||||||
|
|
||||||
|
* **fontFamily** - _string_ - Font family
|
||||||
|
|
||||||
|
* **letterSpacing** - _number_ - Letter spacing
|
||||||
|
|
||||||
|
* **lineHeight** - _integer_ - Line height
|
||||||
|
|
||||||
## Headers
|
## Headers
|
||||||
|
|
||||||
|
@ -174,7 +186,13 @@ docker run --name webssh2 -d -p 2222:2222 -v `pwd`/app/config.json:/usr/src/conf
|
||||||
|
|
||||||
* **terminal.bellStyle** - _string_ - Style of terminal bell: (sound|none). **Default:** "sound".
|
* **terminal.bellStyle** - _string_ - Style of terminal bell: (sound|none). **Default:** "sound".
|
||||||
|
|
||||||
* **terminal.fontSize** - _integer_ - Size of terminal font. **Default:** 14.
|
* **terminal.fontSize** - _number_ - Size of terminal font. **Default:** 14.
|
||||||
|
|
||||||
|
* **terminal.fontFamily** - _string_ - Font family
|
||||||
|
|
||||||
|
* **terminal.letterSpacing** - _number_ - Letter spacing
|
||||||
|
|
||||||
|
* **terminal.lineHeight** - _number_ - Line height
|
||||||
|
|
||||||
* **header.text** - _string_ - Specify header text, defaults to `My Header` but may also be set to `null`. When set to `null` no header bar will be displayed on the client.
|
* **header.text** - _string_ - Specify header text, defaults to `My Header` but may also be set to `null`. When set to `null` no header bar will be displayed on the client.
|
||||||
|
|
||||||
|
|
|
@ -176,6 +176,9 @@ socket.on(
|
||||||
tabStopWidth: number;
|
tabStopWidth: number;
|
||||||
bellStyle: 'none' | 'sound';
|
bellStyle: 'none' | 'sound';
|
||||||
fontSize: number;
|
fontSize: number;
|
||||||
|
fontFamily: string;
|
||||||
|
letterSpacing: number;
|
||||||
|
lineHeight: number;
|
||||||
}) => {
|
}) => {
|
||||||
term.options = data;
|
term.options = data;
|
||||||
}
|
}
|
||||||
|
|
4
app/package-lock.json
generated
4
app/package-lock.json
generated
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "webssh2",
|
"name": "webssh2",
|
||||||
"version": "0.4.7-alpha.1",
|
"version": "0.4.7-alpha.2",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "webssh2",
|
"name": "webssh2",
|
||||||
"version": "0.4.7-alpha.1",
|
"version": "0.4.7-alpha.2",
|
||||||
"license": "SEE LICENSE IN FILE - LICENSE",
|
"license": "SEE LICENSE IN FILE - LICENSE",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"basic-auth": "~2.0.1",
|
"basic-auth": "~2.0.1",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "webssh2",
|
"name": "webssh2",
|
||||||
"version": "0.4.7-alpha.1",
|
"version": "0.4.7-alpha.2",
|
||||||
"ignore": [
|
"ignore": [
|
||||||
".gitignore"
|
".gitignore"
|
||||||
],
|
],
|
||||||
|
|
|
@ -30,7 +30,16 @@ exports.connect = function connect(req, res) {
|
||||||
let { host, port } = config.ssh;
|
let { host, port } = config.ssh;
|
||||||
let { text: header, background: headerBackground } = config.header;
|
let { text: header, background: headerBackground } = config.header;
|
||||||
let { term: sshterm, readyTimeout } = config.ssh;
|
let { term: sshterm, readyTimeout } = config.ssh;
|
||||||
let { cursorBlink, scrollback, tabStopWidth, bellStyle, fontSize } = config.terminal;
|
let {
|
||||||
|
cursorBlink,
|
||||||
|
scrollback,
|
||||||
|
tabStopWidth,
|
||||||
|
bellStyle,
|
||||||
|
fontSize,
|
||||||
|
fontFamily,
|
||||||
|
letterSpacing,
|
||||||
|
lineHeight,
|
||||||
|
} = config.terminal;
|
||||||
|
|
||||||
// capture, assign, and validate variables
|
// capture, assign, and validate variables
|
||||||
|
|
||||||
|
@ -50,59 +59,92 @@ exports.connect = function connect(req, res) {
|
||||||
|
|
||||||
if (req.body.port && validator.isInt(`${req.body.port}`, { min: 1, max: 65535 }))
|
if (req.body.port && validator.isInt(`${req.body.port}`, { min: 1, max: 65535 }))
|
||||||
port = req.body.port;
|
port = req.body.port;
|
||||||
|
|
||||||
if (req.body.header) header = req.body.header;
|
if (req.body.header) header = req.body.header;
|
||||||
|
|
||||||
if (req.body.headerBackground) {
|
if (req.body.headerBackground) {
|
||||||
headerBackground = req.body.headerBackground;
|
headerBackground = req.body.headerBackground;
|
||||||
console.log(`background: ${req.body.headerBackground}`);
|
console.log(`background: ${req.body.headerBackground}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (req.body.sshterm && /^(([a-z]|[A-Z]|\d|[!^(){}\-_~])+)?\w$/.test(req.body.sshterm))
|
if (req.body.sshterm && /^(([a-z]|[A-Z]|\d|[!^(){}\-_~])+)?\w$/.test(req.body.sshterm))
|
||||||
sshterm = req.body.sshterm;
|
sshterm = req.body.sshterm;
|
||||||
|
|
||||||
if (req.body.cursorBlink && validator.isBoolean(`${req.body.cursorBlink}`))
|
if (req.body.cursorBlink && validator.isBoolean(`${req.body.cursorBlink}`))
|
||||||
cursorBlink = parseBool(req.body.cursorBlink);
|
cursorBlink = parseBool(req.body.cursorBlink);
|
||||||
|
|
||||||
if (req.body.scrollback && validator.isInt(`${req.body.scrollback}`, { min: 1, max: 200000 }))
|
if (req.body.scrollback && validator.isInt(`${req.body.scrollback}`, { min: 1, max: 200000 }))
|
||||||
scrollback = req.body.scrollback;
|
scrollback = req.body.scrollback;
|
||||||
if (req.body.tabStopWidth) tabStopWidth = req.body.tabStopWidth;
|
|
||||||
if (req.body.tabStopWidth && validator.isInt(`${req.body.tabStopWidth}`, { min: 1, max: 100 }))
|
if (req.body.tabStopWidth && validator.isInt(`${req.body.tabStopWidth}`, { min: 1, max: 100 }))
|
||||||
tabStopWidth = req.body.tabStopWidth;
|
tabStopWidth = req.body.tabStopWidth;
|
||||||
|
|
||||||
if (req.body.bellStyle && ['sound', 'none'].indexOf(req.body.bellStyle) > -1)
|
if (req.body.bellStyle && ['sound', 'none'].indexOf(req.body.bellStyle) > -1)
|
||||||
bellStyle = req.body.bellStyle;
|
bellStyle = req.body.bellStyle;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
req.body.readyTimeout &&
|
req.body.readyTimeout &&
|
||||||
validator.isInt(`${req.body.readyTimeout}`, { min: 1, max: 300000 })
|
validator.isInt(`${req.body.readyTimeout}`, { min: 1, max: 300000 })
|
||||||
)
|
)
|
||||||
readyTimeout = req.body.readyTimeout;
|
readyTimeout = req.body.readyTimeout;
|
||||||
if (req.body.fontSize && validator.isInt(`${req.body.fontSize}`, { min: 1, max: 300000 }))
|
|
||||||
|
if (req.body.fontSize && validator.isNumeric(`${req.body.fontSize}`))
|
||||||
fontSize = req.body.fontSize;
|
fontSize = req.body.fontSize;
|
||||||
|
|
||||||
|
if (req.body.fontFamily) fontFamily = req.body.fontFamily;
|
||||||
|
|
||||||
|
if (req.body.letterSpacing && validator.isNumeric(`${req.body.letterSpacing}`))
|
||||||
|
letterSpacing = req.body.letterSpacing;
|
||||||
|
|
||||||
|
if (req.body.lineHeight && validator.isNumeric(`${req.body.lineHeight}`))
|
||||||
|
lineHeight = req.body.lineHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (req.method === 'GET') {
|
if (req.method === 'GET') {
|
||||||
if (req.query?.port && validator.isInt(`${req.query.port}`, { min: 1, max: 65535 }))
|
if (req.query?.port && validator.isInt(`${req.query.port}`, { min: 1, max: 65535 }))
|
||||||
port = req.query.port;
|
port = req.query.port;
|
||||||
|
|
||||||
if (req.query?.header) header = req.query.header;
|
if (req.query?.header) header = req.query.header;
|
||||||
|
|
||||||
if (req.query?.headerBackground) headerBackground = req.query.headerBackground;
|
if (req.query?.headerBackground) headerBackground = req.query.headerBackground;
|
||||||
|
|
||||||
if (req.query?.sshterm && /^(([a-z]|[A-Z]|\d|[!^(){}\-_~])+)?\w$/.test(req.query.sshterm))
|
if (req.query?.sshterm && /^(([a-z]|[A-Z]|\d|[!^(){}\-_~])+)?\w$/.test(req.query.sshterm))
|
||||||
sshterm = req.query.sshterm;
|
sshterm = req.query.sshterm;
|
||||||
|
|
||||||
if (req.query?.cursorBlink && validator.isBoolean(`${req.query.cursorBlink}`))
|
if (req.query?.cursorBlink && validator.isBoolean(`${req.query.cursorBlink}`))
|
||||||
cursorBlink = parseBool(req.query.cursorBlink);
|
cursorBlink = parseBool(req.query.cursorBlink);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
req.query?.scrollback &&
|
req.query?.scrollback &&
|
||||||
validator.isInt(`${req.query.scrollback}`, { min: 1, max: 200000 })
|
validator.isInt(`${req.query.scrollback}`, { min: 1, max: 200000 })
|
||||||
)
|
)
|
||||||
scrollback = req.query.scrollback;
|
scrollback = req.query.scrollback;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
req.query?.tabStopWidth &&
|
req.query?.tabStopWidth &&
|
||||||
validator.isInt(`${req.query.tabStopWidth}`, { min: 1, max: 100 })
|
validator.isInt(`${req.query.tabStopWidth}`, { min: 1, max: 100 })
|
||||||
)
|
)
|
||||||
tabStopWidth = req.query.tabStopWidth;
|
tabStopWidth = req.query.tabStopWidth;
|
||||||
|
|
||||||
if (req.query?.bellStyle && ['sound', 'none'].indexOf(req.query.bellStyle) > -1)
|
if (req.query?.bellStyle && ['sound', 'none'].indexOf(req.query.bellStyle) > -1)
|
||||||
bellStyle = req.query.bellStyle;
|
bellStyle = req.query.bellStyle;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
req.query?.readyTimeout &&
|
req.query?.readyTimeout &&
|
||||||
validator.isInt(`${req.query.readyTimeout}`, { min: 1, max: 300000 })
|
validator.isInt(`${req.query.readyTimeout}`, { min: 1, max: 300000 })
|
||||||
)
|
)
|
||||||
readyTimeout = req.query.readyTimeout;
|
readyTimeout = req.query.readyTimeout;
|
||||||
if (req.query?.fontSize && validator.isInt(`${req.query.fontSize}`, { min: 1, max: 300000 }))
|
|
||||||
|
if (req.query?.fontSize && validator.isNumeric(`${req.query.fontSize}`))
|
||||||
fontSize = req.query.fontSize;
|
fontSize = req.query.fontSize;
|
||||||
|
|
||||||
|
if (req.query?.fontFamily) fontFamily = req.query.fontFamily;
|
||||||
|
|
||||||
|
if (req.query?.lineHeight && validator.isNumeric(`${req.query.lineHeight}`))
|
||||||
|
lineHeight = req.query.lineHeight;
|
||||||
|
|
||||||
|
if (req.query?.letterSpacing && validator.isNumeric(`${req.query.letterSpacing}`))
|
||||||
|
letterSpacing = req.query.letterSpacing;
|
||||||
}
|
}
|
||||||
|
|
||||||
req.session.ssh = {
|
req.session.ssh = {
|
||||||
|
@ -125,6 +167,9 @@ exports.connect = function connect(req, res) {
|
||||||
tabStopWidth,
|
tabStopWidth,
|
||||||
bellStyle,
|
bellStyle,
|
||||||
fontSize,
|
fontSize,
|
||||||
|
fontFamily,
|
||||||
|
letterSpacing,
|
||||||
|
lineHeight,
|
||||||
},
|
},
|
||||||
allowreplay:
|
allowreplay:
|
||||||
config.options.challengeButton ||
|
config.options.challengeButton ||
|
||||||
|
|
Loading…
Reference in a new issue