mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2025-01-19 01:31:34 +00:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
d1260563d4
@ -1,4 +1,7 @@
|
||||
![loli-safe](https://a.safe.moe/jcutlz.png)
|
||||
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](https://raw.githubusercontent.com/kanadeko/Kuro/master/LICENSE)
|
||||
[![Chat / Support](https://img.shields.io/badge/Chat%20%2F%20Support-discord-7289DA.svg?style=flat-square)](https://discord.gg/5g6vgwn)
|
||||
|
||||
# lolisafe, a small safe worth protecting.
|
||||
|
||||
## Sites using loli-safe
|
||||
|
@ -155,7 +155,7 @@ albumsController.get = function(req, res, next) {
|
||||
file.file = basedomain + '/' + file.name
|
||||
|
||||
let ext = path.extname(file.name).toLowerCase()
|
||||
if (utils.extensions.includes(ext)) {
|
||||
if (utils.imageExtensions.includes(ext) || utils.videoExtensions.includes(ext)) {
|
||||
file.thumb = basedomain + '/thumbs/' + file.name.slice(0, -ext.length) + '.png'
|
||||
utils.generateThumbs(file)
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ uploadsController.processFilesForDisplay = function(req, res, files, existingFil
|
||||
|
||||
for (let file of files) {
|
||||
let ext = path.extname(file.name).toLowerCase()
|
||||
if (utils.extensions.includes(ext)) {
|
||||
if (utils.imageExtensions.includes(ext) || utils.videoExtensions.includes(ext)) {
|
||||
file.thumb = basedomain + '/thumbs/' + file.name.slice(0, -ext.length) + '.png'
|
||||
utils.generateThumbs(file)
|
||||
}
|
||||
@ -232,17 +232,26 @@ uploadsController.delete = function(req, res) {
|
||||
}
|
||||
|
||||
uploadsController.deleteFile = function(file) {
|
||||
|
||||
const ext = path.extname(file).toLowerCase()
|
||||
return new Promise(function(resolve, reject) {
|
||||
fs.stat(path.join(__dirname, '..', config.uploads.folder, file), function(err, stats) {
|
||||
if (err) { return reject(err) }
|
||||
fs.unlink(path.join(__dirname, '..', config.uploads.folder, file), function(err) {
|
||||
if (err) { return reject(err) }
|
||||
return resolve()
|
||||
if(!utils.imageExtensions.includes(ext) && !utils.videoExtensions.includes(ext)) {
|
||||
return resolve()
|
||||
}
|
||||
file = file.substr(0, file.lastIndexOf(".")) + ".png"
|
||||
fs.stat(path.join(__dirname, '..', config.uploads.folder, "thumbs/", file), function(err, stats) {
|
||||
if (err) { return reject(err) }
|
||||
fs.unlink(path.join(__dirname, '..', config.uploads.folder, "thumbs/", file), function(err) {
|
||||
if (err) { return reject(err) }
|
||||
return resolve()
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
uploadsController.list = function(req, res) {
|
||||
@ -300,7 +309,7 @@ uploadsController.list = function(req, res) {
|
||||
userids.push(file.userid)
|
||||
|
||||
let ext = path.extname(file.name).toLowerCase()
|
||||
if (utils.extensions.includes(ext)) {
|
||||
if (utils.imageExtensions.includes(ext) || utils.videoExtensions.includes(ext)) {
|
||||
file.thumb = basedomain + '/thumbs/' + file.name.slice(0, -ext.length) + '.png'
|
||||
utils.generateThumbs(file)
|
||||
}
|
||||
|
@ -5,7 +5,8 @@ const gm = require('gm')
|
||||
const ffmpeg = require('fluent-ffmpeg')
|
||||
|
||||
const utilsController = {}
|
||||
utilsController.extensions = ['.jpg', '.jpeg', '.bmp', '.gif', '.png', '.webm', '.mp4']
|
||||
utilsController.imageExtensions = ['.jpg', '.jpeg', '.bmp', '.gif', '.png']
|
||||
utilsController.videoExtensions = ['.webm', '.mp4', '.wmv', '.avi', '.mov']
|
||||
|
||||
utilsController.getPrettyDate = function(date) {
|
||||
return date.getFullYear() + '-'
|
||||
@ -26,7 +27,7 @@ utilsController.generateThumbs = function(file, basedomain) {
|
||||
let thumbname = path.join(__dirname, '..', config.uploads.folder, 'thumbs', file.name.slice(0, -ext.length) + '.png')
|
||||
fs.access(thumbname, (err) => {
|
||||
if (err && err.code === 'ENOENT') {
|
||||
if (ext === '.webm' || ext === '.mp4') {
|
||||
if (utilsController.videoExtensions.includes(ext)) {
|
||||
ffmpeg(path.join(__dirname, '..', config.uploads.folder, file.name))
|
||||
.thumbnail({
|
||||
timestamps: [0],
|
||||
|
@ -82,7 +82,7 @@
|
||||
|
||||
<h3 class="subtitle"><a href="/auth" id="loginLinkText"></a></h3>
|
||||
<h3 id="links">
|
||||
<a href="https://github.com/kanadeko/loli-safe" target="_blank" class="is-danger">View on Github</a><span>|</span><a href="https://lolisafe.moe/sharex.txt">ShareX</a><span>|</span><a href="https://chrome.google.com/webstore/detail/loli-safe-uploader/enkkmplljfjppcdaancckgilmgoiofnj" target="_blank" class="is-danger">Chrome extension</a><span>|</span><a href="/faq" class="is-danger">FAQ</a><span>|</span><a href="/auth" target="_blank" class="is-danger">Dashboard</a>
|
||||
<a href="https://github.com/kanadeko/loli-safe" target="_blank" class="is-danger">View on GitHub</a><span>|</span><a href="https://lolisafe.moe/sharex.txt">ShareX</a><span>|</span><a href="https://chrome.google.com/webstore/detail/loli-safe-uploader/enkkmplljfjppcdaancckgilmgoiofnj" target="_blank" class="is-danger">Chrome extension</a><span>|</span><a href="/faq" class="is-danger">FAQ</a><span>|</span><a href="/auth" target="_blank" class="is-danger">Dashboard</a>
|
||||
</h3>
|
||||
|
||||
</div>
|
||||
|
@ -5,6 +5,7 @@ upload.token = localStorage.token;
|
||||
upload.maxFileSize;
|
||||
// add the album var to the upload so we can store the album id in there
|
||||
upload.album;
|
||||
upload.myDropzone;
|
||||
|
||||
upload.checkIfPublic = function(){
|
||||
axios.get('/api/check')
|
||||
@ -131,8 +132,8 @@ upload.prepareDropzone = function(){
|
||||
'token': upload.token
|
||||
},
|
||||
init: function() {
|
||||
upload.myDropzone = this;
|
||||
this.on('addedfile', function(file) {
|
||||
myDropzone = this;
|
||||
document.getElementById('uploads').style.display = 'block';
|
||||
});
|
||||
// add the selected albumid, if an album is selected, as a header
|
||||
@ -184,7 +185,7 @@ window.addEventListener('paste', function(event) {
|
||||
var file = new File([blob], "pasted-image."+blob.type.match(/(?:[^\/]*\/)([^;]*)/)[1]);
|
||||
file.type = blob.type;
|
||||
console.log(file);
|
||||
myDropzone.addFile(file);
|
||||
upload.myDropzone.addFile(file);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -28,7 +28,7 @@ routes.get('/a/:identifier', (req, res, next) => {
|
||||
file.file = basedomain + '/' + file.name
|
||||
|
||||
let ext = path.extname(file.name).toLowerCase()
|
||||
if (utils.extensions.includes(ext)) {
|
||||
if (utils.imageExtensions.includes(ext) || utils.videoExtensions.includes(ext)) {
|
||||
file.thumb = basedomain + '/thumbs/' + file.name.slice(0, -ext.length) + '.png'
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user