[Extension] Jsurlmanager

I can’t yet post this to the official plugin repository so I thought I’d share it here to get any feedback you guys might have.

There hasn’t really been a satisfactory way to use all of the nifty Url Rules with createUrl, in both Frontend Javascript code and to generate urls on the backend.

Current solutions aren’t particularly elegant, either you can write Javascript code in your view files and echo the URLs where appropriate (messy) or pre declare URLs you plan on using at the header of your page (tedious).

To solve this problem for the current project I’m working on I created an implementation of the Yii UrlManager in Javascript, allowing you to call “Yii.app.createUrl” from your Javascript code just as you would call “Yii::app()->createUrl” from your PHP code. Whilst maintaining compatibility with any rules and configuration changes you’ve made to your UrlManager (Any regular expressions must work with Javascript). No additional code changes are required to use this extension apart from loading the component in your configuration file, everything else is seamless.

You should then be able to keep your Javascript code independent from your PHP code when dealing with URL creation.

The Yii test cases for CUrlManager has also been ported over to Javascript to be sure that compatibility is maintained. Check compatibility notes in the Github README.md for more info.

Can’t post URL’s properly yet but code can be found here: github.com/Ainsleh/Yii-EJSUrlManager