• RSS
  • Email
  • Twitter

Improved JavaScript Validation (repost)

Posted by Matt on Sun, Jan 31 2010

This article was written by me and originally published on February 12, 2008 on PHP Architect's C7Y site.  Since that site is no longer around (meaning this article is currently homeless) and their one year exclusive rights expired long ago, I figured why not re-post it here.  The concepts and code in this article eventually evolved into my CakePHP JS Validation Plugin.

 

Your social video ad widget mashup is ready to be unleashed to the public.  Conscious of all the latest SQL injection and cross scripting attacks, you've locked down every form field.  Before the big launch, you enlist your buddy/co-worker/significant to do some user testing. 

After being impressed with your innovated use of a gradient within a gradient, they manage to find the user registration form.  It's just two fields, username and password.  What could go wrong here?

Your tester is feeling spunky and enters the username "D'shiz" and clicks the Join button.  The submission is whisked off across the internet to your co-located server where your stringent validation catches the disallowed apostrophe in the username.

You give a small fist pump when you see the form returned.  Across the top is a concise, highlighted error message detailing the problem.  To make sure there is absolutely no confusion you also mark the username label red.  Your tester has no trouble figuring out the issue and changes their username to "Dshiz".  Again the form is sent and again it is returned.  This time with the error "Your username must be at least 6 characters long".  Your tester changes their identity to "Dshiz49" and re-re-submits.  Ooops.  They forget to re-enter their password.  Your app had been clearing it out every time as part of your uber-security approach.

Finally the fourth submit gets it right, but in the process you wasted three page loads and the precious time of your test user.  So how can we improve this scenario?  Ajax validation is one option, but that can be overkill for many tests.  None of the rules used in this example need the server or database to validate.  If you were checking the availability of a username, that would be another story.

 

JavaScript validation has been around for years, but it's often poorly done to the point where it detracts, rather than add, value.

Let's lay out some requirements for good JavaScript validation.

Seamless To The Developer

First, keep the programmers happy.  It doesn't make sense to maintain two sets of validation rules.  Instead pull the rules from the same source that is used for server side validation and convert them to JavaScript for the client side.  Obviously not all rules can be applied with JavaScript, so you'll need to filter them.   If your rules are a mix of functions and regular expressions, you can use PHP's function_exists function to get just the regular expressions.

Seamless To The User

JavaScript alerts are not seamless.  They are annoying.  To be seamless, the feedback to the user must look the same as if the user submitted the form and the server responded.  In this scenario, we'll assume you're using an unordered list with the id "errors" to display the messages.The first step to building re-useable client side validation is organizing your validation rules.  Regular expressions are great, since they can handle many different validations and work in both PHP and JavaScript.  Here a couple that will help us in the example above.

define('RULE_NOT_EMPTY', '.{1,}');
  define('RULE_ALPHANUMERIC', '^[\w\d]{0,}$');

Hopefully you have a model class with all your rules defined or some other method of keeping them organized.   Unfortunately, everyone's system will be different, so for this article we'll want to get the rules in a keyed array with the format RULE => MESSAGE, such as:

$validation = array(
    'username' => array(
      RULE_NOT_EMPTY => 'You must enter a username.',
      RULE_ALPHANUMERIC => 'You may only use letters and numbers in your username.',
      '.{6,}' => 'Your username must be at least 6 characters.'
    ),
    'password' => array(
      RULE_NOT_EMPTY => 'You must enter a password',
      RULE_ALPHANUMERIC => 'You may only use letters and numbers in your username.',
      '.{6,}' => 'You password must be at least 6 characters'
    )
  );

Don't worry if your validation scheme doesn't match, you can always write a function to convert from your format.  Notice that in addition to the shared rules, we can add a custom rule created just for a particular field.  To simplify the JavaScript and handle cross browser issues, I'll use the jQuery library.   The JavaScript part works in two pieces.  First, a static JavaScript function that will take in the form and the rules and do the validation.  This will live in an external js file, such as common.js.

