Skip to content

Commit 1dcfee2

Browse files
committed
add customization options for the login page
1 parent b2f043a commit 1dcfee2

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

src/browser/pages/login.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
http-equiv="Content-Security-Policy"
1111
content="style-src 'self'; script-src 'self' 'unsafe-inline'; manifest-src 'self'; img-src 'self' data:; font-src 'self' data:;"
1212
/>
13-
<title>code-server login</title>
13+
<title>{{APP_NAME}} login</title>
1414
<link rel="icon" href="{{CS_STATIC_BASE}}/src/browser/media/favicon-dark-support.svg" />
1515
<link rel="alternate icon" href="{{CS_STATIC_BASE}}/src/browser/media/favicon.ico" />
1616
<link rel="manifest" href="{{BASE}}/manifest.json" crossorigin="use-credentials" />
@@ -24,7 +24,7 @@
2424
<div class="center-container">
2525
<div class="card-box">
2626
<div class="header">
27-
<h1 class="main">Welcome to code-server</h1>
27+
<h1 class="main">{{WELCOME_TEXT}}</h1>
2828
<div class="sub">Please log in below. {{PASSWORD_MSG}}</div>
2929
</div>
3030
<div class="content">

src/node/cli.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ export interface UserProvidedArgs extends UserProvidedCodeArgs {
8484
"ignore-last-opened"?: boolean
8585
link?: OptionalString
8686
verbose?: boolean
87+
"app-name"?: string
88+
"welcome-text"?: string
8789
/* Positional arguments. */
8890
_?: string[]
8991
}
@@ -233,7 +235,16 @@ export const options: Options<Required<UserProvidedArgs>> = {
233235

234236
log: { type: LogLevel },
235237
verbose: { type: "boolean", short: "vvv", description: "Enable verbose logging." },
236-
238+
"app-name": {
239+
type: "string",
240+
short: "an",
241+
description: "The name to use in branding. Will be shown in titlebar and welcome message",
242+
},
243+
"welcome-text": {
244+
type: "string",
245+
short: "w",
246+
description: "Text to show on login page",
247+
},
237248
link: {
238249
type: OptionalString,
239250
description: `

src/node/routes/login.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ export class RateLimiter {
2828

2929
const getRoot = async (req: Request, error?: Error): Promise<string> => {
3030
const content = await fs.readFile(path.join(rootPath, "src/browser/pages/login.html"), "utf8")
31+
const appName = req.args["app-name"] || "code-server"
32+
const welcomeText = req.args["welcome-text"] || `Welcome to ${appName}`
3133
let passwordMsg = `Check the config file at ${humanPath(os.homedir(), req.args.config)} for the password.`
3234
if (req.args.usingEnvPassword) {
3335
passwordMsg = "Password was set from $PASSWORD."
@@ -38,6 +40,8 @@ const getRoot = async (req: Request, error?: Error): Promise<string> => {
3840
return replaceTemplates(
3941
req,
4042
content
43+
.replace(/{{APP_NAME}}/g, appName)
44+
.replace(/{{WELCOME_TEXT}}/g, welcomeText)
4145
.replace(/{{PASSWORD_MSG}}/g, passwordMsg)
4246
.replace(/{{ERROR}}/, error ? `<div class="error">${escapeHtml(error.message)}</div>` : ""),
4347
)

0 commit comments

Comments
 (0)