Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

186 umlaute #268

Merged
merged 5 commits into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ test/
eslint*
.prettier*
cypress.config.js
jest*
config.yaml
3 changes: 1 addition & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ name: Build
on: push

env:
REGISTRY:
IMAGE_NAME: ${{ github.repository }}
TEST_TAG: user/app:test

Expand Down Expand Up @@ -117,4 +116,4 @@ jobs:
with:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
labels: ${{ steps.meta.outputs.labels }}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ So if your commit errors, make sure to check the output and fix accordingly.
We use unit, integration and E2E tests, but don't distinguish too hard between unit and integration tests, since the distinction between these are a bit blurry in component development (see [React Testing Overview](https://reactjs.org/docs/testing.html)).
In general a behaviour driven development is favoured and for every new feature an appropriate test should be added.
The unit and integration tests can be found in the `test` folder.
We use [Jest](https://jestjs.io/) and [React Testing Library](https://testing-library.com/docs/react-testing-library/intro/) for testing.
We use [Vitest](https://vitest.dev/) and [React Testing Library](https://testing-library.com/docs/react-testing-library/intro/) for testing.

To run these tests use `npm run test` or `npm run test:coverage` to see coverage reports.

Expand Down
1 change: 0 additions & 1 deletion __mocks__/file-mock.js

This file was deleted.

27 changes: 0 additions & 27 deletions __mocks__/gatsby.js

This file was deleted.

51 changes: 32 additions & 19 deletions gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const { DataFactory } = n3
const { namedNode } = DataFactory
const path = require("path")
const fs = require("fs-extra")
const flexsearch = require("flexsearch")
const { Index } = require("flexsearch")
const omitEmpty = require("omit-empty")
const { i18n, getFilePath, parseLanguages } = require("./src/common")
const context = require("./src/context")
Expand Down Expand Up @@ -71,6 +71,30 @@ const getTurtleFiles = function (dirPath, arrayOfFiles) {
return arrayOfFiles
}

/**
* Exports an index and saves it
* @param {object} index
* @param {object} conceptScheme
* @param {string} language
*
**/
const exportIndex = (index, conceptScheme, language) => {
index.export(function (key, data) {
const path = getFilePath(
conceptScheme.id + `/search/${language}/${key}`,
`json`
)
createData({
path,
data: data !== undefined ? data : "",
})
// fs.writeFileSync(
// `${searchIndexPath}${key}.json`,
// data !== undefined ? (data) : ""
// );
})
}

exports.onPreBootstrap = async ({ createContentDigest, actions, getNode }) => {
const { createNode, createNodeField } = actions
const ttlFiles = getTurtleFiles("./data", [])
Expand Down Expand Up @@ -213,7 +237,7 @@ exports.createPages = async ({ graphql, actions: { createPage } }) => {
languages.forEach((language) =>
createPage({
path: getFilePath(collection.id, `${language}.html`),
component: path.resolve(`./src/components/Collection.js`),
component: path.resolve(`./src/components/Collection.jsx`),
context: {
language,
node: collection,
Expand Down Expand Up @@ -248,13 +272,9 @@ exports.createPages = async ({ graphql, actions: { createPage } }) => {
const languagesOfCS = languagesByCS[conceptScheme.id]
const indexes = Object.fromEntries(
[...languagesOfCS].map((l) => {
const index = flexsearch.create({
const index = new Index({
tokenize: tokenizer,
})
index.addMatcher({
"[Ää]": "a", // replaces all 'ä' to 'a'
"[Öö]": "o",
"[Üü]": "u",
charset: "latin",
})
return [l, index]
})
Expand Down Expand Up @@ -283,7 +303,7 @@ exports.createPages = async ({ graphql, actions: { createPage } }) => {
languagesOfCS.forEach((language) =>
createPage({
path: getFilePath(concept.id, `${language}.html`),
component: path.resolve(`./src/components/Concept.js`),
component: path.resolve(`./src/components/Concept.jsx`),
context: {
language,
node: concept,
Expand All @@ -307,14 +327,10 @@ exports.createPages = async ({ graphql, actions: { createPage } }) => {
)
})

languagesOfCS.forEach((l) => {
console.log(`Built index for language "${l}"`, indexes[l].info())
})

languagesOfCS.forEach((language) =>
createPage({
path: getFilePath(conceptScheme.id, `${language}.html`),
component: path.resolve(`./src/components/ConceptScheme.js`),
component: path.resolve(`./src/components/ConceptScheme.jsx`),
context: {
language,
node: conceptScheme,
Expand All @@ -336,10 +352,7 @@ exports.createPages = async ({ graphql, actions: { createPage } }) => {
})
// create index files
languagesOfCS.forEach((language) =>
createData({
path: getFilePath(conceptScheme.id, `${language}.index`),
data: JSON.stringify(indexes[language].export(), null, 2),
})
exportIndex(indexes[language], conceptScheme, language)
)
}
)
Expand All @@ -349,7 +362,7 @@ exports.createPages = async ({ graphql, actions: { createPage } }) => {
languages.forEach((language) =>
createPage({
path: `/index.${language}.html`,
component: path.resolve(`./src/components/index.js`),
component: path.resolve(`./src/components/index.jsx`),
context: {
language,
conceptSchemes: conceptSchemes.data.allConceptScheme.edges.map(
Expand Down
5 changes: 0 additions & 5 deletions jest-preprocess.js

This file was deleted.

22 changes: 0 additions & 22 deletions jest.config.js

This file was deleted.

2 changes: 0 additions & 2 deletions jest.setup.js

This file was deleted.

3 changes: 0 additions & 3 deletions loadershim.js

This file was deleted.

Loading