mirror of
https://github.com/coder/code-server.git
synced 2026-04-13 11:38:50 -05:00
feat: use --app-name in error page title (#7693)
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
content="style-src 'self'; manifest-src 'self'; img-src 'self' data:; font-src 'self' data:;"
|
||||
/>
|
||||
<meta name="color-scheme" content="light dark" />
|
||||
<title>{{ERROR_TITLE}} - code-server</title>
|
||||
<title>{{ERROR_TITLE}} - {{APP_NAME}}</title>
|
||||
<link rel="icon" href="{{CS_STATIC_BASE}}/src/browser/media/favicon-dark-support.svg" />
|
||||
<link rel="alternate icon" href="{{CS_STATIC_BASE}}/src/browser/media/favicon.ico" />
|
||||
<link rel="manifest" href="/manifest.json" crossorigin="use-credentials" />
|
||||
|
||||
@@ -519,6 +519,7 @@ export interface DefaultedArgs extends ConfigArgs {
|
||||
"extensions-dir": string
|
||||
"user-data-dir": string
|
||||
"session-socket": string
|
||||
"app-name": string
|
||||
/* Positional arguments. */
|
||||
_: string[]
|
||||
}
|
||||
@@ -665,6 +666,10 @@ export async function setDefaults(cliArgs: UserProvidedArgs, configArgs?: Config
|
||||
}
|
||||
args["proxy-domain"] = finalProxies
|
||||
|
||||
if (!args["app-name"]) {
|
||||
args["app-name"] = "code-server"
|
||||
}
|
||||
|
||||
args._ = getResolvedPathsFromArgs(args)
|
||||
|
||||
return {
|
||||
|
||||
@@ -57,7 +57,8 @@ export const errorHandler: express.ErrorRequestHandler = async (err, req, res, n
|
||||
replaceTemplates(req, content)
|
||||
.replace(/{{ERROR_TITLE}}/g, statusCode.toString())
|
||||
.replace(/{{ERROR_HEADER}}/g, statusCode.toString())
|
||||
.replace(/{{ERROR_BODY}}/g, escapeHtml(err.message)),
|
||||
.replace(/{{ERROR_BODY}}/g, escapeHtml(err.message))
|
||||
.replace(/{{APP_NAME}}/g, req.args["app-name"]),
|
||||
)
|
||||
} else {
|
||||
res.json({
|
||||
|
||||
@@ -29,8 +29,7 @@ const getRoot = async (req: Request, error?: Error): Promise<string> => {
|
||||
const content = await fs.readFile(path.join(rootPath, "src/browser/pages/login.html"), "utf8")
|
||||
const locale = req.args["locale"] || "en"
|
||||
i18n.changeLanguage(locale)
|
||||
const appName = req.args["app-name"] || "code-server"
|
||||
const welcomeText = req.args["welcome-text"] || (i18n.t("WELCOME", { app: appName }) as string)
|
||||
const welcomeText = req.args["welcome-text"] || (i18n.t("WELCOME", { app: req.args["app-name"] }) as string)
|
||||
|
||||
// Determine password message using i18n
|
||||
let passwordMsg = i18n.t("LOGIN_PASSWORD", { configFile: req.args.config })
|
||||
@@ -43,7 +42,7 @@ const getRoot = async (req: Request, error?: Error): Promise<string> => {
|
||||
return replaceTemplates(
|
||||
req,
|
||||
content
|
||||
.replace(/{{I18N_LOGIN_TITLE}}/g, i18n.t("LOGIN_TITLE", { app: appName }))
|
||||
.replace(/{{I18N_LOGIN_TITLE}}/g, i18n.t("LOGIN_TITLE", { app: req.args["app-name"] }))
|
||||
.replace(/{{WELCOME_TEXT}}/g, welcomeText)
|
||||
.replace(/{{PASSWORD_MSG}}/g, passwordMsg)
|
||||
.replace(/{{I18N_LOGIN_BELOW}}/g, i18n.t("LOGIN_BELOW"))
|
||||
|
||||
@@ -172,7 +172,6 @@ router.get("/", ensureVSCodeLoaded, async (req, res, next) => {
|
||||
})
|
||||
|
||||
router.get("/manifest.json", async (req, res) => {
|
||||
const appName = req.args["app-name"] || "code-server"
|
||||
res.writeHead(200, { "Content-Type": "application/manifest+json" })
|
||||
|
||||
res.end(
|
||||
@@ -180,8 +179,8 @@ router.get("/manifest.json", async (req, res) => {
|
||||
req,
|
||||
JSON.stringify(
|
||||
{
|
||||
name: appName,
|
||||
short_name: appName,
|
||||
name: req.args["app-name"],
|
||||
short_name: req.args["app-name"],
|
||||
start_url: ".",
|
||||
display: "fullscreen",
|
||||
display_override: ["window-controls-overlay"],
|
||||
|
||||
Reference in New Issue
Block a user