diff options
| author | Jules <jules@asdf.us> | 2018-03-31 08:56:12 -0400 |
|---|---|---|
| committer | Jules <jules@asdf.us> | 2018-03-31 08:56:12 -0400 |
| commit | 655b5ddb4aeca5b89d44828e809caa73cdccfd63 (patch) | |
| tree | 174f1628a44152dbdfea077f174f7b86121d7bda /lib | |
| parent | b3c1619d2027939963d4f906e9da40b26e17eee1 (diff) | |
| parent | a7eba7c34281e59dcae3a24d4cc73c2148c7d6b7 (diff) | |
Merge branch 'master' of ghghgh.us:luckyplop
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/db/index.js | 6 | ||||
| -rw-r--r-- | lib/index.js | 7 |
2 files changed, 12 insertions, 1 deletions
diff --git a/lib/db/index.js b/lib/db/index.js index 93fdd0e..573528d 100644 --- a/lib/db/index.js +++ b/lib/db/index.js @@ -4,7 +4,6 @@ var connection = require("./bookshelf") var bookshelf = connection.bookshelf var knex = connection.knex - /* MODELS */ var Image = db.Image = bookshelf.Model.extend({ @@ -30,6 +29,11 @@ db.getRandom = function () { qb.orderBy(knex.raw('RAND()')).limit(1) }).fetch() } +db.getRandomAscii = function () { + return ShaderImage.query(function(qb){ + qb.where("tag", "=", "ascii").orderBy(knex.raw('RAND()')).limit(1) + }).fetch() +} db.getIndex = function(limit, offset) { return Image.query(function(qb){ qb.orderBy("id", "desc").limit(limit) diff --git a/lib/index.js b/lib/index.js index a4e5263..29baa70 100644 --- a/lib/index.js +++ b/lib/index.js @@ -78,6 +78,12 @@ site.init = function(){ }) }) + app.get("/p/get/randomascii", function(req, res){ + db.getRandomAscii().then(function(img){ + res.json(img) + }) + }) + /* shaderblaster / asciiblaster apis */ app.post("/cgi-bin/im/shader/upload", multer_upload.single('qqfile'), function(req, res){ var now = Math.floor(Date.now() / 1000) @@ -112,6 +118,7 @@ site.init = function(){ app.get("/p/:id", function(req, res){ res.sendFile("index.html", {root: './public'}) }) + app.use('/panke/', express.static(path.join(__dirname, '../public'))) app.use('/p/', express.static(path.join(__dirname, '../public'))) } |
