integrate spec.lbry.io as iframed page at /spec. Fixes #11.

This commit is contained in:
Alex Grintsvayg 2019-01-24 14:09:52 -05:00
parent 9f7904540b
commit 7cdd019815
No known key found for this signature in database
GPG key ID: AEB3F089F86A22B5
3 changed files with 37 additions and 0 deletions

View file

@ -34,6 +34,7 @@ function main() {
app.use(ssr()); app.use(ssr());
app.route("/", page(require("./views/home"))); app.route("/", page(require("./views/home")));
app.route("/spec", page(require("./views/spec")));
app.route("/api/*", page(require("./views/api"))); app.route("/api/*", page(require("./views/api")));
app.route("/*", page(require("./views/redirect"))); app.route("/*", page(require("./views/redirect")));

View file

@ -19,6 +19,9 @@ const config = local("/config");
// E X P O R T // E X P O R T
export default state => { export default state => {
if (state.hideFooter) {
return "";
}
return html` return html`
<section class="email-subscribe-container"> <section class="email-subscribe-container">
${emailSubscribe()} ${emailSubscribe()}

33
app/views/spec.js Normal file
View file

@ -0,0 +1,33 @@
"use strict";
// I M P O R T
import html from "choo/html";
// E X P O R T
export default state => {
state.hideFooter = true;
return html`
<div style="width:100%; height:calc(100vh - 67px)"> <!-- 67px = height of nav. this avoids second scrollbar -->
<iframe id="spec" style="width:100%; height:100%;"></iframe>
</div>
<script>
const specDomain = "https://spec.lbry.io";
const spec = document.getElementById("spec");
spec.src = specDomain + window.location.hash;
window.addEventListener("message", event => {
if (event.origin != specDomain || event.source != spec.contentWindow) { // security
return;
}
const url = window.location.href.substr(0, window.location.href.lastIndexOf('#'));
history.replaceState(null, null, url+"#"+event.data);
});
</script>
`;
};