Skip to content

Commit 2553f45

Browse files
strickvlclaude
andcommitted
feat: replace individual UI flags with unified --custom-strings flag
Replace non-scalable individual flags (--login-title, --login-below, etc.) with a unified --custom-strings flag that accepts JSON file paths or inline JSON for UI customization. This leverages the existing i18n system for better scalability and maintainability. Changes: - Add --custom-strings flag with JSON validation - Extend i18n system to merge custom strings with defaults - Remove newly-added individual login/UI flags - Deprecate legacy --app-name and --welcome-text flags - Update login route to use unified i18n system - Add comprehensive tests for new functionality - Update documentation with migration guide and examples 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent bac8b42 commit 2553f45

File tree

7 files changed

+287
-272
lines changed

7 files changed

+287
-272
lines changed

docs/FAQ.md

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -83,37 +83,20 @@ The default location respects `$XDG_CONFIG_HOME`.
8383

8484
### Login page customization
8585

86-
You can customize the login page appearance using CLI flags or environment variables:
86+
You can customize the login page using the `--custom-strings` flag:
8787

88-
**CLI flags:**
8988
```bash
90-
code-server --login-title "My Code Server" \
91-
--login-env-password-msg "Password set via environment" \
92-
--password-placeholder "Enter password" \
93-
--submit-text "LOGIN"
89+
code-server --custom-strings '{"LOGIN_TITLE": "My Code Server", "WELCOME": "Welcome to my portal"}'
9490
```
9591

96-
**Environment variables:**
92+
Or use a JSON file:
9793
```bash
98-
export CS_LOGIN_TITLE="My Code Server"
99-
export CS_LOGIN_ENV_PASSWORD_MSG="Password set via environment"
100-
export CS_PASSWORD_PLACEHOLDER="Enter password"
101-
export CS_SUBMIT_TEXT="LOGIN"
102-
code-server
94+
code-server --custom-strings /path/to/custom-strings.json
10395
```
10496

105-
**Config file:**
106-
```yaml
107-
bind-addr: 127.0.0.1:8080
108-
auth: password
109-
password: your-password
110-
login-title: "My Code Server"
111-
login-env-password-msg: "Password set via environment"
112-
password-placeholder: "Enter password"
113-
submit-text: "LOGIN"
114-
```
97+
Legacy individual flags (`--app-name`, `--welcome-text`) are still supported but deprecated.
11598

116-
CLI flags take priority over environment variables, which take priority over config file settings.
99+
For detailed customization options and examples, see the [customization guide](./customization.md).
117100

118101
## How do I make my keyboard shortcuts work?
119102

docs/customization.md

Lines changed: 146 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,39 @@
11
# Login Page Customization
22

3-
code-server allows you to customize the login page appearance and messages through CLI arguments, environment variables, or configuration files.
4-
5-
## Available Customization Options
6-
7-
### Branding and Appearance
8-
- **Login Title**: Customize the main title on the login page
9-
- **Welcome Text**: Set custom welcome message
10-
- **App Name**: Change the application branding throughout the interface
11-
12-
### Login Messages
13-
- **Password Instructions**: Customize the message explaining where to find the password
14-
- **Environment Password Message**: Custom message when password is set via `$PASSWORD`
15-
- **Hashed Password Message**: Custom message when password is set via `$HASHED_PASSWORD`
16-
17-
### Form Elements
18-
- **Password Placeholder**: Custom placeholder text for the password field
19-
- **Submit Button**: Custom text for the login button
20-
21-
### Error Messages
22-
- **Rate Limit Message**: Custom message when login attempts are rate limited
23-
- **Missing Password**: Custom message for empty password submissions
24-
- **Incorrect Password**: Custom message for wrong password attempts
25-
26-
## Configuration Methods
27-
28-
### CLI Arguments
3+
code-server allows you to customize the login page appearance and messages through a unified `--custom-strings` flag or legacy CLI arguments.
4+
5+
## Recommended Approach: Custom Strings
6+
7+
The `--custom-strings` flag provides a scalable way to customize any UI text by leveraging the built-in internationalization system.
8+
9+
### Using JSON File
10+
11+
Create a JSON file with your customizations:
12+
13+
```json
14+
{
15+
"WELCOME": "Welcome to {{app}} Development Portal",
16+
"LOGIN_TITLE": "{{app}} Secure Access",
17+
"LOGIN_BELOW": "Please authenticate to continue",
18+
"PASSWORD_PLACEHOLDER": "Enter your access code",
19+
"SUBMIT": "AUTHENTICATE",
20+
"LOGIN_PASSWORD": "Check the config file at {{configFile}} for the password.",
21+
"LOGIN_USING_ENV_PASSWORD": "Access code provided via environment variable",
22+
"LOGIN_USING_HASHED_PASSWORD": "Access code configured securely",
23+
"LOGIN_RATE_LIMIT": "Too many attempts. Please wait before trying again.",
24+
"MISS_PASSWORD": "Access code is required",
25+
"INCORRECT_PASSWORD": "Invalid access code"
26+
}
27+
```
2928

