From 90a5e15bb824b84e5bb60337d6a57a1394090dc6 Mon Sep 17 00:00:00 2001 From: Terry Truong Date: Wed, 4 May 2022 01:17:06 +1000 Subject: Add scripts for obtaining/sending/displaying wikipedia descriptions Add backend/data/enwiki/ directory containing scripts and instructive READMEs. Adjust some other scripts to generate 'eol_ids' sqlite table separate from 'names'. Make server respond to /data/desc requests, and have client TileInfo component display response data. Also adjust .gitignore entries to be root-relative. --- src/components/SearchModal.vue | 3 ++- src/components/TileInfoModal.vue | 35 +++++++++++++++++++++++++++++------ 2 files changed, 31 insertions(+), 7 deletions(-) (limited to 'src/components') diff --git a/src/components/SearchModal.vue b/src/components/SearchModal.vue index a90c945..9cc3a29 100644 --- a/src/components/SearchModal.vue +++ b/src/components/SearchModal.vue @@ -42,7 +42,8 @@ export default defineComponent({ url.search = '?name=' + encodeURIComponent(input.value); fetch(url.toString()) .then(response => response.json()) - .then(results => { + .then(obj => { + let results = obj[0]; if (results.length == 0){ input.value = ''; // Trigger failure animation diff --git a/src/components/TileInfoModal.vue b/src/components/TileInfoModal.vue index 47ad987..3669f8f 100644 --- a/src/components/TileInfoModal.vue +++ b/src/components/TileInfoModal.vue @@ -7,6 +7,12 @@ import {TolNode} from '../tol'; // Displays information about a tree-of-life node export default defineComponent({ + data(){ + return { + desc: null as null | string, + fromRedirect: false, + }; + }, props: { node: {type: Object as PropType, required: true}, tolMap: {type: Object as PropType, required: true}, @@ -37,6 +43,19 @@ export default defineComponent({ } }, }, + created(){ + let url = new URL(window.location.href); + url.pathname = '/data/desc'; + url.search = '?name=' + encodeURIComponent(this.node.name); + fetch(url.toString()) + .then(response => response.json()) + .then(obj => { + if (obj != null){ + this.desc = obj[0]; + this.fromRedirect = obj[1]; + } + }); + }, components: {CloseIcon, }, emits: ['info-modal-close', ], }); @@ -61,12 +80,16 @@ export default defineComponent({ -
- Lorem ipsum dolor sit amet, consectetur adipiscing - elit, sed do eiusmod tempor incididunt ut labore - et dolore magna aliqua. Ut enim ad minim veniam, - quis nostrud exercitation ullamco laboris nisi ut - aliquip ex ea commodo consequat. +
+
+ Redirected: {{fromRedirect}} +
+
+ {{desc}} +
+
+
+ (No description found)
-- cgit v1.2.3