[REF] move libs out of playground, add server.py

So we can share it
This commit is contained in:
Géry Debongnie
2019-04-30 10:51:18 +02:00
parent 8b4a3e45a3
commit 9cc1dd0524
16 changed files with 30 additions and 10 deletions
+1 -1
View File
@@ -13,7 +13,7 @@
<ul>
<li>Github project: <a href="https://github.com/odoo/owl">https://github.com/odoo/owl</a></li>
<li>Documentation: <a href="https://github.com/odoo/owl/blob/master/doc/readme.md">https://github.com/odoo/owl/blob/master/doc/readme.md</a>
<li>Online playground: <a href="https://odoo.github.io/owl/playground/">https://odoo.github.io/owl/playground/</a>
<li>Online playground: <a href="playground/">playground/</a>
</ul>
<p>
+1 -1
View File
@@ -2,6 +2,6 @@
"name": "owl-playground",
"description": "Odoo Web Library",
"scripts": {
"start": "python -m SimpleHTTPServer 8001"
"start": "python server.py"
}
}
+5 -5
View File
@@ -6,7 +6,7 @@ async function owlSourceCode() {
if (owlJS) {
return owlJS;
}
const result = await fetch("/playground/libs/owl.js");
const result = await fetch("/libs/owl.js");
owlJS = await result.text();
return owlJS;
}
@@ -196,7 +196,7 @@ class App extends owl.Component {
// inject js
const owlScript = doc.createElement("script");
owlScript.type = "text/javascript";
owlScript.src = "libs/owl.js";
owlScript.src = "/libs/owl.js";
owlScript.addEventListener("load", () => {
const script = doc.createElement("script");
script.type = "text/javascript";
@@ -278,8 +278,8 @@ class App extends owl.Component {
}
async downloadCode() {
await owl.utils.loadJS("libs/FileSaver.min.js");
await owl.utils.loadJS("libs/jszip.min.js");
await owl.utils.loadJS("/libs/FileSaver.min.js");
await owl.utils.loadJS("/libs/jszip.min.js");
const zip = new JSZip();
@@ -317,7 +317,7 @@ owl.utils.whenReady(startApp);`;
//------------------------------------------------------------------------------
document.title = `${document.title} (v${owl._version})`;
document.addEventListener("DOMContentLoaded", async function() {
const templates = await owl.utils.loadTemplates("src/templates.xml");
const templates = await owl.utils.loadTemplates("templates.xml");
const qweb = new owl.QWeb(templates);
const env = { qweb };
const app = new App(env);
+3 -3
View File
@@ -5,12 +5,12 @@
<title>OWL Playground</title>
<link rel="icon" href="data:,">
<script src="libs/ace.js" type="text/javascript" charset="utf-8"></script>
<script src="libs/owl.js"></script>
<script src="../libs/ace.js" type="text/javascript" charset="utf-8"></script>
<script src="../libs/owl.js"></script>
<!-- Application JS/CSS -->
<link rel="stylesheet" href="playground.css">
<script type="module" src="src/app.js"></script>
<script type="module" src="app.js"></script>
</head>
<body>
+20
View File
@@ -0,0 +1,20 @@
import sys
import thread
import webbrowser
import time
import BaseHTTPServer, SimpleHTTPServer
def start_server():
httpd = BaseHTTPServer.HTTPServer(('127.0.0.1', 3600), SimpleHTTPServer.SimpleHTTPRequestHandler)
httpd.serve_forever()
thread.start_new_thread(start_server,())
url = 'http://127.0.0.1:3600'
webbrowser.open_new(url)
while True:
try:
time.sleep(1)
except KeyboardInterrupt:
sys.exit(0)