From: Benjamin Auder Date: Sat, 22 Dec 2018 21:33:21 +0000 (+0100) Subject: Uniformize path to database X-Git-Url: https://git.auder.net/%7B%7B%20asset%28%27mixstore/images/R.css?a=commitdiff_plain;h=a48ee8b80ae4902f1e70629a608396fe3ff046d0;p=vchess.git Uniformize path to database --- diff --git a/.gitignore b/.gitignore index b3dff511..30651eea 100644 --- a/.gitignore +++ b/.gitignore @@ -20,7 +20,7 @@ pids /db/vchess.sqlite # socket URL file -/public/javascripts/utils/socket_url.js +/public/javascripts/socket_url.js # CSS generated files /public/stylesheets/*.map diff --git a/README.md b/README.md index 6e3171dc..59af28d1 100644 --- a/README.md +++ b/README.md @@ -28,8 +28,8 @@ Pieces images where found at various locations. ## Installation (for developers) 0. Install git-fat https://github.com/jedbrown/git-fat - 1. Rename public/javascripts/utils/socket\_url.js.dist into socket\_url.js + 1. git fat init && git fat pull + 2. Execute db/create.sql script (SQLite) to fill db/vchess.sqlite database + 3. Rename public/javascripts/socket\_url.js.dist into socket\url.js and adjust its content. - 2. git fat init && git fat pull - 3. Execute db/create.sql script (SQLite) to fill db/vchess.sqlite database 4. npm i && npm start diff --git a/public/javascripts/utils/socket_url.js.dist b/public/javascripts/socket_url.js.dist similarity index 100% rename from public/javascripts/utils/socket_url.js.dist rename to public/javascripts/socket_url.js.dist diff --git a/routes/all.js b/routes/all.js index 5ab6ae90..54f1611d 100644 --- a/routes/all.js +++ b/routes/all.js @@ -2,7 +2,8 @@ let express = require('express'); let router = express.Router(); const createError = require('http-errors'); const sqlite3 = require('sqlite3');//.verbose(); -const db = new sqlite3.Database('db/vchess.sqlite'); +const DbPath = __dirname.replace("/routes", "/db/vchess.sqlite"); +const db = new sqlite3.Database(DbPath); const sanitizeHtml = require('sanitize-html'); const MaxNbProblems = 20; diff --git a/sockets.js b/sockets.js index 2d9117d2..11fe91cc 100644 --- a/sockets.js +++ b/sockets.js @@ -1,6 +1,6 @@ const url = require('url'); const sqlite3 = require('sqlite3'); -const db = new sqlite3.Database('db/vchess.sqlite'); +const db = new sqlite3.Database(__dirname + "/db/vchess.sqlite"); // Node version in Ubuntu 16.04 does not know about URL class function getJsonFromUrl(url) { diff --git a/views/index.pug b/views/index.pug index 81aafdb1..ba062e33 100644 --- a/views/index.pug +++ b/views/index.pug @@ -40,6 +40,6 @@ block javascripts script. const variantArray = !{JSON.stringify(variantArray)}; script(src="/javascripts/utils/misc.js") - script(src="/javascripts/utils/socket_url.js") + script(src="/javascripts/socket_url.js") script(src="/javascripts/components/variantSummary.js") script(src="/javascripts/index.js") diff --git a/views/variant.pug b/views/variant.pug index 9400ba58..ff41740e 100644 --- a/views/variant.pug +++ b/views/variant.pug @@ -44,12 +44,12 @@ block content block javascripts script(src="/javascripts/utils/misc.js") - script(src="/javascripts/utils/socket_url.js") script(src="/javascripts/utils/array.js") script(src="/javascripts/utils/md5.js") script(src="/javascripts/utils/printDiagram.js") script(src="/javascripts/utils/ajax.js") script(src="/javascripts/utils/datetime.js") + script(src="/javascripts/socket_url.js") script(src="/javascripts/base_rules.js") script(src="/javascripts/variants/" + variant + ".js") script.