diff --git a/dist/build.js b/dist/build.js index 2a01d61..be69751 100644 --- a/dist/build.js +++ b/dist/build.js @@ -2,16 +2,21 @@ Object.defineProperty(exports, "__esModule", { value: true }); require("dotenv/config"); const log_1 = require("./log"); +const db_1 = require("./db"); const templates_1 = require("./templates"); class Build { constructor() { this.log = (0, log_1.createLog)('build'); this.log.info(`Building site: ${new Date()}`); this.tmpl = new templates_1.Templates(); + this.db = new db_1.DB(); this.main(); } async main() { - this.tmpl.build(); + let photos; + await this.tmpl.build(); + photos = await this.db.getAll(); + await this.tmpl.render('index', { photos }); } } new Build(); diff --git a/dist/build.js.map b/dist/build.js.map index c88b658..a810cdf 100644 --- a/dist/build.js.map +++ b/dist/build.js.map @@ -1 +1 @@ -{"version":3,"file":"build.js","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":";;AAAA,yBAAuB;AACvB,+BAAkC;AAElC,2CAAwC;AAGxC,MAAM,KAAK;IAGV;QACC,IAAI,CAAC,GAAG,GAAG,IAAA,eAAS,EAAC,OAAO,CAAC,CAAC;QAC9B,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,kBAAkB,IAAI,IAAI,EAAE,EAAE,CAAC,CAAC;QAC9C,IAAI,CAAC,IAAI,GAAG,IAAI,qBAAS,EAAE,CAAC;QAC5B,IAAI,CAAC,IAAI,EAAE,CAAC;IACb,CAAC;IAEO,KAAK,CAAC,IAAI;QACjB,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;IACnB,CAAC;CACD;AAED,IAAI,KAAK,EAAE,CAAC"} \ No newline at end of file +{"version":3,"file":"build.js","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":";;AAAA,yBAAuB;AAEvB,+BAAkC;AAIlC,6BAA0B;AAE1B,2CAAwC;AAExC,MAAM,KAAK;IAKV;QACC,IAAI,CAAC,GAAG,GAAG,IAAA,eAAS,EAAC,OAAO,CAAC,CAAC;QAC9B,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,kBAAkB,IAAI,IAAI,EAAE,EAAE,CAAC,CAAC;QAC9C,IAAI,CAAC,IAAI,GAAG,IAAI,qBAAS,EAAE,CAAC;QAC5B,IAAI,CAAC,EAAE,GAAG,IAAI,OAAE,EAAE,CAAC;QACnB,IAAI,CAAC,IAAI,EAAE,CAAC;IACb,CAAC;IAEO,KAAK,CAAC,IAAI;QACjB,IAAI,MAAgB,CAAC;QACrB,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;QAExB,MAAM,GAAG,MAAM,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC;QAChC,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IAC7C,CAAC;CACD;AAED,IAAI,KAAK,EAAE,CAAC"} \ No newline at end of file diff --git a/dist/db/index.js b/dist/db/index.js index 8b858ac..9bc27a8 100644 --- a/dist/db/index.js +++ b/dist/db/index.js @@ -7,9 +7,11 @@ const sqlite3_1 = require("sqlite3"); const env_1 = require("../env"); class DB { constructor() { + const databaseFile = (0, env_1.envString)('DB', 'data/site.db'); this.log = (0, log_1.createLog)('db'); - this.db = new sqlite3_1.Database((0, env_1.envString)('DB', 'data/site.db')); - //this.db.run( 'PRAGMA journal_mode = WAL;'); + this.db = new sqlite3_1.Database(databaseFile); + this.db.run('PRAGMA journal_mode = WAL;'); + this.log.info(`DB: ${databaseFile}`); } async run(query, args = null) { return new Promise((resolve, reject) => { @@ -86,6 +88,17 @@ class DB { } return exists; } + async getAll() { + const query = `SELECT * FROM photos;`; + let rows = []; + try { + rows = await this.all(query); + } + catch (err) { + this.log.error(`Error getting all photos`, err); + } + return rows; + } async cacheLocation(location, latlng) { const query = `INSERT OR IGNORE INTO geocode (location, latitude, longitude) VALUES (?, ?, ?);`; try { diff --git a/dist/db/index.js.map b/dist/db/index.js.map index 934af27..4ed5c01 100644 --- a/dist/db/index.js.map +++ b/dist/db/index.js.map @@ -1 +1 @@ -{"version":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IAAI,CAAC;YACJ,IAAI,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;QAC1C,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACd,QAAQ;QACT,CAAC;QAED,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACrB,GAAG,GAAG;gBACL,QAAQ,EAAG,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ;gBAC3B,SAAS,EAAG,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS;aAC7B,CAAA;QACF,CAAC;QAED,OAAO,GAAG,CAAC;IACZ,CAAC;CAED;AAhID,gBAgIC;AAED,MAAM,CAAC,OAAO,GAAG,EAAE,EAAE,EAAE,CAAC"} \ No newline at end of file diff --git a/dist/templates/index.js b/dist/templates/index.js index a7ee622..d436e3d 100644 --- a/dist/templates/index.js +++ b/dist/templates/index.js @@ -50,6 +50,7 @@ class Templates { templates = templates .filter(el => el.indexOf('.hbs') !== -1 || el.indexOf('.handlebars') !== -1) .map(el => (0, path_1.join)(this.dir, el)); + //this.log.info(`Found ${templates.length} templates`); for (let template of templates) { name = (0, path_1.parse)((0, path_1.basename)(template)).name; try { diff --git a/dist/templates/index.js.map b/dist/templates/index.js.map index 723a741..445841a 100644 --- a/dist/templates/index.js.map +++ b/dist/templates/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/templates/index.ts"],"names":[],"mappings":";;;;;;AAAA,4DAAoC;AACpC,4EAAyC;AACzC,0CAAgD;AAChD,+BAA6C;AAC7C,gCAAmC;AAGnC,IAAA,4BAAO,GAAE,CAAC;AAEV,MAAa,SAAS;IAKrB,YAAa,MAAe,SAAS;QAF7B,cAAS,GAAS,EAAE,CAAC;QAG5B,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,GAAG,GAAG,IAAA,eAAS,EAAC,MAAM,CAAC,CAAC;IAC9B,C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AAC,cAAc,IAAI,EAAE,CAAC,CAAC;QACrC,CAAC;IACF,CAAC;IAEM,MAAM,CAAE,IAAa,EAAE,IAAU;QACvC,MAAM,IAAI,GAAc,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC1C,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,IAAI,gBAAgB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACnE,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC;CACD;AAnED,8BAmEC;AAED,MAAM,CAAC,OAAO,GAAG,EAAE,SAAS,EAAE,CAAC"} \ No newline at end of file diff --git a/src/build.ts b/src/build.ts index 957b117..7e1647c 100644 --- a/src/build.ts +++ b/src/build.ts @@ -1,21 +1,32 @@ import 'dotenv/config'; + import { createLog } from './log'; import type { Logger } from 'winston'; -import { Templates } from './templates'; +import { readFile, writeFile } from 'fs/promises'; +import { DB } from './db'; +import type { Photo } from './db'; +import { Templates } from './templates'; class Build { private log : Logger; private tmpl : Templates; + private db : DB; + constructor () { this.log = createLog('build'); this.log.info(`Building site: ${new Date()}`); this.tmpl = new Templates(); + this.db = new DB(); this.main(); } private async main () { - this.tmpl.build(); + let photos : Photo[]; + await this.tmpl.build(); + + photos = await this.db.getAll(); + await this.tmpl.render('index', { photos }); } } diff --git a/src/db/index.ts b/src/db/index.ts index e9adcd5..6d3fd58 100644 --- a/src/db/index.ts +++ b/src/db/index.ts @@ -35,9 +35,11 @@ export class DB { private log : Logger; constructor () { + const databaseFile : string = envString('DB', 'data/site.db'); this.log = createLog('db'); - this.db = new Database(envString('DB', 'data/site.db')); - //this.db.run( 'PRAGMA journal_mode = WAL;'); + this.db = new Database(databaseFile); + this.db.run( 'PRAGMA journal_mode = WAL;'); + this.log.info(`DB: ${databaseFile}`); } private async run (query : string, args : any[] = null) { @@ -116,6 +118,17 @@ export class DB { return exists; } + public async getAll () : Promise { + const query : string = `SELECT * FROM photos;`; + let rows : Photo[] = []; + try { + rows = await this.all(query); + } catch (err) { + this.log.error(`Error getting all photos`, err); + } + return rows; + } + public async cacheLocation (location : string, latlng : LatLng) { const query : string = `INSERT OR IGNORE INTO geocode (location, latitude, longitude) VALUES (?, ?, ?);`; try { @@ -143,7 +156,6 @@ export class DB { } return res; - } } diff --git a/src/templates/index.ts b/src/templates/index.ts index 117b98c..ef49241 100644 --- a/src/templates/index.ts +++ b/src/templates/index.ts @@ -54,6 +54,8 @@ export class Templates { .filter(el => el.indexOf('.hbs') !== -1 || el.indexOf('.handlebars') !== -1) .map(el => join(this.dir, el)); + //this.log.info(`Found ${templates.length} templates`); + for (let template of templates) { name = parse(basename(template)).name; try {