99
1010 < style >
1111 body {
12- display : flex;
13- justify-content : center;
14- align-items : center;
15- text-align : center;
16- height : 100vh ;
17- margin : 0 ;
18- font-family : Arial, sans-serif;
19- background-color : # f4f4f4 ;
12+ display : flex;
13+ justify-content : center;
14+ align-items : center;
15+ text-align : center;
16+ height : 100vh ;
17+ margin : 0 ;
18+ font-family : Arial, sans-serif;
19+ background-color : # f4f4f4 ;
2020 }
2121 /* #container {
2222 text-align: center;
2626 box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
2727 } */
2828 input [type = "text" ] {
29- width : 80% ;
30- padding : 10px ;
31- margin : 10px 0 ;
32- border-radius : 5px ;
33- border : 1px solid # ccc ;
29+ width : 80% ;
30+ padding : 10px ;
31+ margin : 10px 0 ;
32+ border-radius : 5px ;
33+ border : 1px solid # ccc ;
3434 }
3535 button {
36- padding : 10px 20px ;
37- border : none;
38- border-radius : 5px ;
39- background-color : # 007BFF ;
40- color : white;
41- font-size : 16px ;
42- cursor : pointer;
36+ padding : 10px 20px ;
37+ border : none;
38+ border-radius : 5px ;
39+ background-color : # 007bff ;
40+ color : white;
41+ font-size : 16px ;
42+ cursor : pointer;
4343 }
4444 button : hover {
45- background-color : # 0056b3 ;
45+ background-color : # 0056b3 ;
4646 }
4747 .result {
48- margin-top : 20px ;
49- font-size : 18px ;
48+ margin-top : 20px ;
49+ font-size : 18px ;
5050 }
5151 .result span {
52- font-weight : bold;
53- margin-right : 10px ;
52+ font-weight : bold;
53+ margin-right : 10px ;
5454 }
5555 </ style >
5656 </ head >
5959 < div id ="container ">
6060 < h2 > SPARQL Endpoint Checker</ h2 >
6161 < form id ="sparqlForm ">
62- < input type ="text " id ="sparqlEndpoint " placeholder ="Enter SPARQL endpoint URL " required >
63- < br >
62+ < input type ="text " id ="sparqlEndpoint " placeholder ="Enter SPARQL endpoint URL " required / >
63+ < br / >
6464 < button type ="submit "> Check Endpoint</ button >
6565 </ form >
6666 < div id ="results " class ="result "> </ div >
6767 </ div >
6868
6969 < script >
70- document . getElementById ( ' sparqlForm' ) . addEventListener ( ' submit' , function ( event ) {
71- event . preventDefault ( ) ;
72- runChecks ( ) ;
70+ document . getElementById ( " sparqlForm" ) . addEventListener ( " submit" , function ( event ) {
71+ event . preventDefault ( ) ;
72+ runChecks ( ) ;
7373 } ) ;
7474
7575 async function queryEndpoint ( endpointUrl , query ) {
76- const response = await fetch (
77- `${ endpointUrl } ?ac=1&query=${ encodeURIComponent ( query ) } ` ,
78- {
79- signal : AbortSignal . timeout ( 5000 ) ,
80- headers : {
81- 'Accept' : 'application/json'
82- }
83- }
84- ) ;
76+ const response = await fetch ( `${ endpointUrl } ?ac=1&query=${ encodeURIComponent ( query ) } ` , {
77+ signal : AbortSignal . timeout ( 5000 ) ,
78+ headers : {
79+ Accept : "application/json" ,
80+ } ,
81+ } ) ;
8582 // console.log(await response.text());
8683 const json = await response . json ( ) ;
8784 return json . results . bindings ;
8885 }
8986
9087 async function runChecks ( ) {
91- const endpoint = document . getElementById ( ' sparqlEndpoint' ) . value ;
92- const resultsDiv = document . getElementById ( ' results' ) ;
93- resultsDiv . innerHTML = '' ;
88+ const endpoint = document . getElementById ( " sparqlEndpoint" ) . value ;
89+ const resultsDiv = document . getElementById ( " results" ) ;
90+ resultsDiv . innerHTML = "" ;
9491
95- try {
96- const prefixesResults = await queryEndpoint ( endpoint , `PREFIX sh: <http://www.w3.org/ns/shacl#>
92+ try {
93+ const prefixesResults = await queryEndpoint (
94+ endpoint ,
95+ `PREFIX sh: <http://www.w3.org/ns/shacl#>
9796 SELECT DISTINCT ?prefix ?namespace
9897 WHERE { [] sh:namespace ?namespace ; sh:prefix ?prefix}
99- ORDER BY ?prefix` ) ;
98+ ORDER BY ?prefix` ,
99+ ) ;
100100
101- if ( prefixesResults . length === 0 ) {
102- resultsDiv . innerHTML += `<p>❌ No prefixes found</p>` ;
103- return ;
104- } else {
105- resultsDiv . innerHTML += `<p>✅ Found ${ prefixesResults . length } prefixes</p>` ;
106- }
101+ if ( prefixesResults . length === 0 ) {
102+ resultsDiv . innerHTML += `<p>❌ No prefixes found</p>` ;
103+ return ;
104+ } else {
105+ resultsDiv . innerHTML += `<p>✅ Found ${ prefixesResults . length } prefixes</p>` ;
106+ }
107107
108- const exampleQueriesResults = await queryEndpoint ( endpoint , `PREFIX sh: <http://www.w3.org/ns/shacl#>
108+ const exampleQueriesResults = await queryEndpoint (
109+ endpoint ,
110+ `PREFIX sh: <http://www.w3.org/ns/shacl#>
109111 PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
110112 SELECT DISTINCT ?sq ?comment ?query
111113 WHERE {
112114 ?sq a sh:SPARQLExecutable ;
113115 rdfs:label|rdfs:comment ?comment ;
114116 sh:select|sh:ask|sh:construct|sh:describe ?query .
115- } ORDER BY ?sq` ) ;
117+ } ORDER BY ?sq` ,
118+ ) ;
116119
117- if ( exampleQueriesResults . length === 0 ) {
118- resultsDiv . innerHTML += `<p>❌ No example SPARQL queries found</p>` ;
119- return ;
120- } else {
121- resultsDiv . innerHTML += `<p>✅ Found ${ exampleQueriesResults . length } example SPARQL queries</p>` ;
122- }
120+ if ( exampleQueriesResults . length === 0 ) {
121+ resultsDiv . innerHTML += `<p>❌ No example SPARQL queries found</p>` ;
122+ return ;
123+ } else {
124+ resultsDiv . innerHTML += `<p>✅ Found ${ exampleQueriesResults . length } example SPARQL queries</p>` ;
125+ }
123126
124- const voidResults = await queryEndpoint ( endpoint , `PREFIX up: <http://purl.uniprot.org/core/>
127+ const voidResults = await queryEndpoint (
128+ endpoint ,
129+ `PREFIX up: <http://purl.uniprot.org/core/>
125130 PREFIX void: <http://rdfs.org/ns/void#>
126131 PREFIX void-ext: <http://ldf.fi/void-ext#>
127132 SELECT DISTINCT ?class1
@@ -136,20 +141,20 @@ <h2>SPARQL Endpoint Checker</h2>
136141 ?pp void-ext:datatypePartition [ void-ext:datatype ?datatype ] .
137142 }
138143 }
139- }` ) ;
140-
141- if ( voidResults . length === 0 ) {
142- resultsDiv . innerHTML += `<p>❌ No VoID description found.<br/>Checkout the <a href="https://github.com/JervenBolleman/void-generator" target="_blank">void-generator</a> project to automatically generate a <a href="https://www.w3.org/TR/void/">VoID description</a> for the classes and predicates inside your endpoint.</p>` ;
143- return ;
144- } else {
145- resultsDiv . innerHTML += `<p>✅ Found VoID description for ${ voidResults . length } classes</p>` ;
146- }
144+ }` ,
145+ ) ;
147146
148- } catch ( error ) {
149- console . log ( "Error querying the endpoint" , error ) ;
150- resultsDiv . innerHTML += `<p>❌ Error querying the endpoint: ${ error . message } </p>` ;
151- return ;
147+ if ( voidResults . length === 0 ) {
148+ resultsDiv . innerHTML += `<p>❌ No VoID description found.<br/>Checkout the <a href="https://github.com/JervenBolleman/void-generator" target="_blank">void-generator</a> project to automatically generate a <a href="https://www.w3.org/TR/void/">VoID description</a> for the classes and predicates inside your endpoint.</p>` ;
149+ return ;
150+ } else {
151+ resultsDiv . innerHTML += `<p>✅ Found VoID description for ${ voidResults . length } classes</p>` ;
152152 }
153+ } catch ( error ) {
154+ console . log ( "Error querying the endpoint" , error ) ;
155+ resultsDiv . innerHTML += `<p>❌ Error querying the endpoint: ${ error . message } </p>` ;
156+ return ;
157+ }
153158 }
154159 </ script >
155160 </ body >
0 commit comments