diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2018-05-30 15:14:33 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2018-05-30 15:14:33 +0200 |
| commit | b8885039a6ba87cf329be1daf96c80914ecfef0b (patch) | |
| tree | e5f5ff19e67854b344573da96e6cab8df243af7b /app | |
| parent | ec506db646db214e239a35add31545cdfcb5ef50 (diff) | |
json columns work swimmingly :)
Diffstat (limited to 'app')
| -rw-r--r-- | app/client/api/parser.js | 57 | ||||
| -rw-r--r-- | app/server/db/bookshelf.js | 4 | ||||
| -rw-r--r-- | app/server/db/model.js | 2 | ||||
| -rw-r--r-- | app/server/db/models.js | 10 |
4 files changed, 44 insertions, 29 deletions
diff --git a/app/client/api/parser.js b/app/client/api/parser.js index e116767..d0e6aab 100644 --- a/app/client/api/parser.js +++ b/app/client/api/parser.js @@ -170,35 +170,36 @@ export const integrations = [ // return '<img class="video" type="vimeo" vid="'+media.token+'" src="'+media.thumbnail+'"><span class="playvid">▶</span>'; return '<div class="video" style="width: ' + media.width + 'px; height: ' + media.height + 'px; overflow: hidden; position: relative;"><iframe frameborder="0" scrolling="no" seamless="seamless" webkitallowfullscreen="webkitAllowFullScreen" mozallowfullscreen="mozallowfullscreen" allowfullscreen="allowfullscreen" id="okplayer" src="https://player.vimeo.com/video/' + media.token + '?api=1&title=0&byline=0&portrait=0&playbar=0&player_id=okplayer&loop=0&autoplay=0" width="' + media.width + '" height="' + media.height + '" style="position: absolute; top: 0px; left: 0px; width: ' + media.width + 'px; height: ' + media.height + 'px;"></iframe></div>' } - }, { - type: 'soundcloud', - regex: /soundcloud.com\/[-a-zA-Z0-9]+\/[-a-zA-Z0-9]+\/?$/i, - fetch: function (url, done) { - fetch('https://api.soundcloud.com/resolve.json?url=' - + url - + '&client_id=' - + '0673fbe6fc794a7750f680747e863b10') - .then(result => result.json()) - .then(result => { - console.log(result) - done({ - url: url, - type: "soundcloud", - token: result.id, - thumbnail: result.artwork_url || result.user.avatar_url, - title: result.user.username + " - " + result.title, - duration: result.duration, - width: 166, - height: 166, - }) - }) - }, - tag: function (media) { - return '<iframe width="166" height="166" scrolling="no" frameborder="no"' + - 'src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/' + media.token + - '&color=ff6600&auto_play=false&show_artwork=true"></iframe>' - } }, + // { + // type: 'soundcloud', + // regex: /soundcloud.com\/[-a-zA-Z0-9]+\/[-a-zA-Z0-9]+\/?$/i, + // fetch: function (url, done) { + // fetch('https://api.soundcloud.com/resolve.json?url=' + // + url + // + '&client_id=' + // + '0673fbe6fc794a7750f680747e863b10') + // .then(result => result.json()) + // .then(result => { + // console.log(result) + // done({ + // url: url, + // type: "soundcloud", + // token: result.id, + // thumbnail: result.artwork_url || result.user.avatar_url, + // title: result.user.username + " - " + result.title, + // duration: result.duration, + // width: 166, + // height: 166, + // }) + // }) + // }, + // tag: function (media) { + // return '<iframe width="166" height="166" scrolling="no" frameborder="no"' + + // 'src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/' + media.token + + // '&color=ff6600&auto_play=false&show_artwork=true"></iframe>' + // } + // }, { type: 'link', regex: /^http.+/i, diff --git a/app/server/db/bookshelf.js b/app/server/db/bookshelf.js index 545b574..2f90c9a 100644 --- a/app/server/db/bookshelf.js +++ b/app/server/db/bookshelf.js @@ -2,6 +2,7 @@ require('dotenv').config() const knex = require('knex')({ client: 'mysql2', + // debug: true, connection: { host : process.env.DB_HOST, user : process.env.DB_USER, @@ -19,6 +20,9 @@ const knex = require('knex')({ }) const bookshelf = require('bookshelf')(knex) +const jsonColumns = require('bookshelf-json-columns') + +bookshelf.plugin(jsonColumns) module.exports = { bookshelf: bookshelf, diff --git a/app/server/db/model.js b/app/server/db/model.js index d84f138..18ce28c 100644 --- a/app/server/db/model.js +++ b/app/server/db/model.js @@ -147,7 +147,7 @@ module.exports = function modelScope(type, db_model, _props) { valid[key] = data[key] } }) - // console.log(valid) + console.log(valid) return valid }, diff --git a/app/server/db/models.js b/app/server/db/models.js index 5e1cf6e..8ce0de8 100644 --- a/app/server/db/models.js +++ b/app/server/db/models.js @@ -5,22 +5,32 @@ let bookshelf = require("./bookshelf").bookshelf let Folder = bookshelf.Model.extend({ tableName: 'folders', hasTimestamps: true, +}, { + jsonColumns: ['opt'], }) let File = bookshelf.Model.extend({ tableName: 'files', hasTimestamps: true, +}, { + jsonColumns: ['opt'], }) let Task = bookshelf.Model.extend({ tableName: 'tasks', hasTimestamps: true, +}, { + jsonColumns: ['opt'], }) let User = bookshelf.Model.extend({ tableName: 'user', hasTimestamps: true, +}, { + jsonColumns: ['profile'], }) let Dataset = bookshelf.Model.extend({ tableName: 'datasets', hasTimestamps: true, +}, { + jsonColumns: ['opt'], }) module.exports = { |
