rename PageURL to CurrentPath

This commit is contained in:
perennial
2024-10-18 14:08:42 +11:00
parent b0ef05f84a
commit 46cd5876a4
5 changed files with 10 additions and 10 deletions
+2 -2
View File
@@ -26,7 +26,7 @@
<!-- TODO: can be annoying when you accidentally scroll inside a horizontal scroll area instead of the main content -->
<!-- <script src="/js/horizontal-scroll.js" defer></script> -->
<script src="/js/comment-pagination.js" defer></script>
{{- if PageURL == "/settings" }}
{{- if CurrentPath == "/settings" }}
<script src="/js/proxy-toggle.js" defer></script>
{{- end }}
@@ -35,7 +35,7 @@
<meta property="og:title" content="{{ title }}" />
<meta property="og:site_name" content="PixivFE" />
<meta property="og:type" content="article" />
<meta property="og:url" content="{{ PageURL }}" />
<meta property="og:url" content="{{ CurrentPath }}" />
{{- if isset(.MetaAuthor) }}
<link rel="alternate" type="application/json+oembed" href="{{ BaseURL }}/oembed?a={{ .MetaAuthor }}&u={{ BaseURL }}/users/{{ .MetaAuthorID }}" />
+1 -1
View File
@@ -2,7 +2,7 @@
<feed xmlns="http://www.w3.org/2005/Atom">
<id>{{ BaseURL }}/users/{{ .User.ID }}/{{ .Category }}</id>
<link rel="alternate" href="{{ BaseURL }}/users/{{ .User.ID }}/{{ .Category }}"/>
<link rel="self" href="{{ PageURL }}"/>
<link rel="self" href="{{ CurrentPath }}"/>
<link rel="first" href="{{ BaseURL }}/users/{{ .User.ID }}/{{ .Category }}.atom.xml?page=1"/>
<link rel="last" href="{{ BaseURL }}/users/{{ .User.ID }}/{{ .Category }}.atom.xml?page={{ .PageLimit }}"/>
{{- if .Page - 1 >= 1 }}
+1 -1
View File
@@ -10,7 +10,7 @@ Be careful when you write a .jet.html template file.
If you see error like `<variable name> not found in map[...]` when visiting a page, you need to add a dot before all data member access. e.g. from `Illust` to `.Illust`. gofiber doesn't mention this.
In Jet, variables are accessed without a dot (`PageURL`), while data members (the `data` parameter to `Render(...)`). are accessed with a dot in front.
In Jet, variables are accessed without a dot (`CurrentPath`), while data members (the `data` parameter to `Render(...)`). are accessed with a dot in front.
There are 3 types of variables.
+1 -1
View File
@@ -76,7 +76,7 @@ func GetTemplatingVariables(r *http.Request) jet.VarMap {
return jet.VarMap{}.
Set("BaseURL", baseURL).
Set("PageURL", pageURL).
Set("CurrentPath", pageURL).
Set("LoggedIn", token != "").
Set("Queries", queries).
Set("CookieList", cookies).
+5 -5
View File
@@ -73,11 +73,11 @@ func testWith[T any](t *testing.T, data T) {
variables := jet.VarMap{}
for k, v := range map[string]any{
"BaseURL": fakeData[string](),
"PageURL": fakeData[string](),
"LoggedIn": fakeData[bool](),
"Queries": fakeData[map[string]string](),
"CookieList": fakeData[map[string]string](),
"BaseURL": fakeData[string](),
"CurrentPath": fakeData[string](),
"LoggedIn": fakeData[bool](),
"Queries": fakeData[map[string]string](),
"CookieList": fakeData[map[string]string](),
} {
variables.Set(k, v)
}