mirror of
https://codeberg.org/VnPower/PixivFE
synced 2024-12-06 19:16:23 +01:00
modify browser history on network error (so refresh would retry loading that page)
This commit is contained in:
@@ -213,10 +213,10 @@ func main() {
|
||||
if config.GlobalServerConfig.InDevelopment {
|
||||
go func() {
|
||||
cmd := exec.Command("sass", "--watch", "views/css")
|
||||
cmd.Stdout = os.Stderr // heh. (sass quirk)
|
||||
cmd.Stdout = os.Stderr // Sass quirk
|
||||
cmd.Stderr = os.Stderr
|
||||
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true, Pdeathsig: syscall.SIGHUP}
|
||||
runtime.LockOSThread() // O.O https://github.com/golang/go/issues/27505
|
||||
runtime.LockOSThread() // Go quirk https://github.com/golang/go/issues/27505
|
||||
err := cmd.Run()
|
||||
if err != nil {
|
||||
log.Println(fmt.Errorf("when running sass: %w", err))
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
// make 4xx 5xx responses swap in as well
|
||||
// on network error when clicking on a link, navigate to the page anyway
|
||||
addEventListener('htmx:sendError', function (event) {
|
||||
document.write("A network error prevented an HTTP request from occurring, which is likely because the server is down. Check your Developer Console's Network tab to know what exactly is wrong.")
|
||||
if (event.target.tagName == "A") {
|
||||
// if the server is down, this will show the browser's default "Unable to connect" page, which is familiar to the user
|
||||
document.location = event.detail.pathInfo.requestPath
|
||||
}
|
||||
});
|
||||
|
||||
// make 4xx 5xx responses swap in as well
|
||||
addEventListener('htmx:beforeOnLoad', function (event) {
|
||||
// console.log("%o", event)
|
||||
event.detail.shouldSwap = true;
|
||||
|
||||
Reference in New Issue
Block a user