Skip to content

Commit

Permalink
Correction de l'affichage des propriétés wikidata dans la page wikise…
Browse files Browse the repository at this point in the history
…arch.vue
  • Loading branch information
arthurbnu committed May 7, 2024
1 parent 5dd1bb2 commit 4727213
Show file tree
Hide file tree
Showing 9 changed files with 1,666 additions and 202 deletions.
407 changes: 407 additions & 0 deletions assets/all_properties.json

Large diffs are not rendered by default.

Binary file added gravures_sqlite.db
Binary file not shown.
1,077 changes: 905 additions & 172 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
"nuxt": "3.8.2",
"nuxt-icon": "0.6.7",
"nuxt-quasar-ui": "^2.0.7",
"nuxt3-leaflet": "^1.0.12",
"prettier": "3.1.1",
"prettier-plugin-tailwindcss": "0.5.9",
"sass": "^1.32.12",
"sass-loader": "^12.0.0",
"nuxt3-leaflet": "^1.0.12",
"yarn-upgrade-all": "^0.7.2"
},
"dependencies": {
Expand All @@ -37,6 +37,7 @@
"apexcharts": "^3.45.2",
"fireworks-js": "^2.10.7",
"quasar": "^2.14.2",
"sqlite3": "^5.1.7",
"vue-apexcharts": "^1.6.2",
"vue-draggable-next": "^2.2.1",
"vue-use-fixed-header": "^2.0.0",
Expand Down
72 changes: 72 additions & 0 deletions pages/gravures.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<template>
<main class="space-y-8">
<div class="flex place-items-center gap-4">
<h1 class="text-primary text-xl">{{ TIT }} </h1>
<UInput v-model = "search" variant = "outline" color = "gray" placeholder = "Rechercher une gravure"/>
</div>

<div v-auto-animate class="grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3 m-auto">
<QCard v-for="(val, id) in foundResults" :key="id" dark class="m-1 hover:scale-105 transition-all will-change-transform border-teal-400/20" :TIT="val.TIT" :REP="val.REP" bordered>
<div class="h-48 lg:h-40 overflow-hidden relative">
<UAvatar class="absolute z-20 top-2 left-2 bg-gray-700" size="md">
<UIcon dynamic name="i-lucide-book" />
</UAvatar>
<NuxtImg src="gravures/bnu.png" alt="bnu" height="300" width="400" class="opacity-30"/>

</div>
<div class="p-4">
<h2 class="text-xl font-bold">{{ val.TIT }}</h2>
<p class="text-gray-400">{{ val.REP }}</p>
<p class="mt-2">
<span v-for="(badge, i) in ['hey', 'you']" class="mr-2">
<UBadge :key="i" color="indigo" variant="outline">
{{ badge }}
</UBadge>
</span>
</p>
</div>
</QCard>
</div>

<!-- <section>
<pre>{{ data }}</pre>
</section> -->
</main>
</template>

<script setup>
import { refDebounced } from '@vueuse/core'
const { data } = await useFetch('/api/gravures')
const search = ref('')
const debounceSearch = refDebounced(search, 400)
const foundResults = computed(() =>
debounceSearch.value.length < 3 ? data.value.result :
data.value.result.filter(r => r.TIT.toUpperCase().includes(debounceSearch.value.toUpperCase()))
)
const baseUrl = 'https://dev-lab-one.vercel.app/'
const valImg = val => {
const img = val.image ?? "val-sparql.png"
return "val/" + img
}
const TIT = "Gravures";
const REP = "Gravures et autres imprimés anciens et jolis";
useSeoMeta({
TIT: TIT,
REP,
author: "arthur.brody@bnu.fr",
ogImage: baseUrl + "val/val-renaissance2.png",
ogUrl: baseUrl,
ogType: "website",
ogTIT: TIT,
ogREP: REP,
robots: "index, follow",
themeColor: "teal",
});
</script>
21 changes: 10 additions & 11 deletions pages/wikisearch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
</a>
<p class="text-gray-400">{{ item.description }}</p>

<!-- Propriétés wikidata -->
<!-- Propriétés wikidata trouvées pour le résultat cliqué -->
<div v-if="selectedResult.id === item.id" class="bg-slate-600/20 p-2 rounded-lg my-2"
:class="{ 'opacity-20': pendingSparql }">
<label class="text-primary-300 flex items-center gap-2">
Expand Down Expand Up @@ -75,7 +75,7 @@
</li>
</ul>

<!-- modal - propriétés -->
<!-- modal Infos - propriétés -->
<UModal v-model="open" :transition="false" :ui="{ width: 'w-[80vw]' }" class="[&>*]:text-black p-2">
<div class="p-4">
<UIcon name="i-lucide-info" class="text-primary-500 align-middle mb-1" size="xl" />
Expand All @@ -95,8 +95,14 @@

<script setup>
import { refDebounced } from '@vueuse/core'
import jsonProperties from "@/assets/properties.json"
const {time: timeProperties,place: placeProperties} = jsonProperties
import jsonProperties from "@/assets/all_properties.json"
var {time: timeProperties, place: placeProperties} = jsonProperties
// replace spaces in labels
// function removeLabelSpaces(arr) {
// return arr.map(prop => ({ ...prop, label: prop.label.replace(/ /g, '_') }))
// }
// timeProperties = removeLabelSpaces(timeProperties)
// placeProperties = removeLabelSpaces(placeProperties)
const open = ref(false)
Expand Down Expand Up @@ -159,8 +165,6 @@ const sparqlQuery = computed(() =>
?item wikibase:apiOutputItem mwapi:item .
}
# BIND( uri(concat("https://www.wikidata.org/entity/", ?item)) as ?itemUri)
${optional.time.join('\n')}
${optional.place.join('\n')}
Expand All @@ -181,10 +185,6 @@ const queryParams = computed(() => { return { query: sparqlQuery.value } })
const { data: sparqlResult, error: sparqlError, pending: pendingSparql } =
await useFetch(`${baseUrl}/sparql`, { immediate: false, headers: headers, params: queryParams })
watchEffect(() => {
console.log('sparqlResult', sparqlResult.value)
})
function toDate(date) {
if (date.includes('|')) {
return date.split(' | ').map(d => toDate(d)).join(' | ')
Expand All @@ -198,7 +198,6 @@ const description = 'Interface de recherche pour Wikipédia et affichage des pro
useSeoMeta({
title: title,
description,
author: "A B",
ogImage: "https://dev-lab-one.vercel.app/sparql/wikisearch.png",
ogUrl: "https://dev-lab-one.vercel.app/wikisearch",
ogTitle: title,
Expand Down
Binary file added public/gravures/bnu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions server/api/gravures.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import sqlite3 from "sqlite3";
const db = new sqlite3.Database("gravures_sqlite.db");

async function getGravures() {
return new Promise((resolve, reject) => {
// db.all("SELECT * FROM gravures", (error, rows) => {
db.all("SELECT TIT, REP, REFG, COM FROM gravures LIMIT 100", (error, rows) => {
if (error) {
reject(error);
} else {
resolve(rows);
}
});
});
}

var gravures: any;
getGravures().then((g) => {
gravures = g;
});

export default defineEventHandler(async (event) => {
await getGravures();
return {
result: gravures,
};
});
Loading

0 comments on commit 4727213

Please sign in to comment.