Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/3175-header-simple-welcome-title.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- The fresh-install welcome page no longer renders a browser tab titled `Wheels - Error`; `_header_simple.cfm` now defaults its `<title>` to `Wheels` and the error handler overrides it for error screens (#3175)
8 changes: 7 additions & 1 deletion vendor/wheels/events/EventMethods.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,13 @@ component extends="wheels.Global" implements="wheels.interfaces.events.EventHand
$header(name = "Content-Type", value = "text/xml");
local.rv = $toXml(local.wheelsError);
} else {
// Default HTML error display
// Default HTML error display. The shared _header_simple.cfm
// partial defaults its <title> to "Wheels" (the fresh-install
// welcome page, #3175); override it here so error screens keep
// their error-specific title.
if (StructKeyExists(request, "wheels") && IsStruct(request.wheels)) {
request.wheels.pageTitle = "Wheels - Error";
}
if (!StructKeyExists(request.wheels, "internalHeaderLoaded")) {
local.rv &= $includeAndReturnOutput($template = "/wheels/public/layout/_header_simple.cfm");
}
Expand Down
19 changes: 18 additions & 1 deletion vendor/wheels/public/layout/_header_simple.cfm
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,30 @@ if (!StructKeyExists(application.wheels, "iconsFontDataUri")) {
}
}
}

// Page <title> for this shared chrome. Defaults to "Wheels" — the
// fresh-install welcome page (congratulations.cfm) leaves it at the
// default. The error handler (EventMethods.$runOnError) sets
// request.wheels.pageTitle = "Wheels - Error" before including this
// partial so error screens keep their error-specific title.
// Issue ##3175: the title was hardcoded to "Wheels - Error", so every
// successful first boot rendered a browser tab titled "Error".
local.simpleHeaderTitle = "Wheels";
if (
StructKeyExists(request, "wheels")
&& IsStruct(request.wheels)
&& StructKeyExists(request.wheels, "pageTitle")
&& Len(Trim(request.wheels.pageTitle))
) {
local.simpleHeaderTitle = request.wheels.pageTitle;
}
</cfscript>
<cfoutput>
<!--- cfformat-ignore-start --->
<!DOCTYPE html>
<html>
<head>
<title>Wheels - Error</title>
<title>#EncodeForHTML(local.simpleHeaderTitle)#</title>
<meta charset="utf-8">
<meta name="robots" content="noindex,nofollow">
<style>
Expand Down
45 changes: 45 additions & 0 deletions vendor/wheels/tests/specs/view/HeaderSimpleTitleSpec.cfc
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
component extends="wheels.WheelsTest" {

function run() {

// GH #3175 — _header_simple.cfm hardcoded `<title>Wheels - Error</title>`.
// The partial is shared by the error page (EventMethods.$runOnError, where
// the error title is correct) AND the fresh-install welcome page
// (congratulations.cfm, where it is wrong). The title is now parameterized:
// it defaults to "Wheels" and the error handler sets request.wheels.pageTitle
// to override it.
describe("_header_simple.cfm page title (#chr(35)#3175)", () => {

it("defaults the <title> to 'Wheels' (not the error title) for the welcome page", () => {
// No override present — simulates the welcome-page include path.
if (StructKeyExists(request, "wheels") && IsStruct(request.wheels)) {
StructDelete(request.wheels, "pageTitle")
}

var html = application.wo.$includeAndReturnOutput(
$template = "/wheels/public/layout/_header_simple.cfm"
)

expect(html).toInclude("<title>Wheels</title>")
expect(html).notToInclude("<title>Wheels - Error</title>")
})

it("honours request.wheels.pageTitle so the error page keeps its 'Wheels - Error' title", () => {
if (!StructKeyExists(request, "wheels") || !IsStruct(request.wheels)) {
request.wheels = {}
}
request.wheels.pageTitle = "Wheels - Error"

var html = ""
try {
html = application.wo.$includeAndReturnOutput(
$template = "/wheels/public/layout/_header_simple.cfm"
)
expect(html).toInclude("<title>Wheels - Error</title>")
} finally {
StructDelete(request.wheels, "pageTitle")
}
})
})
}
}
Loading