From 98dcdfa94ac689f127b167fb3bdd17f2dc0d8eb3 Mon Sep 17 00:00:00 2001 From: Christian Ditaputratama Date: Thu, 7 Nov 2024 01:20:50 +0700 Subject: [PATCH] feat: Do not push query strings to URL #155 Slightly increase user browsing privacy by not pushing query strings to browser URL. By using this method, the browser history stay on the main page and filter query strings not recorded. Note: This approach is experimental. Only tested on Firefox and Chromium browser. --- internal/handler/views/partial_datatable.templ | 12 ++++++------ .../handler/views/partial_datatable_templ.go | 12 ++++++------ internal/handler/views/remote_nodes.templ | 16 ++++++++-------- internal/handler/views/remote_nodes_templ.go | 16 ++++++++-------- 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/internal/handler/views/partial_datatable.templ b/internal/handler/views/partial_datatable.templ index b7c62a5..1b745c8 100644 --- a/internal/handler/views/partial_datatable.templ +++ b/internal/handler/views/partial_datatable.templ @@ -17,7 +17,7 @@ templ DtRowPerPage(url, hxTarget string, rowsPerPage int, q interface{}) { autocomplete="off" hx-get={ fmt.Sprintf("%s?%s", url, paging.EncodedQuery(q, []string{"limit"})) } hx-trigger="change" - hx-push-url="true" + hx-push-url="false" hx-target={ hxTarget } hx-swap="outerHTML" > @@ -43,7 +43,7 @@ templ DtRefreshInterval(url, hxTarget, interval string, q interface{}) { autocomplete="off" hx-get={ fmt.Sprintf("%s?%s", url, paging.EncodedQuery(q, []string{"refresh"})) } hx-trigger="change" - hx-push-url="true" + hx-push-url="false" hx-target={ hxTarget } hx-swap="outerHTML" > @@ -92,7 +92,7 @@ templ DtThSort(url, hxTarget, title, expectedSort, sortBy, sortDir string, q int { fmt.Sprintf("%d", page) } diff --git a/internal/handler/views/partial_datatable_templ.go b/internal/handler/views/partial_datatable_templ.go index 8d8df69..58080b7 100644 --- a/internal/handler/views/partial_datatable_templ.go +++ b/internal/handler/views/partial_datatable_templ.go @@ -50,7 +50,7 @@ func DtRowPerPage(url, hxTarget string, rowsPerPage int, q interface{}) templ.Co if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" hx-trigger=\"change\" hx-push-url=\"true\" hx-target=\"") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" hx-trigger=\"change\" hx-push-url=\"false\" hx-target=\"") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -151,7 +151,7 @@ func DtRefreshInterval(url, hxTarget, interval string, q interface{}) templ.Comp if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" hx-trigger=\"change\" hx-push-url=\"true\" hx-target=\"") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" hx-trigger=\"change\" hx-push-url=\"false\" hx-target=\"") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -353,7 +353,7 @@ func DtThSort(url, hxTarget, title, expectedSort, sortBy, sortDir string, q inte } ctx = templ.ClearChildren(ctx) if expectedSort == sortBy && sortDir == "asc" { - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" @@ -144,7 +144,7 @@ templ TableNodes(data monero.Nodes, countries []monero.Countries, q monero.Query autocomplete="off" hx-get={ fmt.Sprintf("%s?%s", "/remote-nodes", paging.EncodedQuery(q, []string{"protocol"})) } hx-trigger="change" - hx-push-url="true" + hx-push-url="false" hx-target="#tbl_nodes" hx-swap="outerHTML" > @@ -162,7 +162,7 @@ templ TableNodes(data monero.Nodes, countries []monero.Countries, q monero.Query autocomplete="off" hx-get={ fmt.Sprintf("%s?%s", "/remote-nodes", paging.EncodedQuery(q, []string{"cc"})) } hx-trigger="change" - hx-push-url="true" + hx-push-url="false" hx-target="#tbl_nodes" hx-swap="outerHTML" > @@ -184,7 +184,7 @@ templ TableNodes(data monero.Nodes, countries []monero.Countries, q monero.Query autocomplete="off" hx-get={ fmt.Sprintf("%s?%s", "/remote-nodes", paging.EncodedQuery(q, []string{"status"})) } hx-trigger="change" - hx-push-url="true" + hx-push-url="false" hx-target="#tbl_nodes" hx-swap="outerHTML" > @@ -203,7 +203,7 @@ templ TableNodes(data monero.Nodes, countries []monero.Countries, q monero.Query checked?={ q.CORS == "on" } hx-get={ fmt.Sprintf("%s?%s", "/remote-nodes", paging.EncodedQuery(q, []string{"cors"})) } hx-trigger="change" - hx-push-url="true" + hx-push-url="false" hx-target="#tbl_nodes" hx-swap="outerHTML" class="shrink-0 mt-0.5 text-orange-400 bg-neutral-800 border-neutral-700 rounded focus:ring-0 checked:bg-orange-400 checked:border-orange-400 focus:ring-offset-orange-500" @@ -370,7 +370,7 @@ templ TableLogs(hxPath string, data monero.FetchLogs, q monero.QueryLogs, p pagi autocomplete="off" hx-get={ fmt.Sprintf("%s?%s", hxPath, paging.EncodedQuery(q, []string{"status"})) } hx-trigger="change" - hx-push-url="true" + hx-push-url="false" hx-target="#tbl_logs" hx-swap="outerHTML" > @@ -389,7 +389,7 @@ templ TableLogs(hxPath string, data monero.FetchLogs, q monero.QueryLogs, p pagi class="frameless" placeholder="Filter reason" hx-get={ fmt.Sprintf("%s?%s", hxPath, paging.EncodedQuery(q, []string{"failed_reason"})) } - hx-push-url="true" + hx-push-url="false" hx-trigger="keyup changed delay:0.4s" hx-target="#tbl_logs" hx-swap="outerHTML" diff --git a/internal/handler/views/remote_nodes_templ.go b/internal/handler/views/remote_nodes_templ.go index b079a54..a4812d2 100644 --- a/internal/handler/views/remote_nodes_templ.go +++ b/internal/handler/views/remote_nodes_templ.go @@ -160,7 +160,7 @@ func TableNodes(data monero.Nodes, countries []monero.Countries, q monero.QueryN if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" hx-push-url=\"true\" hx-trigger=\"keyup changed delay:0.4s\" hx-target=\"#tbl_nodes\" hx-swap=\"outerHTML\"> ") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" hx-trigger=\"change\" hx-push-url=\"false\" hx-target=\"#tbl_nodes\" hx-swap=\"outerHTML\"> ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -232,7 +232,7 @@ func TableNodes(data monero.Nodes, countries []monero.Countries, q monero.QueryN if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" hx-trigger=\"change\" hx-push-url=\"true\" hx-target=\"#tbl_nodes\" hx-swap=\"outerHTML\"> ") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" hx-trigger=\"change\" hx-push-url=\"false\" hx-target=\"#tbl_nodes\" hx-swap=\"outerHTML\"> ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -291,7 +291,7 @@ func TableNodes(data monero.Nodes, countries []monero.Countries, q monero.QueryN if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" hx-trigger=\"change\" hx-push-url=\"true\" hx-target=\"#tbl_nodes\" hx-swap=\"outerHTML\"> ") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" hx-trigger=\"change\" hx-push-url=\"false\" hx-target=\"#tbl_nodes\" hx-swap=\"outerHTML\"> ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -380,7 +380,7 @@ func TableNodes(data monero.Nodes, countries []monero.Countries, q monero.QueryN if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" hx-trigger=\"change\" hx-push-url=\"true\" hx-target=\"#tbl_nodes\" hx-swap=\"outerHTML\">") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" hx-trigger=\"change\" hx-push-url=\"false\" hx-target=\"#tbl_nodes\" hx-swap=\"outerHTML\">") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -449,7 +449,7 @@ func TableNodes(data monero.Nodes, countries []monero.Countries, q monero.QueryN if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" hx-trigger=\"change\" hx-push-url=\"true\" hx-target=\"#tbl_nodes\" hx-swap=\"outerHTML\" class=\"shrink-0 mt-0.5 text-orange-400 bg-neutral-800 border-neutral-700 rounded focus:ring-0 checked:bg-orange-400 checked:border-orange-400 focus:ring-offset-orange-500\"> ") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" hx-trigger=\"change\" hx-push-url=\"false\" hx-target=\"#tbl_nodes\" hx-swap=\"outerHTML\" class=\"shrink-0 mt-0.5 text-orange-400 bg-neutral-800 border-neutral-700 rounded focus:ring-0 checked:bg-orange-400 checked:border-orange-400 focus:ring-offset-orange-500\"> ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -825,7 +825,7 @@ func TableLogs(hxPath string, data monero.FetchLogs, q monero.QueryLogs, p pagin if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" hx-trigger=\"change\" hx-push-url=\"true\" hx-target=\"#tbl_logs\" hx-swap=\"outerHTML\">") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" hx-trigger=\"change\" hx-push-url=\"false\" hx-target=\"#tbl_logs\" hx-swap=\"outerHTML\">") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -897,7 +897,7 @@ func TableLogs(hxPath string, data monero.FetchLogs, q monero.QueryLogs, p pagin if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" hx-push-url=\"true\" hx-trigger=\"keyup changed delay:0.4s\" hx-target=\"#tbl_logs\" hx-swap=\"outerHTML\"> ") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" hx-push-url=\"false\" hx-trigger=\"keyup changed delay:0.4s\" hx-target=\"#tbl_logs\" hx-swap=\"outerHTML\"> ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err }