Firefox Mac vs. Windows

I’ve got some serious JavaScript_age going on with my site: I sometimes wonder if it’s too much. One thing I have noticed is that on my iMac I get occasional “There is a script taking a long time to finish. Continue/Stop Script” errors, but never see these on the PC. I also don’t see them under IE/Win, the platform I am forced to use at work. I also get errors with Camino, but I’m not sure about Safari. I’ve gone into about:config, and changed dom.max_script_run_time_ from the default of 5 to 20, just to see if that makes a difference.

Fixing Generated Invalid XHTML

I had a standard Smarty function, {list_cats}, that under certain circumstances generates invalid XHTML. Specifically, when a feed_image is supplied, not alt tag is generated. This annoys me, as I have worked hard to make my template generate “nice” code. Smarty to the rescue. Whilst you cannot pass the results of a Smarty function through a Smarty filter, like replace, you can capture the results, and then pass this through the filter:

    <h2><a href="/categories/">Main Categories</a></h2>
    <ul>
        {capture name=cats}{list_cats optionall='1' all='All' sort_column='name' optioncount='0' children='0' hierarchical='1' feed_image='/images/feedicon10x10.gif'}{/capture}
        {$smarty.capture.cats|replace:"/></a>":"alt='Live Bookmark (RSS Feed)' /></a>"}
    </ul>

By the way, I used a similar technique to convert a list of (list) items into a list of selects:

    <h2>Links Dropdown</h2>
    <ul>
        <li><form name="linksform" action="" method="post" style="margin: 0px; padding: 0px;">
            <select id="link_list">
            <option value=''>Select Link to View</option>
            {capture name="linklist"}{get_links}{/capture}
            {$smarty.capture.linklist|replace:'<a':'<option'|replace:'</a><br />':'</option>'|replace:'href':'value'}
            </select>
            <input type="button" class="button" value="Go" onclick="window.location = (document.forms.linksform.link_list[document.forms.linksform.link_list.selectedIndex].value);" />
        </form></li>
    </ul>

Conditional Styling

I have an Asides category, posts in which appear differently on my site. That’s all well and good, but I want these posts to appear normally if viewing the Asides category, or an individual Asides post. So, I need to be able to style stuff differently depending on a couple of factors. The most obvious method for this would be to have CSS changing if certain conditions are met. However, in practice this seems to be somewhat difficult. You cannot access the equivalent of a DOM tree in CSS. You can add new entries to a style description, but not find out much real information about the current styles. Approaching this from the other direction, however, looks to be more promising. Especially if you examine the code I use to style differently to begin with:

    <div class="post {is_aside}{if $is_aside=='true'}Asides{/if}" id="post-{the_ID}">

This snippet could be used to have different styles for any category, using something like:

    <div class="post {the_category seperator=' '}" id="post-{the_ID}">

I’m not examining now the mechanics of how to change these styles, as that can be found in another post on my site: Styling Asides Differently. To remove the Aside class entry, I’ve restructured my post.html file to start with:

    {is_aside}
    {if $smarty.server.REQUEST_URI|truncate:17:'':1 == '/category/asides/'}
        {assign var=is_aside value=false}
    {/if}
    
    <div class="post {if $is_aside=='true'}Asides{/if}" id="post-{the_ID}">

But how do we find out if we are viewing a single post? One easy method is to test using the {single_post_title} function:

    {capture name=title}{single_post_title}{/capture}
    {if $smarty.capture.title != ''}
        {assign var=is_aside value=false}
    {/if}

Bingo. All Done. My Mum is right. I am a star.

Folders in the Dock

I have my Dock hidden, and aligned to the left of the screen. I don’t really use it for much other than a launcher, although I do have a couple of shortcuts to folders there as well. I tried to drag an image from a website into one of these folders. I can drag like this to the desktop, or any open window. Why can’t I do this to a folder Dock icon? This seems crazy!

Anygui Redux

Years ago, I was involved in the development of Anygui, a GUI development wrapper designed for python. Basically, it was supposed to be like anydbm is for accessing database modules from python. That is, it was intended to make it into the standard library, and use the best GUI available from it’s list on a given system. I was responsible for the BeOS components, using Donn Cave’s excellent Bethon package. Today, I noticed a referer in my backend from someone searching for PyMail on Google. I had a look on Google as to what else is found on this search, and came across a site with the following content (I’ve reformatted it, since the site was gone, and this is from the cache):

 1     #!/usr/bin/env python
 2     #pyMail 0.1 
 3     #my first program with python and anygui interface 
 4     #coded by teknux ~ teknux@ustc.edu 
 5     #2002/11/4 
 6     #copyright 2002 under GPL
 7     
 8     from anygui import *
 9     import smtplib 
10     from email.MIMEText import MIMEText 
11     import sys as sys
12     
13     #edit these fields with your informations
14     mail_sender = "teknux@localhost"
15     mail_from = "teknux@localhost" 
16     
17     #initialize window 
18     app = Application() 
19     win = Window(title="pyMail 0.1",size=(460,385)) 
20     app.add(win) 
21     opt = Options(left=5, width=21, height=30) 
22     banner = Label(size=(70,25), position=(385,10), text="pyMail 0.1") 
23     to = Label(opt, text="To:") 
24     to_text = TextField(size=(230,25)) 
25     win.add((to,to_text), position=(0,10), direction="right", space=5) 
26     win.add(banner) subject = Label(size=(51,25), text="Subject:") 
27     subject_text = TextField(size=(398,25)) 
28     win.add((subject,subject_text), position=(0,45), direction="right", space=5) 
29     body = TextArea(size=(450,250)) 
30     win.add(body, position=(5,80)) 
31     btn_send = Button(left=5, size=(100,30), text="Send message") 
32     btn_exit = Button(left=5, size=(100,30), text="Exit") 
33     status = Label(size=(240,25), text="...status...") 
34     win.add((btn_send,btn_exit,status), position=(5,350), space=6) 
35     
36     def statbar(stat_msg):
37         status.text = stat_msg status.refresh() 
38     
39     def sendmail(**args): 
40         msg = MIMEText(body.text) 
41         msg["Subject"] = subject_text.text 
42         msg["From"] = mail_from 
43         msg["To"] = to_text.text 
44         mail_to = to_text.text 
45         mail = smtplib.SMTP() 
46         statbar("connecting to SMTP") 
47         mail.connect() 
48         statbar("sendin message") 
49         mail.sendmail(mail_sender, mail_to, msg.as_string()) 
50         statbar("done")
51         mail.close() 
52         
53     def exit(**args): 
54         sys.exit(2) 
55         
56     link(btn_exit, exit) 
57     link(btn_send, sendmail) 
58     app.run()

I don’t have Anygui anymore, and the old site appears to be gone, so I can’t test this out! I do love the cleanliness of this system, however. It’s almost as easy to create a UI in this as in Interface Builder. Amd the coolest thing from my perspective was that this was so easy to implement in BeOS/Bethon. I did write a few of the modules for Donn, and these two bits were probably the first bits of Open Source code I wrote, and that other people might have used.

Boing Boing: Wirelessly-enabled wine glasses

Boing Boing: Wirelessly-enabled wine glasses

MIT Media Lab students Jackie Lee and Hyemin Chung have designed wireless-enabled wine glasses (actually, big tumblers) so couples can imbibe “together,” even when they’re geographically apart. From New Scientist: When either person picks up a glass, red LEDs on their partner’s glass glow gently. And when either puts the glass to their lips, sensors make white LEDs on the rim of the other glass glow brightly, so you can tell when your other half takes a sip. Following tests in separate labs, Lee says the wireless glasses really do “help people feel as if they are sharing a drinking experience together”.

Man, I can’t believe it took this long to invent!

Blog name as Page name

Nardac, a new Blogsome user, tried out my Page Templates hack, and asked the following question:

Gravatar Image

I’m having a hard time getting the pages to work. I think I’ve followed your instructions to a tee… but well… hmmm… can you take a look?
the page in question is http://nardac.blogsome.com/nardac/

I looked, and what is occurring is that his normal blog index page is appearing. So I tried the same with my blog: http://schinckel.net/schinckel/ – I know I don’t have a Page with this name, so I was interested to see what occurred. It too showed my index page. Looking down the bottom, I see the arguments that are passed to the server, and in this case, only the blog name is being sent (wpblog=schinckel). So, it seems that a page with the same name as the blog name cannot be used. I suspect this has something to do with the HTTP Rewrite Rules, but I’m not sure. I don’t see it as a big issue, anyway. Workaround: Don’t use your blog’s name as a Page name.