The Symfony Challenge: Part 3 > Hour 2,...

in case you're behind on whats happened so far:


welcome back dear readers. oh so welcome back. This is taking a lot of effort to write (more than it is to develop actually) so I tell myself there are readers. Please let there be readers.

you can dig any of the above stories (or this one if you too!), help a guy out.

okay moving on.

>Hour 2, and a bit?
Yes, I know it's odd math. lets call it hour 2.5. I'm tired. It's been a long week what with you and my project load and getting my camera back so lets agree that we have (and by we, i mean me) invested 2.5 hours into this redevelopment. mkay? good.

>So your first hour was remarkable how bout your second (and a half)?
I know some of you are waiting for the other shoe to drop. I know you're like, sure, he did that first easy stuff in no time at all now he's going to get bogged down in framework hell and his productivity will wane. Well, I'm happy to report symfony continues to make this site reconstruction a breeze. Let's find out what got done.

>okay, what got done ruzz?
I admit I spent more time here than I expected. But, I also didn't expect the amazing returns on that extra 45 mins either so I call it a win. In hour two ought five:

  • Brought over the CSS, Image files (only logo and what not), and the site Layout over to symfony.
  • integrated the layout with symfony's templates and got that first moment where it started to look like a site. Remember this is only hour 2.
  • Once the layout was in place I added his contact and collectors information to the database via the backend (remember the one I built in like 20 mins?)
  • I wrote about three lines of code and got the two text based sections working (with hard coded content id's, which must be refactored)
  • I installed the plug in sfThumbnail which is handy for generating.. thumnails!
  • I then overwrote the administration actions for adding a photo and deleting a photo to include automagic thumbnail generation at time of uploading a photo (yes photo uploads worked from the first hour!)
  • I tested this functionality out thoroughly and cleaned up some code.
  • I then rewrote the function declarations on sfThumbnail to allow me to override some stuff
  • and then i wrote a class overriding them (See the next bit for why)

>ruzz, if you have at thumbnail class why not just use it?
if any of you have spent any time with customers at all you know they can dream up the most odd and confusing (to the logical mind) requests. They just seem full of them and if i spend too much time around customers I feel as though I should have followed that promising career as a longshoreman. So here's why I had to override a perfectly good thumbnail class.

Most thumbnail generation is meant to generate square thumbnails. I think the very idea of a thumbnail is that it's square. Maybe I'm just nuts. But, the customer (who is always right, remember?) is a photographer and began trembling when he saw his precious photos being squished and contorted to a square when some were rectangles.

So issue number one is the class simply did not have the capacity to establish the proper ratio and maintain it, and it always demanded a second value (width, height). If it's going off a ratio, I don't want to have to calculate the second number just to give it to a function to do something. that's lame.

ruzz is not lame so he overrode the class. but it gets stickier.

The customer's girlfriend is a designer and designed these pages they both quite loved in which all thumbnails were of equal height but varying widths. If I wasn't going to override the class before, now I have to because the first paramater is width and i want to skip right over that, let it be decided by ratio.

Fortunately i hopped this fence once before and had a code snippet for calculating those ratios based on one value (specifically height) and I overrode the class with my own logic for how to handle the generation.

It sounds a lot more daunting than it was. But it did slow me down substantially. That's 45 minutes I coulda been watching LOST.

>okay, swell, where does that leave us?
Where it leaves us after 2.5 hours is a working backend for adding both text and photos, where new photo uploads get automagically created thumbnails. We have a front end that matches the existing site exactly being piped out through symfony and from which we can find contact and collectors information.

>2.5 hours and you sound done!
Not so fast sparky. We still have some hurdles to jump.

  • we have to unbind the content from the id by some identifier
  • we have to build some security around the backend
  • we have to get those images out of the db and make them roll on down the page in the peculiar and frustrating 3 column our customers loved.
  • we have to create a slideshow/browse type system that lets people click through the images.
  • we have to get the main page to show us the featured image
  • we have to look for ways to optimize the site and clean up any code
    • an good example of this might be, in theory, to throw an array of images into the session on first gallery load so that we don't need to summon the db every page load relating to a picture. Sounds good, but lets try it and see if it helps or hurts our performance.

>but ruzz, you only have 97.5 hours left. How can you do all that in 97.5 hours.
Oh pinocchio, you want to be a real boy--trust in the power of symfony!

>so i'm starting to see that symfony rocks hard is there more?
Well, yes my dear imagined reader there is more. The trial and error, and fudging around I did learning how to auto create thumbnails was immediately applied to the project I am working on and effectively halved the used time by getting two implementations for the price of one. Add it to another and i'm at 1/3 the time, you can see where this goes. This is possible with great ease thanks to the dedication of the symfony team making nearly everything overrideable. If it exists you can probably override it to make it the way you want it.

>I'm starting to get excited about symfony, i feel warm in my tender parts.
That's between you and your text editor. If you want to start playing yourself go over to the askeet tutorial and dig in. You can even email me if you get into trouble. ruzz on symonfy at g mail and I will try to help you as best i can.

>nice, those email spiders will never figure that one out.
I know!

>Can I hire you?
yes, yes you can. use the same email and offer me a truckload of money and fame and i'm yours.




Advertisement

Log a comment

You have to be logged in to comment. Don't have a LifeLog yet? Sign up for a better online existence now! It's FREE!