function validateForm(form, rules) {
    //clear out any old errors
    $("#errors").html("");
    $("label").removeClass("error");
    
    //loop through the validation rules and check for errors
    $.each(rules, function(field) {
      $.each(this, function(rule) {
        var val = $.trim($("#" + field).val());
        var exp = new RegExp(rule);
    
        //check if the input exists and violates rule
        if ($("#" + field).attr("id") != undefined && !val.match(exp)) {
          //add the error message
          $("#errors").append("
  • " + this + "
  • "); //highlight the label $("label[for='" + field + "']").addClass("error"); } }); }); if($("#errors").html() != "") { return false; } return true; }

    The second JavaScript part is the rules for the form that is being displayed.  This code is generated by a PHP function and included directly in the html output of your page.The form described above is pretty basic.  It could look something like this:

    <form id="appFrom" action="#" method="post">
        <div>
          <label for="username">Username</label>
          <input id="username" name="username" type="text" />    
        </div>    
        <div>      
          <label for="password">Password</label>      
          <input id="password" name="password" type="password" />    
        </div>    
        <div class="submit">     
          <input name="submitForm" type="submit" value="Submit" />      
        </div>  
      </form>

    We want to apply the rules described above to this form, in a way that is unobtrusive to the original code.  First thing we'll need to do is convert the PHP rules array to JavaScript.  This can be done with the PHP function json_encode.  PHP's JSON functions are included as of version 5.2.  For older versions you can use the JSON PECL extension or code your own version of the function.

    The other critical part is to trap the submit of the form.  You could do that by altering the form tag with an onsubmit, but instead we'll use jQuery's "submit" function, which can be placed anywhere in the html.  Using JavaScript validation does not require the user to have JavaScript on their browsers.  User's without JavaScript support will simply submit the form as normal and the server will handle the validation.

    These two requirements can be encapsulated in a single PHP function.

    function clientValidation($rules, $formId) {  
        $output = array();
        $output[] = '<script type="text/javascript">';    
      
        //convert the rules array into javascript  
        if (function_exists('json_encode')) {
          $output[] = 'var rules = eval(' . json_encode($rules) . ');';
        } else {    
          exit('This code requires PHP JSON support');     
        }  
      
        //catch the form submission  
        $output[] = '$(document).ready(function() {';
        $output[] = '$("#' . $formId . '").submit( function() {'; 
        $output[] = 'return validateForm($(this), rules)';
        $output[] = '});';  
        $output[] = '});';    
        $output[] = '</script>';    
        echo implode("\n", $output);
      }

    To use the JavaScript validation on our form we only need to include the external JavaScript file and call the function above.

    clientValidation($validation, 'appFrom');

    On the client side, when the user submits the form, it is intercepted by the new validation routine.  The supplied rules are looped through, and if there was a matching input field the rules are applied.  Fields that fail a particular test have their labels assigned the CSS class "error".  The message is also added as a <li> element to the errors list. 

    At the end of the validation, if any of the fields failed, the form is stopped from being submitted.  The user can then fix the errors and attempt to re-submit, which is the same process as presented in the original scenario.  Now however the advantages are that the errors are shown instantaneously, as there is no longer any server interaction or page loads.

    We now have a powerful, re-usable client side validation system that can be included in single PHP scripts or converted for MVC frameworks. 

    This type of validation should be used in addition to server side validation.  This code does not protect against users without JavaScript support or users who are attempting malicious attacks.

    Leave a comment

    How Much Money I Made From Side Projects In 2009

    Posted by Matt on Wed, Jan 13 2010

    Last years version of this post was the most read post on this site for 2009.  It got 6500 views on Jan 7th, when it was featured on Hacker News and 11k views for the year.  Let's see if we can make magic again!

    Gone Fishing

    All the sites listed as "The Losers" last year are gone.  I put them in a boat with Al Neri, sent them fishing on the lake and they never came back.  No one noticed or cared.  I probably would have just let them be, but I switched hosting from DreamHost to SliceHost and couldn't even be bothered to move them.

    Hanging Around

    music.rsstalker.com

    music.rsstalker.com is a site that generates a custom RSS feed for new album releases.  Yes, I know iTunes probably already does this, but some of us don't use iTunes.  Oh and it doesn't work at the moment (I'll explain below, but the short explanation: I suck and I'm lazy).  I had hoped this site would make a little bit of money - the links in the feeds are affiliate links to Amazon.  Since $33 qualifies as "a little" I guess you could say I reached my goal.  Also I spent no time marketing or promoting it, so it's not like people will magically start knowing about it (although that would be awesome).

    later.rsstalker.com

    later.rsstalker.com is a bookmarklet that adds the page you're currently viewing to a RSS feed so that you can remember to go back later.  Frankly this is the awesomest thing I've ever done.  And it's retardedly simply to boot.  I use it multiple times per day, which alone makes it a winner.  Although now I realize that the "Recently Saved" section could be renamed "Recently Saved by Matt", since I'm the only one that uses it.  That could get embarrassing if I start saving links to porn or Java sites.

    The Winners - Still Mostly Winning

    rsstalker.com

    rsstalker.com generates a custom RSS feed to track price changes on Amazon.  I make money when people click the links and buy shit from Amazon. 

    Here's the story of why this site was broken for a month and music.rsstalker.com is still broken.  On August 15th Amazon flipped a switch that made all requests to their Product Advertising API require authentication.   They announced the change on May 8th, giving sites that depend on the API (like mine) plenty of time to adjust.  That is if they saw the announcement.  I lived in blissful ignorance of the change until Sept 12th, when I came to realization: "Hey, why the fuck haven't I gotten any price change notifications for the Amazon wishlist that I'm tracking through that awesome site rsstalker.com?"

    I fixed it that day (SVN log message: "FU Amazon"), but the damage had been done.  Or had it?  Oddly, one of the reasons I didn't notice anything was wrong was because it was still getting orders.  Check this out: Aug 15th to Sept 12, 2009: 30 items, $1031 Amazon revenue, $58 referral fees.  Now check out the same time period for 2008: 32 items, $1178 Amazon revenue, $76 referral fees.  Not all that different.

    What about the rest of the year?  Uh, not that great.  Here's a table of the last three years:

    Year # of Items Amazon Revenue Referral Fees
     2007  1048 $68,351
    $3,357
     2008  1029 $73,203
    $3,444
     2009  1293 $51,860
    $2,833

    The two things that jump out are the nice boost in number of items sold (+264) and the drop in how much they sold for.  In 2008 the average item was $71 giving me a referral fee of $3.34.  In 2009 that dropped to $40 for a referral fee of $2.91.  You can see this reflected in the type of items ordered.  We used to get a lot of HDTV and digital camera sales, but hardly had any over the last few months of last year.  Maybe it's a reflection of the economy or maybe it's just that everyone already has 17 HDTVs.  

    Either way, I'm enthused by the growth in items ordered after being stagnant from 2007 to 2008.  I don't promote this site much and the maintenance is minimal (when Amazon isn't fucking with their API), so it's pretty much all gravy.  Gravy that I use to fill my bath tub and swim around in like Scrooge McDuck.  But then I have to shower immediately after, because it isn't socially acceptable to walk around smelling like gravy.

    planbookedu.com

    Now for the ruler of my tiny web kingdom.  PlanbookEdu.com is a web based lesson planner.  There is a free version which has basic functionality and a premium version for $20/year.  In 2008 I completely re-built the site, which was a large effort leaving me little time to do much in terms of marketing or sales.  Last year I was able to add features, and still have time to take a shot at building the user base.  Here's a table of numbers since 2006:

    Year Signups Renewals New OrdersEarnings
     2006  401 0
    28
     $560
     2007  1360 21 66
     $1,740
     2008  1218 49
    88
     $2,740
     2009  2970 88 286
     $7,480

    A couple things I'm proud of in that chart.  Obviously, the huge jump in orders from 2008 to 2009.  But, also the renewal rate.  From 2007 to 2008: 49 of 87 (56%) of people renewed.  From 2008 to 2009: 88 of 137 (64%) people renewed.  If 60% renew next year I'm looking at around 224 orders as a base.

    The jump in earnings didn't come free.  I spent some cash this year doing promotion.  Note: when I say "signup" I'm talking about the free version, "order" I mean the paid version. 

    Here's what I tried:

    StumbleUpon

    I paid $50 for 1000 stumbles ($.05 each).  According Google Analytics the actual result was 887 visits (I'll assume the others had JavaScript off or GA blocked).  This resulted in 5 signups - a .56% rate.  The site average is 9.24%.  At the time I wasn't tracking the original referrer of people who went on to pay for the premium version (a user gets 30 days free to start), so I don't know if I made my money back, but it's doubtful.  Even though StumbleUpon has categories to target (I went with "Education"), the traffic wasn't very good.  

    Google Ads

    Note: As I write this post it's the first time I'm really looking at these numbers.  I'm super nervous.

    I started a campaign on August 19th and ran it off and on for the rest of the year.  In total I spent $762 for 2,696 clicks.  That works out to $0.28 per click.  Of the 2,696 clicks 409 signed up according to AdWords conversion tracking. My numbers have it at 390.  I didn't start the conversion tracking right away on AdWords or in my system, so that probably explains the number differences.  I'll use the 390 here, but the actual count is likely higher (425-450 range).  Of the 390 that signed up 86 (again this number is likely higher since I wasn't tracking originally) eventually upgraded to paid accounts.  That's $1720 in earnings on $762 of ads for a difference of +$958.  Win!

    Contests

    I ran a cheesy Twitter contest to build followers for the @planbookedu Twitter account.  Prizes totaled $150.  We ended up with a little over 400 followers (probably mostly spam).  The contest also resulted in 3 signups, but no orders.  Considering I'm not really utilizing the twitter account, this was probably a waste.

    Blog

    I started a PlanbookEdu Blog, with all the content bought through elance.com.  In total I bought 10 posts for $180.  I think the quality of the posts is solid and I still have a few left to publish.  Actual traffic has been minimal - the 10 Twitter Tips for Teachers post received the most views (320).  I don't have any stats for signups/orders referred from the blog, but I suspect it's low to none.  I look at this as a longer term play, helping to build search traffic.

    New Feature - Sharing

    Again, I don't have hard numbers on this one, but in my heart I know this is one of the top reasons for the past year's growth.  I added the ability for teachers to share parts or all of their planbooks with anyone or everyone.  This has led to two behaviors: 1) Teachers sending links to their plans to other teachers, who are introduced to PlanbookEdu for the first time.  It's a little viraly when you think about it.  2) Teachers posting links to their plans on their websites.  The intent is for parents to be able to see what's going on in the classroom, but the win for me is another inbound link, usually from a .edu or .k12.us domain (which I believe are weighted stronger by Google). 

    New Homepage

    As part of 2008's rebuild I didn't spend much time optimizing the homepage.  As a result it looked like this:

    Not great.  I spent some time reworking it to make it more conversion friendly.  You can visit the live site to see it in action, but I'll warn you: you probably won't be able to resist signing up. 

    I know what you're thinking, "Hey, I've seen that design before".  I won't argue.  It's heavily influenced from some well known web apps.  Design isn't my strong suit. 

    What's Next?

    I have a kinda secret project I've been working on that I have no idea what to do with.  I'll definitely continue plugging away with PlanbookEdu.  I started sending automated emails a week after a person signs up asking for feedback and have gotten some great responses that pointed out weaknesses that need to be fixed. 

    In terms of advertising AdWords did the best for me.  I've scaled the campaign way back at the moment, because even though school is in session, teacher's aren't really looking to change their habits mid-year.  I'll turn it back on in full force next August to October. 

    In some ways it sucks having a seasonal app that's quiet 10 months of the year, but at the same time I hardly get any support requests those months and barely have to pay attention to it.  Although it does use Amazon's S3 service, so I can't let it auto-pilot too much or next thing I'll know they'll switch up the API and nothing will work :)

    10 Comments

    CakePHP Digest #23 - Moving Day

    Posted by Matt on Tue, Jan 12 2010

    News

    Before We Get Going

    I've accumulated a lot of links since the last digest (two months between posts will do that). As a result some links that would normally be included didn't make the cut.  The good news is you'll never know if your blog post/code snippet was cut, so don't feel bad.  Although if you posted something CakePHP related since Thanksgiving then you can assume I saw it.  And if it's not included then you can assume I didn't deem it worthwhile.  So maybe you should feel bad...

    GitHub and Lighthouse

    CakePHP development moved to GitHub (Yea!) and Lighthouse (Lightwhat?).  Plus new plugins (localized and datasources), which are already on version 0.2 (that puts them on target for 1.0 around Jan 2024).

    Cake Prayer

    Via @predominant: A CakePHP Prayer

    New CakeDC

    Cake's parent company CakeDC got a fancy new design (via @PhpNut).  Also you can support CakePHP by grabbing the new migrations plugin for a $15 "donation".

    New Default CSS

    @mark_story posted a couple screenshots of what could be the new default style sheet.  HAWT!

    Sites

    validcake.com

    I actually don't think this a Cake site, but it does generate the validation array for Cake models. 

    checkoutmygarage.net

    From @modethirteen: checkoutmygarage.net - Yes, it is pretty much what you would think it is: A site for uploading pics of your garage.  I might post some shots of my garage - boxes of old baby cloths/toys piled on unused exercise equipment.  Although I don't think that's what they're going for.

    vegasorange.com

    From @mgiglesias: A site for Vegas real estate.  I used to love Vegas, but haven't been in years.  I hear it's kind of lame now and Montreal is the hip gambling spot.  Hey, speaking of Canada...

    harbourstation.ca

    From @???? (I got this from twitter, but didn't note who posted it.  I suck): A Canadian arena that hosts Canada's two most popular forms of entertainment: hockey and Gordon Lightfoot. I'll leave it as an exercise to the reader to determine which is the most popular.

    iqlink.com.au

    From @predominant: iqlink.com.au - A product info site for sweet looking ATM that dispenses documents instead of cash (or something like that).

    In The Blogs

    Loading Helpers As Needed

    Jeremy Burns has a great tip on how to load a helper for a specific action rather then the whole controller. This is nothing new, but it's worth mentioning again.

    Better Zip Code Validation

    Jamie Nay posted a short validation routine for handling various international postal codes.  This is mostly for 1.2 as the localized plugin mentioned above handles these in 1.3.

    Bye-bye $cakeDebug

    Teknoid has a post marking then of the $cakeDebug variable and some bits on how the new system works.

    Code

    Fixture Factory

    I'm going to screw up the description on this one, but here we go: Fixture Factory is a CakePHP plugin for programatically creating fixture at the top of your unit tests, rather then relying on database records or _fixture files.

    CakePHP to LI3 Bridge

    This is more of a LI3 plugin for porting Cake apps bit by bit.  Here's the official descprition:

    The li3_cake plugin allows you to develop applications that use CakePHP and Lithium together, leveraging classes and exposing resources using both frameworks in unison.

    Be honest: you threw up a bit in your mouth reading that.  That description is a "synergy" away from qualifying for the enterprisey buzzword hall of fame.

    Trees

    If you're into trees then last month must have been like Christmas for you.  Also if you're into Christmas, then last month must have been like Christmas for you.  First we have Neil Crookes TreeCounterCacheBehavior plugin.  If you're smart you're probably asking:

    @AD7six: why have a (total)child_count field at all. no-of-children = (rght - lft -1)/2 .

    And obviously the answer is:

    @neilcrookes: ah, I remember now, it's for when I add scope functionality

    @neilcrookes: when I say remember, I mean, that's the excuse I just came up with for being too dumb to realise no-of-children = (rght - lft -1)/2

    Also from Jamie Nay is his post "Adding Better Scope Limiting to CakePHP 1.2’s Tree Behavior".  One more: BTree Behavior from jas osborne, which claims to be faster then the Cake Tree Behavior when dealing with overgrown trees.

    I'm Out!

    And on that note don't forget to subscribe to my feed or follow me on twitter. As always if you think I missed something leave a comment. Or if you do something interesting and want it included in the next digest, send me an email.

    Posted in CakePHP Digest | 14 Comments

    WordPress To Croogo Migration

    Posted by Matt on Mon, Jan 11 2010

    I'd been wanting to dump WordPress for awhile. I'm extremely neutral on WordPress in general, but two things drove me nuts:

    1) It took me way to long to make simple changes to themes or plugins. Probably my own fault, since I don't really know the WordPress API. But I hated dealing with any of the related code.

    2) I had to choose between slow or crashy. I'm on the smallest SliceHost VM - which is generally fine for the dozen other sites that share it. But the two WordPress blogs felt so much slower. I tried the Super Cache plugin, which would bring down all the php-cgi processes randomly when running in "full" mode. Mostly this happened when I was composing a new post (something w/ the auto-save), but other times just randomly in the middle of the night. I was doing all that retarded shit to work around it, like running scripts in cron to check if the site was up and then restarting if need. I hate that.  I spent three hours rocking back and forth in the shower the day I turned that cron on.

    What's Croogo?

    Croogo is CakePHP CMS built by Fahad Ibnay Heylaal (@fahad19).  It is currently at version 1.2 (although I'm running trunk with no problems).  The full feature list is available on the wiki and their are a bunch of screenshots on Flickr. 

    Why Croogo?

    Because it's CakePHP based and it was released when I was at my most frustrated with WordPress. I'm really that easy.  I wanted something Cake based so it would be easy to tweak. Plus it uses Cake's theme, which I already know, so I was able to convert the old WordPress theme (with a few updates) in about 5 minutes. Also this allows me to eventually take all the (neglected) code running on sandbox.pseudocoder.com and move it here. I had been running the subdomain to keep Cake and WordPress separate.

    How To Do It

    It's actually not that hard...since I did all the work for you :)

    1) Install Croogo following the instructions.

    2) Head over to GitHub and grab the Bye WordPress plugin.  Follow the instructions.  I moved about 200 posts and 1000 comments for this site.  If you ever left a comment here please check to make sure it made it successfully.  Thanks.

    3) Create a theme (or use the default one or the one theme that's been released)

    There's Always a Catch

    Ok, so it isn't quite that easy. Here's some things to watch out for.

    1) Database character encoding.  I had some weird issues with angled quotes and em dash's. I never really sorted them out - I just fixed in the final database manually.

    2) Manually copy uploads. The Bye WordPress plugin will move the DB records for the attachments, but not the actual attachments themselves. Just copy everything in /wp-content/uploads to /app/webroot/uploads. Croogo doesn't support sub directories in uploads the moment, but it works fine with the sub directory structure that you'll be taking from your WordPress install.

    Note: WordPress references images by their full url including domain in your posts, so if you're doing the migration on a beta site (as you should) you'll still see broken images until you actually switch the domain over.

    3) Spam protection. Croogo comes with Akismet support built in, but it isn't enough to set your API key (Admin -> Settings -> Service). You also need to turn it on for blog posts (Content -> Content types -> Blog -> Comments).

    URLs

    You'll probably want to maintain your old URLs. Thanks to Cake's routing this isn't hard. Here's a couple I used:

    /archives/this-is-a-post-title

    CroogoRouter::connect('/archives/:slug', array('controller' => 'nodes', 'action' => 'view', 'type' => 'blog'));

    /2010/01/this-is-a-post-title

    CroogoRouter::connect('/:year/:month/:slug', array('controller' => 'nodes', 'action' => 'view', 'type' => 'blog'), array('year' => '[12][0-9]{3}', 'month' => '0[1-9]|1[012]'));

    /2010/01/11/this-is-a-post-title

    CroogoRouter::connect('/archives/:year/:month/:day/:slug', array('controller' => 'nodes', 'action' => 'view', 'type' => 'blog'), array('year' => '[12][0-9]{3}', 'month' => '0[1-9]|1[012]', 'day' => '0[1-9]|[12][0-9]|3[01]'));

    /page-title

    CroogoRouter::connect('/:slug', array('controller' => 'nodes', 'action' => 'view', 'type' => 'page'), array('slug' => '[\w\n\-]+'));

    Note: It's important where in /app/config/routes.php you put these lines. If a URL maps to multiple routes it will use the first one in the file. So put these all at the top or at least the top of the section they apply to.

    More Note: routes.php is included in the Croogo package, so if you do an update you could lose these changes.

    Make It Fast

    I updated my HTML Cache plugin so that it's Croogo compatible.  It generates static HTML files for pages, which are super fast to load.  Go ahead - refresh this page.  Bam!  Done!  The idea is basically the same as the SuperCache plugin for WordPress...except it doesn't crash the server.  I'll be adding that feature in a future version.

    Mini Review

    All thumbs up so far.  And since I decided to replace all the fingers on one hand with thumbs (thumbs are awesome!) that's like 6 thumbs up.  The docs are bit sparse, but if you're familar with Cake you should be able to dig in the code to figure stuff out.  Likewise the admin isn't as slick as WordPress', but it's certainly functional.  All the basic functionality you'd want for a blog is there - maybe missing some polish, but certainly working.

    Wrap

    I'd definitely recommend making the switch if you're frustrated with WordPress and would rather deal with a Cake based platform.  Plus it will give you something to blog about if it's been over a month since your last post.


    Posted in CakePHP | 6 Comments

    CakePHP Digest #22 - Don't Go Away Mad...Just Go Away

    Posted by Matt on Mon, Nov 23 2009

    News

    CakeFest IV - Somewhere, America

    The Cake team is looking for suggestions for the next CakeFest, which will take place somewhere in the U.S.A. I vote for my backyard. There's a 50/50 chance I could actually make it then.

    addons.mozilla.org dumping CakePHP

    The most trafficked CakePHP site has announced plans to switch to the PHP framework Django. Wait, Django is only for Python? So they're not only switching frameworks, but re-coding the whole site? They must have some real issues with CakePHP 1.2 and 1.3 to be making such a drastic change. Oh, they're still running 1.1? Don't you at least take a shot at upgrading before making such a major change? That's like switching to Snow Puppy from Vista without even trying Win7. That's right Cake is Windows in this scenario. Anyone have a problem with that?

    Once addons.mozilla.org is gone (also xplodsony.com is gone too), what will be the largest Cake site in terms of visits/pageviews? Post your site with average monthly visits and pageviews in the comments. Winner will get a prominent mention in the next digest, plus a feature in a future digest when it inevitably moves to Django.

    CakePHP 1.3 Alpha

    CakePHP 1.3 looks pretty awesome. If I had a high traffic site that cataloged addons for a popular internet browser, that was still running 1.1, I would think about upgrading to this version. Just tossing that out there.

    In The Wild

    blackbooksingles.com

    Hmmm...blackbooksingles.com (announced via their twitter account) is free online dating site built with CakePHP. Sound familiar?

    hardwoodinfo.com

    From @nezencreation: The American Hardwood Information Center. If you still find boner jokes funny (and who doesn't!), go to the homepage and read the rotating flash part and pretend all the text is about THAT kind of hardwood. My favorite: "Nature's Brilliance Has Created A Magnificent Material - Eco-Friendly, Durably, Asthetically[sic] Pleasing". I can neither confirm nor deny that this kept for entertained for a solid ten minutes.

    andrw.net

    A Croogo powered blog from @andruu: andrw.net and damn is it sweet looking. I have to be careful and not say too much nice stuff or WordPress will get jealous and take down my server.

    In The Blogs

    Ajax Pagination in 1.3

    Mark Story has a post showing how to do Ajax pagination with Mootools in CakePHP 1.3. Although it seems like it would be just as easy to do with any of the other supported JavaScript frameworks. We could be seeing this in our favorite browser addons catalog in a matter of days if they didn't need to switch the entire underlying framework and coding language first. Instead it'll be roughly 2012 before they're back to 50% of the functionality they have now.

    Routing Explained

    If you've read the Cookbook entry and the "Secrets of Admin Routing" article and still don't get it, now we also have "Routing Explained". No more routing articles. I'm putting my foot down. Unless you still really, really don't get it. Then you get one more. But that's it. And then right to bed for you.

    Get rid of .htaccess

    Ryan Pendergast has a nice article on the bakery showing to speed up your Cake site by moving the mod_rewrite rules that are in your .htaccess file to Apache's config. Another speed up tip: Remove Apache, along with your .htaccess files and install Nginx.

    Code

    Archivable Behavior

    Sohaib Muneer release a new Archivable Behavior. It's kind of like some of the "Soft Deletable" behaviors that are floating around, expect instead of flagging the row in the database it moved it to another table, so that the original table doesn't get too cluttered. I like to call this "The Table of Misfit Rows".

    Searchable Plugin

    This one is from Neil Crookes. It's a plugin for doing site searches, without having to rely on a search engine. I haven't had a chance to play with it yet, but I have no doubt it's completely awesome.

    I'm Out!

    And on that note don't forget to subscribe to my feed or follow me on twitter.

    As always if you think I missed something leave a comment. Or if you do something interesting and want it included in the next digest, send me an email.

    Posted in CakePHP Digest | 14 Comments
    1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9

    Categories

    • CakePHP
    • CakePHP Digest
    • Screencast

    Popular Posts

    • CakePHP Digest #21 - Whose Left?
    • CakePHP Digest #22 - Don't Go Away Mad...Just Go Away
    • CakePHP Digest #23 - Moving Day
    • How Much Money I Made From Side Projects In 2009
    • CakePHP Digest #19 - The Holy Shit Do I Have A Ton Of Links Edition

    My Sites

    • PlanbookEdu.com
    • RSStalker.com
    • Later.RSStalker.com

    My CakePHP Plugins

    • Asset (JS/CSS) Packager
    • Custom Find Types
    • Html Cache
    • JavaScript Validation
    • Site Status Page
    • Static User
    Copyright © 2010 PseudoCoder.com, All Rights Reserved.
    Powered by Croogo, Built with CakePHP