From 90a5e15bb824b84e5bb60337d6a57a1394090dc6 Mon Sep 17 00:00:00 2001
From: Terry Truong <terry06890@gmail.com>
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/TileInfoModal.vue | 35 +++++++++++++++++++++++++++++------
 1 file changed, 29 insertions(+), 6 deletions(-)

(limited to 'src/components/TileInfoModal.vue')

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>
 		
-- 
cgit v1.2.3

