Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add comprehensive login page customization options#7374

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
strickvl wants to merge15 commits intocoder:main
base:main
Choose a base branch
Loading
fromstrickvl:main

Conversation

strickvl
Copy link

@strickvlstrickvl commentedJun 12, 2025
edited
Loading

This PR introduces a unified, scalable approach for customizing code-server's login page UI through a single--i18n flag that leverages the existing internationalization system. The implementation has evolved from multiple specific CLI flags to a clean, file-based configuration system that supports comprehensive UI customization while maintaining simplicity and predictability.

Core Features

  • Single--i18n flag that accepts JSON file paths for UI customization
  • Leverages existing i18n infrastructure for robust string management and placeholder support
  • File-based configuration following Unix conventions for clarity and maintainability
  • Comprehensive error handling with clear, actionable error messages
  • Full documentation with practical examples and migration guidance

Usage

# Create custom strings fileecho'{  "WELCOME": "Welcome to {{app}}",  "LOGIN_TITLE": "{{app}} Access Portal",  "LOGIN_BELOW": "Please log in to continue",  "PASSWORD_PLACEHOLDER": "Enter Password"}'> custom-strings.json# Use with code-servercode-server --i18n ./custom-strings.json

Technical Implementation

Core Changes

  • src/node/i18n/index.ts: EnhancedloadCustomStrings() with file-only approach and comprehensive error handling
  • src/node/cli.ts: Added--i18n flag with clear description
  • src/node/main.ts: Integrated custom string loading into server startup
  • src/node/routes/login.ts: Updated to use i18n system for all UI strings

Documentation

  • Complete documentation indocs/guide.md with practical examples
  • Migration guide from deprecated--welcome-text flag
  • Integration examples showing--app-name +--i18n usage
  • Available keys reference pointing to source files

Migration Path

From Deprecated Flags

# Old (deprecated)code-server --welcome-text"Welcome to development"# Newecho'{"WELCOME": "Welcome to development"}'> strings.jsoncode-server --i18n ./strings.json

Backward Compatibility

  • Existing--app-name flag continues to work and provides{{app}} placeholder
  • Deprecated--welcome-text continues to work but shows deprecation warning

Files Changed

Core Implementation

  • src/node/i18n/index.ts - Enhanced custom string loading
  • src/node/cli.ts - Added--i18n flag
  • src/node/main.ts - Integrated custom string loading
  • src/node/routes/login.ts - Updated to use i18n system

Testing & Documentation

  • test/unit/node/i18n.test.ts - Comprehensive test suite (new)
  • test/unit/node/cli.test.ts - Updated CLI tests
  • docs/guide.md - Complete documentation with examples

