Encode tiffs too.
Update file extension lists. Update mod floater.
This commit is contained in:
parent
9e8b95b1be
commit
01d956f9d1
|
@ -57,7 +57,7 @@ type StringList []string
|
||||||
// TODO: Let admins manage this from the Control Panel
|
// 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
|
// apng is commented out for now, as we have no way of re-encoding it into a smaller file
|
||||||
var AllowedFileExts = StringList{
|
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
|
"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
|
"otf", "woff2", "woff", "ttf", "eot", // fonts
|
||||||
}
|
}
|
||||||
var ImageFileExts = StringList{
|
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{
|
var ArchiveFileExts = StringList{
|
||||||
"bz2", "zip", "gz", "7z", "tar", "cab",
|
"bz2", "zip", "gz", "7z", "tar", "cab",
|
||||||
|
|
|
@ -8,7 +8,9 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/Azareal/Gosora/query_gen"
|
"golang.org/x/image/tiff"
|
||||||
|
|
||||||
|
qgen "github.com/Azareal/Gosora/query_gen"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -47,7 +49,7 @@ func ThumbTask(thumbChan chan bool) {
|
||||||
/*if user.RawAvatar == ".gif" {
|
/*if user.RawAvatar == ".gif" {
|
||||||
return nil
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,10 +127,13 @@ func precodeImage(format string, inPath string, tmpPath string) error {
|
||||||
defer outFile.Close()
|
defer outFile.Close()
|
||||||
|
|
||||||
// TODO: Make sure animated gifs work after being encoded
|
// TODO: Make sure animated gifs work after being encoded
|
||||||
if format == "gif" {
|
switch format {
|
||||||
|
case "gif":
|
||||||
return gif.Encode(outFile, img, nil)
|
return gif.Encode(outFile, img, nil)
|
||||||
} else if format == "png" {
|
case "png":
|
||||||
return png.Encode(outFile, img)
|
return png.Encode(outFile, img)
|
||||||
|
case "tiff", "tif":
|
||||||
|
return tiff.Encode(outFile, img, nil)
|
||||||
}
|
}
|
||||||
return jpeg.Encode(outFile, img, nil)
|
return jpeg.Encode(outFile, img, nil)
|
||||||
}
|
}
|
||||||
|
|
|
@ -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?
|
// ? - 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...
|
// Coming Soon...
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -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", () => {
|
addInitHook("almost_end_init", () => {
|
||||||
function copyToClipboard(str) {
|
function copyToClipboard(str) {
|
||||||
|
@ -49,7 +52,7 @@
|
||||||
|
|
||||||
let ext = getExt(filename);
|
let ext = getExt(filename);
|
||||||
// TODO: Push ImageFileExts to the client from the server in some sort of gen.js?
|
// 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) {
|
if(isImage) {
|
||||||
let reader = new FileReader();
|
let reader = new FileReader();
|
||||||
reader.onload = f;
|
reader.onload = f;
|
||||||
|
@ -79,7 +82,7 @@
|
||||||
let fileItem = document.createElement("div");
|
let fileItem = document.createElement("div");
|
||||||
let ext = getExt(filename);
|
let ext = getExt(filename);
|
||||||
// TODO: Push ImageFileExts to the client from the server in some sort of gen.js?
|
// 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 = "";
|
let c = "";
|
||||||
if(isImage) c = " attach_image_holder"
|
if(isImage) c = " attach_image_holder"
|
||||||
fileItem.className = "attach_item attach_item_item" + c;
|
fileItem.className = "attach_item attach_item_item" + c;
|
||||||
|
@ -115,7 +118,7 @@
|
||||||
|
|
||||||
let ext = getExt(filename);
|
let ext = getExt(filename);
|
||||||
// TODO: Push ImageFileExts to the client from the server in some sort of gen.js?
|
// 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.innerText = "." + ext;
|
||||||
fileItem.className = "formbutton uploadItem";
|
fileItem.className = "formbutton uploadItem";
|
||||||
// TODO: Check if this is actually an image
|
// TODO: Check if this is actually an image
|
||||||
|
@ -249,7 +252,7 @@
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
let selectNode = this.form.querySelector(".mod_floater_options");
|
let selectNode = this.form.querySelector(".mod_floater_options");
|
||||||
let optionNode = selectNode.options[selectNode.selectedIndex];
|
let optionNode = selectNode.options[selectNode.selectedIndex];
|
||||||
let action = optionNode.getAttribute("val");
|
let action = optionNode.getAttribute("value");
|
||||||
|
|
||||||
// Handle these specially
|
// Handle these specially
|
||||||
switch(action) {
|
switch(action) {
|
||||||
|
|
|
@ -19,6 +19,7 @@ import (
|
||||||
"image/gif"
|
"image/gif"
|
||||||
"image/jpeg"
|
"image/jpeg"
|
||||||
"image/png"
|
"image/png"
|
||||||
|
"golang.org/x/image/tiff"
|
||||||
|
|
||||||
c "github.com/Azareal/Gosora/common"
|
c "github.com/Azareal/Gosora/common"
|
||||||
"github.com/Azareal/Gosora/common/counters"
|
"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()
|
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)
|
outFile, err := os.Create(dir + filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, c.LocalError("Upload failed [File Creation Failed]", w, r, user)
|
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)
|
err = gif.Encode(outFile, img, nil)
|
||||||
case "png":
|
case "png":
|
||||||
err = png.Encode(outFile, img)
|
err = png.Encode(outFile, img)
|
||||||
|
case "tiff","tif":
|
||||||
|
err = tiff.Encode(outFile,img,nil)
|
||||||
default:
|
default:
|
||||||
err = jpeg.Encode(outFile, img, nil)
|
err = jpeg.Encode(outFile, img, nil)
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,9 +6,9 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="mod_floater_body">
|
<div class="mod_floater_body">
|
||||||
<select class="mod_floater_options">
|
<select class="mod_floater_options">
|
||||||
<option val="delete">{{lang "topic_list.moderate_delete"}}</option>
|
<option value="delete">{{lang "topic_list.moderate_delete"}}</option>
|
||||||
<option val="lock">{{lang "topic_list.moderate_lock"}}</option>
|
<option value="lock">{{lang "topic_list.moderate_lock"}}</option>
|
||||||
<option val="move">{{lang "topic_list.moderate_move"}}</option>
|
<option value="move">{{lang "topic_list.moderate_move"}}</option>
|
||||||
</select>
|
</select>
|
||||||
<button class="mod_floater_submit">{{lang "topic_list.moderate_run"}}</button>
|
<button class="mod_floater_submit">{{lang "topic_list.moderate_run"}}</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue