tiny 88x31 lexicon for atproto
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

improve template and fix size validation

+22 -21
+21 -21
blobs/validation.go
··· 1 1 package blobs 2 2 3 3 import ( 4 - // "image" 5 - // "log" 6 - // "os" 4 + "image" 5 + _ "image/gif" 6 + _ "image/jpeg" 7 + _ "image/png" 8 + "log" 9 + "os" 7 10 ) 8 11 9 12 func validateButton(path string) bool { 10 - return true 11 - // file, err := os.Open(path) 12 - // if err != nil { 13 - // log.Println("won't open") 14 - // log.Println(err) 15 - // return false 16 - // } 17 - // defer file.Close() 18 - // image, _, err := image.Decode(file) 19 - // if err != nil { 20 - // log.Println("won't decode") 21 - // log.Println(err) 22 - // return false 23 - // } 24 - // bounds := image.Bounds() 25 - // log.Println(bounds) 26 - // return bounds.Dx() == 88 && bounds.Dy() == 31 27 - // 13 + file, err := os.Open(path) 14 + if err != nil { 15 + log.Println("won't open") 16 + log.Println(err) 17 + return false 18 + } 19 + defer file.Close() 20 + cfg, _, err := image.DecodeConfig(file) 21 + if err != nil { 22 + log.Println("won't decode") 23 + log.Println(err) 24 + return false 25 + } 26 + log.Println(cfg) 27 + return cfg.Width == 88 && cfg.Height == 31 28 28 }
+1
tmpl/home.html
··· 1 1 {{define "content"}} 2 2 {{range .Buttons}} 3 3 {{template "buttonpart" .}} 4 + <a href="/upload">upload a button!</a> 4 5 {{else}} 5 6 no buttons yet, <a href="/upload">post the first!</a> 6 7 {{end}}