diff --git a/dist/build.js b/dist/build.js index e79ad52..2a01d61 100644 --- a/dist/build.js +++ b/dist/build.js @@ -1,5 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); +require("dotenv/config"); const log_1 = require("./log"); const templates_1 = require("./templates"); class Build { diff --git a/dist/build.js.map b/dist/build.js.map index 74f3070..c88b658 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,+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;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 diff --git a/dist/generate.js b/dist/generate.js index 3cc30a4..f9edcde 100644 --- a/dist/generate.js +++ b/dist/generate.js @@ -1,11 +1,27 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); +require("dotenv/config"); const log_1 = require("./log"); +const shell_1 = require("./shell"); class Generate { constructor() { this.log = (0, log_1.createLog)('generate'); this.log.info(`Generating site: ${new Date()}`); } + async checkInbox() { + } + async img(file) { + const cmd = ['bash', 'scripts/img.sh', file]; + const shell = new shell_1.Shell(cmd); + try { + await shell.execute(); + } + catch (err) { + this.log.error(err); + return; + } + this.log.info(`Processed image file for ${file}`); + } } new Generate(); //# sourceMappingURL=generate.js.map \ No newline at end of file diff --git a/dist/generate.js.map b/dist/generate.js.map index 406dd58..4aaf634 100644 --- a/dist/generate.js.map +++ b/dist/generate.js.map @@ -1 +1 @@ -{"version":3,"file":"generate.js","sourceRoot":"","sources":["../src/generate.ts"],"names":[],"mappings":";;AAAA,+BAAkC;AAKlC,MAAM,QAAQ;IAEb;QACC,IAAI,CAAC,GAAG,GAAG,IAAA,eAAS,EAAC,UAAU,CAAC,CAAC;QACjC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,oBAAoB,IAAI,IAAI,EAAE,EAAE,CAAC,CAAC;IACjD,CAAC;CACD;AAED,IAAI,QAAQ,EAAE,CAAC"} \ No newline at end of file +{"version":3,"file":"generate.js","sourceRoot":"","sources":["../src/generate.ts"],"names":[],"mappings":";;AAAA,yBAAuB;AACvB,+BAAkC;AAElC,mCAAgC;AAGhC,MAAM,QAAQ;IAGb;QACC,IAAI,CAAC,GAAG,GAAG,IAAA,eAAS,EAAC,UAAU,CAAC,CAAC;QACjC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,oBAAoB,IAAI,IAAI,EAAE,EAAE,CAAC,CAAC;IACjD,CAAC;IAEO,KAAK,CAAC,UAAU;IAExB,CAAC;IAEO,KAAK,CAAC,GAAG,CAAE,IAAa;QAC/B,MAAM,GAAG,GAAc,CAAC,MAAM,EAAE,gBAAgB,EAAE,IAAI,CAAC,CAAC;QACxD,MAAM,KAAK,GAAW,IAAI,aAAK,CAAC,GAAG,CAAC,CAAC;QACrC,IAAI,CAAC;YACJ,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC;QACvB,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACd,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACpB,OAAO;QACR,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,4BAA4B,IAAI,EAAE,CAAC,CAAC;IACnD,CAAC;CACD;AAED,IAAI,QAAQ,EAAE,CAAC"} \ No newline at end of file diff --git a/scripts/img.sh b/scripts/img.sh new file mode 100644 index 0000000..2454870 --- /dev/null +++ b/scripts/img.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +set -e + +source .env + +INPUT="${1}" + +SIZES=( + "home:420" + "full:1024" +) + +function img () { + convert "${1}" -colorspace LAB -filter Lanczos -resize ${3}x -strip -quality 86 -colorspace sRGB "${2}" + echo "${1} -> ${2}" +} + +mkdir -p "${WWW}/img/" +mkdir -p "${PHOTOS}/" + +for sizeRaw in ${SIZES[@]}; do + sizeName=$(echo $sizeRaw | awk -F':' '{print $1}') + size=$(echo $sizeRaw | awk -F':' '{print $2}') + name=$(basename "${1}") + name=${name%.*} + output="${WWW}/img/${name}_${size}.jpg" + img "${1}" "${output}" "${size}" +done + +mv "${1}" "${PHOTOS}/" diff --git a/src/build.ts b/src/build.ts index a4b1273..c542ea4 100644 --- a/src/build.ts +++ b/src/build.ts @@ -1,3 +1,4 @@ +import 'dotenv/config'; import { createLog } from './log'; import type { Logger } from 'winston'; import { Templates } from './templates'; diff --git a/src/generate.ts b/src/generate.ts index f5b98c5..73eee05 100644 --- a/src/generate.ts +++ b/src/generate.ts @@ -1,3 +1,4 @@ +import 'dotenv/config'; import { createLog } from './log'; import type { Logger } from 'winston'; import { Shell } from './shell'; @@ -5,10 +6,27 @@ import { Database } from 'sqlite3'; class Generate { private log : Logger; + private files : string[]; constructor () { this.log = createLog('generate'); this.log.info(`Generating site: ${new Date()}`); } + + private async checkInbox () { + + } + + private async img (file : string) { + const cmd : string[] = ['bash', 'scripts/img.sh', file]; + const shell : Shell = new Shell(cmd); + try { + await shell.execute(); + } catch (err) { + this.log.error(err); + return; + } + this.log.info(`Processed image file for ${file}`); + } } new Generate(); \ No newline at end of file diff --git a/views/partials/img.hbs b/views/partials/img.hbs index f85c1d1..8de44fa 100644 --- a/views/partials/img.hbs +++ b/views/partials/img.hbs @@ -1,3 +1,3 @@ - {{alt}} + {{alt}}