Skip to content

Commit ea27f53

Browse files
committed
Added canonical and window URL information.
1 parent ad2fbe7 commit ea27f53

File tree

3 files changed

+29
-11
lines changed

3 files changed

+29
-11
lines changed

FrontEnd/scripts/controllers/debug_console_controller.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,16 @@
1515
import { Controller } from '@hotwired/stimulus'
1616

1717
export class DebugConsoleController extends Controller {
18-
connect() {
19-
console.log('DebugConsoleController connected')
18+
static targets = ['grid']
2019

20+
connect() {
2121
// Debug console is Hidden by default. Make it visble by typing:
2222
// `localStorage.setItem('spiDebug', 'true');`
2323
// into the browser console.
2424
if (localStorage.getItem('spiDebug') === 'true') {
2525
this.element.classList.remove('hidden')
26+
27+
this.addCanonicalUrls()
2628
}
2729
}
2830

@@ -34,4 +36,24 @@ export class DebugConsoleController extends Controller {
3436
this.element.classList.add('hidden')
3537
localStorage.setItem('spiDebug', 'false')
3638
}
39+
40+
newGridCell(contents) {
41+
const cellElement = document.createElement('div')
42+
cellElement.innerText = contents
43+
return cellElement
44+
}
45+
46+
addCanonicalUrls() {
47+
const canonicalUrl = document.querySelector('link[rel="canonical"]').href
48+
const windowUrl = window.location.href
49+
50+
this.gridTarget.appendChild(this.newGridCell('Canonical URL'))
51+
this.gridTarget.appendChild(this.newGridCell(canonicalUrl))
52+
53+
this.gridTarget.appendChild(this.newGridCell('Window URL'))
54+
this.gridTarget.appendChild(this.newGridCell(windowUrl))
55+
56+
this.gridTarget.appendChild(this.newGridCell('URLs Match'))
57+
this.gridTarget.appendChild(this.newGridCell(canonicalUrl === windowUrl))
58+
}
3759
}

FrontEnd/styles/debug_console.scss

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@
2828
background-color: var(--debug-console-background);
2929
border-top: 1px solid var(--debug-console-border);
3030

31-
h3 {
32-
margin: 5px;
33-
}
34-
3531
.buttons {
3632
position: absolute;
3733
top: 0;
@@ -56,14 +52,15 @@
5652
}
5753
}
5854

59-
[data-debug-console-target='data-grid'] {
55+
[data-debug-console-target='grid'] {
6056
display: grid;
61-
grid-template-columns: 1fr 10fr;
57+
grid-template-columns: min-content 1fr;
58+
gap: 3px 20px;
6259
padding: 5px;
63-
font-size: 13px;
6460

6561
> *:nth-child(odd) {
6662
font-weight: 600;
63+
white-space: nowrap;
6764
}
6865
}
6966
}

Sources/App/Views/PublicPage.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,9 +471,8 @@ class PublicPage {
471471
.data(named: "action", value: "click->debug-console#disable")
472472
)
473473
),
474-
.h3("Debugging information"),
475474
.section(
476-
.data(named: "debug-console-target", value: "data-grid"),
475+
.data(named: "debug-console-target", value: "grid"),
477476
.group(
478477
frontEndDebugConsoleData().map({ dataItem -> Node<HTML.BodyContext> in
479478
.group(

0 commit comments

Comments
 (0)