On Thu, Jul 30, 2009 at 11:45 PM, William Stein<wst...@gmail.com> wrote: > > > On Thu, Jul 30, 2009 at 10:41 PM, Ondrej Certik <ond...@certik.cz> wrote: >> >> On Thu, Jul 30, 2009 at 11:20 PM, William Stein<wst...@gmail.com> wrote: >> > >> > >> > On Thu, Jul 30, 2009 at 10:02 PM, Ondrej Certik <ond...@certik.cz> >> > wrote: >> >> >> >> On Thu, Jul 30, 2009 at 10:51 PM, William Stein<wst...@gmail.com> >> >> wrote: >> >> > >> >> > >> >> > On Thu, Jul 30, 2009 at 9:43 PM, Ondrej Certik <ond...@certik.cz> >> >> > wrote: >> >> >> >> >> >> Hi, >> >> >> >> >> >> so I fixed most of the early bugs, here is my latest attempt: >> >> >> >> >> >> http://4.latest.pythonnb.appspot.com/ >> >> >> >> >> >> it seems to be working reasonably well in most browsers I tried (FF, >> >> >> IE, Safari, Opera, Chrome, ...). >> >> >> >> >> >> >> >> >> Opera can't handle event.preventDefault(), which means that if you >> >> >> press shift+enter, the enter will still get propagated and the new >> >> >> cell will have 2 rows. I think it's a bug in Opera, but maybe there >> >> >> is >> >> >> some fix for this. All other browsers seem to work for me. >> >> > >> >> > I don't think we support Opera in Sage either, by the way. We used >> >> > to, >> >> > maybe, but even when we did it just felt so *SLOW* to render >> >> > javascript >> >> > that >> >> > it wasn't really worth using so much. I actually used Opera as my >> >> > main >> >> > browser for years, but Firefox is definitely ahead now, in most ways. >> >> > >> >> >> >> >> >> It's not as polished as my original javascript version: >> >> >> >> >> >> http://pythonnb.appspot.com/ >> >> >> >> >> >> e.g. the evaluate button is not there, and the blue line is not >> >> >> there >> >> >> yet either, neither is the blue focus rectangle around cells. I will >> >> >> not have time for the next month or so to work on this, but I am now >> >> >> confident that it can be done. >> >> > >> >> > It's really surprising to me that some of those things get messed up >> >> > by >> >> > switching to pyjamas. When I look at your pyjamas version with >> >> > firefox >> >> > 3 on >> >> > OS X, I *do* see the blue bar, but it is in the wrong place, about an >> >> > "em" >> >> > too high. >> >> >> >> It's because in pyjamas I am using some pyjamas widget (I think >> >> RootPanel) that adds <div> after each element, thus the spacing gets >> >> wrong. To fix this, one just has to persuade pyjamas not to put any >> >> <div> in the html output and then it should be ok. >> >> >> >> But all these CSS style things always take me couple hours to fix, so >> >> I'll just leave it as is. It convinced me that it can be done, so >> >> that's all I wanted to know. >> >> >> >> > >> >> >> >> >> >> Look at the code here, that gets translated to javascript: >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> http://github.com/certik/notebook/blob/ef396ef2eb3314ff787000cac7e34b1c08d9af6a/media/index.py >> >> >> >> >> >> It's all pure python and with pyjamas desktop it should be possible >> >> >> to >> >> >> run it on the desktop, e.g. in a python interpreter. I think in the >> >> >> long term, this is the way to go. >> >> >> >> >> >> Pyjamas is still developing, e.g. I contributed the initial urllib >> >> >> package into it (the index.py file above still contains my older >> >> >> hack, >> >> >> that calls javascript --- with new pyjamas, this is not needed >> >> >> anymore), etc. >> >> >> >> >> >> Anyway, I am looking forward, I think in couple years it will be >> >> >> absolutely common thing to have sophisticated web applications and >> >> >> we >> >> >> could write them in Python. >> >> > >> >> > Nice. I have to say honestly that the idea of using pyjamas is the >> >> > only >> >> > thing I've ever seen that made me personally have that feeling "I >> >> > want >> >> > to >> >> > rewrite the javascript part of the notebook". I'm really glad you >> >> > did a >> >> > prototype of this so we could see what some of the issues are. >> >> >> >> I forgot how I got the idea to rewrite it, I think I just wanted to >> >> learn AJAX, so the best thing to learn it is to write it myself from >> >> scratch. >> >> >> >> But if I am going to write some new webapp from scratch, I am going to >> >> use pyjamas. For Sage notebook though, we may just continue improving >> >> the current one, as I am not much a fan of rewriting applications from >> >> scratch. >> > >> > You're right -- same here. At least one I'm planning on doing next >> > quarter on the notebook will be all about "the devil is in the details" >> > polishing of the last few percent. >> >> Yep. There are things that I now don't like on the Sage notebook, like >> that if I click on a cell, the frame gets focused (that's ok), but the >> text moves by one pixel. I hate that. My javascript version doesn't do >> that, at least on firefox. In fact, it's just a CSS styles issue, so >> it's easy to fix -- but I wasn't sure if it's just on my firefox, or >> everywhere. > > I also find that very annoying. I've added it to my "hit list". > >> >> Also, it seems to me the reaction to keys is a bit slow in the cells, >> if I press enter, the cursor first moves half way out of the cell and >> only then (maybe 0.1s) the cell gets resized. I hate that too, but I >> think my javascript version works better in this particular case, so >> we may just use my approach here, if it works everywhere. > > This is partly because a lot happens with every keystroke, and the resizing > is complicated to make it work robustly on lots of different systems and > with lots of different input. Your resizing code seems to work find, and I > would love to change to it! Anyway, this sounds like something that falls > under polish and optimization. That it is a problem was made much clearer > to me by playing with your demos too :-) > >> >> Then just today I had to modify the notebook on about 5 places to >> change the executable to be called: >> >> >> http://github.com/certik/femhub_notebook/commit/4db3c0108ab4f8e44077899d879b8f1bd1927526 >> >> so there should be some variable for that. Things like that, I think >> those are best fixed by improving the current notebook rather than >> rewriting it. > > Agreed and agreed.
I just found out that the new py.test and its plugin here (released today): http://pypi.python.org/pypi/oejskit can test javascript in the real browser against a python server. So I would go that way for testing the javascript. Ondrej --~--~---------~--~----~------------~-------~--~----~ To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---