Kumar Appaiah: Browsing with Elinks and using hooks
Even in the modern times of AJAX, Web 2+ and what not, Elinks is one of my favourite browsers, at least for browsing some sites. The reasons are simple: it cuts the unnecessary distractions, and allows you to digest text based information rather quickly. In addition, since it doesn't display any images or flashy elements like Flash, pages load lightning fast even on poor connections, making it an excellent option.Unfortunately, some sites don't really work very well with Elinks, and for those, I do one of two things. For the ones which are really complex, such as secure login sites with too much AJAX, I just resort to one of the "standard" graphical browsers. For some others, I try to work around the problem using Elinks' rich scripting interface available in many programming languages including Perl and Ruby. I chose Lua, since it seemed simple enough to learn. I wanted to share with you some of the simple workarounds I implemented for some sites I visit often.The first quirk is with the Debian BTS, whose CSS isn't properly interpreted by Elinks (see 593804 and 593840 for details). The short story: the BTS renders like this:
So, I grabbed the CSS, and made some small changes (described in the above mentioned bug reports), and got a new CSS file. I put it in
Much more readable!The second simple example, for which I won't include images, is the Mobile Twitter interface. The mobile Twitter interface is very convenient and functional in Elinks; however, by default, the text font seems to be a light grey, which is not discernible in the bright background. A default user.css file would be a possible solution, but I have not decided whether to go for it just yet. So, for the Twitter site, I add a function like this:
So, I grabbed the CSS, and made some small changes (described in the above mentioned bug reports), and got a new CSS file. I put it in /home/kumar/Kumar/bugs.css, and added the following to my ~/.elinks/hooks.lua:-- Use an alternate CSS for the Debian BTS to work around some quirks function debian_bts_format_html_hook (html) return string.gsub(html, "/css/bugs.css", 'file:///home/kumar/Kumar/bugs.css') end function pre_format_html_hook (url, html) if sstrfind (url, "bugs.debian.org") then return blonnet_format_html_hook(html) end return nil endand with it, the BTS renders like this:
Much more readable!The second simple example, for which I won't include images, is the Mobile Twitter interface. The mobile Twitter interface is very convenient and functional in Elinks; however, by default, the text font seems to be a light grey, which is not discernible in the bright background. A default user.css file would be a possible solution, but I have not decided whether to go for it just yet. So, for the Twitter site, I add a function like this:-- Make the status messages black on Mobile Twitter function mobile_twitter_format_hook(html) return string.gsub(html, ".status.- ", '.status word-wrap: break-word; color : #000; ') endAnd alter the actual hook function to:
function pre_format_html_hook (url, html)
if sstrfind (url, "bugs.debian.org") then
return debian_bts_format_html_hook(html)
elseif sstrfind (url, "mobile.twitter.com") then
return mobile_twitter_format_hook(html)
end
return nil
end
Finally, a more complicated example. I like reading the Indian business newspaper the Hindu Business Line. However, if you try browsing to the site with Elinks, you'll notice that, barring the top hyperlinks in each sectcion, the links on the left are not "linked" at all.In addition, there are some other irritants which are easy to remove, such as the navigation bar on the top, and the text colour being too light for my taste etc. So, I write the following Lua blurb. Why I write this is left for the interested readers to figure out, though it shouldn't be surprising if you open the page. The workaround for the missing links is interesting, though; it is because the website authors have put a hyperlink (<a>) tag before a list item (<li>) tag, and Elinks seems to not like that too much. So, I just swap the two around, and Elinks is happy.-- Reformat the Business Line website function blonnet_format_html_hook (html) html = string.gsub(html, "<body ", '<body text="#000000"') -- I like the text in black on the white background html = string.gsub(html, "<[Ff][Oo][Nn][Tt] class=leftnavi color=brown>.-</[Ff][Oo][Nn][Tt]>", '') -- An ugly hack to remove the navigation bar html = string.gsub(html, "<TD align=left vAlign=top width=\"500\"><IMG.-</FONT><BR>", '', 1) -- Remove description html = string.gsub(html, "<A class=groupnavi href=\"http://epaper.thehindubusinessline.com/\">.-</FONT><BR>", '', 1) -- Remove other group links html = string.gsub(html, "(<[Aa] class=navi.-)<li>(.-</[Aa]>)", "<li>%1%2</li>") -- Fix the erroneous section sidebar return html end function pre_format_html_hook (url, html) if sstrfind (url, "blonnet.com") or sstrfind(url, "thehindubusinessline.com") then return blonnet_format_html_hook(html) elseif sstrfind (url, "bugs.debian.org") then return debian_bts_format_html_hook(html) elseif sstrfind (url, "mobile.twitter.com") then return mobile_twitter_format_hook(html) end return nil endAnd here's the old and new rendering:

