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

QUED-134-Anpassung der Datenausgabe #46

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
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
8 changes: 5 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@

case $1 in
backend)
docker-compose up --build backend db solr apache
(cd edition-archive-backend && mvn clean install) &&
docker compose up --build backend db solr apache
;;
frontend)
docker-compose up --build frontend
docker compose up --build frontend
;;
dev-frontend)
(
cd edition-archive-frontend && yarn dev
)
;;
all)
docker-compose up --build
(cd edition-archive-backend && mvn clean install) &&
docker compose up --build
;;
*) ;;
esac
21 changes: 2 additions & 19 deletions edition-archive-backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,6 @@
FROM maven:3.8.6-eclipse-temurin-17-focal as maven
RUN mkdir /opt/edition-archive-backend
RUN groupadd maven && \
useradd -m -g maven maven && \
chown -R maven:maven /opt/
COPY --chown=maven:maven pom.xml /opt/edition-archive-backend/pom.xml
COPY --chown=maven:maven edition-archive-backend-cli/pom.xml /opt/edition-archive-backend/edition-archive-backend-cli/pom.xml
COPY --chown=maven:maven edition-archive-backend-module/pom.xml /opt/edition-archive-backend/edition-archive-backend-module/pom.xml
COPY --chown=maven:maven edition-archive-backend-webapp/pom.xml /opt/edition-archive-backend/edition-archive-backend-webapp/pom.xml
USER maven
WORKDIR /opt/edition-archive-backend
RUN mvn dependency:go-offline
COPY --chown=maven:maven edition-archive-backend-cli /opt/edition-archive-backend/edition-archive-backend-cli
COPY --chown=maven:maven edition-archive-backend-module /opt/edition-archive-backend/edition-archive-backend-module
COPY --chown=maven:maven edition-archive-backend-webapp /opt/edition-archive-backend/edition-archive-backend-webapp
RUN mvn --version && \
mvn clean install -DskipTests
FROM tomcat:10-jdk17-temurin-jammy
COPY --from=maven --chown=root:root /opt/edition-archive-backend/edition-archive-backend-webapp/target/edition-archive-backend-0.1-SNAPSHOT.war webapps/backend.war
COPY --from=maven --chown=root:root /opt/edition-archive-backend/edition-archive-backend-cli/target/edition-archive-backend-cli-0.1-SNAPSHOT.tar.gz /opt/mycore/cli.tar.gz
COPY --chown=root:root ./edition-archive-backend-webapp/target/edition-archive-backend-0.1-SNAPSHOT.war webapps/backend.war
COPY --chown=root:root ./edition-archive-backend-cli/target/edition-archive-backend-cli-0.1-SNAPSHOT.tar.gz /opt/mycore/cli.tar.gz
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
ENV MCR_CONFIG_DIR="/mcr/home/"
ENV MCR_DATA_DIR="/mcr/data/"
Expand Down
4 changes: 2 additions & 2 deletions edition-archive-backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.mycore</groupId>
<artifactId>mycore-parent</artifactId>
<version>50</version>
<version>51</version>
</parent>
<groupId>de.gbv</groupId>
<artifactId>edition-archive-backend</artifactId>
Expand All @@ -21,7 +21,7 @@
</scm>
<properties>
<jetty.version>11.0.11</jetty.version>
<mycore.version>2022.06.2</mycore.version>
<mycore.version>2022.06.3-SNAPSHOT</mycore.version>
<java.target.version>17</java.target.version>
</properties>
<repositories>
Expand Down
4 changes: 3 additions & 1 deletion edition-archive-frontend/api/Mods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Genre from "~/components/MODS/Genre.vue";

export interface Title {
language?: string;
type?: string;
title: string;
subtitle?: string;
}
Expand Down Expand Up @@ -49,9 +50,10 @@ export function getTitles(modsOrRelatedItem: XElement): Title[] {
const title = flattenElement(findFirstElement(titleInfoElement, byName("mods:title")));
const subtitle = flattenElement(findFirstElement(titleInfoElement, byName("mods:subTitle"))) || undefined;
const language = getAttribute(titleInfoElement, "xml:lang")?.value;
const type = getAttribute(titleInfoElement, "type")?.value;

if (title != null) {
titles.push({language, title, subtitle});
titles.push({language, title, subtitle, type});
}
}

Expand Down
90 changes: 87 additions & 3 deletions edition-archive-frontend/api/SearchHelper.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import {LocationQuery} from "vue-router";

