Commit f325e77e authored by Markus Opolka's avatar Markus Opolka
Browse files

Merge branch 'validation' into 'master'

Add XML Validation and fix regression

See merge request bi40resu/vue-letters!4
parents f9041967 76f88edb
......@@ -45,12 +45,17 @@ function inCacheFormat (docname, docobj) {
collection: docobj.TEI.teiHeader.fileDesc.titleStmt.collection._text,
url: '/api/letters/' + docname.slice(0, -4),
name: docname.replace(/_/g, ' ').slice(0, -4),
valid: true,
hash: hash,
object: docobj
}
} catch (err) {
console.log(arguments.callee) // eslint-disable-line no-caller
console.error('>> Error while loading ' + docname)
doc = {
name: docname.replace(/_/g, ' ').slice(0, -4),
valid: false
}
}
return doc
......@@ -147,13 +152,15 @@ app.get('/api/search', function (req, res) {
}
let data = []
for (let item of cache.keys()) {
let obj = loadDocument(item)
for (let name of cache.keys()) {
let obj = loadDocument(name)
if (obj.valid) {
let results = lib.search(obj, query)
if (results !== null) {
data.push(results)
}
}
}
res.send(data)
console.timeEnd('> Search All')
......@@ -176,20 +183,24 @@ app.get('/api/features/:letter?', function (req, res) {
if (req.params.letter) {
console.time('> Search Features - Letter')
let obj = loadDocument(DOC)
if (obj.valid) {
let results = lib.features(obj, query)
if (results !== null) {
data.push(results)
}
}
console.timeEnd('> Search Features - Letter')
} else {
console.time('> Search Features')
for (let item of cache.keys()) {
let obj = loadDocument(item)
if (obj.valid) {
let results = lib.features(obj, query)
if (results !== null) {
data.push(results)
}
}
}
console.timeEnd('> Search Features')
}
......
......@@ -151,8 +151,8 @@ function metadataTable (objs) {
let items = []
for (let item of objs) {
let meta = item.object.TEI.teiHeader.fileDesc.titleStmt
try {
let meta = item.object.TEI.teiHeader.fileDesc.titleStmt
items.push({
title: meta.title._text,
name: item.name,
......@@ -163,11 +163,16 @@ function metadataTable (objs) {
date: meta.date._text,
place: meta.place._text,
url: item.url,
link: item.link
link: item.link,
valid: true
})
} catch (err) {
console.log(arguments.callee) // eslint-disable-line no-caller
console.log('>> Error while table formating' + meta.title._text)
console.log('>> Error while table formating' + item.name)
items.push({
name: item.name,
valid: false
})
}
}
......
{
"name": "cdbp",
"version": "1.1",
"version": "1.1.1",
"description": "FAU CDBP",
"author": "Markus Opolka <markus@martialblog.de>",
"private": true,
......
......@@ -142,7 +142,7 @@ export default {
// Sums up all hits in all letters
let hits = 0
for (let value of this.results) {
hits = hits + value.count
hits = hits + value.hits
}
return hits
}
......
......@@ -9,14 +9,23 @@
<v-flex xs12 v-if="letters">
<v-list>
<template v-for="letter in letters">
<v-list-tile avatar v-bind:key="letter.url" :to="letter.link">
<v-list-tile avatar v-if="letter.valid" v-bind:key="letter.url" :to="letter.link">
<v-list-tile-avatar>
<v-icon grey lighten-1 white--text>mail</v-icon>
<v-icon grey lighten-1>mail</v-icon>
</v-list-tile-avatar>
<v-list-tile-content>
<v-list-tile-title v-html="letter.name"></v-list-tile-title>
</v-list-tile-content>
</v-list-tile>
<v-list-tile avatar v-else v-bind:key="letter.name" class="red darken-4">
<v-list-tile-avatar>
<v-icon grey lighten-1 dark>error</v-icon>
</v-list-tile-avatar>
<v-list-tile-content>
<v-list-tile-title v-html="letter.name" class="white--text"></v-list-tile-title>
<span class="white--text caption">Error while loading file</span>
</v-list-tile-content>
</v-list-tile>
<v-divider></v-divider>
</template>
</v-list>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment