Commit

Author:

Hash:

Timestamp:

+42 -27 +/-2 browse

Kevin Schoon [me@kevinschoon.com]

8860b228be1040867b2c0502fb97017a8a073ddf

Thu, 04 Dec 2025 14:01:32 +0000 (3 days ago)

wrap up most validator functionality
1diff --git a/static/style.css b/static/style.css
2index 1dfb5ab..6cdd142 100644
3--- a/static/style.css
4+++ b/static/style.css
5 @@ -3,6 +3,18 @@
6 margin: 0 auto;
7 }
8
9+ .positive {
10+ background-color: green;
11+ color: white;
12+ font-weight: bolder;
13+ }
14+
15+ .negative {
16+ background-color: salmon;
17+ color: white;
18+ font-weight: bolder;
19+ }
20+
21 header {
22 width: 170px;
23 float: left;
24 @@ -101,7 +113,6 @@ footer {
25
26 pre {
27 padding: 8px 15px;
28- // background: #f8f8f8;
29 border-radius: 5px;
30 border: 1px solid #e5e5e5;
31 overflow-x: auto;
32 diff --git a/static/verifier.js b/static/verifier.js
33index 9bcd9f2..d45905e 100644
34--- a/static/verifier.js
35+++ b/static/verifier.js
36 @@ -69,6 +69,8 @@ function validateLink(object, recorder, constraints = []) {
37 }
38 }
39
40+ const _vcs_types = ["bzr", "darcs", "fossil", "git", "hg", "pijul", "svn"];
41+
42 const _project = {
43 "http://forge-feed.org/rel/avatar": [constraint(Kind.HREF)],
44 "http://forge-feed.org/rel/chatroom": [
45 @@ -86,8 +88,7 @@ const _project = {
46 constraint(Kind.HREF),
47 constraint(Kind.PROPERTIES, {
48 "http://forge-feed.org/ns/repository-uri": null,
49- "http://forge-feed.org/ns/vcs-type": [
50- "bzr", "darcs", "fossil", "git", "hg", "pijul", "svn"],
51+ "http://forge-feed.org/ns/vcs-type": _vcs_types,
52 }),
53 constraint(Kind.TITLES),
54 ],
55 @@ -106,9 +107,7 @@ const _repository = {
56 "http://feed-forge.org/rel/clone": [
57 constraint(Kind.HREF),
58 constraint(Kind.PROPERTIES, {
59- "http://feed-forge.org/ns/vcs-type": [
60- "bzr", "darcs", "fossil", "git", "hg", "pijul", "svn",
61- ]
62+ "http://feed-forge.org/ns/vcs-type": _vcs_types,
63 })],
64 "http://forge-feed.org/rel/description": [constraint(Kind.TITLES)],
65 "http://forge-feed.org/rel/license": [constraint(Kind.PROPERTIES, {
66 @@ -118,6 +117,10 @@ const _repository = {
67 constraint(Kind.PROPERTIES, { "http://forge-feed.org/ns/label": null }),
68 ],
69 "http://forge-feed.org/rel/homepage": [constraint(Kind.HREF)],
70+ "http://forge-feed.org/rel/project": [
71+ constraint(Kind.HREF),
72+ constraint(Kind.PROPERTIES, { "http://forge-feed.org/ns/vcs-type": _vcs_types }),
73+ ],
74 "http://forge-feed.org/rel/mailing-list": [
75 constraint(Kind.HREF),
76 constraint(Kind.PROPERTIES, {
77 @@ -128,6 +131,21 @@ const _repository = {
78 "http://forge-feed.org/rel/ticketing-system": [constraint(Kind.HREF)],
79 };
80
81+ function makeTable(data) {
82+ let innerHTML = "<table id=\"test-results\"><tr><th>Test</th><th>State</th><th>Message</th><th>Object</th><tr>";
83+ for (let i = 0; i < data.length; i++) {
84+ if (data[i][1]) {
85+ let kind = data[i][0];
86+ let message = data[i][1];
87+ let object = data[i][2];
88+ innerHTML += "<tr class=\"negative\">" + "<td>" + kind + "</td>" + "<td>Fail</td><td>" + message + "</td><td><code>" + JSON.stringify(object) + "</code></td></tr>";
89+ } else {
90+ innerHTML += "<tr class=\"positive\">Pass</tr>";
91+ }
92+ }
93+ innerHTML += "</table>";
94+ return innerHTML
95+ }
96
97 function doQuery(url, cb) {
98 let xhr = new XMLHttpRequest();
99 @@ -145,7 +163,7 @@ function validateProject() {
100 const fqdn = document.getElementById("fqdn")[0].value;
101 const project = document.getElementById("project")[0].value;
102 let queryUrl = "https://" + fqdn + "/.well-known/webfinger?resource=" + project;
103- document.getElementById("query-url").innerText = queryUrl;
104+ document.getElementById("query-url").innerHTML = "<code>" + queryUrl + "</code>";
105 doQuery(queryUrl, function(data) {
106 let parsed = JSON.parse(data);
107 let recorder = newRecorder();
108 @@ -156,16 +174,8 @@ function validateProject() {
109 validateLink(link, recorder, constraints);
110 }
111 };
112- var textResult = "";
113- for (let i = 0; i < recorder.state.length; i++) {
114- console.log(recorder.state[i]);
115- if (recorder.state[i][1]) {
116- textResult += "Fail: " + recorder.state[i][1] + "\r\n";
117- let asJson = JSON.stringify(recorder.state[i][2]);
118- textResult += "\t\t" + asJson + "\r\n";
119- }
120- document.getElementById("results").innerText = textResult;
121- }
122+ let innerHTML = makeTable(recorder.state);
123+ document.getElementById("results").innerHTML = innerHTML;
124 });
125 }
126
127 @@ -181,18 +191,12 @@ function validateRepository() {
128 for (let i = 0; i < parsed.links.length; i++) {
129 let link = parsed.links[i];
130 if (link["rel"] in _repository) {
131- let constraints = _project[link["rel"]];
132+ let constraints = _repository[link["rel"]];
133 validateLink(link, recorder, constraints);
134 }
135 };
136- var textResult = "";
137- for (let i = 0; i < recorder.state.length; i++) {
138- if (recorder.state[i][1]) {
139- textResult += "Fail: " + recorder.state[i][1] + "\r\n";
140- let asJson = JSON.stringify(recorder.state[i][2]);
141- textResult += "\t\t" + asJson + "\r\n";
142- }
143- document.getElementById("results").innerText = textResult;
144- }
145+ let innerHTML = makeTable(recorder.state);
146+ document.getElementById("results").innerHTML = innerHTML;
147 });
148+
149 }