Skip to content

Instantly share code, notes, and snippets.

View mitchkramez's full-sized avatar

Mitch Kramer mitchkramez

View GitHub Profile
@redoPop
redoPop / extension_specific_route.php
Created May 27, 2011 22:59
CakePHP custom Route class that restricts a route to a single extension.
<?php
/**
* Custom Route class that restricts a route to a single extension.
* Enables you to build controller actions that are only applied to specific
* extensions, e.g., '/posts.json' goes to PostsController::index_json while
* '/posts' goes to PostsController::index.
*
* To use, drop this into app/libs/routes/extension_specific_route.php and add
* the following to the top of app/config/routes.php:
*
// loop through the 'paper' variable from Raphael JS and build up the JSON object describing all images and paths within it.
loadJSON = function(paper, json) {
var set = paper.set();
$.each(json, function(index, node) {
try {
var el = paper[node.type]().attr(node);
set.push(el);
} catch(e) {}
});
return set;