ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> pyxpcom
pyxpcom
[pyxpcom] FireFox Live Preview API
by Nicholas Dudfield other posts by this author
Mar 29 2008 12:40AM messages near this date
view in the new Beta List Site
Re: [pyxpcom] PyXPCOM extension - PyEgg | Re: [pyxpcom] FireFox Live Preview API
Greetings all, 

My name is Nicholas Dudfield. Recently, I have been tinkering around with
the excellent win32 extensions to Python and managed to create a Live
Preview plugin for the editor I use using manipulation of the DOM via COM
automation of IE.  Google Summer of Code is on and I would like to do a
project using PyXPCOM/PyDOM to do the same thing cross platform and editor
agnostic(as possible).  The idea only really came to me of late so I am
cutting it fine with scheduling.  If I could get any feedback on my ideas I
would be very thankful.

Here are some excerpts from my proposal. 


Â? I would like to implement using PyXPCOM a wrapper around FireFox,
particularly the DOM with automated docstrings built from the Mozilla
documentation. This would enable autocompletion and help() , facilitating
easy experimentation from IPython or your choice of shell/editor. This makes
it much more likely for people to use it Â?in the heat of the momentÂ?. 

The API would contain convenience functions for recurring useage patterns so
people could very quickly experiment in IPython and create test macros.
Python wielding web developers everywhere would benefit as would Â?designersÂ?
for whom Python is an approachable language. 

Some editors these days have inbuilt support for Live Preview of HTML as you
type. This speeds up the creative process considerably. I have created a
Live preview plugin for an windows editor using the win32py extensions,
using COM to manipulate the DOM. I would very much like to create a cross
platform solution that is easily callable from any editor with Python
embedded. 

As part of the project I would create an example of Live Preview for the VIM
editor (built with Python extensions).There are a number of feature
enhancements I would like to implement above Â?stockÂ? Live Preview, useful as
it is. An url scheme that editors could register to be handled by their
editor of choice.
 
This would include line and column numbers eg.
edit://file=/home/joe/bloe.html&line=40column=20. This coupled with a
javascript hack that created links to the source of any element on mouseOver
would turn a MozillaBrowser into a source browser.

Also, with a fully documented foundation class to build from it would be
trivial to build editor hooks that could get FireFox to scroll to the
element your cursor currently resided on in your editor.

A lot of this functionality could be done in an editor agnostic manner.
Functionality that mapped buffer regions in byte positions to DOM elements
and updated on modifications for example is something that need only be
written once.

With straight HTML itÂ?s pretty straight forward to update the page based on
the buffer, but once you start talking about dynamic things start to get a
little more complicated.

You also have CSS to deal with;  internal styles embedded in the <head>  tag
or in element style attributes are fairly easy. However, what if you want to
view some specific HTML, generated with PHP, how would you update live as
you modified some text on the page or say some external CSS? These are the
sort of facilities that would make LivePreview truly useful and are the nuts
I want to crack.

As of now here are some my thoughts (subject to evolution):
    
    First thing I will do is create the basic Wrapper Class of FireFox with
PyXPCOM
    Next I will do the binding of all documented methods and properties,
automating the process using HTML screen scraping (BeautifulSoup Library)
	( The docstring documentation is the main part here, it seems most
of the work is done)
    This will give me a great sandbox to experiment with creative solutions
to the above
    
    Editing HTML inside PHP:
        Basic concept: 
            
            I will keep a copy of all the text nodes and their DOM
sourceIndex cached
            
            You can search these to see if they contain the text currently
being edited and update where possible
            InternetExplorer actually has a TextRange object, where you can
easily search and replace just the text in the DOM.
            Implementing similar convenience functions would be on the
agenda. 
            
    How would you make the live Preview as flicker free as possible?
        Investigate the possibility of forcing the browser to do
offscreenBuffering. 
    
    How would you update a Page's styles live while editing external CSS?
    
Based on some prototyping with Internet Explorer and COM I think with time
and some help these problems could be solved.    
Â?

Is this sort of thing feasible with PyXPCOM?  

Does PyXPCOM have something like the MakePY utility that win32 COM
extensions do? 

If so does it document the methods via docstrings? Does it document the DOM?

Can you force Mozilla to do offscreen buffering?


Thanks very much.

_______________________________________________
pyxpcom mailing list
pyxpcom@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Thread:
Nicholas Dudfield
Mark Hammond

Privacy Policy | Email Opt-out | Feedback | Syndication
© 2004 ActiveState, a division of Sophos All rights reserved