Python, Firefox programming and Irish Whiskey.

Saturday, May 22, 2010

facebook :-(

I am on a facebook too. Nothing to board about though. I just wanted to let you readers know I have just created a group named I won't join every silly facebook group I am invited into. Still accepting members. Feel free to join. If anybody at all reads this blog.

Wednesday, April 28, 2010

pylons in appengine

Hello again, after more than a month. Sorry you had to wait. So I have got pylons in google appengine up and running. Haven't done anything yet, just an "empty" application. Anyway, I had to compile my own python, as OpenSUSE 11.2 already contains version 2.6 and doesn't seem to have 2.5 packages in my current set of repositories. After I compiled python for the first time (./configure ; make ; sudo make install) and run python2.5, I saw that I could not use commandline properly, so I installed readline-devel. Then I compiled again, tried a bit of the appengine-monkey guide, found out that something wasn't compiled in, installed another devel package and went again. The packages I had to install were:
  • readline-devel
  • zlib-devel
  • openssl-devel
  • sqlite3-devel
Then I successfully run the bloody thing. After some mistake on my side I decided to go for Pylons-0.9.7 instead of the fresh 1.0-prerelease and I installed an older webob as one of the comments on appengine-monkey wiki advices. That's about it for now. I will keep you posted with updates.

Sunday, March 14, 2010

word count for chrome

Just a quick note: The approach described in word count and word count II seems to be working well in Google Chrome too.

Sunday, March 7, 2010

localized html in a chrome extension

Google Chrome implements a function to get a localized version of a string. Using it to update HTML can be rather tedious if we use the most naive approach I can think of:

Let's do something smarter: We shall mark all tags that contain translatable strings with a class, then we will select all tags of that class, simply take their innerText as the message id, get the message and replace innerText. Done.

Done.

Thursday, March 4, 2010

SEO Profesional Toolbar for Google Chrome

So it's finally here. I have been working on the Google Chrome port of our "famous" SEO Profesional Toolbar for some time and the very first release has been made yesterday.

You can get it here. I will appreciate any comments. Please note that it isn't really finished yet. Developers can look forward to reading some related posts.

Friday, February 26, 2010

better template

Great! I have found a template main part of which is wider than some 30% of the page! Wow! That's my second post today.

Wednesday, February 24, 2010

highlight things in a firefox extension

If you did some highlighting in a web application you would have to manipulate DOM to insert tags that would change background color (or style in general) of the area being highlighted. It is not only slow but also rather complicated and limited. Firefox offers a stronger tool, which is used for example for highlighting searched strings. Here we will look into some details.

We will start with document.createRange. This is not firefox specific yet. This is a pure DOM and should be pretty cross-browser. (I haven't tried it in MSIE8 but according to quirksmode's Introduction to Range it does not work in MSIE6/7. Honestly, I haven't tried in anything else than FF3+). Anyway, we have got quite a set of functions for manipulating ranges, and honestly they are not too easy to work with. Try this in your Firebug:

For description of functions see DOM/range @ developer.mozilla.org. So, we have got a range or more and we would like to highlight them. Here, Firefox comes to our help. We need to obtain a selection controller for the window, add the ranges to desired type of selection and tell the controller to highlight them. There are a few things to remember:

  • The selection controller can contain something. We should clear it first.
  • There are a few types of selection, like SELECTION_FIND and SELECTION_NORMAL.
  • You must do all the stuff shown below for all frames in your document separately. This will not be shown here but you can look at SEO Profesional Toolbar source code, file seopsidebar.js
  • Remember that some windows do not contain DOM. In that case this method will fail

Just for those curious: In SEO Profesional Toolbar we offer a list of something (links, found texts) in a sidebar and hightlight all these entities using SELECTION_FIND and when one of them is clicked in the sidebar, we will highlight it using SELECTION_NORMAL and scroll to it with controller.scrollSelectionIntoView(Ci.nsISelectionController.SELECTION_NORMAL, Ci.nsISelectionController.SELECTION_ANCHOR_REGION, false)

The best thing at the end: I have put some examples into my testbed firefox extension, so fire-up your browser, install testbed, look at the source code (overlay.js), sit back and enjoy! Do not forget to uninstall or disabled testbed when you are done.