-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
1,140 additions
and
588 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
import { TimeContext } from './time/TimeContext'; | ||
import { CaseDirectoryStep } from './science/crypto/ufo/enquete/dossier/CaseDirectoryStep'; | ||
import { PeopleDirectoryStep } from './people/PeopleDirectoryStep'; | ||
import { promise as glob } from 'glob-promise'; | ||
import { GooglePlaceService } from './place/GooglePlaceService'; | ||
import { OrganizationService } from './org/OrganizationService'; | ||
import { RR0SsgContextImpl } from './RR0SsgContext'; | ||
import { CLI } from './util/cli/CLI'; | ||
import { TimeContext } from "./time/TimeContext" | ||
import { CaseDirectoryStep } from "./science/crypto/ufo/enquete/dossier/CaseDirectoryStep" | ||
import { PeopleDirectoryStep } from "./people/PeopleDirectoryStep" | ||
import { promise as glob } from "glob-promise" | ||
import { GooglePlaceService } from "./place/GooglePlaceService" | ||
import { OrganizationService } from "./org/OrganizationService" | ||
import { RR0SsgContextImpl } from "./RR0SsgContext" | ||
import { CLI } from "./util/cli/CLI" | ||
import { | ||
AngularExpressionReplaceCommand, | ||
ClassDomRegexReplaceCommand, | ||
|
@@ -25,203 +25,206 @@ import { | |
SsiLastModifiedReplaceCommand, | ||
SsiSetVarReplaceCommand, | ||
StringEchoVarReplaceCommand | ||
} from 'ssg-api'; | ||
import { LanguageReplaceCommand } from './lang/LanguageReplaceCommand'; | ||
import { SsiTitleReplaceCommand } from './time/SsiTitleReplaceCommand'; | ||
import { PeopleReplacerFactory } from './people/PeopleReplacerFactory'; | ||
import { SourceReplacerFactory } from './source/SourceReplacerFactory'; | ||
import { timeDefaultHandler } from './time/TimeDefaultTitle'; | ||
import { NoteReplacerFactory } from './note/NoteReplacerFactory'; | ||
import { WitnessReplacerFactory } from './people/witness/WitnessReplacerFactory'; | ||
import { AnchorReplaceCommand } from './anchor/AnchorReplaceCommand'; | ||
import { TimeLinkDefaultHandler } from './time/TimeLinkDefaultHandler'; | ||
import { AuthorReplaceCommand } from './people/author/AuthorReplaceCommand'; | ||
import { rr0DefaultCopyright } from './RR0DefaultCopyright'; | ||
import { PlaceReplacerFactory } from './place/PlaceReplacerFactory'; | ||
import { TimeReplacerFactory } from './time/TimeReplacerFactory'; | ||
import { LinkReplaceCommand } from './LinkReplaceCommand'; | ||
import { OutlineReplaceCommand } from './outline/OutlineReplaceCommand'; | ||
import { RR0ContentStep } from './RR0ContentStep'; | ||
import { ImageCommand } from './ImageCommand'; | ||
import { SearchCommand } from './search/SearchCommand'; | ||
import { SearchIndexStep } from './search/SearchIndexStep'; | ||
import { BaseReplaceCommand } from './BaseReplaceCommand'; | ||
import { OpenGraphCommand } from './OpenGraphCommand'; | ||
import { DescriptionReplaceCommand } from './DescriptionReplaceCommand'; | ||
import { BookDirectoryStep } from './book/BookDirectoryStep'; | ||
import path from 'path'; | ||
import { IndexedReplacerFactory } from './index/indexedReplacerFactory'; | ||
import { CodeReplacerFactory } from './tech/info/soft/proj/impl/lang/CodeReplacerFactory'; | ||
} from "ssg-api" | ||
import { LanguageReplaceCommand } from "./lang/LanguageReplaceCommand" | ||
import { SsiTitleReplaceCommand } from "./time/SsiTitleReplaceCommand" | ||
import { PeopleReplacerFactory } from "./people/PeopleReplacerFactory" | ||
import { SourceReplacerFactory } from "./source/SourceReplacerFactory" | ||
import { timeDefaultHandler } from "./time/TimeDefaultTitle" | ||
import { NoteReplacerFactory } from "./note/NoteReplacerFactory" | ||
import { WitnessReplacerFactory } from "./people/witness/WitnessReplacerFactory" | ||
import { AnchorReplaceCommand } from "./anchor/AnchorReplaceCommand" | ||
import { TimeLinkDefaultHandler } from "./time/TimeLinkDefaultHandler" | ||
import { AuthorReplaceCommand } from "./people/author/AuthorReplaceCommand" | ||
import { rr0DefaultCopyright } from "./RR0DefaultCopyright" | ||
import { PlaceReplacerFactory } from "./place/PlaceReplacerFactory" | ||
import { TimeReplacerFactory } from "./time/TimeReplacerFactory" | ||
import { LinkReplaceCommand } from "./LinkReplaceCommand" | ||
import { OutlineReplaceCommand } from "./outline/OutlineReplaceCommand" | ||
import { RR0ContentStep } from "./RR0ContentStep" | ||
import { ImageCommand } from "./ImageCommand" | ||
import { SearchCommand } from "./search/SearchCommand" | ||
import { SearchIndexStep } from "./search/SearchIndexStep" | ||
import { BaseReplaceCommand } from "./BaseReplaceCommand" | ||
import { OpenGraphCommand } from "./OpenGraphCommand" | ||
import { DescriptionReplaceCommand } from "./DescriptionReplaceCommand" | ||
import { BookDirectoryStep } from "./book/BookDirectoryStep" | ||
import path from "path" | ||
import { IndexedReplacerFactory } from "./index/indexedReplacerFactory" | ||
import { CodeReplacerFactory } from "./tech/info/soft/proj/impl/lang/CodeReplacerFactory" | ||
import { ChronologyReplacerFactory } from "./time/datasource/ChronologyReplacerFactory" | ||
import { BaseOvniFranceChronologySource } from "./time/datasource/BaseOvniFranceChronologySource" | ||
|
||
const args = new CLI().getArgs(); | ||
const cliContents = args.contents; | ||
const args = new CLI().getArgs() | ||
const cliContents = args.contents | ||
const contentRoots = cliContents | ||
? cliContents.split(',') | ||
? cliContents.split(",") | ||
: [ | ||
'croyance/**/*.html', | ||
'index.html', '404.html', 'googlebe03dcf00678bb7c.html', 'Contact.html', 'Copyright.html', 'preambule.html', 'FAQ.html', 'Referencement.html', | ||
'time/**/*.html', | ||
'book/**/*.html', | ||
'droit/**/*.html', | ||
'org/**/*.html', | ||
'people/**/*.html', | ||
'place/**/*.html', | ||
'politique/**/*.html', | ||
'science/**/*.html', | ||
'tech/**/*.html', | ||
'politique/**/*.html', | ||
'udb/*.html', | ||
'js/**/*.html' | ||
]; | ||
const copiesArg = args.copies; | ||
const copies = copiesArg ? copiesArg.split(',') : [ | ||
'favicon.ico', 'manifest.json', 'opensearch.xml', 'apple-touch-icon.png', 'apple-touch-icon_400x400.png', 'screenshot1.jpg', | ||
'rr0.css', 'print.css', | ||
"croyance/**/*.html", | ||
"index.html", "404.html", "googlebe03dcf00678bb7c.html", "Contact.html", "Copyright.html", "preambule.html", "FAQ.html", "Referencement.html", | ||
"time/**/*.html", | ||
"book/**/*.html", | ||
"droit/**/*.html", | ||
"org/**/*.html", | ||
"people/**/*.html", | ||
"place/**/*.html", | ||
"politique/**/*.html", | ||
"science/**/*.html", | ||
"tech/**/*.html", | ||
"politique/**/*.html", | ||
"udb/*.html", | ||
"js/**/*.html" | ||
] | ||
const copiesArg = args.copies | ||
const copies = copiesArg ? copiesArg.split(",") : [ | ||
"favicon.ico", "manifest.json", "opensearch.xml", "apple-touch-icon.png", "apple-touch-icon_400x400.png", "screenshot1.jpg", | ||
"rr0.css", "print.css", | ||
// "**/*.png", "**/*.jpg", "**/*.gif", "**/*.webp", "!out/**/*", | ||
'**/*.cmmn', '**/*.bpmn', | ||
'people/index.js', 'people/lier.svg', 'people/index.css', | ||
'search/index.js', 'search/index.json', | ||
'index/index.js', 'index/lang.js', | ||
'croyance/religion/theisme/mono/livre/islam/coran/index.js', | ||
'udb/**/*.js', | ||
'udb/netlify.toml', | ||
'udb/input/db/udb/data/*.*' | ||
]; | ||
"**/*.cmmn", "**/*.bpmn", | ||
"people/index.js", "people/lier.svg", "people/index.css", | ||
"search/index.js", "search/index.json", | ||
"index/index.js", "index/lang.js", | ||
"croyance/religion/theisme/mono/livre/islam/coran/index.js", | ||
"udb/**/*.js", | ||
"udb/netlify.toml", | ||
"udb/input/db/udb/data/*.*" | ||
] | ||
const config: SsgConfig = { | ||
outDir: 'out' | ||
}; | ||
outDir: "out" | ||
} | ||
|
||
const outputFunc: OutputFunc | ||
= async (context: SsgContext, info: SsgFile, outDir = config.outDir + '/'): Promise<void> => { | ||
= async (context: SsgContext, info: SsgFile, outDir = config.outDir + "/"): Promise<void> => { | ||
// TODO: Fix this | ||
if (info.name.startsWith(outDir)) { | ||
if (info.name.startsWith(path.join(outDir, outDir))) { | ||
info.name = info.name.substring(outDir.length); | ||
info.name = info.name.substring(outDir.length) | ||
} | ||
} else { | ||
info.name = outDir + info.name; | ||
info.name = outDir + info.name | ||
} | ||
try { | ||
context.log('Writing', info.name); | ||
await info.write(); | ||
context.log("Writing", info.name) | ||
await info.write() | ||
} catch (e) { | ||
context.error(info.name, e); | ||
context.error(info.name, e) | ||
} | ||
}; | ||
} | ||
|
||
const timeFormat: Intl.DateTimeFormatOptions = { | ||
year: 'numeric', | ||
month: 'long', | ||
day: 'numeric', | ||
weekday: 'long', | ||
hour: '2-digit', | ||
minute: '2-digit' | ||
}; | ||
const timeContext = new TimeContext(timeFormat); | ||
const context = new RR0SsgContextImpl('fr', timeContext); | ||
context.setVar('mail', '[email protected]'); | ||
year: "numeric", | ||
month: "long", | ||
day: "numeric", | ||
weekday: "long", | ||
hour: "2-digit", | ||
minute: "2-digit" | ||
} | ||
const timeContext = new TimeContext(timeFormat) | ||
const context = new RR0SsgContextImpl("fr", timeContext) | ||
context.setVar("mail", "[email protected]") | ||
|
||
const siteBaseUrl = 'https://rr0.org/'; | ||
const siteBaseUrl = "https://rr0.org/" | ||
const htAccessToNetlifyConfig: ContentStepConfig = { | ||
replacements: [new HtAccessToNetlifyConfigReplaceCommand(siteBaseUrl)], | ||
roots: ['.htaccess'], | ||
roots: [".htaccess"], | ||
getOutputFile(context: SsgContext): SsgFile { | ||
return SsgFile.read(context, 'netlify.toml', 'utf-8'); | ||
return SsgFile.read(context, "netlify.toml", "utf-8") | ||
} | ||
}; | ||
} | ||
|
||
async function getTimeFiles(): Promise<string[]> { | ||
const minusYearFiles = await glob('time/-?/?/?/?/index.html'); | ||
const year1Files = await glob('time/?/index.html'); | ||
const year2Files = await glob('time/?/?/index.html'); | ||
const year3Files = await glob('time/?/?/?/index.html'); | ||
const year4Files = await glob('time/?/?/?/?/index.html'); | ||
const monthFiles = await glob('time/?/?/?/?/??/index.html'); | ||
const dayFiles = await glob('time/?/?/?/?/??/??/index.html'); | ||
const minusYearFiles = await glob("time/-?/?/?/?/index.html") | ||
const year1Files = await glob("time/?/index.html") | ||
const year2Files = await glob("time/?/?/index.html") | ||
const year3Files = await glob("time/?/?/?/index.html") | ||
const year4Files = await glob("time/?/?/?/?/index.html") | ||
const monthFiles = await glob("time/?/?/?/?/??/index.html") | ||
const dayFiles = await glob("time/?/?/?/?/??/??/index.html") | ||
return year1Files.concat(year2Files).concat(year3Files).concat(year4Files).concat( | ||
minusYearFiles).concat(monthFiles).concat(dayFiles).sort(); | ||
minusYearFiles).concat(monthFiles).concat(dayFiles).sort() | ||
} | ||
|
||
getTimeFiles().then(async (timeFiles) => { | ||
const ufoCasesStep = await CaseDirectoryStep.create(outputFunc, config); | ||
const peopleSteps = await PeopleDirectoryStep.create(outputFunc, config); | ||
const booksStep = await BookDirectoryStep.create(outputFunc, config); | ||
const ufoCasesStep = await CaseDirectoryStep.create(outputFunc, config) | ||
const peopleSteps = await PeopleDirectoryStep.create(outputFunc, config) | ||
const booksStep = await BookDirectoryStep.create(outputFunc, config) | ||
|
||
const apiKey = process.env.GOOGLE_MAPS_API_KEY; | ||
const apiKey = process.env.GOOGLE_MAPS_API_KEY | ||
if (!apiKey) { | ||
throw Error('GOOGLE_MAPS_API_KEY is required'); | ||
throw Error("GOOGLE_MAPS_API_KEY is required") | ||
} | ||
context.setVar('mapsApiKey', apiKey); | ||
const placeService = new GooglePlaceService('place', apiKey); | ||
context.setVar("mapsApiKey", apiKey) | ||
const placeService = new GooglePlaceService("place", apiKey) | ||
|
||
const orgService = new OrganizationService('org'); | ||
const orgService = new OrganizationService("org") | ||
|
||
const searchCommand = new SearchCommand({ | ||
notIndexedUrls: ['404.html', 'Referencement.html'], | ||
notIndexedUrls: ["404.html", "Referencement.html"], | ||
indexWords: false, | ||
indexContent: 'contentsIndex.json' | ||
}); | ||
const baseUrl = 'https://rr0.org'; | ||
indexContent: "contentsIndex.json" | ||
}) | ||
const baseUrl = "https://rr0.org" | ||
const contentReplacements = [ | ||
new SsiIncludeReplaceCommand(), | ||
new BaseReplaceCommand('/'), | ||
new BaseReplaceCommand("/"), | ||
new LanguageReplaceCommand(), | ||
new StringEchoVarReplaceCommand('mail'), | ||
new StringEchoVarReplaceCommand('mapsApiKey'), | ||
new StringEchoVarReplaceCommand("mail"), | ||
new StringEchoVarReplaceCommand("mapsApiKey"), | ||
new AngularExpressionReplaceCommand(), | ||
new SsiEchoVarReplaceCommand('copyright', [rr0DefaultCopyright]), | ||
new SsiEchoVarReplaceCommand("copyright", [rr0DefaultCopyright]), | ||
new SsiIfReplaceCommand(), | ||
new SsiSetVarReplaceCommand('title', (match: string, ...args: any[]) => `<title>${args[0]}</title>`), | ||
new SsiSetVarReplaceCommand('url', | ||
new SsiSetVarReplaceCommand("title", (match: string, ...args: any[]) => `<title>${args[0]}</title>`), | ||
new SsiSetVarReplaceCommand("url", | ||
(match: string, ...args: any[]) => `<meta name="url" content="${args[0]}"/>`), | ||
new SsiLastModifiedReplaceCommand(context.time.options), | ||
new SsiTitleReplaceCommand([timeDefaultHandler]), | ||
new AuthorReplaceCommand(timeFiles), | ||
new HtmlTagReplaceCommand('time', new TimeReplacerFactory(timeFiles)), | ||
new HtmlTagReplaceCommand('code', new CodeReplacerFactory()), | ||
new ClassDomReplaceCommand('people', new PeopleReplacerFactory()), | ||
new ClassDomReplaceCommand('place', new PlaceReplacerFactory(placeService, orgService)), | ||
new ClassDomRegexReplaceCommand('temoin(.?)', new WitnessReplacerFactory()), | ||
new ClassDomReplaceCommand('note', new NoteReplacerFactory()), | ||
new ClassDomReplaceCommand('source', new SourceReplacerFactory()), | ||
new ClassDomReplaceCommand('indexed', new IndexedReplacerFactory()), | ||
new HtmlTagReplaceCommand("ul", new ChronologyReplacerFactory([new BaseOvniFranceChronologySource()])), | ||
new HtmlTagReplaceCommand("time", new TimeReplacerFactory(timeFiles)), | ||
new HtmlTagReplaceCommand("code", new CodeReplacerFactory()), | ||
new ClassDomReplaceCommand("people", new PeopleReplacerFactory()), | ||
new ClassDomReplaceCommand("place", new PlaceReplacerFactory(placeService, orgService)), | ||
new ClassDomRegexReplaceCommand("temoin(.?)", new WitnessReplacerFactory()), | ||
new ClassDomReplaceCommand("note", new NoteReplacerFactory()), | ||
new ClassDomReplaceCommand("source", new SourceReplacerFactory()), | ||
new ClassDomReplaceCommand("indexed", new IndexedReplacerFactory()), | ||
new LinkReplaceCommand(new TimeLinkDefaultHandler(timeFiles)), | ||
new OutlineReplaceCommand(), | ||
new AnchorReplaceCommand(siteBaseUrl), | ||
new DescriptionReplaceCommand('UFO data for french-reading people', 'abstract'), | ||
new DescriptionReplaceCommand("UFO data for french-reading people", "abstract"), | ||
new ImageCommand(config.outDir, 275, 500), | ||
new OpenGraphCommand(config.outDir, timeFiles, baseUrl), | ||
searchCommand | ||
]; | ||
] | ||
const contentConfigs: ContentStepConfig[] = [ | ||
htAccessToNetlifyConfig, | ||
{ | ||
roots: contentRoots, | ||
replacements: contentReplacements, | ||
getOutputFile(context: SsgContext): SsgFile { | ||
return context.outputFile; | ||
return context.outputFile | ||
} | ||
} | ||
]; | ||
const copyStep = new CopyStep(copies, config, {ignore: ['node_modules/**', 'out/**']}); | ||
] | ||
const copyStep = new CopyStep(copies, config, {ignore: ["node_modules/**", "out/**"]}) | ||
const ssg = new Ssg(config) | ||
.add(new RR0ContentStep(contentConfigs, outputFunc)) | ||
.add(ufoCasesStep) | ||
.add(...peopleSteps) | ||
.add(booksStep); | ||
.add(booksStep) | ||
|
||
if (args.reindex === 'true') { | ||
ssg.add(new SearchIndexStep('search/index.json', searchCommand)); | ||
if (args.reindex === "true") { | ||
ssg.add(new SearchIndexStep("search/index.json", searchCommand)) | ||
} | ||
ssg | ||
.add(copyStep) | ||
.start(context) | ||
.then(result => context.log('Completed', result)) | ||
.then(result => context.log("Completed", result)) | ||
.catch(err => { | ||
try { | ||
context.error(err, context.inputFile.name, '=>', context.outputFile?.name); | ||
context.error(err, context.inputFile.name, "=>", context.outputFile?.name) | ||
} catch (e) { | ||
context.error(err); | ||
context.error(err) | ||
} | ||
}); | ||
}); | ||
}) | ||
}) |
Oops, something went wrong.