diff --git a/README.md b/README.md index 7bba6c0..c8f46cf 100644 --- a/README.md +++ b/README.md @@ -45,10 +45,50 @@ To install all node dependencies, run (do this once): See [config/default.json](config/default.json). Set `storage_local_path` for a local sqlite database or `storage_region`, `storage_bucket`, `storage_cdn` and `storage_endpoint` for AWS S3. `mail_provider` may be one of `console` or `smtp`. Also, omit a trailing `/` for the `endpoint`. + ## Disable DB logs ```json +... "db_logs_disabled": true +... +``` + +## Configure color swatches + +Add a custom array of swatches to your config/default.json. + +**You should include the swatch transparent (rgba(0,0,0,0)) so users can remove the color applied.** + +## Configure default colors +You can define text, stroke and fill color in your config/default.json. + +**You also should include the default colors in your custom swatches palette.** + +```json +... +"spacedeck": { + "default_text_color": "#E11F26", + "default_stroke_color": "#9E0F13", + "default_fill_color": "#64BCCA", + "swatches": [ + {"id":8, "hex":"#000000"}, + {"id":30, "hex":"rgba(0,0,0,0)"}, + {"id":31, "hex": "#E11F26"}, + {"id":32, "hex": "#9E0F13"}, + {"id":33, "hex": "#64BCCA"}, + {"id":34, "hex": "#40808A"}, + {"id":35, "hex": "#036492"}, + {"id":36, "hex": "#005179"}, + {"id":37, "hex": "#84427E"}, + {"id":38, "hex": "#6C3468"}, + {"id":39, "hex": "#F79B84"}, + {"id":40, "hex": "#B57362"}, + {"id":41, "hex": "#E7D45A"}, + {"id":42, "hex": "#ACA044"} + ] +} +... ``` # Run (web server) @@ -70,6 +110,26 @@ For advanced media conversion: By default, media files are uploaded to the ```storage``` folder. The database is stored in ```database.sqlite``` by default. +# Other databases (Not officially supported) + +## Postgres + +Add the [pg](https://www.npmjs.com/package/pg) module and change the config/default.json to + +``` +"storage_dialect": "postgres", +``` + +Adapt the other values as needed + +``` +"storage_host": "localhost", +"storage_database": "spacedeck", +"storage_username": "username", +"storage_password": "password", +``` + + # Run with Docker - configure `config/default.json` diff --git a/config/default.json b/config/default.json index 2838396..d47d223 100644 --- a/config/default.json +++ b/config/default.json @@ -7,6 +7,13 @@ "endpoint": "http://localhost:9666", "invite_code": "top-sekrit", + "storage_dialect": "sqlite", + + "storage_host": "localhost", + "storage_database": "spacedeck", + "storage_username": "username", + "storage_password": "password", + "storage_local_path": "./storage", "storage_local_db": "./database.sqlite", "storage_region": "eu-central-1", @@ -26,5 +33,6 @@ "mail_smtp_secure": true, "mail_smtp_require_tls": true, "mail_smtp_user": "your.smtp.user", - "mail_smtp_pass": "your.secret.smtp.password" + "mail_smtp_pass": "your.secret.smtp.password", + "spacedeck": {} } diff --git a/models/db.js b/models/db.js index c11a9aa..384058a 100644 --- a/models/db.js +++ b/models/db.js @@ -6,24 +6,28 @@ function sequel_log(a,b,c) { } const Sequelize = require('sequelize'); -const sequelize = new Sequelize('database', 'username', 'password', { - host: 'localhost', - dialect: 'sqlite', - - pool: { - max: 5, - min: 0, - acquire: 30000, - idle: 10000 - }, - - // SQLite only - storage: config.get('storage_local_db'), - logging: config.has('db_logs_disabled') ? false : sequel_log, - - // http://docs.sequelizejs.com/manual/tutorial/querying.html#operators - operatorsAliases: false -}); +const sequelize = new Sequelize( + config.get('storage_database'), + config.get('storage_username'), + config.get('storage_password'), + { + host: config.get('storage_host'), + dialect: config.get('storage_dialect'), + pool: { + max: 5, + min: 0, + acquire: 30000, + idle: 10000 + }, + logging: config.has('db_logs_disabled') ? false : sequel_log, + // http://docs.sequelizejs.com/manual/tutorial/querying.html#operators + operatorsAliases: false, + // SQLite only + storage: config.get('storage_local_db') + } +); +// https://github.com/sequelize/sequelize/issues/8019#issuecomment-384316346 +Sequelize.postgres.DECIMAL.parse = function (value) { return parseFloat(value); }; var User; var Session; diff --git a/public/javascripts/spacedeck_sections.js b/public/javascripts/spacedeck_sections.js index 4d931e7..82b584a 100644 --- a/public/javascripts/spacedeck_sections.js +++ b/public/javascripts/spacedeck_sections.js @@ -68,9 +68,9 @@ var SpacedeckSections = { line_height: 1.5, letter_spacing: 0, - stroke_color: "#000000", - fill_color: "#00000000", - text_color: "#000000", + stroke_color: ENV.options.default_stroke_color ? ENV.options.default_stroke_color : "#000000", + fill_color: ENV.options.default_fill_color ? ENV.options.default_fill_color : "#000000", + text_color: ENV.options.default_text_color ? ENV.options.default_text_color : "#000000", background_color: "#ffffff", padding: 0, @@ -109,7 +109,7 @@ var SpacedeckSections = { color_picker_hue: 127, color_picker_opacity: 255, - swatches: [ + swatches: ENV.options.swatches ? ENV.options.swatches : [ {id:1, hex:"#ff00ff"}, {id:2, hex:"#ffff00"}, {id:3, hex:"#00ffff"}, @@ -133,18 +133,7 @@ var SpacedeckSections = { {id:26, hex:"#d55c4b"}, {id:27, hex:"#6f4021"}, {id:29, hex:"#95a5a6"}, - {id:30, hex:"rgba(0,0,0,0)"}, - ], - - swatches_text: [ - {id:1, hex:"#9b59b6"}, - {id:2, hex:"#3498db"}, - {id:3, hex:"#2ecc71"}, - {id:4, hex:"#f1c40f"}, - {id:5, hex:"#e67e22"}, - {id:6, hex:"#d55c4b"}, - {id:8, hex:"#ffffff"}, - {id:10, hex:"#252525"}, + {id:30, hex:"rgba(0,0,0,0)"} ], fonts: [ diff --git a/views/spacedeck.ejs b/views/spacedeck.ejs index d17d7a6..9c8b99a 100644 --- a/views/spacedeck.ejs +++ b/views/spacedeck.ejs @@ -17,7 +17,8 @@ webHost: location.host, webEndpoint: location.origin, apiEndpoint: location.origin, - websocketsEndpoint: location.origin.replace("https:","wss:").replace("http:","ws:") + websocketsEndpoint: location.origin.replace("https:","wss:").replace("http:","ws:"), + options: <%- config.spacedeck ? JSON.stringify(config.spacedeck) : "{}" %> };