From 3b2f391d291e37e0c39a3fc4c7a406c4b6da12b1 Mon Sep 17 00:00:00 2001 From: Gio Date: Mon, 25 Mar 2024 20:47:21 -0500 Subject: upd8: Search implementation --- src/upd8.js | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'src/upd8.js') diff --git a/src/upd8.js b/src/upd8.js index cdf39923..358bf47b 100755 --- a/src/upd8.js +++ b/src/upd8.js @@ -51,6 +51,8 @@ import {sortByName} from '#sort'; import {generateURLs, urlSpec} from '#urls'; import {identifyAllWebRoutes} from '#web-routes'; +import {writeSearchIndex} from '#search' + import { colors, decorateTime, @@ -143,6 +145,9 @@ async function main() { {...defaultStepStatus, name: `generate thumbnails`, for: ['thumbs']}, + buildSearchIndex: + {...defaultStepStatus, name: `generate search index`}, + loadDataFiles: {...defaultStepStatus, name: `load and process data files`, for: ['build']}, @@ -356,6 +361,11 @@ async function main() { type: 'flag', }, + 'skip-search': { + help: `Skip creation of the text search file`, + type: 'flag', + }, + // Just working on data entries and not interested in actually // generating site HTML yet? This flag will cut execution off right // 8efore any site 8uilding actually happens. @@ -760,6 +770,15 @@ async function main() { buildConfig: 'webRoutes', }); + fallbackStep('buildSearchIndex', { + default: 'perform', + buildConfig: 'search', + cli: { + flag: 'skip-search', + negate: true, + }, + }); + fallbackStep('verifyImagePaths', { default: 'perform', buildConfig: 'mediaValidation', @@ -1456,6 +1475,23 @@ async function main() { }); } + if (stepStatusSummary.buildSearchIndex.status === STATUS_NOT_STARTED) { + Object.assign(stepStatusSummary.buildSearchIndex, { + status: STATUS_STARTED_NOT_DONE, + timeStart: Date.now(), + }); + + const search_index_path = path.join(mediaPath, "search_index.json") + logInfo(`Search index: ${search_index_path}`) + + await writeSearchIndex(search_index_path, wikiData) + + Object.assign(stepStatusSummary.buildSearchIndex, { + status: STATUS_DONE_CLEAN, + timeEnd: Date.now(), + }); + } + // Filter out any things with duplicate directories throughout the data, // warning about them too. -- cgit 1.3.0-6-gf8a5