Your Next UK Bus / My First Widget

Discussion in 'Mac Programming' started by tyr2, Feb 18, 2007.

  1. macrumors 6502a

    tyr2

    Joined:
    May 6, 2006
    Location:
    Leeds, UK
    #1
    I've finally completed my first Dashboard widget for public release. As it's my first one I thought I'd post it here and see if anyone has any comments?

    It's displays live bus stop timetable information for bus stops in the following UK regions:

    West Yorkshire
    South Yorkshire
    Belfast
    Cardiff
    Gloucestershire
    Oxfordshire
    Surrey
    Kent

    Download it here : http://widget.newswall.org.uk/yournextbus/
     
  2. j26
    macrumors 65816

    j26

    Joined:
    Mar 30, 2005
    Location:
    Paddyland
    #2
    Looks cool. Any chance of adding Dublin to it?
     
  3. thread starter macrumors 6502a

    tyr2

    Joined:
    May 6, 2006
    Location:
    Leeds, UK
    #3
    All the regions above use the same system to provide the timetable information. Since I live in Leeds I started out making a widget for West Yorks after that the others were trivial to add.

    It may be possible to add Dublin but I expect they use a different system, do they have a website with live bus information?
     
  4. j26
    macrumors 65816

    j26

    Joined:
    Mar 30, 2005
    Location:
    Paddyland
    #4
    I'm not sure if they have a live website, but I know there's a text based service
    Here's the website. I wouldn't know what I'm looking for. If you could find anything you can use it would be great.
     
  5. thread starter macrumors 6502a

    tyr2

    Joined:
    May 6, 2006
    Location:
    Leeds, UK
    #5
    I've had a look round the site and, unfortunately, I can't see anything that I could use to make this work for Dublin.
     
  6. j26
    macrumors 65816

    j26

    Joined:
    Mar 30, 2005
    Location:
    Paddyland
    #6
    Oh well,

    Thanks for having go.
     
  7. Administrator emeritus

    xUKHCx

    Joined:
    Jan 15, 2006
    Location:
    The Kop
    #7
    Hey that is pretty cool, didnt expect it to be a UK thread let alone a one that is relevant to me, thanks from Sheffield.
     
  8. thread starter macrumors 6502a

    tyr2

    Joined:
    May 6, 2006
    Location:
    Leeds, UK
    #8
    I should have put 'UK' in the thread title. Anyway, glad you like it, hope you find it useful.
     
  9. macrumors 6502a

    Dunepilot

    Joined:
    Feb 25, 2002
    Location:
    UK
    #9
    Nice work - I'll tell my brothers about it - one's in Oxford, the other's in Cardiff.
     
  10. macrumors 6502a

    Joined:
    Dec 4, 2006
    Location:
    Katy, Texas
    #10
    Sounds pretty neat. Too bad it doesn't apply to Katy, Texas!!

    Would you mind sharing any of your experiences writing the widget? How did you tackle it? Is there an API where you are grabbing the information, or are you just bringing up the page programmatically and parsing the info?

    I want to write a widget too, but am not sure where to start. Any info you care to share would be appreciated.

    Thanks, Todd
     
  11. thread starter macrumors 6502a

    tyr2

    Joined:
    May 6, 2006
    Location:
    Leeds, UK
    #11
    Sure. It's coded with the beta version of DashCode which helps a lot when it comes to doing the interface design as it has all the widget specific features that you can just drag/drop onto the interface, like the scrollable areas. DashCode is clearly still a beta application tho and some things don't work as well as they might.

    After designing the widget the rest of it is just some JavaScript and some Perl code. The JavaScript manages the widget side of things, such as setting preferences and running the refresh timer. To get the timetable the JS calls a Perl script which uses 'curl' to request a web page with the details on.

    Curl ships with OS X, it's a handy way to interface with webpages from the command line. The pages all come from acislive.com who provide the timetable service to the regions above. The Perl script parses this a bit then hands it back to the JS which displays it. It may have been possible to do all the things that the Perl script does in JS but it just seemed easier to do in Perl and as it's there, why not use it.

    That's about it really.
     
  12. macrumors 6502a

    Joined:
    Dec 4, 2006
    Location:
    Katy, Texas
    #12
    Thanks so much! Sounds easy!

    Todd
     

Share This Page