Skip to content

Commit

Permalink
Fix Gallery and Console
Browse files Browse the repository at this point in the history
  • Loading branch information
juancarlospaco committed Oct 11, 2014
1 parent 95c7d38 commit 5c5c44e
Show file tree
Hide file tree
Showing 11 changed files with 871 additions and 639 deletions.
2 changes: 0 additions & 2 deletions README.txt

This file was deleted.

3 changes: 2 additions & 1 deletion site/benchmarks/index.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<script type="text/javascript" src="../../src/brython.js"></script>

<script type="text/python">
Expand Down Expand Up @@ -31,7 +32,7 @@
if _test['name'] == name:
return _test['num_runs']

return 0
return 0

def run_tests(e):
_tbody=doc.get(selector='tbody')[0]
Expand Down
100 changes: 55 additions & 45 deletions site/brython.css
Original file line number Diff line number Diff line change
@@ -1,45 +1,55 @@
body {font-family:arial,verdana;
font-size:14px;
}
ul
{
list-style-type:none;
margin:0;
padding:0;
overflow:hidden;
}
li
{
float:left;
}
a.banner:link,a.banner:visited
{
display:block;
font-size:14px;
font-weight:bold;
color:#FFFFFF;
line-height:35px; /*hauteur de l'image de fond*/
background:black url(doc/images/noir-1.png) repeat-x;
padding:8px;
text-align:center;
text-decoration:none;
}
a.banner:hover,a.banner:active
{
background:black url(doc/images/noir-2.png) repeat-x;
color:white;
}
#banner{
width:85%;
padding-bottom:15px;
}
#console{
color:#FFF;
background-color:#000;
font-weight:bold;
}
a.glink{
text-decoration:underline;
background-color: #FFF;
color: #000;
}
@charset 'utf-8';
@-ms-viewport{width:device-width};
@-o-viewport{width:device-width};
@viewport{width:device-width};


#banner {
padding-bottom:15px;
width:85%
}

#console {
background-color:#000;
color:#FFF;
font-weight:700
}

a.banner:hover,a.banner:active {
background:#000 url(doc/images/noir-2.png) repeat-x;
color:#FFF
}

a.banner:link,a.banner:visited {
background:#000 url(doc/images/noir-1.png) repeat-x;
color:#FFF;
display:block;
font-size:14px;
font-weight:700;
line-height:35px;
padding:8px;
text-align:center;
text-decoration:none
}

a.glink {
background-color:#FFF;
color:#000;
text-decoration:underline
}

body {
font-family:Oxygen,arial;
font-size:14px
}

li {
float:left
}

ul {
list-style-type:none;
margin:0;
overflow:hidden;
padding:0
}

2 comments on commit 5c5c44e

@PierreQuentel
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Juan Carlo,

I just realised that this commit changed the place where the brython() function is called : instead of the standard you put it in

<script src="../../src/brython.js" async onload=brython(1) ></script>

It didn't break anything at the time so I didn't notice, but it broke another change I am working on. So I restored the standard code in changeset e770f9e, and in the same time the quoted attributes

- Pierre

@PierreQuentel
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Brython needs to know the URL matching the directory of the standard distribution, to be able to search modules eg in Lib/site-packages by Ajax calls

For the moment this is done in the function brython() of py2js.js, by looking at the files inserted in the script (<script src="brython.js">) and looking if one of them has its src attribute in ["py2js.js", "brython.js", "brython_dist.js"]

I am trying to make this more flexible because I would like to allow customised distributions : JS files that hold the Brython engine and only a part of the standard distribution (eg the browser package). The distribution could have any name, so the current mechanism that relies on the script name doesn't work

The approach I am working on is to include a piece of code in brython_builtins.js that would detect its own name, just by searching the last item in document.getElementsByTagName("scripts")

Just for testing, introduce these 2 lines at the beginning of the function in brython_builtins.js (line 6) :

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

and generate a brython.js with make_dist.py

With your version of gallery_en.html, I get a blank value in the alert box, so my code to get the URL wouldn't work. I had not tested removing the "async" attribute, in this case I get the expected value, but in the meantime restoring onload = "brython(1)" solved the problem

On the other hand, the idea of having just one line to include Brython in the page is interesting. Either by adding the onload attribute to the script tag as you did, or even more simple, by putting something like

window.addEventListener('load', brython)

in the code ; but in this case we would have to change the mechanism to set options such as the debug level

Please sign in to comment.