Skip to content

Commit

Permalink
fix some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Javarome committed Jul 13, 2024
1 parent 0669ede commit dd86856
Show file tree
Hide file tree
Showing 15 changed files with 102 additions and 106 deletions.
2 changes: 1 addition & 1 deletion CopyrightReplaceCommand.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe("CopyrightReplaceCommand", () => {
context.file.meta.copyright = undefined
await command.execute(context)
expect(context.file.meta.copyright).toBeUndefined()
expect(context.file.contents).toBe(`This is published by !`)
expect(context.file.contents).toBe(`This is published by <!--#echo var="copyright" -->!`)
})

test("default copyright with handler", async () => {
Expand Down
1 change: 1 addition & 0 deletions OpenGraphCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import assert from "assert"
* Create a preview image for each page sharing.
*/
export class OpenGraphCommand implements ReplaceCommand<HtmlRR0SsgContext> {

protected num = 0

constructor(
Expand Down
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# RR0 [![Build Status](https://travis-ci.org/RR0/rr0.org.svg?branch=master)](https://travis-ci.org/RR0/rr0.org) [![Code Climate](https://codeclimate.com/github/RR0/rr0.org/badges/gpa.svg)](https://codeclimate.com/github/RR0/rr0.org) [![Test Coverage](https://codeclimate.com/github/RR0/rr0.org/badges/coverage.svg)](https://codeclimate.com/github/RR0/rr0.org)

This repository hosts both data and code of the [RR0 website](https://rr0.org).
This repository hosts both data and code for the [RR0 website](https://rr0.org).

## Motivation

This website was created around 1998 as the publication of personal notes regarding the study of Unidentified Flying Objects (UFOs).
It was further motivated by the lack of french-speaking resources about the subject, especially when it comes to cases synthesis, history and objective reporting.

## Analysis

Expand All @@ -16,7 +21,6 @@ RR0 is:

### To do

* directives to handle measurements (lengths, weights, speed)
* User settings to customize rendering of directives (i18n, how to display people names, which units to use for
expressing measurements)

Expand All @@ -26,9 +30,9 @@ RR0 has been designed in different ways over the years:

1. a vanilla JS app (parsing tags and updating the client HTML)
2. an [AngularJS](https://angularjs.org/) app with RR0-specific directives.
3. NodeJS-generated pages with a bit of client-side code, using the [ssg-api](https://www.npmjs.com/package/ssg-api).
3. Static Site Generated (SSG) pages with a bit of client-side code, using the [ssg-api](https://www.npmjs.com/package/ssg-api).

So today the design is basically about converting page templates to final HTML, including a bit of client-side JS.
So today the design is basically about converting page templates to final HTML, including a bit of client-side JS when interactivity is supported.

### Replacers

Expand All @@ -47,9 +51,9 @@ respectively, as stated in the [ISO_8601 standard](https://en.wikipedia.org/wiki
By default, rendered dates add a `checkedLink` towards a possible page documenting this date (all examples below using a
french locale):

`<time datetime="1952"></time>` renders as `<a href="/time/1/9/5/2/" title="1952">1952</a>`.
`<time>1952</time>` renders as `<a href="/time/1/9/5/2/">1952</a>`.

`<time datetime="1952-07"></time>` renders as `<a href="/time/1/9/5/2/07" title="Juillet 1952">Juillet 1952</a>`.
`<time datetime="">1952-07</time>` renders as `<a href="/time/1/9/5/2/07" title="Juillet 1952">Juillet 1952</a>`.

`<time datetime="1952-07-01"></time>` renders
as `<a href="/time/1/9/5/2/07/01" title="Mardi 1er Juillet 1952">Mardi 1er Juillet 1952</a>`.
Expand Down Expand Up @@ -172,7 +176,7 @@ RR0.org is built through a Static Site Generation (SSG) using the [ssg-api](http
run it:

1. Make sure you have a Google Maps embed API keys and set its value to the `GOOGLE_MAPS_API_KEY` env var.
1. To build the website, run `npm run build --reindex true`. This will generate the website in the `out` subdirectory, including a refreshed index of pages to be used in the search form.
1. Build the website using `npm run build --reindex true`. This will generate the website in the `out` subdirectory, including a refreshed index of pages to be used in the search form.

### Publish

Expand Down
4 changes: 2 additions & 2 deletions WordFinder.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ConsoleLogger, HtmlSsgFile, Logger } from "ssg-api"
import { ConsoleLogger, HtmlFileContents, Logger } from "ssg-api"
import { promise as glob } from "glob-promise"
import { CLI } from "./util/cli/CLI"
import { CSVFileReader } from "./CSVFileReader"
Expand Down Expand Up @@ -55,7 +55,7 @@ glob(inputPattern).then(async (inputFiles) => {
const dictWords = await dictionary.read(dictionaryFile)
logger.debug("Looking for files", inputPattern)
for (const inputFile of inputFiles) {
const file = HtmlSsgFile.read(context, inputFile)
const file = HtmlFileContents.read(context, inputFile)
const contents = file.contents
let pos: number
let errorToFix: boolean
Expand Down
10 changes: 5 additions & 5 deletions book/Chapters.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { promise as glob } from 'glob-promise';
import { HtmlRR0SsgContext } from '../RR0SsgContext';
import { LinkType } from 'ssg-api';
import path from 'path';
import { promise as glob } from "glob-promise"
import { HtmlRR0SsgContext } from "../RR0SsgContext"
import { LinkType } from "ssg-api"
import path from "path"

export class Chapter {

Expand Down Expand Up @@ -89,7 +89,7 @@ const context = new RR0SsgContextImpl('fr', new TimeContext({
minute: '2-digit'
}
));
const file = HtmlSsgFile.read(context, startFileName);
const file = HtmlFileContents.read(context, startFileName);
const startFileNames = [file.name];
const variants = file.lang.variants;
for (const variant of variants) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"preview": "vite preview --host",
"chapters": "tsx Chapters.ts",
"test": "testscript",
"test-one": "tsx time/datasource/nuforc/NuforcDatasource.test.ts"
"test-one": "tsx time/TimeTagReplaceCommand.test.ts"
},
"dependencies": {
"@googlemaps/google-maps-services-js": "^3.4.0",
Expand Down
6 changes: 3 additions & 3 deletions search/SearchCommand.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { HtmlSsgContext, HtmlSsgFile, ReplaceCommand } from "ssg-api"
import { HtmlFileContents, HtmlSsgContext, ReplaceCommand } from "ssg-api"
import { HtmlRR0SsgContext } from "../RR0SsgContext"
import fs from "fs"
import { TimeTextBuilder } from "../time/TimeTextBuilder"
Expand Down Expand Up @@ -86,7 +86,7 @@ export class SearchCommand implements ReplaceCommand<HtmlSsgContext> {
return div.textContent
}

protected indexContent(context: HtmlRR0SsgContext, outputFile: HtmlSsgFile) {
protected indexContent(context: HtmlRR0SsgContext, outputFile: HtmlFileContents) {
const contents = this.getContents(outputFile.document)
const contentsRecord: PageInfo = {
title: outputFile.title,
Expand All @@ -98,7 +98,7 @@ export class SearchCommand implements ReplaceCommand<HtmlSsgContext> {
this.contentStream.write(str)
}

protected indexWords(context: HtmlRR0SsgContext, outputFile: HtmlSsgFile) {
protected indexWords(context: HtmlRR0SsgContext, outputFile: HtmlFileContents) {
const pageIndex = this.index.pages.length
const nonSignificant = context.messages.nonSignificantWords
const contents = this.getContents(outputFile.document)
Expand Down
4 changes: 4 additions & 0 deletions test-results/.last-run.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"status": "failed",
"failedTests": []
}
4 changes: 2 additions & 2 deletions test/RR0TestUtil.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { HtmlRR0SsgContext, RR0SsgContext, RR0SsgContextImpl } from "../RR0SsgContext"
import { TimeContext } from "../time/TimeContext"
import { FileContents, HtmlSsgFile } from "ssg-api"
import { FileContents, HtmlFileContents } from "ssg-api"

class RR0TestUtil {

Expand Down Expand Up @@ -31,7 +31,7 @@ class RR0TestUtil {
const titleExec = /<title>(.*)<\/title>/.exec(contents)
const title = titleExec && titleExec.length > 0 ? titleExec[1].trim() : undefined
const currentFile = context.file
context.file = new HtmlSsgFile(currentFile.name, currentFile.encoding, currentFile.contents,
context.file = new HtmlFileContents(currentFile.name, currentFile.encoding, currentFile.contents,
currentFile.lastModified, currentFile.lang, {author: []}, {}, title)
const htmlContext = context as HtmlRR0SsgContext
Object.assign(htmlContext.time, TimeContext.fromFileName(htmlContext, inputFileName))
Expand Down
2 changes: 1 addition & 1 deletion time/1/9/5/2/08/BeauJerome_RR0.csv
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
url,place,dateTime,description,sources,id
https://rr0.org/time/1/9/5/2/08/index.html,,1952-08,"01:14 A Lancaster (Californie), des officiers du sheriff et d'autres personnes, dont un nommé Mallette, observent 2 lumières rouges brillantes stationner et effectuer des manœuvre durant 5 mn Cas Blue Book n° 1771 non expliqué. A Bellefontaine (Ohio), observation. Près de Yaak (Montana), un radar de l'ADC repère un objet non-identifié, visuellement observé comme un cigare sombre Robertson, LB. A Sharonville (Ohio) un disque blanc brilliant est observé à basse altitude. D'autres signalent un objet ovale. A Albuquerque (Nouveau-Mexique), Scripps-Howard, Staff Writer, observe des ovnis changer de position en formation.","",1952-08
https://rr0.org/time/1/9/5/2/08/index.html,,1952-08,"01:14 A Lancaster (Californie), des officiers du sheriff et d'autres personnes, dont un nommé Mallette, observent 2 lumières rouges brillantes stationner et effectuer des manœuvres durant 5 mn Cas Blue Book n° 1771 non expliqué. A Bellefontaine (Ohio), observation. Près de Yaak (Montana), un radar de l'ADC repère un objet non-identifié, visuellement observé comme un cigare sombre Robertson, LB. À Sharonville (Ohio) un disque blanc brilliant est observé à basse altitude. D'autres signalent un objet ovale. À Albuquerque (Nouveau-Mexique), Scripps-Howard, Staff Writer, observe des ovnis changer de position en formation.","",1952-08
https://rr0.org/time/1/9/5/2/08/index.html,,1952-08,"Au lac Charles (Louisiane), le 1er lieutenant de l'USAF W. A. Theil et un autre homme observent une boule rouge avant une queue de flamme bleue voler horizontalement durant 3 à 4 s Cas Blue Book n° 1783 non expliqué.","",1952-08
https://rr0.org/time/1/9/5/2/08/index.html,,1952-08,"A la base USAF de Hamilton (Californie), des pilotes au sol, le radar et des aiguilleurs du ciel repèrent 2 disques argentés se comportant comme dans un combat de chiens.","",1952-08
https://rr0.org/time/1/9/5/2/08/index.html,,1952-08,"02:20 A Phoenix (Arizona), l'A. de 3ᵉ classe de l'USAF W. F. Vain observe une boule jaune s'allonger et se contracter en une forme plate, voler horizontalement durant 5 mn Cas Blue Book n° 1812 non expliqué. 11:37 A Mount Vernon (New York), une femme et 2 enfants observent durant 2 h un objet de la forme de bouée ou de beignet émettre une fumée noire de son sommet et effectuer un ar de 15' en 1,5 mn Cas Blue Book n° 1813 non expliqué. M. H. Siret fait à nouveau part de ses observations de plusieurs objets suspects.","",1952-08
Expand Down
16 changes: 8 additions & 8 deletions time/1/9/5/2/08/index.html
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
<!--#include virtual="/header.html" -->
<ul>
<li><time>1952-08-01</time>
<li><time>08-01</time>
<ul>
<li><time>01:14</time> A <span class="place">Lancaster (Californie)</span>, des officiers du sheriff et d'autres
personnes, dont un nommé Mallette, observent 2 lumières rouges brillantes stationner et effectuer des manœuvre
durant 5 mn <span class="source">Cas Blue Book n° 1771 non expliqué</span>.
</li>
personnes, dont un nommé Mallette, observent 2 lumières rouges brillantes stationner et effectuer des manœuvres
durant 5 mn <span class="source">Cas Blue Book n° 1771 non expliqué</span>.</li>
<li>A <span class="place">Bellefontaine (Ohio)</span>, observation.</li>
<li>Près de Yaak (Montana), un radar de l'<a href="/org/us/dod/af/adc/index.html">ADC</a> repère un objet
<li>Près de <span class="place">Yaak (Montana)</span>, un radar de l'<a
href="/org/us/dod/af/adc/index.html">ADC</a> repère un objet
non-identifié, visuellement observé comme un cigare sombre <span class="source">Robertson, LB</span>. </li>
<li>A <span class="place">Sharonville (Ohio)</span> un disque blanc brilliant est observé à basse altitude.
<li>À <span class="place">Sharonville (Ohio)</span> un disque blanc brilliant est observé à basse altitude.
D'autres signalent un objet ovale.</li>
<li>A <span class="place">Albuquerque (Nouveau-Mexique)</span>, <span class="temoin">Scripps-Howard</span>, Staff
<li>À <span class="place">Albuquerque (Nouveau-Mexique)</span>, <span class="temoin">Scripps-Howard</span>, Staff
Writer, observe des ovnis changer de position en formation.</li>
</ul>
</li>
<li><time>1952-08-02 03:00</time> Au <span class="place">lac Charles (Louisiane)</span>, le 1er
<li><time>08-02 03:00</time> Au <span class="place">lac Charles (Louisiane)</span>, le 1er
lieutenant de l'USAF <span
class="temoin">W. A. Theil</span> et un autre homme observent une boule rouge avant une queue de flamme bleue
voler horizontalement durant 3 à 4 s <span class="source">Cas Blue Book n° 1783 non expliqué</span>.</li>
Expand Down
2 changes: 1 addition & 1 deletion time/1/9/5/7/05/BeauJerome_RR0.csv
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ https://rr0.org/time/1/9/5/7/05/index.html,,1957-05,"À la base aérienne d'Edwa
https://rr0.org/time/1/9/5/7/05/index.html,,1957-05,"Cooper, Leroy Gordon: LDLN 358.","",1957-05
https://rr0.org/time/1/9/5/7/05/index.html,,1957-05,"[04:00 PDT?] Sur la côte californienne, le copilote USAF d'un appareil de patrouille radar avec la 552ᵉ Escadrille AEW&C voit une lumière rouge jaunâtre à 10 000 pieds passer devant son appareil. L'observation a duré 30 s Weinstein, D.Index du FUFOR.","",1957-05
https://rr0.org/time/1/9/5/7/05/index.html,,1957-05,"Photographie à Yokohama (Japon) le 7 A Yokohama (Japon), photographie (ci-contre).","",1957-05
https://rr0.org/time/1/9/5/7/05/index.html,,1957-05,"A Beaucourt-sur-l'Ancre (Somme), 3 petits êtres à proximité d'un engin. La veille et l'avant-veille, des habitants auraient remarqué les allées et venues dans la campagne environnante d'une 2 CV grise pilotée par un homme élégant, vêtu d’un costume pied de poule, et inconnu au pays. Ce dernier aurait abandonné le véhicule devant une gare de la région Couten, François < Macé, C.: ""Les rendez-vous Ovni-Voiture"" in ""Les extra-terrestres qui sont parmi nous"", UFOWeb.","",1957-05
https://rr0.org/time/1/9/5/7/05/index.html,,1957-05,"A Beaucourt-sur-l'Ancre (Somme), 3 petits êtres à proximité d'un engin. La veille et l'avant-veille, des habitants auraient remarqué les allées et venues dans la campagne environnante d'une 2 CV grise pilotée par un homme élégant, vêtu d’un costume pied de poule, et inconnu au pays. Ce dernier aurait abandonné le véhicule devant une gare de la région Couten, François < Macé, Christian : ""Les rendez-vous Ovni-Voiture"" in ""Les extra-terrestres qui sont parmi nous"", UFOWeb.","",1957-05
https://rr0.org/time/1/9/5/7/05/index.html,,1957-05,"A Moab (Utah), un ovni bleu-vert rond observé passant sous l'altitude de l'observateur UFO Evidence, NICAP, IV.","",1957-05
https://rr0.org/time/1/9/5/7/05/index.html,,1957-05,Inauguration du cosmodrome de Baïkonour.,"",1957-05
https://rr0.org/time/1/9/5/7/05/index.html,,1957-05,Le décret ordonnant la création du lanceur russe R7 est signé.,"",1957-05
Expand Down
Loading

0 comments on commit dd86856

Please sign in to comment.