As a full time developer, I search the web... a lot. If you are writing a lot of new code without at least searching to see what exists, you're either getting paid by the hour (or line of code), stubborn or a glutton for punishment. Even if I don't use it, I can get some guidance on what someone else tried, and how it worked out before I start coding. Granted, it usually requires a lot of refactoring the code to my standards or needs, but it's a great start.
As I was thinking of things I wanted to put on my site, I realized it would be nice to share my "favorites"...sort of. If I found something useful, I wanted to be able to show what it was, how I found it useful and where someone else can find it. In a way, I am also helping to promote someone else's hard work and improving their search engine visibility to return the favor of their sharing their work.
Out of this, I came up with an idea for a "Useful Links" section. I wanted to be able to add links and commentary, and also add it to my Activity Aggregator to show help show the content of the site has changed. Later, as I was using Bing, I got the idea to add some webthumbs to enhance the page graphically, so the reader would know what the site looked like before going there. I also needed to add an admin page for creating the useful links (and ultimately maintaining them -- which is on my TODO list). I'll also leave out the icon creation part, although I really need to farm out for a new cool looking icon, which is also on my list of things to do.
I'll skip the admin section, as it's just data entry fields. The process for creating the entries does change a bit, as I needed to do a few extra steps.
- Save the UsefulLink class
- Default the webthumb image to a default "safety" image in case we can't get a webthumb
- Make a request to get a webthumb image of the target site
- Once the image is retrieved, update the UsefulLink record to point to the new webthumb
- Update the Activity Aggregator to show we have a new useful link.
Step 3 is where things get tricky. How in all getout do we get webthumb images? There are controls out there you can get, and they are reasonably priced as well. But I decided to keep searching so I could write this one on my own, as it seems like an interesting challenge.
My next thought was to create my own service to do this. There's plenty of code out there, but the easiest way to do this would require some WinForms programming. Don't get me wrong, I LOVE programming WinForms. The problem is I don't want to have to install it everywhere I am at, as I need a service. I could possibly create a Web and Windows service to do this as well, but that seemed overly complex. So I did a search, and I found this, which is a service which does it for you. What's even nicer is that they expose a nice API to use. As of now, the first 100 images a month are free, and after that, the fees are very reasonable. Even though I doubt I will go over 100 images per month, I am so impressed I may pay just to keep the service going.
I was also able to find some c# code to make learning the API fast. I did end up changing it some, but in general it worked very well. You can find it here.
So when the service returns with my image (I used the medium size), I save it to a thumbs directory (had to add write permissions to the directory, or I got an obscure GDI+ error), and call a method on my UsefulLink class to update the record with the thumbnail image. I name the image with the current date and time so that the names will be unique as well.
Finally, once I have downloaded the image and updated the UsefulLink record, I add a call to my Activity class which creates an entry for the Activity Aggregator. As I add more items to throw into the Activity Aggregator, I am considering refactoring things to do some delegate multicasting for all the updates, or perhaps creating a factory where you provide class (should be easy since my business objects share the same base class) or interface, and it knows how to create the activity record instead of making individual calls. That's on my list down the road. :)
Here's what the Activity Aggrgator looks like, with a special Useful Link icon(
):

And here's what the Useful Link section (which has the webthumbs) looks like. I will only be showing 10 at a time to save web page real estate. But I also don't want to lose older links off the page. I am debating now whether to use paging, or just have a smaller hyperlink-only section below the most recent links. I am leaning towards paging, as I have a very neat service I want to implement which makes paging and sorting incredibly fast and easy (more on that someday.. I need to upgrade it to user .Net 3.5 functionality before I post it).