metada are populated for texts & indexes #1796

This commit is contained in:
2023-03-02 22:09:53 +01:00
parent f903424ddb
commit 1f106b3842
4 changed files with 116 additions and 12 deletions
+40 -6
View File
@@ -144,7 +144,8 @@ export default {
metaInfo () { metaInfo () {
// console.log('metainfo', this.meta) // console.log('metainfo', this.meta)
return { return {
title: this.metainfotitle title: this.metainfotitle,
meta: this.meta
} }
}, },
components: { components: {
@@ -155,7 +156,7 @@ export default {
EdPagination EdPagination
}, },
data: () => ({ data: () => ({
meta: null, meta: [],
editionid: null, editionid: null,
textid: null, textid: null,
extract: null, extract: null,
@@ -227,6 +228,7 @@ export default {
console.log('reftoscrollto changed', oldref, newref) console.log('reftoscrollto changed', oldref, newref)
}, },
textid (newid, oldid) { textid (newid, oldid) {
// triggered when route change (when TOC item clicked)
console.log('textid watcher', this, oldid, newid) console.log('textid watcher', this, oldid, newid)
this.texts = [] this.texts = []
this.textsuuids = [] this.textsuuids = []
@@ -237,10 +239,10 @@ export default {
this.inifinite_load_id += 1 this.inifinite_load_id += 1
} }
}, },
textdata (newtxtdata, oldtxtdata) { // textdata (newtxtdata, oldtxtdata) {
console.log('textdata watcher', oldtxtdata, newtxtdata) // console.log('textdata watcher', oldtxtdata, newtxtdata)
this.metainfotitle = `${this.title} ${newtxtdata.meta.title}` // this.metainfotitle = `${this.title} ${newtxtdata.meta.title}`
}, // },
page_selected (newp, oldp) { page_selected (newp, oldp) {
console.log('page_selected watcher', oldp, newp) console.log('page_selected watcher', oldp, newp)
this.scrollToPage(newp) this.scrollToPage(newp)
@@ -276,6 +278,11 @@ export default {
if (mutation.type === 'Corpus/setEditionsByUUID') { if (mutation.type === 'Corpus/setEditionsByUUID') {
// console.log('Edition state.Coprus.editionsbyuuid', this.editionid, state.Corpus.editionsbyuuid) // console.log('Edition state.Coprus.editionsbyuuid', this.editionid, state.Corpus.editionsbyuuid)
this.title = this.metainfotitle = state.Corpus.editionsbyuuid[this.editionid].title 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.biblio = state.Corpus.editionsbyuuid[this.editionid].biblio
this.description = state.Corpus.editionsbyuuid[this.editionid].description this.description = state.Corpus.editionsbyuuid[this.editionid].description
this.date = state.Corpus.editionsbyuuid[this.editionid].date this.date = state.Corpus.editionsbyuuid[this.editionid].date
@@ -306,6 +313,11 @@ export default {
} else { } else {
// console.log(''); // console.log('');
this.title = this.metainfotitle = this.editionsbyuuid[this.editionid].title 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.biblio = this.editionsbyuuid[this.editionid].biblio
this.description = this.editionsbyuuid[this.editionid].description this.description = this.editionsbyuuid[this.editionid].description
this.date = this.editionsbyuuid[this.editionid].date this.date = this.editionsbyuuid[this.editionid].date
@@ -342,8 +354,13 @@ export default {
this.textsuuids.unshift(data.content.uuid) this.textsuuids.unshift(data.content.uuid)
} }
if ($state) { if ($state) {
// triggered by infinite scroll
$state.loaded() $state.loaded()
this.next_loaded = true this.next_loaded = true
} else {
// triggered by TOC item click
// UPDATE METATAGS
this.updateMetaData(data.meta.metadata)
} }
}) })
.catch((error) => { .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) { onCenterScrolled (e) {
console.log('Edition centerScrolled(e)', e.target.scrollTop) console.log('Edition centerScrolled(e)', e.target.scrollTop)
if (!this.center_scrolled && e.target.scrollTop > this.inifinite_load_distance * 1.5) { 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) { onClickIndexItem (o) {
this.selectedindex = o this.selectedindex = o
+26 -2
View File
@@ -45,11 +45,15 @@ export default {
IndexItemOcurrences IndexItemOcurrences
}, },
data: () => ({ data: () => ({
content: null content: null,
meta: [],
metainfotitle: undefined
}), }),
metaInfo () { metaInfo () {
// console.log('metainfo', this.meta)
return { return {
title: `Locorum ${this.$route.params.id}` title: this.metainfotitle,
meta: this.meta
} }
}, },
computed: { computed: {
@@ -61,7 +65,9 @@ export default {
console.log('locorum REST: data', data) console.log('locorum REST: data', data)
if (data.content) { if (data.content) {
this.content = data.content this.content = data.content
this.metainfotitle = data.content.title
} }
this.updateMetaData(data.meta.metadata)
}) })
.catch((error) => { .catch((error) => {
console.warn('Issue with locorum', error) console.warn('Issue with locorum', error)
@@ -71,6 +77,24 @@ export default {
query: { fullpath: this.$route.path } 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)
})
}
} }
} }
</script> </script>
+24 -2
View File
@@ -64,11 +64,15 @@ export default {
IndexItemOcurrences IndexItemOcurrences
}, },
data: () => ({ data: () => ({
content: null content: null,
meta: [],
metainfotitle: undefined
}), }),
metaInfo () { metaInfo () {
// console.log('metainfo', this.meta)
return { return {
title: `Nominum ${this.$route.params.id}` title: this.metainfotitle,
meta: this.meta
} }
}, },
created () { created () {
@@ -78,7 +82,9 @@ export default {
console.log('nominum REST: data', data) console.log('nominum REST: data', data)
if (data.content) { if (data.content) {
this.parseOccurences(data.content) this.parseOccurences(data.content)
this.metainfotitle = data.content.title
} }
this.updateMetaData(data.meta.metadata)
}) })
.catch((error) => { .catch((error) => {
console.warn('Issue with nominum', error) console.warn('Issue with nominum', error)
@@ -90,6 +96,22 @@ export default {
}) })
}, },
methods: { 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) { parseOccurences (content) {
console.log('parseOccurences', content) console.log('parseOccurences', content)
// ! parsing occurences // ! parsing occurences
+26 -2
View File
@@ -53,11 +53,15 @@ export default {
IndexItemOcurrences IndexItemOcurrences
}, },
data: () => ({ data: () => ({
content: null content: null,
meta: [],
metainfotitle: undefined
}), }),
metaInfo () { metaInfo () {
// console.log('metainfo', this.meta)
return { return {
title: `Operum ${this.$route.params.id}` title: this.metainfotitle,
meta: this.meta
} }
}, },
beforeCreate () { beforeCreate () {
@@ -67,7 +71,9 @@ export default {
console.log('operum REST: data', data) console.log('operum REST: data', data)
if (data.content) { if (data.content) {
this.content = data.content this.content = data.content
this.metainfotitle = data.content.title
} }
this.updateMetaData(data.meta.metadata)
}) })
.catch((error) => { .catch((error) => {
console.warn('Issue with operum', error) console.warn('Issue with operum', error)
@@ -77,6 +83,24 @@ export default {
query: { fullpath: this.$route.path } 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)
})
}
} }
} }
</script> </script>