Parcourir la source

metada are populated for texts & indexes #1796

bach il y a 1 an
Parent
commit
1f106b3842
4 fichiers modifiés avec 116 ajouts et 12 suppressions
  1. 40 6
      src/pages/Edition.vue
  2. 26 2
      src/pages/Locorum.vue
  3. 24 2
      src/pages/Nominum.vue
  4. 26 2
      src/pages/Operum.vue

+ 40 - 6
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

+ 26 - 2
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)
+      })
+    }
   }
 }
 </script>

+ 24 - 2
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

+ 26 - 2
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)
+      })
+    }
   }
 }
 </script>