diff options
| -rw-r--r-- | bucky-schema.sql | 55 | ||||
| -rw-r--r-- | bucky/app/api.js | 2 | ||||
| -rw-r--r-- | bucky/app/bucky.js | 4 | ||||
| -rw-r--r-- | bucky/app/privacy.js | 2 | ||||
| -rw-r--r-- | bucky/db/bookshelf.js | 1 | ||||
| -rw-r--r-- | bucky/search/search.js | 22 | ||||
| -rw-r--r-- | package.json | 1 | ||||
| -rw-r--r-- | public/assets/js/lib/views/details/gallery.js | 2 | ||||
| -rw-r--r-- | public/assets/js/util/format.js | 1 |
9 files changed, 49 insertions, 41 deletions
diff --git a/bucky-schema.sql b/bucky-schema.sql index 2adcfec..0a66ca6 100644 --- a/bucky-schema.sql +++ b/bucky-schema.sql @@ -32,6 +32,32 @@ CREATE TABLE `boxes` ( /*!40101 SET character_set_client = @saved_cs_client */; -- +-- Table structure for table `threads` +-- + +DROP TABLE IF EXISTS `threads`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `threads` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `title` varchar(64) NOT NULL DEFAULT '', + `username` varchar(16) NOT NULL DEFAULT '', + `keyword` varchar(16) DEFAULT NULL, + `createdate` int(11) NOT NULL DEFAULT 0, + `lastmodified` int(11) DEFAULT NULL, + `size` int(11) DEFAULT NULL, + `privacy` smallint(6) DEFAULT 0, + `allowed` varchar(500) DEFAULT NULL, + `flagged` int(11) DEFAULT NULL, + `color` varchar(16) DEFAULT NULL, + `viewed` int(11) DEFAULT NULL, + `revision` int(11) DEFAULT 0, + `settings` varchar(512) DEFAULT '{}', + PRIMARY KEY (`id`) +) ENGINE=MyISAM AUTO_INCREMENT=4504 DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- -- Table structure for table `comments` -- @@ -50,6 +76,8 @@ CREATE TABLE `comments` ( PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=35359 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; +alter table comments add foreign key (thread) references threads(id); + -- -- Table structure for table `files` @@ -70,6 +98,8 @@ CREATE TABLE `files` ( PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=29503 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; +alter table files add foreign key (thread) references threads(id); + -- -- Table structure for table `invites` @@ -144,31 +174,6 @@ CREATE TABLE `search_log` ( ) ENGINE=MyISAM AUTO_INCREMENT=12711 DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; --- --- Table structure for table `threads` --- - -DROP TABLE IF EXISTS `threads`; -/*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE `threads` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `title` varchar(64) NOT NULL DEFAULT '', - `username` varchar(16) NOT NULL DEFAULT '', - `keyword` varchar(16) DEFAULT NULL, - `createdate` int(11) NOT NULL DEFAULT 0, - `lastmodified` int(11) DEFAULT NULL, - `size` int(11) DEFAULT NULL, - `privacy` smallint(6) DEFAULT 0, - `allowed` varchar(500) DEFAULT NULL, - `flagged` int(11) DEFAULT NULL, - `color` varchar(16) DEFAULT NULL, - `viewed` int(11) DEFAULT NULL, - `revision` int(11) DEFAULT 0, - `settings` varchar(512) DEFAULT '{}', - PRIMARY KEY (`id`) -) ENGINE=MyISAM AUTO_INCREMENT=4504 DEFAULT CHARSET=utf8; -/*!40101 SET character_set_client = @saved_cs_client */; -- -- Table structure for table `users` diff --git a/bucky/app/api.js b/bucky/app/api.js index d2472c3..8840fa0 100644 --- a/bucky/app/api.js +++ b/bucky/app/api.js @@ -186,8 +186,8 @@ function route (app){ privacy.checkThreadPrivacy, multer.array("files"), bucky.verifyFilesOrComment, - bucky.createOptionalComment, bucky.createOptionalFiles, + bucky.createOptionalComment, bucky.bumpThreadRevisions, function(req, res){ res.json({ diff --git a/bucky/app/bucky.js b/bucky/app/bucky.js index ab153f9..47026a8 100644 --- a/bucky/app/bucky.js +++ b/bucky/app/bucky.js @@ -413,7 +413,7 @@ var bucky = module.exports = { }) }, createOptionalComment: function(req, res, next){ - if (! req.body.comment || ! req.body.comment.length) { + if (! req.body.comment || ! req.body.comment.length ) { return next() } bucky.createComment(req, res, next) @@ -514,7 +514,7 @@ var bucky = module.exports = { privacy: false, storage: process.env.S3_BUCKET, } - req.body.comment = url+"\n"+file.originalname + req.body.comment = (req.body.comment.length) ? req.body.comment + "<hr>\n" + url + "\n" + file.originalname : url+"\n"+file.originalname db.createFile(data).then(function(file){ resolve(file) }).catch( (err) => reject(err) ).then( diff --git a/bucky/app/privacy.js b/bucky/app/privacy.js index fb1fcd1..86f2475 100644 --- a/bucky/app/privacy.js +++ b/bucky/app/privacy.js @@ -47,4 +47,4 @@ var privacy = module.exports = { }) next() }, -}
\ No newline at end of file +} diff --git a/bucky/db/bookshelf.js b/bucky/db/bookshelf.js index df14961..47a9636 100644 --- a/bucky/db/bookshelf.js +++ b/bucky/db/bookshelf.js @@ -17,6 +17,7 @@ var knex = require('knex')({ }) var bookshelf = require('bookshelf')(knex) +bookshelf.plugin('registry'); module.exports = { bookshelf: bookshelf, diff --git a/bucky/search/search.js b/bucky/search/search.js index 9891963..a4888ad 100644 --- a/bucky/search/search.js +++ b/bucky/search/search.js @@ -1,5 +1,5 @@ var db = require('../db') -var eachSeries = require('async/eachSeries'); +//var eachSeries = require('async/eachSeries'); var redisClient = require('./redis-client.js') const { promisify } = require("util"); const lookupAsync = promisify(redisClient.get).bind(redisClient); @@ -41,13 +41,13 @@ function search (query, start, limit, cb) { var file_ids = [] var results = [] - - eachSeries( - terms, - function(term, callback){ + var promise_terms = terms.map((term) => { + return new Promise((resolve, reject) => { if (STOPWORDS.has(term)) return; redisClient.get(term, function(err, results){ -// if (!results) return callback(); + if (err) { reject(err) } + if (!results) return resolve(); + results = split_results(results) results.forEach((result) => { @@ -59,10 +59,12 @@ function search (query, start, limit, cb) { score.strength += parseFloat(result.strength) score.count += 1 }) - callback() + resolve() }) - }, - function() { + }) + }) + Promise.all( promise_terms) + .then(() => { total = Object.keys(scores).length Object.values(scores).sort((b,a) => { return cmp(a.strength, b.strength) @@ -90,7 +92,7 @@ function search (query, start, limit, cb) { comment_ids: comment_ids, file_ids: file_ids, }); - }) + }) } diff --git a/package.json b/package.json index 97e5b9f..558b162 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,6 @@ "author": "", "license": "LNT", "dependencies": { - "async": "^3.2.0", "berkeleydb": "^0.2.1", "body-parser": "^1.19.0", "bookshelf": "^0.13.3", diff --git a/public/assets/js/lib/views/details/gallery.js b/public/assets/js/lib/views/details/gallery.js index de9a6a4..1ac2614 100644 --- a/public/assets/js/lib/views/details/gallery.js +++ b/public/assets/js/lib/views/details/gallery.js @@ -48,4 +48,4 @@ var GalleryView = View.extend({ this.$el.append($el) }, -})
\ No newline at end of file +}) diff --git a/public/assets/js/util/format.js b/public/assets/js/util/format.js index d868ddd..441430e 100644 --- a/public/assets/js/util/format.js +++ b/public/assets/js/util/format.js @@ -214,6 +214,7 @@ function get_age (t, long) { function tidy_urls (s, short_urls) { var ret = s.split("\n").map(function(line){ + if (line.indexOf("<") !== -1) { return line } |
