24 October 2007
off to FSOSS
I'm off to FSSOS in a few hours. We'll be opening up the Komodo sources next Wednesday, so Shane and I will be there to start the discussion about what Open Komodo and Snapdragon should focus on to best improve the tool story for open web development. (Currently the Open Komodo sources are available to a small group of mozillians. If you have some ideas and would like to take a peek, let me know and I'll hook you up!)
I'm hoping to meet a few of the Mozilla folks that will be there: Benjamin to ask about breakpad (I want to get breakpad running for Open Komodo and Komodo builds), looking forward to Mike Beltzner's talk on UE design at Mozilla, Eric Shephed to ask about how mozilla handles localization of their docs.
As well, if any of the mozilla folks involved in the AUS will be there, I'd love to talk with you to compare notes with Komodo's auto-update system.
1 comments18 October 2007
html5lib rocks (and a patch to preserve attribute order)
I've been playing with the Python html5lib package -- having come across it reading Sam Ruby's blog. What a fantastically useful library!
Originally my interest in it was with the discussion surrounding santization, and I expect to use it for that later, but today I've been playing with some general parse/filter/serialize code to support some preprocessing of HTML documentation for Open Komodo.
My code looks like this:
import sys
from html5lib import treebuilders, treewalkers
from html5lib.serializer.xhtmlserializer import XHTMLSerializer
def filter_play(path):
p = html5lib.XHTMLParser(tree=treebuilders.getTreeBuilder("simpletree"))
f = open(path)
dom = p.parse(f)
walker = treewalkers.getTreeWalker("simpletree")
stream = walker(dom)
#stream = MyPreprocessingFilter()
s = XHTMLSerializer()
outputter = s.serialize(stream)
for item in outputter:
sys.stdout.write(item)
filter_play(sys.argv[1])
One thing that bugged me a little with the output generated with this is that attributes on HTML elements get sorted, i.e. their order is not preserved. While totally cool for correctness, this reduces the utility of using diff or similar for comparing input with output. As well, I work on the Komodo IDE/editor and would like to consider using html5lib for an HTML reflow/beautifier feature at some point. Preserving attribute order for this will be important.
To that end, here is a small patch that adds the ability to preserve attribute order in serialized output. To use it:
- You need odict.py.
You need to change the above code to:
... s = XHTMLSerializer(preserve_attr_order=True) ...
Obviously this isn't something that would be ready to check-in to html5lib. Reasons why:
- It only works for the "simpletree" treebuilder/treewalker. I'm not sure if it is feasible/practical to get it to work with some of the others (e.g. dom).
- It unconditionally requires an external non-standard module (
odict.py). - It should be optional on the parser because (a) using
OrderedDictinstead ofdictwould presumably have an undesired perf impact and (b) the attribute order normalization could be desirable for many users.
Maybe a better solution would be a custom "roundtriptree" tree type? Anyway, just throwing this up here to perhaps come back to later. I have to dig into the html5lib discussion list to see if this has come up before.
tags: komodo, programming, python
0 comments15 October 2007
CakePHP view codeintel (autocomplete) in komodo
It is great to see more and more posts these days about adding functionality to Komodo. Only a few month back, daily blog posts about Komodo tended to be of the "Tried Komodo. Like it. Using it for blah.". Now blog posts about Komodo are often "Tried Komodo. Like it. Using it for blah. Used the macro or extension system to add blah."
For example, this post by Travis Cline shows a brilliant little hack to get Komodo's PHP codeintel (autocomplete and calltips) to work with the implicit environment for CakePHP views ('.ctp' files). It is a great example of the kinds of things you can do with Komodo macros.
Note to self: Look into providing this same functionality via a special CakeViewEnvironment class that does a similar thing and that is attached to any buffer for a CakePHP view. Every "buffer" in Komodo's codeintel system (there is one buffer for each open file and each file used for autocomplete info) has an "env" attribute which is a instance of the "Environment" class. This class defines special runtime environment information -- typically just Komodo preferences and environment variables. However, subclasses can provide other info. An example is the "KoJavaScriptMacroEnvironment" that is attached to a buffer for editing a Komodo JavaScript macro in the editor. This environment class hooks up the Komodo JS API catalog so that you get autocomplete for Komodo JS macro API.
I have to look into (1) documenting this (when we have the Open Komodo wiki setup, that'll probably be the right place) and (2) ensuring that extensions can provide these environment classes and do interesting things with them. Currently it might require some custom work on the codeintel engine to hook this up. But codeintel Environment classes are the plan.
0 comments04 October 2007
installing hg 0.9.4
Cleaning out some notes of mine, it seemed a shame to just throw out notes on installing hg. I'm happy to update this with sections for other platforms and other Linux distros if people send them my way.
Installation on Ubuntu (< Gutsy)
Note: only Ubuntu Gutsy has hg 0.9.4, and my Ubuntu isn't yet Gutsy.
sudo apt-get install python2.4 python2.4-dev
wget http://www.selenic.com/mercurial/release/mercurial-0.9.4.tar.gz
tar xzf mercurial-0.9.4.tar.gz
cd mercurial-0.9.4
sudo make install
which hg # should be /usr/local/bin/hg
hg debuginstall
Installation on Linux (with no package mgmt support):
Presumably this works just as well on other Unix-y platforms.
# You must have a Python >=2.4 installation and first on your PATH.
cd tmp
wget http://www.selenic.com/mercurial/release/mercurial-0.9.4.tar.gz
tar xzf mercurial-0.9.4.tar.gz
cd mercurial-0.9.4
python setup.py install
hg debuginstall
Installation on Mac OS X (using MacPorts):
sudo port selfupdate
sudo port search mercurial
# ensure this is version >= 0.9.4
sudo port install mercurial
Troubleshooting : install fails with "Another version of this port (mercurial @0.9.1_0) is already active."
sudo port uninstall mercurial @0.9.1_0 # the old one
sudo port uninstall mercurial @0.9.4_0 # the broken new one
sudo port install mercurial
Installation on other platforms (Windows, Solaris, FreeBSD, ...)
Look for an available binary package.
tags: mercurial
0 comments