export const SoSuFilterParams = [
"objectKind:mycoreobject",
"objectType:mods",
Expand All @@ -10,7 +12,89 @@ export const SoSuParams = [
"sort=id asc",
];

export function buildSOSUSearchRequestURL(url: string, search: string | null, start: number, rows = 20) {
export enum TranslationMode {
ALL = "ALL",
ORIGINAL_ONLY = "ORIGINAL_ONLY",
TRANSLATION_ONLY = "TRANSLATION_ONLY"
}

export interface Filters {
genres: string[];
languages: string[];
translationMode: TranslationMode;
}

export function buildSOSUSearchRequestURL(url: string, search: string | null, filters: Filters, start: number, rows = 20) {
const query = `allMeta:${search || "*"}`
return `${url}mir/select?q=${query}&fq=${SoSuFilterParams.join("%20AND%20")}&start=${start}&${SoSuParams.join("&")}&rows=${rows}`;
}
const genreFilter = filters?.genres?.length > 0 ? `fq=mods.genre:(${filters.genres.join("%20AND%20")})` : '';
const languageFilter = filters?.languages?.length > 0 ? `fq=survivors.mods.language:${filters.languages.join("%20AND%20")}` : '';
let translationFilter = '';
switch (filters.translationMode) {
case TranslationMode.ALL:
// empty filter
break;
case TranslationMode.TRANSLATION_ONLY:
translationFilter = "fq=mods.relatedItem.original:*";
break;
case TranslationMode.ORIGINAL_ONLY:
translationFilter = "fq=NOT%28mods.relatedItem.original:*%29";
break;
}
let filtersParams = [genreFilter, languageFilter, translationFilter, ...SoSuParams].filter(s=>s.length>0).join("&");
return `${url}mir/select?q=${query}&fq=${SoSuFilterParams.join("%20AND%20")}&${filtersParams}&start=${start}&rows=${rows}&facet=true&facet.field=survivors.mods.language`;
}


export function modelToQuery(model: any): any {
const query: any = {
q: model.searchString,
}


query.start = model.start.toString();


if (model.filters.genres.length > 0) {
query.genres = model.filters.genres.slice();
}

if (model.filters.languages.length > 0) {
query.languages = model.filters.languages;
}

if (model.filters.translationMode !== TranslationMode.ALL) {
query.translationMode = model.filters.translationMode;
}

return query;
}

export function queryToModel(query: LocationQuery, model:any) {
model.searchString = query.q as string || "*";
if (query.start) {
model.start = parseInt(query.start as string);
} else {
model.start = 0;
}

if (query.genres) {
if (Array.isArray(query.genres)) {
model.filters.genres = query.genres as string[];
} else {
model.filters.genres = [query.genres as string];
}
}

if (query.languages) {
if (Array.isArray(query.languages)) {
model.filters.languages = query.languages as string[];
} else {
model.filters.languages = [query.languages as string];
}
}

if (query.translationMode) {
model.filters.translationMode = query.translationMode as TranslationMode;
}
}

4 changes: 2 additions & 2 deletions edition-archive-frontend/components/CMSPageEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ const editorOptions: Ref<any> = ref({
"setup": setup,
"external_plugins": {} as Record<string, string>,
"custom_elements": "~gallia-pontificia-online-regest-bibl",
"extended_valid_elements": "gallia-pontificia-online-editor-link[type|refe]",
"content_style": "gallia-pontificia-online-editor-link { display: inline-block; color: #0000ff; }",
"extended_valid_elements": "gallia-pontificia-online-editor-link[type|refe],change-language[lang]",
"content_style": "gallia-pontificia-online-editor-link { display: inline-block; color: #0000ff; } change-language { display: inline-block; color: #0000ff; }",
"save_enablewhendirty": false
});

Expand Down
23 changes: 23 additions & 0 deletions edition-archive-frontend/components/ChangeLanguage.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<template>
<a v-if="props.lang" href="#changeLang" class="clickable" v-on:click.prevent="changeLanguage(props.lang)"><slot></slot></a>
<span v-else><slot></slot></span>
</template>

<script setup lang="ts">
import {useI18n} from "vue-i18n";

const props = defineProps(["lang"]);
const i18n = useI18n();

function changeLanguage(newLanguage: string) {
//i18n.locale.value = newLanguage;
i18n.setLocale(newLanguage);
i18n.setLocaleCookie(newLanguage);
}
</script>

<style scoped>
.clickable {
cursor: pointer;
}
</style>
4 changes: 2 additions & 2 deletions edition-archive-frontend/components/DynamicCompiled.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// DynamicComponent.vue
<script setup lang="ts">
import type { Component } from '@vue/runtime-core'
import { NuxtLink, GalliaPontificiaOnlineEditorLink } from '#components'
import { NuxtLink, GalliaPontificiaOnlineEditorLink, ChangeLanguage } from '#components'

const props = defineProps<{
template?: string
Expand All @@ -10,7 +10,7 @@ const props = defineProps<{
const renderer = computed(() => () => h({
template: props.template,
components: {
NuxtLink, GalliaPontificiaOnlineEditorLink
NuxtLink, GalliaPontificiaOnlineEditorLink, ChangeLanguage
},
}))
</script>
Expand Down
2 changes: 2 additions & 0 deletions edition-archive-frontend/components/LanguageDisplay.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ function convert(langCode:string){
return "Français";
case "ru":
return "Русский";
case "uk":
return "Українська";
default:
return langCode;
}
Expand Down
Loading