From 3bedb51f6a878253cfdf10ab89c67312fcd93886 Mon Sep 17 00:00:00 2001 From: FChannel <=> Date: Sun, 31 Jan 2021 23:18:21 -0800 Subject: preload metadata of video to see first frame --- OutboxPost.go | 6 +- main.go | 4 +- static/catalog.html | 189 --------------------------------------------------- static/ncatalog.html | 2 +- static/posts.html | 9 ++- 5 files changed, 10 insertions(+), 200 deletions(-) delete mode 100644 static/catalog.html diff --git a/OutboxPost.go b/OutboxPost.go index b51e7cc..f509b04 100644 --- a/OutboxPost.go +++ b/OutboxPost.go @@ -503,8 +503,10 @@ func CheckCaptcha(db *sql.DB, captcha string) bool { path := "public/" + parts[0] + ".png" code := GetCaptchaCodeDB(db, path) - DeleteCaptchaCodeDB(db, path) - CreateNewCaptcha(db) + if code != "" { + DeleteCaptchaCodeDB(db, path) + CreateNewCaptcha(db) + } if (code == strings.ToUpper(parts[1])) { return true diff --git a/main.go b/main.go index 90cd238..0bc509e 100644 --- a/main.go +++ b/main.go @@ -243,7 +243,6 @@ func main() { auth := CreateTripCode(verify.Code) auth = CreateTripCode(auth) - if CreateTripCode(auth) == code { w.WriteHeader(http.StatusOK) } else { @@ -266,7 +265,6 @@ func main() { w.WriteHeader(http.StatusForbidden) w.Write([]byte("404 no path")) - }) http.HandleFunc("/post", func(w http.ResponseWriter, r *http.Request){ @@ -780,7 +778,7 @@ func main() { return } - if(!CheckCaptcha(db, captcha)) { + if(r.FormValue("captchaCode") == "" || !CheckCaptcha(db, captcha)) { w.WriteHeader(http.StatusBadRequest) w.Write([]byte("captcha required")) return diff --git a/static/catalog.html b/static/catalog.html deleted file mode 100644 index b5b361e..0000000 --- a/static/catalog.html +++ /dev/null @@ -1,189 +0,0 @@ - - - - {{ .Title }} - - - - - - {{ $board := .Board }} - {{ if $board.IsMod }} - [Manage Board] - {{ end }} -
-

/{{ $board.Name }}/ - {{ $board.PrefName }}

-
-
-
-
-
-
-
-
-
- - - - -

-
-
-
- -
-
-
- -
- -
- -
- {{ range .Posts }} -
- {{ if $board.IsMod }} - [Delete Post] - {{ end }} - {{ if .Attachment }} - {{ if $board.IsMod }} - [Delete Attachment] - {{ end }} - -
- - - - {{ end }} -
- {{ $replies := .Replies }} - R: {{ $replies.TotalItems }}{{ if $replies.TotalImgs }}/ A: {{ $replies.TotalImgs }}{{ end }} - {{ if .Name }} - {{ .Name }} - {{ end }} - {{ if .Content }} - {{.Content}} - {{ end }} -
-
-
- - {{ end }} -
-
- -
- - - diff --git a/static/ncatalog.html b/static/ncatalog.html index a57e291..b4e6f76 100644 --- a/static/ncatalog.html +++ b/static/ncatalog.html @@ -49,7 +49,7 @@ if(getMIMEType({{ (index .Attachment 0).MediaType }}) == "video"){ var video = document.createElement("video") video.controls = 'controls' - video.preload = 'none' + video.preload = 'metadata' video.muted = 'muted' video.src = '{{ (index .Attachment 0).Href }}' video.type = '{{ (index .Attachment 0).MediaType }}' diff --git a/static/posts.html b/static/posts.html index e146032..0e381ea 100644 --- a/static/posts.html +++ b/static/posts.html @@ -39,7 +39,7 @@ if(getMIMEType({{ (index .Attachment 0).MediaType }}) == "audio"){ var audio = document.createElement("audio") audio.controls = 'controls' - audio.preload = 'none' + audio.preload = 'metadata' audio.src = '{{ (index .Attachment 0).Href }}' audio.type = '{{ (index .Attachment 0).MediaType }}' audio.style = "float: left; margin-right: 10px; margin-bottom: 10px; width: 250px;" @@ -50,7 +50,7 @@ if(getMIMEType({{ (index .Attachment 0).MediaType }}) == "video"){ var video = document.createElement("video") video.controls = 'controls' - video.preload = 'none' + video.preload = 'metadata' video.muted = 'muted' video.src = '{{ (index .Attachment 0).Href }}' video.type = '{{ (index .Attachment 0).MediaType }}' @@ -105,7 +105,7 @@ if(getMIMEType({{ (index .Attachment 0).MediaType }}) == "audio"){ var audio = document.createElement("audio") audio.controls = 'controls' - audio.preload = 'none' + audio.preload = 'metadata' audio.src = '{{ (index .Attachment 0).Href }}' audio.type = '{{ (index .Attachment 0).MediaType }}' audio.style = "float: left; margin-right: 10px; margin-bottom: 10px; width: 250px;" @@ -116,7 +116,7 @@ if(getMIMEType({{ (index .Attachment 0).MediaType }}) == "video"){ var video = document.createElement("video") video.controls = 'controls' - video.preload = 'none' + video.preload = 'metadata' video.muted = 'muted' video.src = '{{ (index .Attachment 0).Href }}' video.type = '{{ (index .Attachment 0).MediaType }}' @@ -175,7 +175,6 @@ var content = document.getElementById("{{ .Id }}-content"); content.innerHTML = convertContent('{{$board.Actor}}', content.innerText, '{{ $opId }}') - {{ end }} {{ end }} -- cgit v1.2.3