worldwideweb 0.0.18 → 0.0.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,14 @@
1
+ chrome.webRequest.onHeadersReceived.addListener(
2
+ function(details) {
3
+ for (var header of details.responseHeaders) {
4
+ if (header.name.toLowerCase() === 'content-type' && header.value.toLowerCase().includes('text/turtle')) {
5
+ // Redirect to the data browser page with the original URL as a parameter
6
+ var redirectUrl = chrome.runtime.getURL('databrowser.html') + '?uri=' + encodeURIComponent(details.url);
7
+ return { redirectUrl: redirectUrl };
8
+ }
9
+ }
10
+ },
11
+ { urls: ["<all_urls>"], types: ["main_frame"] },
12
+ ["blocking", "responseHeaders"]
13
+ );
14
+
@@ -0,0 +1,53 @@
1
+ <!DOCTYPE html>
2
+ <html id="docHTML">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <title>Turtle Data Browser</title>
6
+ <link rel="stylesheet" type="text/css" href="mashlib.min.css" />
7
+ <script type="text/javascript" src="mashlib.min.js"></script>
8
+ <script type="text/javascript" src="databrowser.js"></script>
9
+ </head>
10
+ <body>
11
+
12
+ <div style="width:100%;" id="inputArea">
13
+ <div style="margin-bottom:0.6em">
14
+ The SolidOS Databrowser
15
+ </div>
16
+ <div style="margin-left:1em">
17
+ Viewing <input id="uriField" type="text" style="font-size:100%; min-width:25em; padding:0.5em;" placeholder="enter a pod address e.g. https://you.solidcommunity.net/"/> <input type="button" id="goButton" value="Go" />
18
+ </div>
19
+ <div style="margin-top:0.5em;margin-left:1em">
20
+ As user <span id="webId">&lt;public user></span> <span id="loginButtonArea"></span>
21
+ </div>
22
+ </div>
23
+
24
+ <div class="TabulatorOutline" id="DummyUUID" role="main">
25
+ <table id="outline"></table>
26
+ <div id="GlobalDashboard"></div>
27
+ </div>
28
+
29
+ <style>
30
+ #inputArea {
31
+ width:100%;
32
+ padding:0.5em;
33
+ background-color:#d0d0d0;
34
+ }
35
+ #loginButtonArea input {
36
+ display:inline-block;
37
+ margin:0.25em !important;
38
+ padding:0.25em !important;
39
+ }
40
+ #webId {
41
+ display:inline-block;
42
+ padding-top:0.6em;
43
+ padding-bottom:0.6em;
44
+ }
45
+ #uriField {
46
+ width:70%;
47
+ margin-top:0.6em !important;
48
+ }
49
+ </style>
50
+
51
+ </body>
52
+ </html>
53
+
@@ -0,0 +1,69 @@
1
+ document.addEventListener('DOMContentLoaded', function() {
2
+ const authn = UI.authn
3
+ const authSession = UI.authn.authSession
4
+ const store = UI.store
5
+ const $rdf = UI.rdf
6
+ const dom = document
7
+ $rdf.Fetcher.crossSiteProxyTemplate = self.origin + '/xss?uri={uri}'
8
+ const uri = new URLSearchParams(window.location.search).get('uri');
9
+ window.document.title = 'SolidOS Web App: ' + uri
10
+ const outliner = panes.getOutliner(dom) // function from solid-panes
11
+
12
+ function go () {
13
+ const subject = $rdf.sym(uriField.value || uri);
14
+ outliner.GotoSubject(subject, true, undefined, true, undefined);
15
+ mungeLoginArea();
16
+ }
17
+
18
+ const uriField = dom.getElementById('uriField')
19
+ const goButton = dom.getElementById('goButton')
20
+ const loginButtonArea = document.getElementById("loginButtonArea");
21
+ const webIdArea = dom.getElementById('webId')
22
+ const banner = dom.getElementById('inputArea')
23
+
24
+ uriField.value = uri || '';
25
+ goButton.addEventListener('click', go, false);
26
+
27
+ uriField.addEventListener('keyup', function (e) {
28
+ if (e.keyCode === 13) {
29
+ go(e)
30
+ }
31
+ }, false)
32
+
33
+ async function mungeLoginArea(){
34
+ loginButtonArea.innerHTML="";
35
+ if(uriField.value) {
36
+ loginButtonArea.appendChild(UI.login.loginStatusBox(document, null, {}))
37
+ }
38
+ const me = authn.currentUser()
39
+ if (me) {
40
+ const logoutButton = loginButtonArea.querySelector('input');
41
+ logoutButton.value = "Logout";
42
+ let displayId = `&lt;${me.value}>`;
43
+ webIdArea.innerHTML = displayId;
44
+ banner.style.backgroundColor="#bbccbb";
45
+ } else {
46
+ banner.style.backgroundColor="#ccbbbb";
47
+ }
48
+ loginButtonArea.style.display="inline-block";
49
+ }
50
+
51
+ if (authSession) {
52
+ authSession.onLogin(() => {
53
+ mungeLoginArea();
54
+ go()
55
+ })
56
+ authSession.onLogout(() => {
57
+ mungeLoginArea();
58
+ webIdArea.innerHTML = "public user";
59
+ go()
60
+ })
61
+ authSession.onSessionRestore((url) => {
62
+ mungeLoginArea();
63
+ go()
64
+ })
65
+ }
66
+ mungeLoginArea();
67
+ if (uri) go();
68
+ });
69
+
@@ -0,0 +1,21 @@
1
+ {
2
+ "manifest_version": 2,
3
+ "name": "Turtle Data Browser",
4
+ "description": "Displays a data browser for resources with MIME type text/turtle.",
5
+ "version": "1.0",
6
+ "permissions": [
7
+ "webRequest",
8
+ "webRequestBlocking",
9
+ "<all_urls>"
10
+ ],
11
+ "background": {
12
+ "scripts": ["background.js"]
13
+ },
14
+ "web_accessible_resources": [
15
+ "databrowser.html",
16
+ "mashlib.min.js",
17
+ "mashlib.min.css"
18
+ ],
19
+ "content_security_policy": "script-src 'self'; object-src 'self'"
20
+ }
21
+