From 43c06e39f5db21f0dfa937e00c4df6348152a537 Mon Sep 17 00:00:00 2001 From: shoofle Date: Mon, 21 Oct 2024 11:56:48 -0400 Subject: [PATCH] command interpreting now bassically works. --- client/package-lock.json | 9 + client/package.json | 1 + client/src/apiTools.jsx | 8 +- client/src/embodied/Live.jsx | 2 +- client/src/embodied/MessageFeed.css | 3 + client/src/embodied/Sidebar.jsx | 11 +- client/src/page/Page.jsx | 36 +++- server/interpreter.js | 286 +++++++++++++++++++++------- server/package-lock.json | 19 +- server/package.json | 3 +- server/routes/api.js | 4 +- server/routes/live.js | 47 +++++ server/routes/pages.js | 24 ++- server/routes/sockets.js | 32 ---- server/routes/users.js | 2 + 15 files changed, 360 insertions(+), 127 deletions(-) create mode 100644 server/routes/live.js delete mode 100644 server/routes/sockets.js diff --git a/client/package-lock.json b/client/package-lock.json index 75280788..fecb4d4d 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -18,6 +18,7 @@ "graphology": "^0.25.4", "graphology-layout": "^0.6.1", "graphology-layout-force": "^0.2.4", + "highlight.js": "^11.10.0", "react": "^18.3.1", "react-dom": "^18.3.1", "react-hook-form": "^7.53.0", @@ -2507,6 +2508,14 @@ "node": ">= 0.4" } }, + "node_modules/highlight.js": { + "version": "11.10.0", + "resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-11.10.0.tgz", + "integrity": "sha512-SYVnVFswQER+zu1laSya563s+F8VDGt7o35d4utbamowvUNLLMovFqwCLSocpZTz3MgaSRA1IbqRWZv97dtErQ==", + "engines": { + "node": ">=12.0.0" + } + }, "node_modules/indent-string": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-4.0.0.tgz", diff --git a/client/package.json b/client/package.json index d845f2f9..ca4a0694 100644 --- a/client/package.json +++ b/client/package.json @@ -13,6 +13,7 @@ "graphology": "^0.25.4", "graphology-layout": "^0.6.1", "graphology-layout-force": "^0.2.4", + "highlight.js": "^11.10.0", "react": "^18.3.1", "react-dom": "^18.3.1", "react-hook-form": "^7.53.0", diff --git a/client/src/apiTools.jsx b/client/src/apiTools.jsx index b12beeb3..4cec4b57 100644 --- a/client/src/apiTools.jsx +++ b/client/src/apiTools.jsx @@ -50,10 +50,10 @@ export async function fetchPageAtEdit(number, id) { return shoofetch(`${apiUrl}/page/${number}/${id}`, {method: 'GET'}); } -export async function postPage({id, title, description}) { +export async function postPage({id, title, description, type}) { return shoofetch(`${apiUrl}/page/${id}`, { method: 'POST', - body: JSON.stringify({id: id, title: title, description: description}), + body: JSON.stringify({id: id, title: title, description: description, type: type}), }) } @@ -98,4 +98,8 @@ export async function postLogOut() { export async function fetchProfile() { return shoofetch(`${apiUrl}/user`, {method: 'GET'}); +} + +export async function fetchCurrentVerbs() { + return shoofetch(`${apiUrl}/embody/verbs`, {method: 'GET'}); } \ No newline at end of file diff --git a/client/src/embodied/Live.jsx b/client/src/embodied/Live.jsx index 6c83bfda..5c89726c 100644 --- a/client/src/embodied/Live.jsx +++ b/client/src/embodied/Live.jsx @@ -64,7 +64,7 @@ function Live({editing, ...props}) { - + { console.log(w); sendMessage(w); } }/> ); } diff --git a/client/src/embodied/MessageFeed.css b/client/src/embodied/MessageFeed.css index 013e2fba..23847ab8 100644 --- a/client/src/embodied/MessageFeed.css +++ b/client/src/embodied/MessageFeed.css @@ -22,4 +22,7 @@ } .messages-tray li { list-style: none; +} +.messages-tray li:nth-child(even) { + background: lightgray; } \ No newline at end of file diff --git a/client/src/embodied/Sidebar.jsx b/client/src/embodied/Sidebar.jsx index 88352d09..c9e64aff 100644 --- a/client/src/embodied/Sidebar.jsx +++ b/client/src/embodied/Sidebar.jsx @@ -1,5 +1,7 @@ import { useState } from 'react'; +import { useQuery } from '@tanstack/react-query'; import { useLoggedIn } from '../AuthProvider.jsx'; +import { fetchCurrentVerbs } from '../apiTools.jsx'; import './Sidebar.css'; @@ -7,13 +9,18 @@ function Sidebar({children, pagenumber, hidden=false, sendWord=(()=>null)}) { const [open, setOpen] = useState(!hidden); const loggedIn = useLoggedIn(); - const verbs = ["go", "take"]; + const { isPending, isError, error, data } = useQuery({ // fetch the currrent values + queryKey: ['my verbs'], + queryFn: fetchCurrentVerbs, + }); + + const verbs = data; return (
    - {verbs.map( (name) => ( + {(verbs || []).map( (name) => (