...awesome.
OK, I'm writing this while I'm still in USA, but there are so many
things to say about these weeks that I can't write them in only one
blog post. And, still, this one will be quite long as it will talk
about hacking, running and sightseeing...:)
Let's start about hacking: after all, this is the first reason for
being there in US, isn't it?
I cam to DebConf with a very long TODO list and, for the first time in
seven DebConfs, I'm pretty happy with what I achieved from it:
long time no RC bug posting. in july I was at the
DebConf launched with a bang the day I arrived
Debian package building scripts consist of several inter-related tools, which are documented well with manpages, but not in the code itself.
Should you have some free time I urge you to take a peak at the source code of dpkg-buildpackage, debsign, and debuild. They work. They work well, but they're not shining examples of clear code are they?
Given that they work, and that they are complex I'm not sure I'm interested in improving things, but I do have a personal desire to run something like:
A while ago I was with my SO at a concert of a band I might cover at a later point. This time I want to cover the support act of that concert: 
* So, here is late report!
Sometime back Praveen started discussion at DebianIndia mailing list about having MiniDebConf kind of conference here in India. MiniDebConfs are generally focused on development rather than at introduction to Debian . But, since this was our first attempt, out focus was more on to introduce Debian to student community and after writing this after 5 days I realize that we ve done good job!
Many thanks to Joerg Jaspert for setting up Mini website:
I was in New York for three full weeks, before, during and after DebConf 10 took place. Unfortunately, I wasn't able to attend talks or go hang out with folks as much as I would've wanted. Most of the time I was busy at the office with a new product launch we have been preparing for the last few months. However, I was able to come and say hi to a few people, attend the C&W party and talk with friends and ran into. I was, however, following all conversations on IRC so I was pretty informed of all of what was going on. Some random thoughts:
So, DebConf time is over once again. The two weeks worth of fifty weeks waiting are left behind once again, and it's back to get back to normal. DebConf was great Yes, it always is, and that's what we are all saying, but hey - Seriously! Being in the same building than 300 crazed developers is always fun, and it's always better than last year's fun. A good highlight this year is that, given the number of Free Software and Free Culture groups that exist in USA's north-eastern coast, we had the opportunity to join a large crowd which has never been part of DebConf. Also, I must agree that the USA bid for DebConf was aiming to attract as many Debian people (developers, maintainers, or just happy users) which had not yet been to a DebConf before as possible. And it was a great success! I finally met several people I have long read in the mailing lists, in blogs or in IRC. A much higher proportion than usual, I'd venture to say. Another interesting phenomenon /methinks is that this year's DebCamp started much more staffed than usual: I arrived on the first day, Sunday 25, and there were ~40 people there already; I don't have the actual numbers, but we quickly grew, and the number started to stabilize past mid-week, only to (sharply) rise in the weekend, in time for DebianDay and DebConf start. Great time!
But, they say, nobody can go to the USA without buying some sweet toys, right?
Well, being the proud owner of six very hairy cats, I have thought into entering the looming and weaving industry... But cat hair, while abundant, I have heard is untreadable... Maybe due to the indisciplined, natural and independent personality of the cats (catonality should I say?)...
So I had two choices: Clean up my home quite often, or live in a literally hairy mess.
Enter choice #3: 

So, DebConf is over and it was a blast. I wanted to blog
about my talks for a couple of days, but the conference was
so great that I did not get around to it until now.
The unique thing about this year's conference were the
outstanding contributions by non-Debian FLOSS people from
the east coast. I am really glad the organizers decided to
reach out to the communi
ty and take this opportunity when a lot of great minds were
just a couple of hours away. Also, discussing and hanging
out with the local team people was so much fun and
interesting that it was wor
th the visit alone.
The venue was just perfect, the dorms were on campus, the
cafeteria had an all-you-can-eat buffet, everything was in
short walking distance and the Columbia campus is beautiful.
I would have liked to go to a couple more places in the
evenings, but hanging out in the Carman basement lounge with
awesome people was just as good. A big thanks to Richard
Darst, Biella, Micah and the rest of the
crew.
The