Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
beta.ordbok.uib.no
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Margunn.Rauset
beta.ordbok.uib.no
Commits
cfcd41b6
Commit
cfcd41b6
authored
5 years ago
by
Ole Voldsæter
Browse files
Options
Downloads
Patches
Plain Diff
tospråklig igjen
parent
a77ad2fe
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/App.vue
+36
-27
36 additions, 27 deletions
src/App.vue
src/components/SearchResults.vue
+1
-1
1 addition, 1 deletion
src/components/SearchResults.vue
with
37 additions
and
28 deletions
src/App.vue
+
36
−
27
View file @
cfcd41b6
...
...
@@ -3,9 +3,13 @@
<img
alt=
"Vue logo"
src=
"./assets/logo.png"
>
<header>
<autocomplete
:debounceTime=
"50"
:auto-select=
"true"
:search=
"search"
:get-result-value=
"result_view"
@
submit=
"select_result"
placeholder=
"søk..."
></autocomplete>
<input
type=
"radio"
id=
"radio_nob"
value=
"nob"
v-model=
"path_lang"
>
<label
for=
"radio_nob"
>
Bokmål
</label>
<input
type=
"radio"
id=
"radio_nno"
value=
"nno"
v-model=
"path_lang"
>
<label
for=
"radio_nno"
>
Nynorsk
</label>
</header>
<img
id=
"spinner"
:class=
"waiting ? 'show' : 'hide'"
src=
"./assets/spinner.gif"
alt=
"Venter på innhold"
/>
<SearchResults
:hits=
"search_results"
:lang=
"
query
_lang"
/>
<SearchResults
:hits=
"search_results"
:lang=
"
path
_lang"
/>
<Article
:article=
"article"
/>
</main>
</
template
>
...
...
@@ -17,40 +21,20 @@ import SearchResults from './components/SearchResults.vue'
import
Autocomplete
from
'
@trevoreyre/autocomplete-vue
'
import
'
@trevoreyre/autocomplete-vue/dist/style.css
'
var
api_endpoint
=
'
https://ordbok-dev.aws.uib.no/cache/article
/nob
'
var
api_endpoint
=
'
https://ordbok-dev.aws.uib.no/cache/article
'
export
default
{
name
:
'
app
'
,
data
:
function
()
{
let
params
=
new
URLSearchParams
(
window
.
location
.
search
.
substring
(
1
))
let
path
=
window
.
location
.
href
.
split
(
"
/
"
)
let
path
=
window
.
location
.
pathname
.
split
(
"
/
"
)
return
{
article_id
:
parseInt
(
path
.
pop
()),
search_query
:
params
.
get
(
'
q
'
),
query_lang
:
params
.
get
(
'
lang
'
),
path_lang
:
path
.
pop
(),
path_lang
:
path
.
pop
()
||
'
nob
'
,
search_results
:
[],
waiting
:
true
,
article
:
{
lemmas
:
[],
body
:{
pronunciation
:
[],
definitions
:
[],
etymology
:
[]}},
search
:
function
(
q
)
{
return
new
Promise
(
resolve
=>
{
return
axios
.
post
(
api_endpoint
+
'
/_search/
'
,
{
"
suggest
"
:
{
"
suggest
"
:
{
"
prefix
"
:
q
,
"
completion
"
:
{
"
field
"
:
"
suggest
"
}
}
}
}).
then
(
function
(
response
)
{
let
hits
=
response
.
data
.
suggest
.
suggest
[
0
].
options
if
(
q
.
length
)
hits
=
hits
.
concat
({
q
:
q
})
resolve
(
hits
)
})
})
},
result_view
:
function
(
result
)
{
if
(
result
.
_source
)
return
result
.
_source
.
lemmas
.
map
(
x
=>
x
.
lemma
).
join
(
'
,
'
)
...
...
@@ -59,6 +43,31 @@ export default {
}
}
},
computed
:
{
search
:
function
()
{
console
.
log
(
this
)
let
self
=
this
return
function
(
q
)
{
return
new
Promise
(
resolve
=>
{
return
axios
.
post
(
api_endpoint
+
'
/
'
+
self
.
path_lang
+
'
/_search/
'
,
{
"
suggest
"
:
{
"
suggest
"
:
{
"
prefix
"
:
q
,
"
completion
"
:
{
"
field
"
:
"
suggest
"
}
}
}
}).
then
(
function
(
response
)
{
let
hits
=
response
.
data
.
suggest
.
suggest
[
0
].
options
if
(
q
.
length
)
hits
=
hits
.
concat
({
q
:
q
})
resolve
(
hits
)
})
})
}
}
},
components
:
{
Article
,
Autocomplete
,
...
...
@@ -70,14 +79,14 @@ export default {
this
.
search_results
=
[]
this
.
article
=
event
.
_source
}
else
{
window
.
location
.
href
=
"
/search?q=
"
+
event
.
q
window
.
location
.
href
=
'
/
'
+
this
.
path_lang
+
"
/search?q=
"
+
event
.
q
}
}
},
mounted
:
function
(){
var
self
=
this
;
if
(
this
.
search_query
)
{
axios
.
get
(
api_endpoint
+
'
/_search?q=
'
+
self
.
search_query
)
axios
.
get
(
api_endpoint
+
'
/
'
+
self
.
path_lang
+
'
/_search?q=
'
+
self
.
search_query
)
.
then
(
function
(
response
){
self
.
search_results
=
response
.
data
.
hits
.
hits
self
.
waiting
=
false
...
...
@@ -85,7 +94,7 @@ export default {
}
else
if
(
this
.
article_id
)
{
axios
.
get
(
api_endpoint
+
'
/
'
+
self
.
article_id
)
axios
.
get
(
api_endpoint
+
'
/
'
+
self
.
path_lang
+
'
/
'
+
self
.
article_id
)
.
then
(
function
(
response
){
self
.
article
=
response
.
data
.
_source
self
.
waiting
=
false
...
...
This diff is collapsed.
Click to expand it.
src/components/SearchResults.vue
+
1
−
1
View file @
cfcd41b6
...
...
@@ -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=
"'/' + result.id"
>
{{
result
.
label
}}
</a>
(
{{
result
.
classification
}}
)
<a
:href=
"'/' +
lang + '/' +
result.id"
>
{{
result
.
label
}}
</a>
(
{{
result
.
classification
}}
)
</li>
</ul>
</section>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment