-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
151 lines (134 loc) · 4.82 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous" />
<script type="module">
import init, {html_to_rdfa} from "./rdfa-wasm/pkg/rdfa_wasm.js";
async function run() {
const form = document.querySelector("form");
form.classList.add("d-none");
await init();
form.classList.remove("d-none");
const text_area = document.querySelector("#html");
text_area.value = `
<!DOCTYPE html>
<html prefix="foaf: http://xmlns.com/foaf/0.1/">
<head>
<title>Test 0083</title>
</head>
<body>
<div about="http://www.example.org/#somebody" rel="foaf:knows">
<p property="foaf:name">Ivan Herman</p>
<p rel="foaf:mailbox" resource="mailto:[email protected]">mailto:[email protected]</p>
<p about="http://danbri.org/foaf.rdf#danbri" typeof="foaf:Person" property="foaf:name">Dan Brickley</p>
</div>
</body>
</html>
`;
form.addEventListener("submit", (e) => {
e.preventDefault();
const data = new FormData(e.target);
let res = html_to_rdfa(
data.get("html") || "",
data.get("base") || "",
data.get("wellKnownPrefix") || "",
);
const out = document.querySelector("pre");
out.innerText = res;
});
const issueLink = document.querySelector("#issueLink");
issueLink.onclick = (e) => {
e.preventDefault();
const a = document.createElement("a");
let params = new URLSearchParams();
const data = new FormData(form);
params.append("title", "RDFa processing bug");
params.append(
"body",
`
### Base:
\`${data.get("base") || ""}\`
### Well Known Prefix:
\`${data.get("base") || ""}\`
### Html:
\`\`\`html
${data.get("html") || ""}
\`\`\`
`,
);
a.href = `https://github.com/nbittich/graph-rdfa-processor/issues/new?${params.toString()}`;
a.target = "_blank";
a.click();
};
}
const copyToClipboardBtn = document.querySelector("#copyToClipboard");
copyToClipboardBtn.onclick = function (e) {
e.preventDefault();
const out = document.querySelector("pre");
navigator.clipboard.writeText(out.innerText);
alert("Copied to clipboard");
};
run();
</script>
</head>
<body>
<h1>RDFa Playground</h1>
<p>
This is a poc of an rdfa library written in rust. If you find any bug,
please <a href="#issueLink" id="issueLink">open an issue.</a>
</p>
<hr />
<div class="d-flex justify-content-center">
<div class="col-3 me-1 border p-2">
<form action="" id="rdfaForm">
<div class="mb-2 align-items-center">
<div class="col-auto">
<label for="base" class="col-form-label fw-bold">Base</label>
</div>
<div class="col-auto">
<input required type="url" id="base" name="base" class="form-control" aria-describedby="base url"
value="http://example.com" />
</div>
</div>
<div class="mb-2 align-items-center">
<div class="col-auto">
<label for="base" class="col-form-label fw-bold">Well Known prefix</label>
</div>
<div class="col-auto">
<input required type="url" id="wellKnownPrefix" name="wellKnownPrefix" class="form-control"
aria-describedby="well known prefix" value="http://example.com/.well-known/" />
<div id="passwordHelpBlock" class="form-text">
Well known prefix for
<a target="_blank" href="https://www.w3.org/2011/rdf-wg/wiki/Skolemisation">Skolemisation</a>
</div>
</div>
</div>
<div class="mb-2 align-items-center">
<div class="col-auto">
<label for="html" class="col-form-label fw-bold">Html</label>
</div>
<div class="col-auto">
<textarea required rows="18" id="html" name="html" class="form-control"
aria-describedby="Html content"></textarea>
</div>
</div>
<div class="d-grid gap-2">
<button type="submit" class="btn btn-outline-danger">Submit</button>
<button class="btn btn-primary" id="copyToClipboard">
Copy Output
</button>
</div>
</form>
</div>
<div class="col-8">
<div class="bg-light border h-100">
<pre class="p-2" id="out"></pre>
</div>
</div>
</div>
</body>
</html>