Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Javarome committed Jul 28, 2024
1 parent 4d70b74 commit e346353
Show file tree
Hide file tree
Showing 51 changed files with 1,081 additions and 275 deletions.
4 changes: 1 addition & 3 deletions DataService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ export class DataService {
}

async get<T extends RR0Data = RR0Data>(dirName: string, types: string[], fileNames: string[] = this.factories.reduce(
(allFileNames,
factory) => factory.fileNames.concat(
allFileNames), [])): Promise<T[]> {
(allFileNames, factory) => factory.fileNames.concat(allFileNames), [])): Promise<T[]> {
const key = dirName + "$" + fileNames.join("$")
let dataList = this.pathToData.get(key)
if (dataList === undefined) {
Expand Down
31 changes: 31 additions & 0 deletions PerFileCounter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { HtmlSsgContext } from "ssg-api/dist/src/HtmlSsgContext"
import { ReferenceGenerator } from "./ReferenceGenerator"

export abstract class PerFileCounter<C extends HtmlSsgContext> implements ReferenceGenerator<C> {
/**
* Source counter in the scope of the current page/context.
*/
protected number = 1

/**
* The current/previous page
*
* @protected
*/
protected fileName: string

get value(): string {
return "" + this.number
}

next(context: C): string {
const contextFilename = context.file.name
if (contextFilename !== this.fileName) {
this.fileName = contextFilename
this.number = 1
} else {
this.number++
}
return this.value
}
}
8 changes: 8 additions & 0 deletions ReferenceGenerator.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { HtmlSsgContext } from "ssg-api/dist/src/HtmlSsgContext"

export interface ReferenceGenerator<C extends HtmlSsgContext> {

readonly value: string

next(context: C): string
}
9 changes: 9 additions & 0 deletions book/Book.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,18 @@ import { Chapter } from "./Chapters"
import { Source } from "../source/Source"

export type Book = Source & {
/**
* Here the "book" type is assertained.
*/
type: "book"

/**
* Variants roots (language-specific, typically)
*/
readonly variants: Chapter[],

/**
* ISBN codes
*/
readonly isbn?: string
}
2 changes: 1 addition & 1 deletion book/BookDirectoryStep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class BookDirectoryStep extends DirectoryStep {
}
books.push(dirBook)
try {
const jsonFileInfo = FileContents.read(context, `${dirName}/book.json`)
const jsonFileInfo = FileContents.read(`${dirName}/book.json`)
Object.assign(dirBook, JSON.parse(jsonFileInfo.contents))
} catch (e) {
context.warn(`${dirName} has no book*.json description`)
Expand Down
29 changes: 21 additions & 8 deletions build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ import { CaseAnchorHandler } from "./anchor/CaseAnchorHandler"
import { DataService, DefaultDataFactory } from "./DataService"
import { DataAnchorHandler } from "./anchor/DataAnchorHandler"
import { CaseSummaryRenderer } from "./time/CaseSummaryRenderer"
import { EventReplacerFactory } from "./time/EventReplacerFactory"
import { EventReplacer, EventReplacerFactory } from "./time/EventReplacerFactory"
import { HttpSource } from "./time/datasource/HttpSource"
import { SourceRenderer } from "./source/SourceRenderer"
import { TimeService } from "./time/TimeService"
Expand All @@ -71,6 +71,12 @@ import { TimeReplacer } from "./time/TimeReplacer"
import { UnitReplaceCommand } from "./value/UnitReplaceCommand"
import { BookContentVisitor } from "./book/BookContentVisitor"
import { ChronologyReplacerActions } from "./time/datasource/ChronologyReplacerActions"
import { SourceReplacer } from "./source/SourceReplacer"
import { NoteReplacer } from "./note/NoteReplacer"
import { NoteFileCounter } from "./note/NoteFileCounter"
import { SourceSiteCounter } from "./source/SourceSiteCounter"
import { PersisentSourceRegistry } from "./source/PersisentSourceRegistry"
import { SourceIndexStep } from "./source/SourceIndexStep"

interface RR0BuildArgs {
/**
Expand Down Expand Up @@ -209,10 +215,7 @@ timeService.getFiles().then(async (timeFiles) => {

const orgService = new OrganizationService([], "org", undefined)

const searchCommand = new SearchCommand({
notIndexedUrls: ["404.html", "Referencement.html"],
indexWords: false
})
const searchCommand = new SearchCommand({notIndexedUrls: ["404.html", "Referencement.html"], indexWords: false})
const baseUrl = "https://rr0.org"
const sourceRenderer = new SourceRenderer()
const caseRenderer = new CaseSummaryRenderer(sourceRenderer)
Expand Down Expand Up @@ -242,17 +245,26 @@ timeService.getFiles().then(async (timeFiles) => {
new AuthorReplaceCommand(timeService)
]
const http = new HttpSource()
const sourceReplacerFactory = new SourceReplacerFactory(sourceRenderer, dataService, http, baseUrl)
const sourceRegistryFileName = "source/index.json"
const sourceFactory = new PersisentSourceRegistry(dataService, http, baseUrl, sourceRegistryFileName)
// const sourceCounter = new SourceFileCounter()
const sourceCounter = new SourceSiteCounter()
const sourceReplacer = new SourceReplacer(sourceRenderer, sourceFactory, sourceCounter)
const sourceReplacerFactory = new SourceReplacerFactory(sourceReplacer)
const noteCounter = new NoteFileCounter()
const noteReplacer = new NoteReplacer(noteCounter)
const noteReplacerFactory = new NoteReplacerFactory(noteReplacer)
const eventReplacer = new EventReplacer(caseRenderer, dataService)
const contentsReplaceCommand = [
databaseAggregationCommand,
new ClassDomReplaceCommand(new EventReplacerFactory(caseRenderer, sourceReplacerFactory), "event"),
new ClassDomReplaceCommand(new EventReplacerFactory(eventReplacer), "event"),
new ClassDomReplaceCommand(sourceReplacerFactory, "source"),
new HtmlTagReplaceCommand("time", new TimeReplacerFactory(timeService.renderer)),
new HtmlTagReplaceCommand("code", new CodeReplacerFactory()),
new ClassDomReplaceCommand(new PeopleReplacerFactory(peopleService), "people"),
new ClassDomReplaceCommand(new PlaceReplacerFactory(), "place"),
new ClassDomReplaceCommand(new WitnessReplacerFactory(), "temoin", "temoin1", "temoin2", "temoin3"),
new ClassDomReplaceCommand(new NoteReplacerFactory(), "note"),
new ClassDomReplaceCommand(noteReplacerFactory, "note"),
new ClassDomReplaceCommand(new IndexedReplacerFactory(), "indexed"),
new UnitReplaceCommand(),
new MetaLinkReplaceCommand(new TimeLinkDefaultHandler(timeFiles))
Expand Down Expand Up @@ -300,6 +312,7 @@ timeService.getFiles().then(async (timeFiles) => {
}
if (args.reindex === "true") {
ssg.add(new SearchIndexStep("search/index.json", searchCommand))
ssg.add(new SourceIndexStep(sourceRegistryFileName, sourceFactory))
}
if (copies) {
const copyConfig: CopyStepConfig = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
href="/org/us/region/wa/pentagone/index.html">Pentagone</a></q> était à l'évidence la cible. Il volait de manière
et fluide et
calme, sans aucun indice que quelque chose n'allait pas </q><a class="source"
href="https://web.archive.org/web/20021014034353/https://www.attackonthefreeworld.com/news/usatoday/hlead.htm"><em>USA
href="https://www.attackonthefreeworld.com/news/usatoday/hlead.htm"><em>USA
Today</em></a>.
</p>
<p>Egalement Mike Walter : <q>J'étais assis au nord au 27 et le traffic était, vous savez, typique des heures de pointe
Expand Down
Loading

0 comments on commit e346353

Please sign in to comment.