Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e09effa2ca | ||
|
|
148062ec28 |
No files matched your search
+11
-1
@@ -67,7 +67,17 @@ func (h *PageHeader) ApplyAppearance(r *http.Request) {
|
||||
if c, err := r.Cookie(PaletteCookie); err == nil && known(Palettes, c.Value) {
|
||||
h.Palette = c.Value
|
||||
}
|
||||
back := url.URL{Path: strings.TrimPrefix(r.URL.Path, h.BasePath), RawQuery: r.URL.RawQuery}
|
||||
// Only a whole leading BasePath segment is cut: behind
|
||||
// http.StripPrefix the path is already relative, and "/r" must not
|
||||
// eat the start of "/release-notes".
|
||||
path := r.URL.Path
|
||||
if h.BasePath != "" && (path == h.BasePath || strings.HasPrefix(path, h.BasePath+"/")) {
|
||||
path = strings.TrimPrefix(path, h.BasePath)
|
||||
}
|
||||
if path == "" {
|
||||
path = "/"
|
||||
}
|
||||
back := url.URL{Path: path, RawQuery: r.URL.RawQuery}
|
||||
h.AppearanceBack = back.String()
|
||||
}
|
||||
|
||||
|
||||
@@ -142,6 +142,15 @@ func TestApplyAppearance(t *testing.T) {
|
||||
if h.AppearanceBack != "/tasks?f=1" {
|
||||
t.Errorf("AppearanceBack = %q, want %q", h.AppearanceBack, "/tasks?f=1")
|
||||
}
|
||||
|
||||
// Behind http.StripPrefix the path is already relative to BasePath.
|
||||
for path, want := range map[string]string{"/release-notes": "/release-notes", "/r": "/", "/r/x": "/x"} {
|
||||
h := PageHeader{BasePath: "/r"}
|
||||
h.ApplyAppearance(httptest.NewRequest(http.MethodGet, path, nil))
|
||||
if h.AppearanceBack != want {
|
||||
t.Errorf("BasePath /r, path %s: AppearanceBack = %q, want %q", path, h.AppearanceBack, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestAppearanceHandler(t *testing.T) {
|
||||
|
||||
+5
-3
@@ -82,8 +82,8 @@
|
||||
--yw-link-rgb: var(--yw-if-light, 10, 114, 163) var(--yw-if-dark, 79, 195, 247);
|
||||
--yw-link-hover: light-dark(#085a80, #81d4fa);
|
||||
--yw-link-hover-rgb: var(--yw-if-light, 8, 90, 128) var(--yw-if-dark, 129, 212, 250);
|
||||
--yw-primary: light-dark(#0d6efd, #0d6efd);
|
||||
--yw-primary-rgb: var(--yw-if-light, 13, 110, 253) var(--yw-if-dark, 13, 110, 253);
|
||||
--yw-primary: light-dark(#2595c8, #2595c8);
|
||||
--yw-primary-rgb: var(--yw-if-light, 37, 149, 200) var(--yw-if-dark, 37, 149, 200);
|
||||
--yw-on-primary: light-dark(#ffffff, #ffffff);
|
||||
--yw-nav-link: light-dark(#0b82b8, #0b82b8);
|
||||
--yw-nav-link-hover-text: light-dark(#0a4f72, #c8d4e4);
|
||||
@@ -246,7 +246,9 @@
|
||||
}
|
||||
|
||||
/* Bootstrap writes its primary blue straight into these components
|
||||
rather than reading --bs-primary, so they get the palette's here. */
|
||||
rather than reading --bs-primary, so they get the palette's here.
|
||||
The default palette's #2595c8 is the button color every consumer's
|
||||
own stylesheet used (as yasta), so those rules can go. */
|
||||
.btn-primary {
|
||||
--bs-btn-color: var(--yw-on-primary);
|
||||
--bs-btn-bg: var(--yw-primary);
|
||||
|
||||
Reference in new issue
Block a user