diff --git a/compose.yaml b/compose.yaml index e3f6b99..0c49d9f 100644 --- a/compose.yaml +++ b/compose.yaml @@ -8,13 +8,14 @@ services: - "3000:8080" - "3001:1984" volumes: - - basex-lsp:/srv/basex/data + - ./data:/srv/basex/data + - ./webapp/static/ace:/srv/basex/webapp/static/ace - ./webapp/lsp:/srv/basex/webapp/lsp - - ./setup.bxs:/srv/basex/setup.bxs + # - ./jars:/srv/basex/lib/custom # - ./repo:/srv/basex/repo environment: - - "SERVER_OPTS= -c basex/setup.bxs" + - "SERVER_OPTS= -d" volumes: basex-lsp: diff --git a/data/.logs/2025-07-17.log b/data/.logs/2025-07-17.log new file mode 100644 index 0000000..f0136c3 --- /dev/null +++ b/data/.logs/2025-07-17.log @@ -0,0 +1,30 @@ +13:46:33.043 SERVER admin OK Server was started (port: 1984). +13:46:33.076 SERVER admin INFO Initial admin password (change after first login): c980aed4-8234-48e0-84b9-195d0ef6b049 +13:46:33.110 SERVER admin OK HTTP Server was started (port: 8080). +13:49:38.435 172.19.0.1:33068 admin REQUEST [GET] /dba/logs +13:49:40.374 172.19.0.1:33068 admin 302 Location: login?_page=logs 1942.58 ms +13:49:40.401 172.19.0.1:33068 admin REQUEST [GET] /dba/login?_page=logs +13:49:40.527 172.19.0.1:33068 public 200 126.37 ms +13:50:11.142 172.19.0.1:33068 admin REQUEST [POST] /dba/login +13:50:11.255 172.19.0.1:33068 public DBA Login: admin +13:50:11.256 172.19.0.1:33068 public 302 Location: logs 114.16 ms +13:50:11.281 172.19.0.1:33068 admin REQUEST [GET] /dba/logs +13:50:11.485 172.19.0.1:33068 admin 200 205.03 ms +13:50:11.677 172.19.0.1:33068 admin REQUEST [POST] /dba/logs?date=2025-07-17&page=1 +13:50:11.828 172.19.0.1:33068 admin 200 150.97 ms +13:51:01.795 172.19.0.1 admin REQUEST [WS-OPEN] http://127.0.0.1:3000/ws/lsp +13:51:01.806 SERVER admin TRACE CONNECT: "websocket0" +13:51:20.443 172.19.0.1:33068 admin REQUEST [GET] /dba/logs?input= +13:51:20.535 172.19.0.1:33068 admin 200 105.53 ms +13:51:20.619 172.19.0.1:33068 admin REQUEST [POST] /dba/logs?date=2025-07-17&page=1 +13:51:20.712 172.19.0.1:33068 admin 200 92.72 ms +13:54:21.878 172.19.0.1 admin REQUEST [WS-OPEN] http://127.0.0.1:3000/ws/lsp +13:54:21.886 SERVER admin TRACE CONNECT: "websocket1" +13:54:38.250 172.19.0.1:54556 admin REQUEST [GET] /dba/logs?input= +13:54:38.304 172.19.0.1:54556 admin 200 54.29 ms +13:54:38.386 172.19.0.1:54556 admin REQUEST [POST] /dba/logs?date=2025-07-17&page=1 +13:54:38.467 172.19.0.1:54556 admin 200 81.02 ms +13:59:11.360 172.19.0.1 admin REQUEST [WS-OPEN] http://127.0.0.1:3000/ws/lsp +13:59:11.369 SERVER admin TRACE CONNECT: "websocket2" +14:03:40.821 172.19.0.1 admin REQUEST [WS-OPEN] http://127.0.0.1:3000/ws/lsp +14:03:40.829 SERVER admin TRACE CONNECT: "websocket3" diff --git a/data/users.xml b/data/users.xml new file mode 100644 index 0000000..95ec701 --- /dev/null +++ b/data/users.xml @@ -0,0 +1,11 @@ + + + + 60a56ebb6dcce833b7b25f1b30308230 + + + 1380009415456 + d05ace1a12d885eefaeeefaff9064b79dba66099e4b746ee670ee40740b59010 + + + \ No newline at end of file diff --git a/setup.bxs b/setup.bxs deleted file mode 100644 index 403be29..0000000 --- a/setup.bxs +++ /dev/null @@ -1,2 +0,0 @@ -CREATE DB xmark http://files.basex.org/xml/xmark.xml -REPO INSTALL https://github.com/expkg-zone58/pdfbox/releases/download/v0.3.6/pdfbox-0.3.6.xar \ No newline at end of file diff --git a/webapp/lsp/lsp-util.xqm b/webapp/lsp/lsp-util.xqm index 39d8360..d43e2d2 100644 --- a/webapp/lsp/lsp-util.xqm +++ b/webapp/lsp/lsp-util.xqm @@ -2,24 +2,24 @@ : Simple WebSocket chat. Utility functions. : @author BaseX Team, BSD License :) -module namespace chat-util = 'chat/util'; +module namespace lsp-util = 'chat/util'; + -import module namespace session = 'http://basex.org/modules/session'; import module namespace ws = 'http://basex.org/modules/ws'; (:~ User id (bound to sessions and WebSockets). :) -declare variable $chat-util:id := 'id'; +declare variable $lsp-util:id := 'id'; (:~ : Sends a users list (all, active) to all registered clients. :) -declare function chat-util:users() as empty-sequence() { +declare function lsp-util:users() as empty-sequence() { ws:emit(map{ 'type': 'users', 'users': array { sort(user:list()) }, 'active': array { distinct-values( for $id in ws:ids() - return ws:get($id, $chat-util:id) + return ws:get($id, $lsp-util:id) )} }) }; @@ -29,15 +29,15 @@ declare function chat-util:users() as empty-sequence() { : @param $text text to be sent : @param $to receiver of a private message (optional) :) -declare function chat-util:message( +declare function lsp-util:message( $text as xs:string, $to as xs:string? ) as empty-sequence() { - let $ws-ids := ws:ids()[not($to) or ws:get(., $chat-util:id) = $to] + let $ws-ids := ws:ids()[not($to) or ws:get(., $lsp-util:id) = $to] return ws:send(map{ 'type': 'message', 'text': serialize($text), - 'from': ws:get(ws:id(), $chat-util:id), + 'from': ws:get(ws:id(), $lsp-util:id), 'date': format-time(current-time(), '[H02]:[m02]:[s02]'), 'private': boolean($to) }, $ws-ids) @@ -47,10 +47,10 @@ declare function chat-util:message( : Closes all WebSocket connections from the specified user. : @param $name username :) -declare function chat-util:close( +declare function lsp-util:close( $name as xs:string ) as empty-sequence() { for $id in ws:ids() - where ws:get($id, $chat-util:id) = $name + where ws:get($id, $lsp-util:id) = $name return ws:close($id) }; diff --git a/webapp/lsp/lsp-ws.xqm b/webapp/lsp/lsp-ws.xqm index 2237d1b..ed9174c 100644 --- a/webapp/lsp/lsp-ws.xqm +++ b/webapp/lsp/lsp-ws.xqm @@ -2,19 +2,24 @@ : Simple WebSocket chat. WebSocket functions. : @author BaseX Team, BSD License :) -module namespace chat-ws = 'chat-ws'; +module namespace lsp-ws = 'lsp-ws'; import module namespace chat-util = 'chat/util' at 'lsp-util.xqm'; +declare +%ws:error('/lsp', '{$error}') +function lsp-ws:error($error) { + trace($error,"ERR ") +}; (:~ : Creates a WebSocket connection. Registers the user and notifies all clients. :) declare %ws:connect('/lsp') -function chat-ws:connect() as empty-sequence() { - ws:set(ws:id()=>trace("CONNECT: "), $chat-util:id, session:get($chat-util:id)), - chat-util:users() +function lsp-ws:connect() as empty-sequence() { + ws:set(ws:id()=>trace("CONNECT: "), $chat-util:id, session:get($chat-util:id)) + (: ,chat-util:users() :) }; (:~ @@ -23,10 +28,10 @@ function chat-ws:connect() as empty-sequence() { :) declare %ws:message('/lsp', '{$message}') -function chat-ws:message( +function lsp-ws:message( $message as xs:string ) as empty-sequence() { - let $json := parse-json($message) + let $json := parse-json($message=>trace("MSG ")) let $type := $json?type return if($type = 'message') then ( chat-util:message($json?text, $json?to) @@ -40,7 +45,7 @@ function chat-ws:message( :) declare %ws:close('/lsp') -function chat-ws:close() as empty-sequence() { +function lsp-ws:close() as empty-sequence() { ws:delete(ws:id(), $chat-util:id), chat-util:users() }; diff --git a/webapp/static/ace/acego.js b/webapp/static/ace/acego.js new file mode 100644 index 0000000..afb01c0 --- /dev/null +++ b/webapp/static/ace/acego.js @@ -0,0 +1,28 @@ +import * as aceBuilds from 'https://esm.run/ace-builds'; + +import ace from 'https://cdn.jsdelivr.net/npm/ace/+esm' + +/* import 'ace-builds/src-noconflict/mode-javascript'; +import 'ace-builds/src-noconflict/theme-chrome'; */ + +/* import {AceLanguageClient} from "ace-linters/build/ace-language-client"; + +const serverData = { + module: () => import("ace-linters/build/language-client"), + modes: "json|json5", + type: "socket", + socket: new WebSocket("ws://127.0.0.1:3000/ws/lsp"), // your websocket server address +} + */ + // Initialize the editor + const editor = ace.edit("editor", { + theme: "ace/theme/chrome", + mode: "ace/mode/javascript", + fontSize: "14px", + showPrintMargin: false, + useWorker: false // Disable web worker for this simple demo +}); + +// Create a language provider for WebSocket +//let languageProvider = AceLanguageClient.for(serverData); +//languageProvider.registerEditor(editor); \ No newline at end of file diff --git a/webapp/static/ace/index.html b/webapp/static/ace/index.html new file mode 100644 index 0000000..6aceabc --- /dev/null +++ b/webapp/static/ace/index.html @@ -0,0 +1,52 @@ + + + + + + BaseX LSP + + + + + + + + + + +
somethingdba
+
some text
+ + + + + + \ No newline at end of file