3029
```bash
31-
code-server \
32-
--app-name "My Development Server" \
33-
--welcome-text "Welcome to the development environment" \
34-
--login-title "Secure Access Portal" \
35-
--login-below "Please authenticate to continue" \
36-
--password-placeholder "Enter your access code" \
37-
--submit-text "AUTHENTICATE" \
38-
--login-env-password-msg "Access code provided via environment variable" \
39-
--login-rate-limit-msg "Too many attempts. Please wait before trying again." \
40-
--missing-password-msg "Access code is required" \
41-
--incorrect-password-msg "Invalid access code"
30+
code-server --custom-strings /path/to/custom-strings.json
4231
```
4332

44-
### Environment Variables
45-
46-
Perfect for Docker deployments and containerized environments:
33+
### Using Inline JSON
4734

4835
```bash
49-
# Basic branding
50-
export CS_APP_NAME="My Development Server"
51-
export CS_WELCOME_TEXT="Welcome to the development environment"
52-
53-
# Login page customization
54-
export CS_LOGIN_TITLE="Secure Access Portal"
55-
export CS_LOGIN_BELOW="Please authenticate to continue"
56-
export CS_PASSWORD_PLACEHOLDER="Enter your access code"
57-
export CS_SUBMIT_TEXT="AUTHENTICATE"
58-
59-
# Message customization
60-
export CS_LOGIN_ENV_PASSWORD_MSG="Access code provided via environment variable"
61-
export CS_LOGIN_RATE_LIMIT_MSG="Too many attempts. Please wait before trying again."
62-
export CS_MISSING_PASSWORD_MSG="Access code is required"
63-
export CS_INCORRECT_PASSWORD_MSG="Invalid access code"
64-
65-
code-server
36+
code-server --custom-strings '{"WELCOME": "Welcome to My Dev Portal", "LOGIN_TITLE": "Development Access", "SUBMIT": "SIGN IN"}'
6637
```
6738

