Work in progress

This commit is contained in:
mmcwilliams 2024-01-08 15:10:39 -05:00
parent 2106cafbe2
commit 120ba4545f
8 changed files with 70 additions and 3 deletions

1
dist/build.js vendored
View File

@ -1,5 +1,6 @@
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
require("dotenv/config");
const log_1 = require("./log"); const log_1 = require("./log");
const templates_1 = require("./templates"); const templates_1 = require("./templates");
class Build { class Build {

2
dist/build.js.map vendored
View File

@ -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"} {"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"}

16
dist/generate.js vendored
View File

@ -1,11 +1,27 @@
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
require("dotenv/config");
const log_1 = require("./log"); const log_1 = require("./log");
const shell_1 = require("./shell");
class Generate { class Generate {
constructor() { constructor() {
this.log = (0, log_1.createLog)('generate'); this.log = (0, log_1.createLog)('generate');
this.log.info(`Generating site: ${new Date()}`); 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(); new Generate();
//# sourceMappingURL=generate.js.map //# sourceMappingURL=generate.js.map

View File

@ -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"} {"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"}

31
scripts/img.sh Normal file
View File

@ -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}/"

View File

@ -1,3 +1,4 @@
import 'dotenv/config';
import { createLog } from './log'; import { createLog } from './log';
import type { Logger } from 'winston'; import type { Logger } from 'winston';
import { Templates } from './templates'; import { Templates } from './templates';

View File

@ -1,3 +1,4 @@
import 'dotenv/config';
import { createLog } from './log'; import { createLog } from './log';
import type { Logger } from 'winston'; import type { Logger } from 'winston';
import { Shell } from './shell'; import { Shell } from './shell';
@ -5,10 +6,27 @@ import { Database } from 'sqlite3';
class Generate { class Generate {
private log : Logger; private log : Logger;
private files : string[];
constructor () { constructor () {
this.log = createLog('generate'); this.log = createLog('generate');
this.log.info(`Generating site: ${new Date()}`); 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(); new Generate();

View File

@ -1,3 +1,3 @@
<a href="{{full}}"> <a href="{{full}}">
<img id="{{public_id}}" src="{{home}}" loading="lazy" class="lazy" width="1024" alt="{{alt}}" title="{{title}}" /> <img id="{{public_id}}" src="{{home}}" loading="lazy" class="lazy" width="1024" alt="{{alt}}" title="{{title}}" />
</a> </a>