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

Mail.app Chokes on HTML Email

I’ve noticed that Mail.app really takes ages to render HTML emails, or those with images in them. Seconds elapse between clicking on a message, and it fully rendering in the preview pane.

Mini-review: The First Casualty

Ben Elton is pretty fantastic. He wrote for The Young Ones, and Blackadder, and has since written several books, most of which are pretty good. His latest is The First Casualty, a historical fiction (?) piece set during the Great War. I was gripped, and read it in one sitting. No comedy here, guys, but well worth the effort. The guts of the story: in 1917, a war hero and poet is killed, not in action, but while recuperating after being injured, and shellshocked. A disgraced police officer, who was sent to jail for refusing to fight in the war (not a conchie, as his grounds were “purely intellectual”) is ‘recruited’ to find the identity of the killer.

Killer Kitten

From Scot Hacker’s blog:

iPod Software 3.1.1 Crashes

If you have a 4G (Clickwheel) iPod, and you use it, don’t install iPod Software 3.1.1. This version of the firmware causes the iPod to crash sometimes, even often, when going to sleep or waking up. You then need to do a force-reset (hold MENU & SELECT for 6-10 secs) in order to cause it to spin up, losing your place in a bookmarkable file, and possibly play counts for other tracks. I downgraded (using the Restore feature from iPod Updater 2005-09-23.app), and haven’t had a single crash since.

Blogsome Mention

creativepro.com - Putting Your Best Blog Forward Smith Jackson, over on creativepro.com, has written a nice article on how and why to blog: it’s fairly heavily pointed towards Blogger, but there is a mention of Blogsome, and more importantly, my site is the example of a Blogsome blog linked to. I only noticed because of a referer hit, so, welcome to all of my new visitors who came from that direction! If you are keen on signing up with Blogsome, please do so. It costs nothing, but be sure to sign up in the Forums too, and have a look at some of the features (and caveats) of this service. I’m a very happy customer with Blogsome.