From 1f106b3842ad94c9df5414961ad9df63b3f8c58f Mon Sep 17 00:00:00 2001 From: bach Date: Thu, 2 Mar 2023 22:09:53 +0100 Subject: [PATCH] metada are populated for texts & indexes #1796 --- src/pages/Edition.vue | 46 +++++++++++++++++++++++++++++++++++++------ src/pages/Locorum.vue | 28 ++++++++++++++++++++++++-- src/pages/Nominum.vue | 26 ++++++++++++++++++++++-- src/pages/Operum.vue | 28 ++++++++++++++++++++++++-- 4 files changed, 116 insertions(+), 12 deletions(-) diff --git a/src/pages/Edition.vue b/src/pages/Edition.vue index a4692f1..2336449 100644 --- a/src/pages/Edition.vue +++ b/src/pages/Edition.vue @@ -144,7 +144,8 @@ export default { metaInfo () { // console.log('metainfo', this.meta) return { - title: this.metainfotitle + title: this.metainfotitle, + meta: this.meta } }, components: { @@ -155,7 +156,7 @@ export default { EdPagination }, data: () => ({ - meta: null, + meta: [], editionid: null, textid: null, extract: null, @@ -227,6 +228,7 @@ export default { console.log('reftoscrollto changed', oldref, newref) }, textid (newid, oldid) { + // triggered when route change (when TOC item clicked) console.log('textid watcher', this, oldid, newid) this.texts = [] this.textsuuids = [] @@ -237,10 +239,10 @@ export default { this.inifinite_load_id += 1 } }, - textdata (newtxtdata, oldtxtdata) { - console.log('textdata watcher', oldtxtdata, newtxtdata) - this.metainfotitle = `${this.title} ${newtxtdata.meta.title}` - }, + // textdata (newtxtdata, oldtxtdata) { + // console.log('textdata watcher', oldtxtdata, newtxtdata) + // this.metainfotitle = `${this.title} ${newtxtdata.meta.title}` + // }, page_selected (newp, oldp) { console.log('page_selected watcher', oldp, newp) this.scrollToPage(newp) @@ -276,6 +278,11 @@ export default { if (mutation.type === 'Corpus/setEditionsByUUID') { // console.log('Edition state.Coprus.editionsbyuuid', this.editionid, state.Corpus.editionsbyuuid) this.title = this.metainfotitle = state.Corpus.editionsbyuuid[this.editionid].title + + this.meta = [ + { name: 'test', content: 'edition chargé' } + ] + this.biblio = state.Corpus.editionsbyuuid[this.editionid].biblio this.description = state.Corpus.editionsbyuuid[this.editionid].description this.date = state.Corpus.editionsbyuuid[this.editionid].date @@ -306,6 +313,11 @@ export default { } else { // console.log(''); this.title = this.metainfotitle = this.editionsbyuuid[this.editionid].title + + this.meta = [ + { name: 'test', content: 'edition deja là' } + ] + this.biblio = this.editionsbyuuid[this.editionid].biblio this.description = this.editionsbyuuid[this.editionid].description this.date = this.editionsbyuuid[this.editionid].date @@ -342,8 +354,13 @@ export default { this.textsuuids.unshift(data.content.uuid) } if ($state) { + // triggered by infinite scroll $state.loaded() this.next_loaded = true + } else { + // triggered by TOC item click + // UPDATE METATAGS + this.updateMetaData(data.meta.metadata) } }) .catch((error) => { @@ -367,6 +384,22 @@ export default { // }) }) }, + updateMetaData (metadata) { + this.meta = [] + metadata.forEach(m => { + let o = {} + o.name = m.name + if (Array.isArray(m.content)) { + o.content = m.content.join(', ') + } else { + o.content = m.content + } + if (typeof m.scheme !== 'undefined') { + o.scheme = m.scheme + } + this.meta.push(o) + }) + }, onCenterScrolled (e) { console.log('Edition centerScrolled(e)', e.target.scrollTop) if (!this.center_scrolled && e.target.scrollTop > this.inifinite_load_distance * 1.5) { @@ -433,6 +466,7 @@ export default { } }) } + this.meta.push({ name: 'itemclicked', content: 'alors ?' }) }, onClickIndexItem (o) { this.selectedindex = o diff --git a/src/pages/Locorum.vue b/src/pages/Locorum.vue index ab3189e..67e3380 100644 --- a/src/pages/Locorum.vue +++ b/src/pages/Locorum.vue @@ -45,11 +45,15 @@ export default { IndexItemOcurrences }, data: () => ({ - content: null + content: null, + meta: [], + metainfotitle: undefined }), metaInfo () { + // console.log('metainfo', this.meta) return { - title: `Locorum ${this.$route.params.id}` + title: this.metainfotitle, + meta: this.meta } }, computed: { @@ -61,7 +65,9 @@ export default { console.log('locorum REST: data', data) if (data.content) { this.content = data.content + this.metainfotitle = data.content.title } + this.updateMetaData(data.meta.metadata) }) .catch((error) => { console.warn('Issue with locorum', error) @@ -71,6 +77,24 @@ export default { query: { fullpath: this.$route.path } }) }) + }, + methods: { + updateMetaData (metadata) { + this.meta = [] + metadata.forEach(m => { + let o = {} + o.name = m.name + if (Array.isArray(m.content)) { + o.content = m.content.join(', ') + } else { + o.content = m.content + } + if (typeof m.scheme !== 'undefined') { + o.scheme = m.scheme + } + this.meta.push(o) + }) + } } } diff --git a/src/pages/Nominum.vue b/src/pages/Nominum.vue index 0db9f4d..5c621e8 100644 --- a/src/pages/Nominum.vue +++ b/src/pages/Nominum.vue @@ -64,11 +64,15 @@ export default { IndexItemOcurrences }, data: () => ({ - content: null + content: null, + meta: [], + metainfotitle: undefined }), metaInfo () { + // console.log('metainfo', this.meta) return { - title: `Nominum ${this.$route.params.id}` + title: this.metainfotitle, + meta: this.meta } }, created () { @@ -78,7 +82,9 @@ export default { console.log('nominum REST: data', data) if (data.content) { this.parseOccurences(data.content) + this.metainfotitle = data.content.title } + this.updateMetaData(data.meta.metadata) }) .catch((error) => { console.warn('Issue with nominum', error) @@ -90,6 +96,22 @@ export default { }) }, methods: { + updateMetaData (metadata) { + this.meta = [] + metadata.forEach(m => { + let o = {} + o.name = m.name + if (Array.isArray(m.content)) { + o.content = m.content.join(', ') + } else { + o.content = m.content + } + if (typeof m.scheme !== 'undefined') { + o.scheme = m.scheme + } + this.meta.push(o) + }) + }, parseOccurences (content) { console.log('parseOccurences', content) // ! parsing occurences diff --git a/src/pages/Operum.vue b/src/pages/Operum.vue index 78d5624..72ebf4f 100644 --- a/src/pages/Operum.vue +++ b/src/pages/Operum.vue @@ -53,11 +53,15 @@ export default { IndexItemOcurrences }, data: () => ({ - content: null + content: null, + meta: [], + metainfotitle: undefined }), metaInfo () { + // console.log('metainfo', this.meta) return { - title: `Operum ${this.$route.params.id}` + title: this.metainfotitle, + meta: this.meta } }, beforeCreate () { @@ -67,7 +71,9 @@ export default { console.log('operum REST: data', data) if (data.content) { this.content = data.content + this.metainfotitle = data.content.title } + this.updateMetaData(data.meta.metadata) }) .catch((error) => { console.warn('Issue with operum', error) @@ -77,6 +83,24 @@ export default { query: { fullpath: this.$route.path } }) }) + }, + methods: { + updateMetaData (metadata) { + this.meta = [] + metadata.forEach(m => { + let o = {} + o.name = m.name + if (Array.isArray(m.content)) { + o.content = m.content.join(', ') + } else { + o.content = m.content + } + if (typeof m.scheme !== 'undefined') { + o.scheme = m.scheme + } + this.meta.push(o) + }) + } } }