Conversation
Deploying vc-examples with
|
| Latest commit: |
786001d
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://9a4f44e1.vc-examples.pages.dev |
| Branch Preview URL: | https://html-render-method.vc-examples.pages.dev |
| "/issuer/name", | ||
| "/credentialSubject/name" | ||
| ], | ||
| "template": "<div>\n <script>\n document.addEventListener('DOMContentLoaded', (event) => {\n console.log('running template render script');\n\n // display credential as JSON as an example renderer; anything\n // could be done here instead, including mustache/other-style\n // template processing to generate the HTML for display\n\n // FIXME: determine best name/location for the datablock/script tag\n const credential = JSON.parse(document.querySelector(\n 'head > script[name=\"credential\"]').innerHTML);\n\n document.querySelector('#credentialSubject-name').innerText =\n credential.credentialSubject.name;\n document.querySelector('#issuer-name').innerText =\n credential.issuer.name;\n\n // TBD: signal to host that rendering is complete\n window.renderMethodReady();\n}); </script>\n <style>\n h1 {\n color: blue;\n }\n </style>\n\n <h1 id=\"credentialSubject-name\"></h1>\n <p>Issued by: <span id=\"issuer-name\"></span></p>\n</div>", |
There was a problem hiding this comment.
I think this needs to be in a data URL.
| "/issuer/name", | ||
| "/credentialSubject/name" | ||
| ], | ||
| "template": "<div>\n <script>\n document.addEventListener('DOMContentLoaded', (event) => {\n console.log('running template render script');\n\n // display credential as JSON as an example renderer; anything\n // could be done here instead, including mustache/other-style\n // template processing to generate the HTML for display\n\n // FIXME: determine best name/location for the datablock/script tag\n const credential = JSON.parse(document.querySelector(\n 'head > script[name=\"credential\"]').innerHTML);\n\n document.querySelector('#credentialSubject-name').innerText =\n credential.credentialSubject.name;\n document.querySelector('#issuer-name').innerText =\n credential.issuer.name;\n\n // TBD: signal to host that rendering is complete\n window.renderMethodReady();\n}); </script>\n <style>\n h1 {\n color: blue;\n }\n </style>\n\n <h1 id=\"credentialSubject-name\"></h1>\n <p>Issued by: <span id=\"issuer-name\"></span></p>\n</div>", |
There was a problem hiding this comment.
This?
| "template": "<div>\n <script>\n document.addEventListener('DOMContentLoaded', (event) => {\n console.log('running template render script');\n\n // display credential as JSON as an example renderer; anything\n // could be done here instead, including mustache/other-style\n // template processing to generate the HTML for display\n\n // FIXME: determine best name/location for the datablock/script tag\n const credential = JSON.parse(document.querySelector(\n 'head > script[name=\"credential\"]').innerHTML);\n\n document.querySelector('#credentialSubject-name').innerText =\n credential.credentialSubject.name;\n document.querySelector('#issuer-name').innerText =\n credential.issuer.name;\n\n // TBD: signal to host that rendering is complete\n window.renderMethodReady();\n}); </script>\n <style>\n h1 {\n color: blue;\n }\n </style>\n\n <h1 id=\"credentialSubject-name\"></h1>\n <p>Issued by: <span id=\"issuer-name\"></span></p>\n</div>", | |
| "template": "data:text/html;base64,PGRpdj4KICA8c2NyaXB0PgogICAgZG9jdW1lbnQuYWRkRXZlbnRMaXN0ZW5lcignRE9NQ29udGVudExvYWRlZCcsIChldmVudCkgPT4gewogICAgY29uc29sZS5sb2coJ3J1bm5pbmcgdGVtcGxhdGUgcmVuZGVyIHNjcmlwdCcpOwoKICAgIC8vIGRpc3BsYXkgY3JlZGVudGlhbCBhcyBKU09OIGFzIGFuIGV4YW1wbGUgcmVuZGVyZXI7IGFueXRoaW5nCiAgICAvLyBjb3VsZCBiZSBkb25lIGhlcmUgaW5zdGVhZCwgaW5jbHVkaW5nIG11c3RhY2hlL290aGVyLXN0eWxlCiAgICAvLyB0ZW1wbGF0ZSBwcm9jZXNzaW5nIHRvIGdlbmVyYXRlIHRoZSBIVE1MIGZvciBkaXNwbGF5CgogICAgLy8gRklYTUU6IGRldGVybWluZSBiZXN0IG5hbWUvbG9jYXRpb24gZm9yIHRoZSBkYXRhYmxvY2svc2NyaXB0IHRhZwogICAgY29uc3QgY3JlZGVudGlhbCA9IEpTT04ucGFyc2UoZG9jdW1lbnQucXVlcnlTZWxlY3RvcigKICAgICAgJ2hlYWQgPiBzY3JpcHRbbmFtZT0iY3JlZGVudGlhbCJdJykuaW5uZXJIVE1MKTsKCiAgICBkb2N1bWVudC5xdWVyeVNlbGVjdG9yKCcjY3JlZGVudGlhbFN1YmplY3QtbmFtZScpLmlubmVyVGV4dCA9CiAgICAgIGNyZWRlbnRpYWwuY3JlZGVudGlhbFN1YmplY3QubmFtZTsKICAgIGRvY3VtZW50LnF1ZXJ5U2VsZWN0b3IoJyNpc3N1ZXItbmFtZScpLmlubmVyVGV4dCA9CiAgICAgIGNyZWRlbnRpYWwuaXNzdWVyLm5hbWU7CgogICAgLy8gVEJEOiBzaWduYWwgdG8gaG9zdCB0aGF0IHJlbmRlcmluZyBpcyBjb21wbGV0ZQogICAgd2luZG93LnJlbmRlck1ldGhvZFJlYWR5KCk7Cn0pOyAgPC9zY3JpcHQ+CiAgPHN0eWxlPgogICAgaDEgewogICAgICBjb2xvcjogYmx1ZTsKICAgIH0KICA8L3N0eWxlPgoKICA8aDEgaWQ9ImNyZWRlbnRpYWxTdWJqZWN0LW5hbWUiPjwvaDE+CiAgPHA+SXNzdWVkIGJ5OiA8c3BhbiBpZD0iaXNzdWVyLW5hbWUiPjwvc3Bhbj48L3A+CjwvZGl2Pg==", |
There was a problem hiding this comment.
I think base64-ing these should fall to the choice of the implementer and the data: URL spec should be references for if/when/how to do that or find a need/reason to. I'd rather not require it as it overly constrains the URL space (which won't makes us friends...) and base64-ing often bloats the size of plain text.
There was a problem hiding this comment.
Heh...just realized this is the examples repo not the spec repo. I'll fix it here and fix https://github.com/digitalbazaar/vc-viewer to match. Thanks!
125416f to
786001d
Compare
|
Still avoiding base64 in the example, but digitalbazaar/vc-viewer#13 does implement that as an option. |
| "/issuer/name", | ||
| "/credentialSubject/name" | ||
| ], | ||
| "template": "data:text/html,<div>\n <script>\n document.addEventListener('DOMContentLoaded', (event) => {\n console.log('running template render script');\n\n // display credential as JSON as an example renderer; anything\n // could be done here instead, including mustache/other-style\n // template processing to generate the HTML for display\n\n // FIXME: determine best name/location for the datablock/script tag\n const credential = JSON.parse(document.querySelector(\n 'head > script[name=\"credential\"]').innerHTML);\n\n document.querySelector('#credentialSubject-name').innerText =\n credential.credentialSubject.name;\n document.querySelector('#issuer-name').innerText =\n credential.issuer.name;\n\n // TBD: signal to host that rendering is complete\n window.renderMethodReady();\n}); </script>\n <style>\n h1 {\n color: blue;\n }\n </style>\n\n <h1 id=\"credentialSubject-name\"></h1>\n <p>Issued by: <span id=\"issuer-name\"></span></p>\n</div>", |
There was a problem hiding this comment.
Only comment is just me not knowing whether base64 encoding is a requirement here for proper parsing or not. Not a blocker because if we find out it needs it, we'll fix this, and if we don't, then we don't need the overhead.
queries.jsonto be optional.The contained
credential.jsonVC can be tested on VC Viewer. Once merged, this will show up in the examples list there automatically.