Uniformize path to database
authorBenjamin Auder <benjamin.auder@somewhere>
Sat, 22 Dec 2018 21:33:21 +0000 (22:33 +0100)
committerBenjamin Auder <benjamin.auder@somewhere>
Sat, 22 Dec 2018 21:33:21 +0000 (22:33 +0100)
.gitignore
README.md
public/javascripts/socket_url.js.dist [moved from public/javascripts/utils/socket_url.js.dist with 100% similarity]
routes/all.js
sockets.js
views/index.pug
views/variant.pug

index b3dff51..30651ee 100644 (file)
@@ -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
index 6e3171d..59af28d 100644 (file)
--- 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
index 5ab6ae9..54f1611 100644 (file)
@@ -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;
 
index 2d9117d..11fe91c 100644 (file)
@@ -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) {
index 81aafdb..ba062e3 100644 (file)
@@ -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")
index 9400ba5..ff41740 100644 (file)
@@ -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.