6839
### Configuration File
@@ -73,75 +44,142 @@ Add to your `~/.config/code-server/config.yaml`:
7344
bind-addr: 127.0.0.1:8080
7445
auth: password
7546
password: your-password
76-
77-
# Branding
78-
app-name: "My Development Server"
79-
welcome-text: "Welcome to the development environment"
80-
81-
# Login page
82-
login-title: "Secure Access Portal"
83-
login-below: "Please authenticate to continue"
84-
password-placeholder: "Enter your access code"
85-
submit-text: "AUTHENTICATE"
86-
87-
# Messages
88-
login-env-password-msg: "Access code provided via environment variable"
89-
login-rate-limit-msg: "Too many attempts. Please wait before trying again."
90-
missing-password-msg: "Access code is required"
91-
incorrect-password-msg: "Invalid access code"
47+
custom-strings: |
48+
{
49+
"WELCOME": "Welcome to {{app}} Development Portal",
50+
"LOGIN_TITLE": "{{app}} Secure Access",
51+
"PASSWORD_PLACEHOLDER": "Enter your access code",
52+
"SUBMIT": "AUTHENTICATE"
53+
}
9254
```
9355
56+
## Available Customization Keys
57+
58+
| Key | Description | Default | Supports {{app}} placeholder |
59+
|-----|-------------|---------|------------------------------|
60+
| `WELCOME` | Welcome message on login page | "Welcome to {{app}}" | ✅ |
61+
| `LOGIN_TITLE` | Main title on login page | "{{app}} login" | ✅ |
62+
| `LOGIN_BELOW` | Text below the login title | "Please log in below." | ❌ |
63+
| `PASSWORD_PLACEHOLDER` | Password field placeholder text | "PASSWORD" | ❌ |
64+
| `SUBMIT` | Login button text | "SUBMIT" | ❌ |
65+
| `LOGIN_PASSWORD` | Message for config file password | "Check the config file at {{configFile}} for the password." | ❌ |
66+
| `LOGIN_USING_ENV_PASSWORD` | Message when using `$PASSWORD` env var | "Password was set from $PASSWORD." | ❌ |
67+
| `LOGIN_USING_HASHED_PASSWORD` | Message when using `$HASHED_PASSWORD` env var | "Password was set from $HASHED_PASSWORD." | ❌ |
68+
| `LOGIN_RATE_LIMIT` | Rate limiting error message | "Login rate limited!" | ❌ |
69+
| `MISS_PASSWORD` | Empty password error message | "Missing password" | ❌ |
70+
| `INCORRECT_PASSWORD` | Wrong password error message | "Incorrect password" | ❌ |
71+
9472
## Docker Examples
9573

96-
### Basic Docker Deployment with Customization
74+
### Basic Docker Deployment
9775

9876
```bash
9977
docker run -it --name code-server -p 127.0.0.1:8080:8080 \
10078
-v "$PWD:/home/coder/project" \
101-
-e "CS_LOGIN_TITLE=Development Environment" \
102-
-e "CS_LOGIN_ENV_PASSWORD_MSG=Password configured in container environment" \
103-
-e "CS_PASSWORD_PLACEHOLDER=Enter development password" \
104-
-e "CS_SUBMIT_TEXT=ACCESS ENVIRONMENT" \
105-
codercom/code-server:latest
79+
-v "$PWD/custom-strings.json:/custom-strings.json" \
80+
codercom/code-server:latest --custom-strings /custom-strings.json
10681
```
10782

108-
### Corporate Branding Example
83+
### Corporate Branding with Inline JSON
10984

11085
```bash
11186
docker run -it --name code-server -p 127.0.0.1:8080:8080 \
11287
-v "$PWD:/home/coder/project" \
113-
-e "CS_APP_NAME=ACME Corporation Dev Portal" \
114-
-e "CS_LOGIN_TITLE=ACME Development Portal" \
115-
-e "CS_LOGIN_BELOW=Enter your corporate credentials" \
116-
-e "CS_PASSWORD_PLACEHOLDER=Corporate Password" \
117-
-e "CS_SUBMIT_TEXT=SIGN IN" \
118-
-e "CS_LOGIN_ENV_PASSWORD_MSG=Password managed by IT department" \
119-
codercom/code-server:latest
88+
codercom/code-server:latest --custom-strings '{
89+
"WELCOME": "Welcome to ACME Corporation Development Portal",
90+
"LOGIN_TITLE": "ACME Dev Portal Access",
91+
"LOGIN_BELOW": "Enter your corporate credentials",
92+
"PASSWORD_PLACEHOLDER": "Corporate Password",
93+
"SUBMIT": "SIGN IN",
94+
"LOGIN_USING_ENV_PASSWORD": "Password managed by IT department"
95+
}'
96+
```
97+
98+
## Legacy Support (Deprecated)
99+
100+
The following individual flags are still supported but deprecated. Use `--custom-strings` for new deployments:
101+
102+
```bash
103+
# Deprecated - use --custom-strings instead
104+
code-server \
105+
--app-name "My Development Server" \
106+
--welcome-text "Welcome to the development environment"
107+
```
108+
109+
These legacy flags will show deprecation warnings and may be removed in future versions.
110+
111+
## Migration Guide
112+
113+
### From Individual Flags to Custom Strings
114+
115+
**Old approach:**
116+
```bash
117+
code-server \
118+
--app-name "Dev Portal" \
119+
--welcome-text "Welcome to development" \
120+
--login-title "Portal Access"
121+
```
122+
123+
**New approach:**
124+
```bash
125+
code-server --custom-strings '{
126+
"WELCOME": "Welcome to development",
127+
"LOGIN_TITLE": "Portal Access"
128+
}'
129+
```
130+
131+
**Note:** The `--app-name` flag controls the `{{app}}` placeholder in templates. Use it alongside `--custom-strings` or customize the full text without placeholders.
132+
133+
### From Environment Variables
134+
135+
**Old approach:**
136+
```bash
137+
export CS_LOGIN_TITLE="Portal Access"
138+
export CS_WELCOME_TEXT="Welcome message"
139+
code-server
140+
```
141+
142+
**New approach:**
143+
```bash
144+
echo '{"LOGIN_TITLE": "Portal Access", "WELCOME": "Welcome message"}' > strings.json
145+
code-server --custom-strings strings.json
120146
```
121147

122-
## Priority Order
148+
## Benefits of Custom Strings
149+
150+
- ✅ **Scalable**: Add any new UI strings without new CLI flags
151+
- ✅ **Flexible**: Supports both files and inline JSON
152+
- ✅ **Future-proof**: Automatically supports new UI strings as they're added
153+
- ✅ **Organized**: All customizations in one place
154+
- ✅ **Version-controlled**: JSON files can be tracked in your repository
123155

124-
Settings are applied in the following priority order (highest to lowest):
156+
## Advanced Usage
125157

126-
1. **CLI arguments** - Highest priority
127-
2. **Environment variables** - Medium priority
128-
3. **Config file** - Lowest priority
158+
### Multi-language Support
129159

130-
This allows you to set defaults in your config file and override them with environment variables or CLI arguments as needed.
160+
Create different JSON files for different languages:
131161

132-
## Complete Reference
162+
```bash
163+
# English
164+
code-server --custom-strings /config/strings-en.json
165+
166+
# Spanish
167+
code-server --custom-strings /config/strings-es.json --locale es
168+
```
133169

134-
| CLI Argument | Environment Variable | Description |
135-
|--------------|---------------------|-------------|
136-
| `--app-name` | `CS_APP_NAME` | Application name used throughout the interface |
137-
| `--welcome-text` | `CS_WELCOME_TEXT` | Welcome message on login page |
138-
| `--login-title` | `CS_LOGIN_TITLE` | Main title on login page |
139-
| `--login-below` | `CS_LOGIN_BELOW` | Text below the login title |
140-
| `--password-placeholder` | `CS_PASSWORD_PLACEHOLDER` | Password field placeholder text |
141-
| `--submit-text` | `CS_SUBMIT_TEXT` | Login button text |
142-
| `--login-password-msg` | `CS_LOGIN_PASSWORD_MSG` | Message for config file password |
143-
| `--login-env-password-msg` | `CS_LOGIN_ENV_PASSWORD_MSG` | Message when using `$PASSWORD` env var |
144-
| `--login-hashed-password-msg` | `CS_LOGIN_HASHED_PASSWORD_MSG` | Message when using `$HASHED_PASSWORD` env var |
145-
| `--login-rate-limit-msg` | `CS_LOGIN_RATE_LIMIT_MSG` | Rate limiting error message |
146-
| `--missing-password-msg` | `CS_MISSING_PASSWORD_MSG` | Empty password error message |
147-
| `--incorrect-password-msg` | `CS_INCORRECT_PASSWORD_MSG` | Wrong password error message |
170+
### Dynamic Customization
171+
172+
Generate JSON dynamically in scripts:
173+
174+
```bash
175+
#!/bin/bash
176+
COMPANY_NAME="ACME Corp"
177+
cat > /tmp/strings.json << EOF
178+
{
179+
"WELCOME": "Welcome to ${COMPANY_NAME} Development Portal",
180+
"LOGIN_TITLE": "${COMPANY_NAME} Access Portal"
181+
}
182+
EOF
183+
184+
code-server --custom-strings /tmp/strings.json
185+
```

0 commit comments

Comments
 (0)