Skip to content

Commit

Permalink
More tries to get it working.
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Meems committed Mar 15, 2019
1 parent b57eec8 commit bfeb1c8
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 11 deletions.
12 changes: 1 addition & 11 deletions docs/source/_static/docson/css/docson.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

.docson {
font-family: 'Droid Sans', verdana, helvetica, serif;
font-family: 'Droid Sans',verdana,helvetica;
font-size: 13px;
padding: 6px 6px 6px 6px;
}
Expand Down Expand Up @@ -437,11 +437,6 @@

.docson .json, .json-schema {
font-family: "Lucida Console", Monaco, monospace;
overflow-x: auto;
white-space: pre-wrap;
white-space: -moz-pre-wrap;
white-space: -o-pre-wrap;
word-wrap: break-word;
}

.docson .json-punctuation {
Expand Down Expand Up @@ -483,8 +478,3 @@
font-style: italic;
}

/* Overrides */

.docson .box {
width: 96% !important;
}
9 changes: 9 additions & 0 deletions docs/source/_static/docson/lib/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const express = require('express');
const path = require('path');
const app = express();

app.use(express.static('files'))

app.use('/', express.static(path.join(__dirname, '..')) );

module.exports = app;
48 changes: 48 additions & 0 deletions docs/source/_static/docson/widget.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright 2013 Laurent Bovet <laurent.bovet@windmaster.ch>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

var scripts = document.getElementsByTagName('script');
var script = scripts[ scripts.length - 1 ];

if (script.attributes["data-schema"]) {
var docson;
if (script.attributes["data-docson"]) {
docson = script.attributes["data-docson"].value;
} else {
docson = script.src.replace("widget.js", "index.html");
}
document.write("<iframe id='" + script.attributes["data-schema"].value +
"' style='padding: 0; border: 0; width:100%; background: transparent' src='" +
docson + "#" +
script.attributes["data-schema"].value + "'></iframe>");
function receiveMessage(event) {
console.log("<", event)
if (event.data.id && event.data.id == "docson") {
var frame = document.getElementById(event.data.url);
if(event.data.action == "resized") {
frame.height = event.data.height + 18;
}
if(event.data.action == "ready") {
console.log(frame.parentNode)
frame.contentWindow.postMessage({ id: "docson", font: window.getComputedStyle(frame.parentNode).fontFamily}, "*");
}
}

}
window.addEventListener("message", receiveMessage, false);
} else {
alert("<p style='color:red'>Missing data-schema (url to schema)</p>")
}

0 comments on commit bfeb1c8

Please sign in to comment.