Tuesday, December 8, 2009

Put the clamps on your friends

Ever invited your goofy photographer friends into your album, only to see your collection of carefully crafted compositions get tainted by their trigger happy, underexposed, dubiously angled or simply unrelated shots?

Now you can safely invite them into an album without the permission to upload, invite, share or tag. We thought it'd be fair to still allow them to comment on your nice photos and videos. The option can be found on the invite page as well as inside the tagging feature. Check it out!

This has been a highly requested feature, so we're happy to know your comments and/or suggestions to make it even better; a simple "good job" comment is also welcome of course ;-)

Saturday, November 21, 2009

jQuery conditions

One of the powers of jQuery lies in its ability to chain actions on a set of elements. Sometimes, the chain needs to be interrupted to apply specific actions based on a condition. For instance, when you construct menu items on-the-fly, you may want to apply a CSS class or add child nodes for a few of those items.

Introducing the doif() extension:

$('<li />')
.text('menu item #1')
.doif(my_condition)
.addClass('selected')
.end()
.appendTo(menu)

All conditional statements start with doif(<condition>) and stop with end(), just like how all the other "destructive" jQuery operations work.

And here's the internal code:

(function($){
$.fn.doif = function(cond)
{
return this.pushStack(cond?this:[]);
}
})(jQuery);

Wednesday, October 28, 2009

We're liking it

The last few weeks were spent hunched over new designs and features we wanted to introduce in the near future, hopefully in time for Christmas. As a result, not much actual development was done despite many suggestions from our respected users.

However, over the last week or so we have managed to get a few new features in:
* Like it - a feature that allows users to indicate photos or videos that they like; in future we will also allow filtering based on this rating so that you can make muvees with only the best material ;-)

* Date changer - manually update the date at which a photo or video was taken from the view mode; in future we also want to offer our users a batch update mode to change the date of more than photo or video at a time.

* Facebook updates - the Facebook Connect feature looks nicer now ;-)

In the meantime we've also fixed a few bugs here and there, such as Windows Live and Gmail contacts import.

Another update will be scheduled in a few weeks, hopefully with more changes! And keep that feedback coming ;-)

Tuesday, October 27, 2009

IE6: we don't like you no more

IE6 is really a developer nightmare: a large part of the time we spend building shwup, is used to address cross-browser issues, with IE6 taking the largest chunk of time.

IE6 really is old technology. IE8 is now released, and there is a plethora of other modern browsers out there, such as Firefox 3.5, Safari, Opera, etc.

For that reason, we will officially be dropping support for IE6, from January 2010. IE6 users (if we still have any by then) will probably be greeted with a message inviting them to upgrade their browser to access shwup.com .

Monday, May 25, 2009

Authorization header passing in Apache/FastCGI

When PHP is running as an Apache module, any Authorization header is passed as HTTP_AUTHORIZATION inside $_SERVER; this, unfortunately, stops working when you switch to FastCGI.

The guys over at Best Host Ratings have a simple solution using mod_rewrite:

#Remove this part if you always have this module loaded
<Ifmodule !mod_rewrite.c>
LoadModule rewrite_module modules/mod_rewrite.so
<IfModule>
RewriteEngine on
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]

You can put this piece of configuration in your virtual host definitions or closer to where you really need it.

Thursday, May 21, 2009

Paypal IPN issues with Unicode

I've spent several hours today trying to figure out why I couldn't verify the IPN data I was receiving from Paypal.

The code itself couldn't be easier:

return 'VERIFIED'==file_get_contents(
'https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_notify-validate',
false,
stream_context_create(array(
'http'=>array(
'method'=>'POST',
'header' => 'Content-Type: application/x-www-form-urlencoded',
'content' => file_get_contents('php://input'),
)
))
);


After reading Jacques' article regarding this issue, the source of my problems was easily found. As it turned out, the "Language Encoding" inside our profile page was miraculously set to "Chinese Simplified"; changing this to UTF-8 made the problem go away immediately.

Thursday, May 14, 2009

Splitting a jquery object into 2

In shwup, using jquery, we had to handle a few times situations where we need to apply some actions on some elements, and other actions to all other elements. Typically, you'd do it with a filter, and then the same filter in a not(). For example:
myJquery
.filter(".important").css('background', 'red')

.not(".important").css('background', 'yellow');

The duplication of the filter is very annoying. Here is a nice jQuery plugin that we are using, discovered last year on the jQuery mailing list in a post by Oliver:
$.fn.others = function() {
return this.end().not(this);
};

Now we can do:
myJquery
.filter(".important").css('background', 'red')
.others().css('background', 'yellow')

And that works regardless of the filter function used, including is() and not().

I recently had to implement shifting some elements of a jquery set ahead of all other elements. This is using a set of floating nodes, not attached to the DOM _yet_. Using the nice 'others' plugin, here is some code to do that:
var importants = myJquery.filter(".important");
myJquery = importants.add(importants.others());