diff options
| author | Terry Truong <terry06890@gmail.com> | 2022-05-04 01:17:06 +1000 |
|---|---|---|
| committer | Terry Truong <terry06890@gmail.com> | 2022-05-04 01:17:06 +1000 |
| commit | 90a5e15bb824b84e5bb60337d6a57a1394090dc6 (patch) | |
| tree | 661ea356c8d83b74d16f19d3555b0a1d3eb6eb56 /src | |
| parent | ec29e5731136c74a1991e2f93b5e233747f2a230 (diff) | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/components/SearchModal.vue | 3 | ||||
| -rw-r--r-- | src/components/TileInfoModal.vue | 35 | ||||
| -rw-r--r-- | src/tol.ts | 2 |
3 files changed, 33 insertions, 7 deletions
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<LayoutNode>, required: true}, tolMap: {type: Object as PropType<TolMap>, 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({ </ul> </div> </div> - <div> - 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. + <div v-if="desc != null"> + <div> + Redirected: {{fromRedirect}} + </div> + <div> + {{desc}} + </div> + </div> + <div v-else> + (No description found) </div> </div> @@ -17,11 +17,13 @@ export class TolNode { license: string, copyrightOwner: string }; + desc: null | [string, boolean]; constructor(children: string[] = [], parent = null, tips = 0, pSupport = false){ this.children = children; this.parent = parent; this.tips = tips; this.pSupport = pSupport; this.img = null; + this.desc = null; } } |
