1414 < title > YASGUI Graph Plugin Demo</ title >
1515
1616 <!-- YASGUI CSS -->
17- < link rel ="stylesheet " href ="https://cdn.jsdelivr.net/npm/@zazuko/yasgui@4/build/yasgui.min.css ">
17+ < link rel ="stylesheet " href ="https://cdn.jsdelivr.net/npm/@zazuko/yasgui@4.6.1 /build/yasgui.min.css ">
1818
1919 <!-- Font Awesome for icons -->
2020 < link rel ="stylesheet " href ="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css ">
@@ -111,12 +111,11 @@ <h2 onclick="toggleInstructions()">
111111 </ h2 >
112112 < div class ="instructions-content collapsed ">
113113 < ul >
114- < li > Click the < strong > "Graph"</ strong > tab after running a CONSTRUCT query</ li >
115- < li > < strong > Sample queries</ strong > are pre-loaded (see tabs: Basic, Ontology, Blank Nodes, Multiple Edges)</ li >
114+ < li > Click the < strong > "Graph"</ strong > tab after running a CONSTRUCT or DESCRIBE query</ li >
115+ < li > < strong > Sample queries</ strong > are pre-loaded (see tabs: Basic, Ontology, Blank Nodes, Multiple Edges, DESCRIBE )</ li >
116116 < li > < strong > Navigate</ strong > : Mouse wheel to zoom, drag background to pan, click "Zoom to Fit" button</ li >
117117 < li > < strong > Reorganize</ strong > : Drag individual nodes to rearrange the layout</ li >
118118 < li > < strong > Inspect</ strong > : Hover over nodes/edges to see full details (300ms delay)</ li >
119- < li > < strong > Export</ strong > : Click "Export PNG" to save the current viewport as an image</ li >
120119 < li > < strong > Color coding</ strong > : < span style ="color: #c5c5c5ff "> ⬤ Grey</ span > = literals,
121120 < span style ="color: #e15b13ff "> ⬤ Orange</ span > = blank nodes,
122121 < span style ="color: #a6c8a6ff "> ⬤ Green</ span > = rdf:type objects,
@@ -137,7 +136,7 @@ <h2 onclick="toggleInstructions()">
137136 < div id ="yasgui "> </ div >
138137
139138 <!-- YASGUI JavaScript -->
140- < script src ="https://cdn.jsdelivr.net/npm/@zazuko/yasgui@4/build/yasgui.min.js "> </ script >
139+ < script src ="https://cdn.jsdelivr.net/npm/@zazuko/yasgui@4.6.1 /build/yasgui.min.js "> </ script >
141140
142141 <!-- vis-network (required dependency) -->
143142 < script src ="
https://unpkg.com/[email protected] /standalone/umd/vis-network.min.js "
> </ script > @@ -159,87 +158,36 @@ <h2 onclick="toggleInstructions()">
159158
160159 // Initialize YASGUI after plugin is registered
161160 const yasgui = new Yasgui ( document . getElementById ( 'yasgui' ) , {
162- endpoint : 'http://localhost:3030/g' ,
161+ // Set the SPARQL endpoint
162+ requestConfig : {
163+ endpoint : 'http://localhost:3030/g' ,
164+ } ,
165+ yasr : {
166+ pluginOrder : [ 'Table' , 'Response' , 'Graph' ] ,
167+ defaultPlugin : 'Graph' ,
168+ } ,
163169 copyEndpointOnNewTab : false ,
164170 } ) ;
165171
166- // Helper to create mock results from CONSTRUCT query
167- function createMockResults ( query ) {
168- const bindings = [ ] ;
169-
170- // Parse triples from CONSTRUCT clause
171- const constructMatch = query . match ( / C O N S T R U C T \s * { ( [ ^ } ] + ) } / i) ;
172- if ( ! constructMatch ) return { getBindings : ( ) => [ ] } ;
173-
174- const constructBody = constructMatch [ 1 ] ;
175- const tripleLines = constructBody . split ( '\n' )
176- . map ( line => line . trim ( ) )
177- . filter ( line => line && ! line . startsWith ( 'PREFIX' ) ) ;
178-
179- tripleLines . forEach ( line => {
180- // Simple triple parsing (subject predicate object .)
181- const match = line . match ( / ^ ( [ ^ \s ] + ) \s + ( [ ^ \s ] + ) \s + ( .+ ?) \s * \. ? \s * $ / ) ;
182- if ( match ) {
183- const [ , subject , predicate , objectStr ] = match ;
184-
185- // Parse object
186- let object ;
187- if ( objectStr . startsWith ( '"' ) ) {
188- // Literal
189- const literalMatch = objectStr . match ( / " ( [ ^ " ] + ) " (?: \^ \^ < ( [ ^ > ] + ) > ) ? / ) ;
190- if ( literalMatch ) {
191- object = {
192- value : literalMatch [ 1 ] ,
193- type : 'literal' ,
194- datatype : literalMatch [ 2 ]
195- } ;
196- } else {
197- object = { value : objectStr . replace ( / " / g, '' ) , type : 'literal' } ;
198- }
199- } else {
200- // URI or blank node
201- object = {
202- value : objectStr . replace ( / < | > / g, '' ) ,
203- type : objectStr . startsWith ( '_:' ) ? 'bnode' : 'uri'
204- } ;
205- }
206-
207- bindings . push ( {
208- subject : { value : subject . replace ( / < | > / g, '' ) , type : subject . startsWith ( '_:' ) ? 'bnode' : 'uri' } ,
209- predicate : { value : predicate . replace ( / < | > / g, '' ) , type : 'uri' } ,
210- object : object
211- } ) ;
212- }
213- } ) ;
214-
215- return {
216- getBindings : ( ) => bindings ,
217- getVariables : ( ) => ( { prefixes : {
218- 'ex' : 'http://example.org/' ,
219- 'rdf' : 'http://www.w3.org/1999/02/22-rdf-syntax-ns#' ,
220- 'rdfs' : 'http://www.w3.org/2000/01/rdf-schema#' ,
221- 'owl' : 'http://www.w3.org/2002/07/owl#' ,
222- 'xsd' : 'http://www.w3.org/2001/XMLSchema#'
223- } } ) ,
224- getResponseTime : ( ) => 0 ,
225- getType : ( ) => 'construct' ,
226- getOriginalResponseAsString : ( ) => '' ,
227- getOriginalResponse : ( ) => null ,
228- getError : ( ) => null ,
229- getContentType : ( ) => 'application/sparql-results+json'
230- } ;
231- }
232-
233172 // Add sample query tabs
234173 const tabs = [
235- { name : 'Basic Graph' , query : queries . basic } ,
236174 { name : 'Ontology' , query : queries . ontology } ,
237175 { name : 'Blank Nodes' , query : queries . blankNodes } ,
238- { name : 'Multiple Edges' , query : queries . multiplePredicates }
176+ { name : 'Multiple Edges' , query : queries . multiplePredicates } ,
177+ { name : 'DESCRIBE Query' , query : queries . describe } ,
178+ { name : 'Basic Graph' , query : queries . basic } ,
239179 ] ;
240180
241- // Clear default tab
242- yasgui . getTab ( ) . close ( ) ;
181+ // Close all existing tabs
182+ let tab ;
183+ while ( ( tab = yasgui . getTab ( ) ) != null ) {
184+ try {
185+ tab . close ( ) ;
186+ } catch ( e ) {
187+ console . error ( 'Failed to close tab:' , e ) ;
188+ break ;
189+ }
190+ }
243191
244192 // Add sample tabs
245193 tabs . forEach ( ( tab , index ) => {
@@ -249,14 +197,7 @@ <h2 onclick="toggleInstructions()">
249197 name : tab . name ,
250198 yasqe : { value : tab . query }
251199 }
252- ) ;
253-
254- // Simulate query results for demo (since we have no real endpoint)
255- setTimeout ( ( ) => {
256- // Mock CONSTRUCT results
257- yasguiTab . yasr . results = createMockResults ( tab . query ) ;
258- yasguiTab . yasr . draw ( ) ;
259- } , 100 ) ;
200+ ) ;
260201 } ) ;
261202 </ script >
262203</ body >
0 commit comments