Jason Leveille’s Blog

Beauty’s where you find it

Archive for June, 2008

jQuery is an ultimate time saver

jQuery took what would have been a 4 - 6 hour job ordeal and turned it into 10 minutes of pure enjoyment. Read on.

One of our clients at work has a site which is maintained with Dreamweaver (DW) templates and Contribute. If there is anything I have learned about this combination, especially DW templates, it’s that updating templates/libraries and pushing those updates to pages can become increasingly painful as a site grows. This particular client insisted on the template/Contribute route, and at the time we couldn’t make a solid argument about why they should not pursue this solution to content management (we now have that argument). We are on a maintenance contract with this client and once per week we have requests to update content. Because I did the initial setup, and because I have the most experience with DW, this job falls on my plate. Here’s the rough flow of data management / updates.

  • We get a request to update the xxx section based on the yyy template.
  • We checkout the xxx section pages, and the yyy template. Some sections have 100+ pages. In total this site has ~600 pages.
    • With each page checkout, DW performs a check to see if the page is already checked out.
    • DW checks the page out.
    • DW updates a lock file indicating that the pages is currently checked out.
  • Templates/Libraries are updated and changes are pushed out to files.
  • Files get checked back in (and locks are removed, etc)

This process is time consuming, slow at best, and very frustrating. Now I would normally be working on other tasks while files are being checked in/out, however that’s not the point. This whole workflow makes we want to vomit.

Today we had a request to add a footer to each page in the site, where previously there had been no footer. That’s an update for every template file, and every page in the site. You might be thinking, why didn’t you initially add markup for an empty footer, or at least add an include that pointed to an empty file? We didn’t, but that is a good idea. Instead, I took what would have amounted to 4 - 6 hours worth of mindless, brain numbing work (believe it or not, it would have taken 4 - 6 hours), and instead implemented a javascript/php include solution. This took about 10 minutes. Here is the markup.

$.get("/assets/php/includes/footer.inc.php", function(data){
   $("#wrap").after(data);
});

As you can see, I created a footer include file, used jQuery’s get method to retrieve the contents, and inserted those contents after the main wrapper div. I chose to pull the contents of the footer from an include file in order to make future updates of that content more manageable. I wouldn’t want a future developer pecking around in the JavaScript just to update the footer. That would be just plain wrong.

Conclusion

In the world of web development implementation typically isn’t the issue. Figuring out the proper solution usually takes more time. What I’ve done here isn’t rocket science, but it did save me hours of time, while not sacrificing future application maintenance. I can live with that.

  • 0 Comments
  • Filed under: JavaScript
  • How cool is this?  A tool to visualize the commit history of a software project.  The project in this case is the Eclipse IDE.


    code_swarm - Eclipse (short ver.) from Michael Ogawa on Vimeo.

     

  • 0 Comments
  • Filed under: Miscellaneous
  • Corey and his Partner


    IMG_0156

    Originally uploaded by Family Leveille

    My brother Corey is a k-9 officer with the Seattle Police Department in Seattle, Washington, USA. He’s been working with his dog for less than 6 months, and he says that they are getting along great. It stinks that he is all the way on the other side of the US, but things are going great for him so I am happy. We’re both traveling to Maine (born and raised in West Enfield, Maine) in a few weeks to hang out with family … and to have a few beers.

  • 0 Comments
  • Filed under: Miscellaneous