Alex Bosworth's Weblog

developing search engine marketing software, living the expat life in beijing, other fun stuff.

previous projects: alchemy, swik, open source stuff, now adylitica.

Building HTML5 Webapps

In the revamp of TweetBe.at and for another contract project for the iPhone browser I’ve been working a ton with new HTML5 (+CSS3) features, and I’m finding them very very useful in building rich web applications, although new capabilities are not without their perils.

In TweetBe.at I pretty much run the gamut of HTML5 features available today, and I am happy Firefox 3.6 was released, because for a while things were not working perfectly on Firefox due to lack of feature support.

The new features I found most useful are:

  1. Linear Gradients
  2. RGBA colors
  3. Offline storage
  4. Input placeholder
  5. Input type=number|email|search
  6. Box shadows / Text Shadows / Rounded Corners
  7. Input autofocus
  8. :empty pseudoclass
  9. Attribute searching
  10. Nth child and not()

Linear gradients are killer and super easy. It’s not too hard of course to do your own gradient, but gradient support in the browser makes it 100% trivial.

I do gradients with 3 lines:

background-color:#D2F796 (this is for legacy browsers)

background:-moz-linear-gradient(270deg, #D2F796, #B2D776);
background-image:-webkit-gradient(linear,0 0, 0 100%, from(#D2F796), to(#B2D776));

I started doing gradients like this in Chrome, and was happy to see that FF3.6 supports them too, with a better syntax in my opinion.

RGBA colors are also easy, but you probably wouldn’t use them too much. I used them only once in TweetBe.at - essentially if you want a color to be transparent - such as a background, but not the content: you use RGBA instead of opacity.

RGBA is used simply like color:rgba(200,200,200,0.8) - and you can use it wherever color is accepted. Happily this format is the same on both webkit and gecko.

Offline Storage is pretty amazingly cool and I’ve been using it since the original TweetBe.at to bring native like richness to web apps. The premise is that you can store variables locally without the extreme drawbacks to saving them in cookies.

The syntax is the same in all browsers that support it (chrome, safari, firefox, opera 10.5 alpha)

localStorage.setItem(key, value) //sets the item

localStorage.getItem(key) // gets the item

localStorage.clear() // empty cache

I typically only use localStorage, I don’t really see a lot of point to sessionStorage. With localStorage I use JSON.stringify on vars to save them for the next page load.

LocalStorage is a powerful feature: you can easily hang yourself on it. Three big things to beware of are:

  • concurrency - like any cache you can have a race condition where you cache prematurely;
  • corruption or old state - a webpage is pretty stateless, but if you have a bug or don’t clean up as you move through versions, people can be easily stuck with bad data that can’t be easily gotten rid of and can cause hard to diagnose bugs.
  • storage limitation - if you can increase this limit, I don’t know how. Yes I have run into it with TweetBe.at and I have no good solution for this one other than try not to waste space.

Input Placeholder is pretty damn awesome. Basically if you want to put some text in an input box explaining what it’s for, just do

<input placeholder=”Type a user name here” type=”text”/>

And if the input is empty it will have your placeholder instead, all done by the browser for free.

Input types are vastly expanded in HTML5, they just went nuts. Basically only the iPhone supports them though - it changes the data entry keyboard to suit the type. This only works on 3.1 iPhones though.

Shadows and rounded corners pretty self explanatory:

-moz-box-shadow:1px 1px 1px black;

-webkit-box-shadow:1px 1px 1px black;

Makes a shadow. Mozilla can do 4 values, which effects the shadowyness of the shadow.

-moz-border-radius:5px;

-webkit-border-radius:5px;

Makes rounded corners. Webkit and Mozilla annoyingly use a totally different syntax for the individual corners however. I also think that a lot of times Mozilla’s rounded corners don’t look great.

Input autofocus is like placeholder, just something that should be part of the browser. Adding the autofocus attribute to an input will make the cursor focus there on page load (like Google.com)

<input name=”search” autofocus/>

Drop dead easy.

:empty is a totally invaluable css pseudoclass that I didn’t know I needed so badly until they gave it to me. Essentially it just selects elements that are empty. This is really useful for things like empty boxes that because of padding still appear as ghost boxes.

div { padding:5px; background:red; }

div:empty { padding:0; }

Now you can empty out a div and it display as a little 10px red box that you don’t need. I ran into problems using *:empty or element:empty { display:none; } - so I don’t use those.

Attribute searches can be done in CSS3, using a regex like syntax: element[foo^=”bar”] matches every element with attr foo that starts with bar. This stuff can be really useful:

a[href$=”.pdf”] { background-image: url(icons/pdf.png) no-repeat; }

To show icons next to all pdf links to tell people don’t click on them they will launch the evil Adobe reader and the Chinese will check out all your source trees.

Not and nTh child are useful for a similar reason, it basically moves towards a declarative query language for the DOM.

li:nth-child(2n + 1) { background:red; }

Makes it very simple to add every other row highlighting.

These features are only some of the CSS3 and HTML5 features, but I’ve found them the most useful so far. Of course IE doesn’t support any of this stuff and probably crashes if a page doesn’t have at least one <font> or <marquee> tag, so if you want to support browsers that hate you, keep it in mind that you have to code some workarounds for Redmond.

Comments (View)
Comments (View)
Comments (View)

Talking Carl is an app with a cute figure ‘Carl’ who listens to what you say and then says it back to you in a cute ‘Carl’ voice. You can also poke or tickle him and watch his reaction. It’s a $1 app.

The main reason this app is great is the character design, done by a French 3d artist Yann Le Coroller

The app hasn’t got a lot of attention, but to me it’s a unique concept that has great art and a good example of an indie project that I’m happy to have on my iPhone.

Comments (View)
I made a new Twitter tool: http://dropital.com/.
The basic idea is: share a collection of files with your Twitter followers.
There are no limits to the files you can share, but there are some built in modes for photos and mp3s. It&#8217;s pretty simple to use: write a tweet, attach some files, and push submit.
Note: Only your followers may download what you share through Dropital, verified through Twitter OAuth.

I made a new Twitter tool: http://dropital.com/.

The basic idea is: share a collection of files with your Twitter followers.

There are no limits to the files you can share, but there are some built in modes for photos and mp3s. It’s pretty simple to use: write a tweet, attach some files, and push submit.

Note: Only your followers may download what you share through Dropital, verified through Twitter OAuth.

Comments (View)

(twitter) ReTweet dilemna

I’m fully in the Twitter cult now, even though I may have been dragged in kicking and screaming, I like tumblr but the conversation ability of Twitter really takes things to a level above blogging…

I’m still working on http://tweetbe.at/ , which has solved a lot of the ‘noise’ problem that I had on twitter - but it’s been challenging work given the limitations of twitter’s API and the problems inherent in writing a web application in pure javascript without any server code.

Now twitter is throwing a curveball at me where they want to own the ‘retweet’ and make it an official part of twitter.

To me this is pretty significant because it’s the first feature where twitter is introducing something that is impossible to do with an SMS. I don’t really count replies because you can still reply over SMS, it just wont’ provide a link back - but retweeting won’t be something you can do on your standard cell phone.

My issue with this feature though is more in that they are messing up the way I use Twitter. When I retweet I add info! If I retweet someone I add something like ‘cool’ or ‘this sucks’. I sometimes credit multiple people, or a chain of people. I sometimes alter the message to make it more readable or relevant.

In the future, this will not be possible, retweets will only be an identical copy of the original message and un-alterable. They won’t credit who you heard it from, they will credit who originally said it.

Of course I can just keep doing things the same old way: just post a copy of someone’s message and add “RT” to it. All I will lose is the metadata with the id of the original message.

My dilemna is that it confuses my twitter tool: do I keep the RT functionality that copies a message for you, or do I add a new RT functionality that doesn’t copy anything and just adds a pointer to your stream?

The answer might be to let you choose to edit a retweet which then disables the ‘official’ support, but it sounds a little clunky to me.

Comments (View)
Working on a totally new look and feel for http://tweetbe.at/

Working on a totally new look and feel for http://tweetbe.at/

Comments (View)
11 days and 50 versions later tweetbe.at is coming along great, thanks to everyone who has tried it and especially thanks to those who have given me feedback - @cleverclogs and @spinchange for the most part.
You can see from the screenshot I&#8217;ve added new styles support, also noise fighting tools including a &#8216;mute words/phrases list&#8217; and &#8216;1 click block&#8217;.
Tweetbe.at started as a way to emulate IRC channels over Twitter, but now my goal has shifted somewhat, now I want to make Twitter into a full fledged instant chat client, both 1 on 1 and many to many. That includes everything from join/part and presence notifications to emoticons and theming.
The major barriers are basically Twitter&#8217;s strict limitations, and some data structures missing from Twitter&#8217;s web implementation. I&#8217;m hoping that other Twitter developers will start coming up with a portable (and extensible) &#8216;groups&#8217; format, since they all seem to be independently developing the same feature more or less.

11 days and 50 versions later tweetbe.at is coming along great, thanks to everyone who has tried it and especially thanks to those who have given me feedback - @cleverclogs and @spinchange for the most part.

You can see from the screenshot I’ve added new styles support, also noise fighting tools including a ‘mute words/phrases list’ and ‘1 click block’.

Tweetbe.at started as a way to emulate IRC channels over Twitter, but now my goal has shifted somewhat, now I want to make Twitter into a full fledged instant chat client, both 1 on 1 and many to many. That includes everything from join/part and presence notifications to emoticons and theming.

The major barriers are basically Twitter’s strict limitations, and some data structures missing from Twitter’s web implementation. I’m hoping that other Twitter developers will start coming up with a portable (and extensible) ‘groups’ format, since they all seem to be independently developing the same feature more or less.

Comments (View)
Irish pub, beijing china, us independence day bbq

Irish pub, beijing china, us independence day bbq

Comments (View)

Tweetbe.at live twitter chat

I’ve been working on a side project for Twitter, which I discussed in a previous post - what it is is a live chatstream for twitter, which builds on the #hashtag idea

With tweetbe.at you can see who else is watching a #hashtag and chat with them. You can also fold in other searches or hashtags, or posts from other users into the stream:

The idea is based on the similarities between IRC and twitter, this tries to bridge the gap and add some of the benefits of IRC to twitter. In IRC you can start chatting without having to build a network of friends to chat with, and you can chat about some subjects at some times and then leave them alone at other times.

Right now it’s a proof of concept, but everything should be working mostly ok, and it features oauth integration so you can chat directly from tweetbe.at

You can change channels via the location hashtag ie: http://tweetbe.at/#tv - http://tweetbe.at/#javascript - http://tweetbe.at/#socialmedia

Channels can have added users, searches, hashtags, and also block users from appearing.

Give it a try and let me know what you think!

Comments (View)