Skip to content
Snippets Groups Projects
Commit a77ad2fe authored by Ole Voldsæter's avatar Ole Voldsæter
Browse files

fungerer mot cache, men igjen bare for bokmål

parent cc209c42
No related branches found
No related tags found
No related merge requests found
......@@ -2,14 +2,7 @@
<main id="app">
<img alt="Vue logo" src="./assets/logo.png">
<header>
<form class="" action="search" method="get">
<input placeholder="Søk..." name="q" />
<select class="" name="lang">
<option value="nob">Bokmål</option>
<option value="nno">Nynorsk</option>
</select>
<input type="submit" name="" value="Yay!">
</form>
<autocomplete :debounceTime="50" :auto-select="true" :search="search" :get-result-value="result_view" @submit="select_result" placeholder="søk..."></autocomplete>
</header>
<img id="spinner" :class="waiting ? 'show' : 'hide'" src="./assets/spinner.gif" alt="Venter på innhold" />
<SearchResults :hits="search_results" :lang="query_lang" />
......@@ -21,10 +14,10 @@
import axios from "axios"
import Article from './components/Article.vue'
import SearchResults from './components/SearchResults.vue'
//import Autocomplete from '@trevoreyre/autocomplete-vue'
//import '@trevoreyre/autocomplete-vue/dist/style.css'
import Autocomplete from '@trevoreyre/autocomplete-vue'
import '@trevoreyre/autocomplete-vue/dist/style.css'
var api_endpoint = 'https://ordbok-dev.aws.uib.no/api/dict/'
var api_endpoint = 'https://ordbok-dev.aws.uib.no/cache/article/nob'
export default {
name: 'app',
......@@ -39,9 +32,9 @@ export default {
search_results: [],
waiting: true,
article: {lemmas: [], body:{pronunciation: [], definitions: [], etymology: []}},
/*search: function(q) {
search: function(q) {
return new Promise(resolve => {
return axios.post(api_endpoint + '_search/',
return axios.post(api_endpoint + '/_search/',
{
"suggest": {
"suggest" : {
......@@ -57,10 +50,10 @@ export default {
resolve(hits)
})
})
},*/
},
result_view: function(result) {
if (result._source)
return result._source.lemmas.map(x => x.word).join(', ')
return result._source.lemmas.map(x => x.lemma).join(', ')
else
return 'Alle søkeresultater...'
}
......@@ -68,7 +61,7 @@ export default {
},
components: {
Article,
//Autocomplete,
Autocomplete,
SearchResults
},
methods: {
......@@ -77,24 +70,24 @@ export default {
this.search_results = []
this.article = event._source
}else{
window.location.href="search?q=" + event.q
window.location.href="/search?q=" + event.q
}
}
},
mounted: function(){
var self = this;
if(this.search_query) {
axios.get(api_endpoint + self.query_lang + '/article' + '?expand_lemmas=true&lemma_text=' + self.search_query)
axios.get(api_endpoint + '/_search?q=' + self.search_query)
.then(function(response){
self.search_results = response.data
self.search_results = response.data.hits.hits
self.waiting = false
})
}
else if(this.article_id)
{
axios.get(api_endpoint + self.path_lang + '/article' + '/' + self.article_id + '?expand_lemmas=true&expand_refs=true')
axios.get(api_endpoint + '/' + self.article_id)
.then(function(response){
self.article = response.data
self.article = response.data._source
self.waiting = false
})
}
......
......@@ -6,7 +6,7 @@
<h4>{{lemma.lemma}}</h4>
<table v-for="(std, index) in lemma.standardisations" :key="index">
<tr>
<th rowspan="2">{{std.tags.join(', ')}}</th>
<th rowspan="2">{{std.tags ? std.tags.join(', ') : ''}}</th>
<th v-for="(inflection, index) in std.inflection" :key="index">{{inflection.tags.join(', ')}}</th>
</tr>
<tr>
......
......@@ -3,7 +3,7 @@
<h2 v-if="hits.length">Søkeresultater</h2>
<ul>
<li v-for="(result, index) in extended_results" :key="index">
<a :href="'/' + lang + '/' + result.id">{{result.label}}</a> ({{result.classification}})
<a :href="'/' + result.id">{{result.label}}</a> ({{result.classification}})
</li>
</ul>
</section>
......@@ -22,9 +22,9 @@ export default {
return this.hits.map(
function(hit){
return {
id: hit.article_id,
label: hit.lemmas.map(x => x.lemma).join(', '),
classification: helpers.group_list(hit.lemmas)
id: hit._id,
label: hit._source.lemmas.map(x => x.lemma).join(', '),
classification: helpers.group_list(hit._source.lemmas)
}
})
}
......
......@@ -2,7 +2,9 @@ var group_list = function(grps) {
var grp_collection = new Set()
grps.forEach(function(lemma){
lemma.standardisations.forEach(function(grp){
grp_collection.add(grp.tags[0] == 'subst' ? grp.tags[0] + ',' + grp.tags[1] : grp.tags[0])
if (grp.tags){
grp_collection.add(grp.tags[0] == 'subst' ? grp.tags[0] + ',' + grp.tags[1] : grp.tags[0])
}
})
})
return Array.from(grp_collection).join('; ')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment