Skip to content

Commit 4b247c8

Browse files
Merge pull request #40 from DHBern/18-umsetzung-suche
18 Umsetzung Suche
2 parents 1f20af4 + 4687fc9 commit 4b247c8

30 files changed

+516
-198
lines changed

package-lock.json

+17-16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,10 @@
4646
"@floating-ui/dom": "^1.6.3",
4747
"@fortawesome/fontawesome-free": "^6.4.2",
4848
"@types/openseadragon": "^3.0.10",
49+
"@vincjo/datatables": "^2.3.0",
4950
"d3": "^7.9.0",
5051
"estree-walker": "^3.0.3",
52+
"minisearch": "^7.1.1",
5153
"openseadragon": "^5.0.0"
5254
}
5355
}

src/app.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
</head>
99
<!--<body data-sveltekit-preload-data="hover" data-theme="parzival">-->
1010
<body data-sveltekit-preload-data="hover" data-theme="vintage">
11-
<div style="display: contents" class="h-full overflow-hidden">%sveltekit.body%</div>
11+
<div style="display: contents">%sveltekit.body%</div>
1212
</body>
1313
</html>

src/app.postcss

-6
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,6 @@
1111
font-display: swap;
1212
}
1313

14-
15-
html,
16-
body {
17-
@apply h-full overflow-hidden;
18-
}
19-
2014
:root [data-theme='vintage'] {
2115
/* =~= Theme On-X Colors =~= */
2216
--on-primary: "var(--color-surface-800)",

src/lib/components/VerseSelector.svelte

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script>
22
import { goto, preloadData } from '$app/navigation';
33
import { base } from '$app/paths';
4+
import { NUMBER_OF_PAGES } from '$lib/constants';
45
56
/** @type {{targetPath?: string, coordinates?: [String | boolean, String | boolean]}} */
67
let { targetPath = '/einzelverssynopse', coordinates = ['1', '1'] } = $props();
@@ -62,7 +63,7 @@
6263
placeholder="Dreißiger"
6364
class="input inline max-w-28"
6465
min="1"
65-
max="827"
66+
max={NUMBER_OF_PAGES}
6667
oninput={handleInput}
6768
bind:this={thirties}
6869
bind:value={thirtiesVal}

src/lib/constants.js

+2
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ export const teipb = `http://localhost:8081/exist/apps/parzival/api`;
55
export const iiif = `https://iiif.ub.unibe.ch/image/v3/Parzival`;
66

77
export const summaryLabel = 'Fassungen';
8+
9+
export const NUMBER_OF_PAGES = 827;

src/lib/data.svelte.js

-5
This file was deleted.

src/lib/data/metadata.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { api } from '$lib/constants';
2+
3+
export const metadata = fetch(`${api}/json/metadata-nomenclature.json`).then((r) => {
4+
return r.json();
5+
});

src/lib/data/searchIndexFassung.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { api } from '$lib/constants';
2+
3+
export default fetch(`${api}/json/search-index-fassung.json`)
4+
.then((r) => {
5+
return r.json();
6+
})
7+
.then((data) => data.docs);

src/lib/data/searchIndexWitness.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { api } from '$lib/constants';
2+
3+
export default fetch(`${api}/json/search-index-transkript.json`)
4+
.then((r) => {
5+
return r.json();
6+
})
7+
.then((data) => data.docs);
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
import { metadata } from './data.svelte.js';
2-
import { api } from './constants.js';
1+
import { api } from '$lib/constants';
32

43
/**
54
* Generate all 827 Dreissiger with 1-30 verses for all sigla
65
* @param {boolean} sigla
76
* @returns {Promise<Array<{ sigla?: string, thirties: string, verse?: string }>>}
87
*/
8+
99
export async function generateEntries(sigla) {
10+
/** @type {{verses: {thirties: string, verse: string}[]}} */
1011
const { verses } = await fetch(`${api}/json/metadata-ms-verses.json`).then((r) => r.json());
1112
if (sigla) {
1213
return verses;
@@ -24,28 +25,3 @@ export async function generateEntries(sigla) {
2425
return returnArray;
2526
}
2627
}
27-
28-
/**@type {{fragments: {handle: String, sigil: String}[], codices: {handle: String, sigil: String}[]}} */
29-
const { fragments, codices } = await metadata;
30-
31-
/**
32-
* @param {string} handle
33-
*/
34-
export function siglaFromHandle(handle) {
35-
if (handle.includes('fr')) {
36-
return fragments.find(({ handle: s }) => s === handle)?.sigil;
37-
} else {
38-
return codices.find(({ handle: s }) => s === handle)?.sigil;
39-
}
40-
}
41-
42-
/**
43-
* @param {string} handle
44-
*/
45-
export function metadataFromHandle(handle) {
46-
if (handle.includes('fr')) {
47-
return fragments.find(({ handle: s }) => s === handle);
48-
} else {
49-
return codices.find(({ handle: s }) => s === handle);
50-
}
51-
}
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { metadata } from '$lib/data/metadata';
2+
3+
/**@type {{fragments: {handle: String, sigil: String}[], codices: {handle: String, sigil: String}[]}} */
4+
const { fragments, codices } = await metadata;
5+
6+
/**
7+
* @param {string} handle
8+
*/
9+
10+
export default function metadataFromHandle(handle) {
11+
if (handle.includes('fr')) {
12+
return fragments.find(({ handle: s }) => s === handle);
13+
} else {
14+
return codices.find(({ handle: s }) => s === handle);
15+
}
16+
}

src/lib/functions/siglaFromHandle.js

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { metadata } from '$lib/data/metadata';
2+
3+
const { fragments, codices, hyparchetypes } = await metadata;
4+
/**
5+
* @param {string} handle
6+
* @returns {string}
7+
*/
8+
export default function siglaFromHandle(handle) {
9+
/**@type {{fragments: {handle: String, sigil: String}[], codices: {handle: String, sigil: String}[]}} */
10+
if (handle.includes('fr')) {
11+
return fragments.find(({ handle: s }) => s === handle)?.sigil ?? '';
12+
} else if (handle.includes('*')) {
13+
return hyparchetypes.find(({ handle: s }) => s === handle)?.sigil ?? '';
14+
} else {
15+
return codices.find(({ handle: s }) => s === handle)?.sigil ?? '';
16+
}
17+
}

src/lib/minisearch.svelte.js

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import MiniSearch from 'minisearch';
2+
3+
/**
4+
* @param {string} term
5+
*/
6+
export function processTerm(term) {
7+
return term.normalize('NFKD').toLowerCase();
8+
}
9+
10+
const miniSearchConfig = {
11+
fields: ['content_all', 'content', 'terms'],
12+
storeFields: ['content', 'verse', 'd', 'sigla'],
13+
processTerm
14+
};
15+
16+
// Create two instances of MiniSearch because there are two different indices
17+
export const minisearches = Array(2)
18+
.fill('')
19+
.map(() => new MiniSearch(miniSearchConfig));

0 commit comments

Comments
 (0)