Add CLI arguments and environment variables to customize all login page elements:- Login title, subtitle, and welcome text- Password field placeholder and submit button text- Password instruction messages (config file, env var, hashed)- Error messages (rate limit, missing/incorrect password)New CLI options:  --login-title, --login-below, --password-placeholder, --submit-text  --login-password-msg, --login-env-password-msg, --login-hashed-password-msg  --login-rate-limit-msg, --missing-password-msg, --incorrect-password-msgNew environment variables:  CS_LOGIN_TITLE, CS_LOGIN_BELOW, CS_PASSWORD_PLACEHOLDER, CS_SUBMIT_TEXT  CS_LOGIN_PASSWORD_MSG, CS_LOGIN_ENV_PASSWORD_MSG, CS_LOGIN_HASHED_PASSWORD_MSG  CS_LOGIN_RATE_LIMIT_MSG, CS_MISSING_PASSWORD_MSG, CS_INCORRECT_PASSWORD_MSGFeatures:- Full backwards compatibility with existing --app-name/--welcome-text- HTML escaping for security (prevents XSS)- Config file support (YAML)- Priority: CLI args > env vars > config file > defaults- Internationalization preserved for non-customized messagesPerfect for Docker deployments and corporate branding.🤖 Generated with [Claude Code](https://claude.ai/code)Co-Authored-By: Claude <noreply@anthropic.com>
@strickvlstrickvl requested a review froma team as acode ownerJune 12, 2025 17:19
@code-asher
Copy link
Member

code-asher commentedJun 13, 2025
edited
Loading

Thank you for the contribution!

Thinking out loud, my first impression is that the flags are not scaling well. Since we have this concept of language files that we can use for strings in the app, I wonder if we can re-use this for user-provided strings as well? Maybe we have a flag that accepts ajson file (or accepts raw json itself) and then we can pass that to the i18n library (merged with the default language file).

Then, all strings, including future ones, will automatically be available for configuration. What do you think?

We could then also deprecate--welcome-msg and--app-name.

strickvl reacted with thumbs up emoji

@strickvl
Copy link
Author

Sounds good. I'll work on that change.

strickvland others added5 commitsJune 17, 2025 12:53
Replace non-scalable individual flags (--login-title, --login-below, etc.)with a unified --custom-strings flag that accepts JSON file paths or inlineJSON for UI customization. This leverages the existing i18n system forbetter 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 <noreply@anthropic.com>
Remove migration examples for flags that were never released.Only --app-name and --welcome-text were in the original codebaseand might be used by existing users.🤖 Generated with [Claude Code](https://claude.ai/code)Co-Authored-By: Claude <noreply@anthropic.com>
Replace outdated CS_* environment variable examples with the new--custom-strings flag approach. Include both inline JSON andmounted file examples for Docker users.🤖 Generated with [Claude Code](https://claude.ai/code)Co-Authored-By: Claude <noreply@anthropic.com>
@strickvl
Copy link
Author

@code-asher is this in line with what you were thinking?

Copy link
Member

@code-ashercode-asher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Yes this is exactly along the line I was thinking! Thank you, this is really great.

strickvland others added9 commitsJune 24, 2025 19:09
Remove login page customization sections from FAQ.md and install.md as they were too specific for those documents. Move customization reference to guide.md where it's more appropriate.🤖 Generated with [Claude Code](https://claude.ai/code)Co-Authored-By: Claude <noreply@anthropic.com>
Remove duplicate validation in cli.ts since comprehensive validation already exists in loadCustomStrings(). Also eliminate unnecessary customStrings global variable by using customStringsData directly.🤖 Generated with [Claude Code](https://claude.ai/code)Co-Authored-By: Claude <noreply@anthropic.com>
…dlingMake customStringsArg parameter required since caller already checks existence. Remove redundant try-catch block in main.ts to avoid duplicate error logging since loadCustomStrings already provides descriptive error messages.🤖 Generated with [Claude Code](https://claude.ai/code)Co-Authored-By: Claude <noreply@anthropic.com>
Remove tests for legacy individual flags (--login-title, --password-placeholder, --submit-text, etc.) that have been replaced by the unified --custom-strings flag. Also remove cleanup of non-existent environment variables in CLI tests.🤖 Generated with [Claude Code](https://claude.ai/code)Co-Authored-By: Claude <noreply@anthropic.com>
Replace manual resource merging and re-initialization with i18next's built-in addResourceBundle API. This is more efficient, cleaner, and the idiomatic way to add custom translations dynamically.🤖 Generated with [Claude Code](https://claude.ai/code)Co-Authored-By: Claude <noreply@anthropic.com>
Change "custom UI strings" to "custom translations" to better reflect that this feature uses the i18n system and could be used for more than just UI elements, making it more accurate and future-proof.🤖 Generated with [Claude Code](https://claude.ai/code)Co-Authored-By: Claude <noreply@anthropic.com>
Remove deprecation from --app-name since it serves a valuable purpose for the {{app}} placeholder in custom strings, especially useful for internationalization. Update documentation to show how --app-name works with --custom-strings and clarify that only --welcome-text is deprecated.🤖 Generated with [Claude Code](https://claude.ai/code)Co-Authored-By: Claude <noreply@anthropic.com>
Change CLI flag from --custom-strings to --i18n to use standard internationalization terminology. This is more accurate since the feature leverages the i18next system and follows industry conventions. Update all documentation, tests, and code references.🤖 Generated with [Claude Code](https://claude.ai/code)Co-Authored-By: Claude <noreply@anthropic.com>
Replace login-specific customization.md with generic internationalization section in guide.md. This approach is more maintainable, reduces file sprawl, points to source files as truth, and encourages community contributions. Removes repetitive examples that could get out of sync.🤖 Generated with [Claude Code](https://claude.ai/code)Co-Authored-By: Claude <noreply@anthropic.com>
@codecovCodecov
Copy link

codecovbot commentedJun 25, 2025

Codecov Report

Attention: Patch coverage is52.38095% with10 lines in your changes missing coverage. Please review.

Project coverage is 73.18%. Comparing base(85ee441) to head(ca12a25).
Report is 6 commits behind head on main.

Files with missing linesPatch %Lines
src/node/i18n/index.ts27.27%7 Missing and 1 partial⚠️
src/node/main.ts50.00%2 Missing⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@##             main    #7374      +/-   ##==========================================- Coverage   73.44%   73.18%   -0.26%==========================================  Files          29       29                Lines        1796     1816      +20       Branches      385      387       +2     ==========================================+ Hits         1319     1329      +10- Misses        404      413       +9- Partials       73       74       +1
Files with missing linesCoverage Δ
src/node/cli.ts93.52% <ø> (ø)
src/node/routes/login.ts88.70% <100.00%> (+0.99%)⬆️
src/node/main.ts49.13% <50.00%> (+0.03%)⬆️
src/node/i18n/index.ts57.89% <27.27%> (-42.11%)⬇️

Continue to review full report in Codecov by Sentry.

Legend -Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing data
Powered byCodecov. Last updatebd34cd5...ca12a25. Read thecomment docs.

🚀 New features to boost your workflow:
  • ❄️Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@code-ashercode-asherAwaiting requested review from code-asher

At least 1 approving review is required to merge this pull request.

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@strickvl@code-asher

[8]ページ先頭

©2009-2025 Movatter.jp