Remove TinyMce Added Squire
This commit is contained in:
1 parent
68effaa5c3
commit
133a86e09e
91 files changed
+6538
-10672
No files matched your search
+58
-40
@@ -12,6 +12,37 @@ const fs = require('fs')
|
||||
|
||||
let Note = module.exports = {}
|
||||
|
||||
const gm = require('gm')
|
||||
|
||||
Note.fixAttachmentThumbnails = () => {
|
||||
const filePath = '../staticFiles/'
|
||||
db.promise()
|
||||
.query(`SELECT * FROM attachment WHERE file_location NOT LIKE "%.%"`)
|
||||
.then( (rows, fields) => {
|
||||
|
||||
rows[0].forEach(line => {
|
||||
|
||||
const rawFilename = line['file_location']
|
||||
const goodFileName = rawFilename+'.jpg'
|
||||
|
||||
//Rename file to have jpg extension, create thumbnail, update database
|
||||
fs.rename(filePath+rawFilename, filePath+goodFileName, (err) => {
|
||||
|
||||
db.promise()
|
||||
.query(`UPDATE attachment SET file_location = ? WHERE id = ?`,[goodFileName, line['id'] ])
|
||||
.then( (rows, fields) => {
|
||||
gm(filePath+goodFileName)
|
||||
.resize(550) //Resize to width of 550 px
|
||||
.quality(75) //compression level 0 - 100 (best)
|
||||
.write(filePath + 'thumb_'+goodFileName, function (err) {
|
||||
console.log('Done for -> ', goodFileName)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
Note.stressTest = () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
@@ -81,33 +112,30 @@ Note.reindex = (userId, noteId) => {
|
||||
|
||||
Note.get(userId, noteId)
|
||||
.then(note => {
|
||||
|
||||
const noteText = note.text
|
||||
|
||||
//Process note text and attachment data
|
||||
Attachment.scanTextForWebsites(userId, noteId, noteText)
|
||||
.then( allNoteAttachmentText => {
|
||||
//
|
||||
// Update Solr index
|
||||
//
|
||||
Tags.string(userId, noteId)
|
||||
.then(tagString => {
|
||||
//
|
||||
// Update Solr index
|
||||
//
|
||||
Tags.string(userId, noteId)
|
||||
.then(tagString => {
|
||||
|
||||
const fullText = ProcessText.removeHtml(noteText) +' '+ tagString +' '+ ProcessText.removeHtml(allNoteAttachmentText)
|
||||
const fullText = ProcessText.removeHtml(noteText) +' '+ tagString
|
||||
|
||||
db.promise()
|
||||
.query(`
|
||||
|
||||
INSERT INTO note_text_index (note_id, user_id, text)
|
||||
VALUES (?,?,?)
|
||||
ON DUPLICATE KEY UPDATE text = ?
|
||||
db.promise()
|
||||
.query(`
|
||||
|
||||
INSERT INTO note_text_index (note_id, user_id, text)
|
||||
VALUES (?,?,?)
|
||||
ON DUPLICATE KEY UPDATE text = ?
|
||||
|
||||
`, [noteId, userId, fullText, fullText])
|
||||
.then((rows, fields) => {
|
||||
resolve(true)
|
||||
})
|
||||
.catch(console.log)
|
||||
|
||||
`, [noteId, userId, fullText, fullText])
|
||||
.then((rows, fields) => {
|
||||
resolve(true)
|
||||
})
|
||||
.catch(console.log)
|
||||
|
||||
})
|
||||
|
||||
})
|
||||
@@ -132,6 +160,9 @@ Note.update = (userId, noteId, noteText, color, pinned, archived) => {
|
||||
|
||||
//Async solr note reindex
|
||||
Note.reindex(userId, noteId)
|
||||
|
||||
//Async attachment reindex
|
||||
Attachment.scanTextForWebsites(userId, noteId, noteText)
|
||||
|
||||
//Send back updated response
|
||||
resolve(rows[0])
|
||||
@@ -147,29 +178,15 @@ Note.update = (userId, noteId, noteText, color, pinned, archived) => {
|
||||
Note.delete = (userId, noteId) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
//
|
||||
// Delete, note, text index, tags
|
||||
// Leave the attachments, they can be deleted on their own
|
||||
//
|
||||
|
||||
db.promise().query('DELETE FROM note WHERE note.id = ? AND note.user_id = ?', [noteId,userId])
|
||||
.then((rows, fields) => {
|
||||
return db.promise().query('DELETE FROM note_text_index WHERE note_text_index.note_id = ? AND note_text_index.user_id = ?', [noteId,userId])
|
||||
})
|
||||
.then((rows, fields) => {
|
||||
//Select all attachments with files
|
||||
return db.promise().query('SELECT file_location FROM attachment WHERE attachment.note_id = ? AND attachment.user_id = ?', [noteId,userId])
|
||||
})
|
||||
.then((attachmentRows, fields) => {
|
||||
|
||||
//Go through each selected attachment and delete the files
|
||||
attachmentRows[0].forEach( location => {
|
||||
const fileName = location['file_location']
|
||||
if(fileName != null && fileName.length > 1){
|
||||
fs.unlink('../staticFiles/'+fileName ,function(err){ //Async, just rip through them.
|
||||
if(err) return console.log(err);
|
||||
// console.log('file deleted successfully => ', fileName);
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
return db.promise().query('DELETE FROM attachment WHERE attachment.note_id = ? AND attachment.user_id = ?', [noteId,userId])
|
||||
})
|
||||
.then((rows, fields) => {
|
||||
return db.promise().query('DELETE FROM note_tag WHERE note_tag.note_id = ? AND note_tag.user_id = ?', [noteId,userId])
|
||||
})
|
||||
@@ -449,6 +466,7 @@ Note.search = (userId, searchQuery, searchTags, fastFilters) => {
|
||||
|
||||
//Deduce note title
|
||||
const textData = ProcessText.deduceNoteTitle(note.text)
|
||||
// console.log(textData)
|
||||
|
||||
// console.log(textData)
|
||||
|
||||
|
||||
Reference in new issue
Block a user