diff --git a/common/common.go b/common/common.go index 651caed6..5384005b 100644 --- a/common/common.go +++ b/common/common.go @@ -57,7 +57,7 @@ type StringList []string // TODO: Let admins manage this from the Control Panel // apng is commented out for now, as we have no way of re-encoding it into a smaller file var AllowedFileExts = StringList{ - "png", "jpg", "jpeg", "svg", "bmp", "gif", "tif", "webp", /*"apng",*/ // images + "png", "jpg", "jpeg","jfif", "svg", "bmp", "gif", "tiff","tif", "webp", /*"apng",*/ // images "txt", "xml", "json", "yaml", "toml", "ini", "md", "html", "rtf", "js", "py", "rb", "css", "scss", "less", "eqcss", "pcss", "java", "ts", "cs", "c", "cc", "cpp", "cxx", "C", "c++", "h", "hh", "hpp", "hxx", "h++", "rs", "rlib", "htaccess", "gitignore", /*"go","php",*/ // text @@ -66,7 +66,7 @@ var AllowedFileExts = StringList{ "otf", "woff2", "woff", "ttf", "eot", // fonts } var ImageFileExts = StringList{ - "png", "jpg", "jpeg","jfif", "svg", "bmp", "gif", "tif", "webp", /* "apng",*/ + "png", "jpg", "jpeg","jfif", "svg", "bmp", "gif", "tiff","tif", "webp", /* "apng",*/ } var ArchiveFileExts = StringList{ "bz2", "zip", "gz", "7z", "tar", "cab", diff --git a/common/thumbnailer.go b/common/thumbnailer.go index c611eef9..24af9ceb 100644 --- a/common/thumbnailer.go +++ b/common/thumbnailer.go @@ -8,7 +8,9 @@ import ( "os" "strconv" - "github.com/Azareal/Gosora/query_gen" + "golang.org/x/image/tiff" + + qgen "github.com/Azareal/Gosora/query_gen" "github.com/pkg/errors" ) @@ -47,7 +49,7 @@ func ThumbTask(thumbChan chan bool) { /*if user.RawAvatar == ".gif" { return nil }*/ - if user.RawAvatar != ".png" && user.RawAvatar != ".jpg" && user.RawAvatar != ".jpeg" && user.RawAvatar != ".jfif" && user.RawAvatar != ".gif" { + if user.RawAvatar != ".png" && user.RawAvatar != ".jpg" && user.RawAvatar != ".jpeg" && user.RawAvatar != ".jfif" && user.RawAvatar != ".gif" && user.RawAvatar != "tiff" && user.RawAvatar != "tif" { return nil } @@ -68,11 +70,11 @@ func ThumbTask(thumbChan chan bool) { } /* - err := acc.Select("attach_image_queue").Columns("attachID").Limit("0,5").EachInt(func(attachID int) error { - return nil + err := acc.Select("attach_image_queue").Columns("attachID").Limit("0,5").EachInt(func(attachID int) error { + return nil - _, err = acc.Delete("attach_image_queue").Where("attachID = ?").Run(uid) - } + _, err = acc.Delete("attach_image_queue").Where("attachID = ?").Run(uid) + } */ if err = acc.FirstError(); err != nil { LogError(err) @@ -125,10 +127,13 @@ func precodeImage(format string, inPath string, tmpPath string) error { defer outFile.Close() // TODO: Make sure animated gifs work after being encoded - if format == "gif" { + switch format { + case "gif": return gif.Encode(outFile, img, nil) - } else if format == "png" { + case "png": return png.Encode(outFile, img) + case "tiff", "tif": + return tiff.Encode(outFile, img, nil) } return jpeg.Encode(outFile, img, nil) } diff --git a/common/topic_store.go b/common/topic_store.go index d687b158..a9ed4c9c 100644 --- a/common/topic_store.go +++ b/common/topic_store.go @@ -226,7 +226,7 @@ func (s *DefaultTopicStore) Create(fid int, topicName string, content string, ui } // ? - What is this? Do we need it? Should it be in the main store interface? -func (s *DefaultTopicStore) AddLastTopic(item *Topic, fid int) error { +func (s *DefaultTopicStore) AddLastTopic(t *Topic, fid int) error { // Coming Soon... return nil } diff --git a/public/member.js b/public/member.js index 34c13e68..24d1457d 100644 --- a/public/member.js +++ b/public/member.js @@ -1,3 +1,6 @@ +// TODO: Push ImageFileExts to the client from the server in some sort of gen.js? +var imageExts = ["png", "jpg", "jpeg","jfif", "svg", "bmp", "gif", "tiff","tif", "webp"]; + (() => { addInitHook("almost_end_init", () => { function copyToClipboard(str) { @@ -49,7 +52,7 @@ let ext = getExt(filename); // TODO: Push ImageFileExts to the client from the server in some sort of gen.js? - let isImage = ["png", "jpg", "jpeg", "svg", "bmp", "gif", "tif", "webp"].includes(ext); + let isImage = imageExts.includes(ext); if(isImage) { let reader = new FileReader(); reader.onload = f; @@ -79,7 +82,7 @@ let fileItem = document.createElement("div"); let ext = getExt(filename); // TODO: Push ImageFileExts to the client from the server in some sort of gen.js? - let isImage = ["png", "jpg", "jpeg", "svg", "bmp", "gif", "tif", "webp"].includes(ext); + let isImage = imageExts.includes(ext); let c = ""; if(isImage) c = " attach_image_holder" fileItem.className = "attach_item attach_item_item" + c; @@ -115,7 +118,7 @@ let ext = getExt(filename); // TODO: Push ImageFileExts to the client from the server in some sort of gen.js? - let isImage = ["png", "jpg", "jpeg", "svg", "bmp", "gif", "tif", "webp"].includes(ext); + let isImage = imageExts.includes(ext); fileItem.innerText = "." + ext; fileItem.className = "formbutton uploadItem"; // TODO: Check if this is actually an image @@ -249,7 +252,7 @@ event.preventDefault(); let selectNode = this.form.querySelector(".mod_floater_options"); let optionNode = selectNode.options[selectNode.selectedIndex]; - let action = optionNode.getAttribute("val"); + let action = optionNode.getAttribute("value"); // Handle these specially switch(action) { diff --git a/routes/topic.go b/routes/topic.go index 72014cf7..1cd07b60 100644 --- a/routes/topic.go +++ b/routes/topic.go @@ -19,6 +19,7 @@ import ( "image/gif" "image/jpeg" "image/png" + "golang.org/x/image/tiff" c "github.com/Azareal/Gosora/common" "github.com/Azareal/Gosora/common/counters" @@ -494,7 +495,7 @@ func uploadFilesWithHash(w http.ResponseWriter, r *http.Request, user c.User, di } defer inFile.Close() - if ext != "jpg" && ext != "jpeg" && ext != "png" && ext != "gif" { + if ext != "jpg" && ext != "jpeg" && ext != "png" && ext != "gif" && ext != "tiff" && ext != "tif" { outFile, err := os.Create(dir + filename) if err != nil { return nil, c.LocalError("Upload failed [File Creation Failed]", w, r, user) @@ -522,6 +523,8 @@ func uploadFilesWithHash(w http.ResponseWriter, r *http.Request, user c.User, di err = gif.Encode(outFile, img, nil) case "png": err = png.Encode(outFile, img) + case "tiff","tif": + err = tiff.Encode(outFile,img,nil) default: err = jpeg.Encode(outFile, img, nil) } diff --git a/templates/topics_mod_floater.html b/templates/topics_mod_floater.html index 7b4d0a9d..f8bdfc47 100644 --- a/templates/topics_mod_floater.html +++ b/templates/topics_mod_floater.html @@ -6,9 +6,9 @@