Skip to content
Snippets Groups Projects
Commit 54e9e8fc authored by Henrik Askjer's avatar Henrik Askjer
Browse files

add RIS download

parent 80b72eb5
No related branches found
No related tags found
No related merge requests found
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
<v-btn depressed x-small class="toolbar-button" rounded tabindex="0" @click="copy_citation"><br> <v-btn depressed x-small class="toolbar-button" rounded tabindex="0" @click="copy_citation"><br>
<v-icon x-small icon>content_copy</v-icon> <span class = "button-text">Kopier</span> <v-icon x-small icon>content_copy</v-icon> <span class = "button-text">Kopier</span>
</v-btn> </v-btn>
<v-btn depressed x-small class="toolbar-button" rounded tabindex="0" @click="close_citation_dialog"><br> <v-btn depressed x-small class="toolbar-button" rounded tabindex="0" @click="download_ris"><br>
<v-icon x-small icon>get_app</v-icon> <span class = "button-text">Last ned</span> <v-icon x-small icon>get_app</v-icon> <span class = "button-text">Last ned</span>
</v-btn> </v-btn>
<v-btn depressed x-small class="toolbar-button" rounded tabindex="0" @click="close_citation_dialog"><br> <v-btn depressed x-small class="toolbar-button" rounded tabindex="0" @click="close_citation_dialog"><br>
...@@ -67,17 +67,20 @@ export default { ...@@ -67,17 +67,20 @@ export default {
create_link() { create_link() {
return host + this.article.dictionary + '/' + this.article.article_id + '/' + encodeURIComponent(this.article.lemmas[0].lemma) return host + this.article.dictionary + '/' + this.article.article_id + '/' + encodeURIComponent(this.article.lemmas[0].lemma)
}, },
create_citation() { get_citation_info() {
let date = new Date(); let date = new Date();
let dd = (date.getDate() < 10? '0' : '') + date.getDate() let dd = (date.getDate() < 10? '0' : '') + date.getDate()
let mm = (date.getMonth() < 9? '0' : '') + (date.getMonth()+1) let mm = (date.getMonth() < 9? '0' : '') + (date.getMonth()+1)
let yyyy = date.getFullYear() let yyyy = date.getFullYear()
let link = this.create_link() let link = this.create_link()
let citation = {"bm": ${this.article.lemmas[0].lemma}». I: <em>Bokmålsordboka.</em> Språkrådet og Universitetet i Bergen. &lt;<a href='${link}'>${link}</a>&gt; (hentet ${dd}.${mm}.${yyyy}).`, let lemma = this.article.lemmas[0].lemma
"nn":${this.article.lemmas[0].lemma}». I: <em>Nynorskordboka.</em> Språkrådet og Universitetet i Bergen. &lt;<a href='${link}'>${link}</a>&gt; (henta ${dd}.${mm}.${yyyy}).` return [lemma, dd, mm, yyyy, link]
},
create_citation() {
const [lemma, dd, mm, yyyy, link] = this.get_citation_info()
let citation = {"bm": ${lemma}». I: <em>Bokmålsordboka.</em> Språkrådet og Universitetet i Bergen. &lt;<a href='${link}'>${link}</a>&gt; (hentet ${dd}.${mm}.${yyyy}).`,
"nn":${lemma}». I: <em>Nynorskordboka.</em> Språkrådet og Universitetet i Bergen. &lt;<a href='${link}'>${link}</a>&gt; (henta ${dd}.${mm}.${yyyy}).`
}[this.article.dictionary] }[this.article.dictionary]
return citation return citation
}, },
copy_link() { copy_link() {
...@@ -92,8 +95,19 @@ export default { ...@@ -92,8 +95,19 @@ export default {
close_citation_dialog() { close_citation_dialog() {
this.citation_dialog = false this.citation_dialog = false
} },
download_ris() {
const [lemma, dd, mm, yyyy, link] = this.get_citation_info()
const a = document.createElement("a")
a.style = "display: none"
a.setAttribute("download", `${lemma}_${this.article.dictionary}.ris`)
const dict = {"bm":"Bokmålsordboka", "nn": "Nynorskordboka"}[this.article.dictionary]
const text = `TY - DICT\nTI - ${lemma}\nT2 - ${dict}\nPB - Språkrådet og Universitetet i Bergen\nUR - ${link}\nY2 - ${yyyy}/${mm}/${dd}/\nER - `
a.setAttribute('href', 'data:application/x-research-info-systems;charset=utf-8,' + encodeURIComponent(text));
document.body.appendChild(a)
a.click()
document.body.removeChild(a)
},
} }
} }
......
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