{"id":18750598,"url":"https://github.com/invis1ble/kohana-jsroute","last_synced_at":"2025-09-09T04:39:06.615Z","repository":{"id":152080121,"uuid":"4243858","full_name":"Invis1ble/kohana-jsroute","owner":"Invis1ble","description":"Client side routing for Kohana","archived":false,"fork":false,"pushed_at":"2012-05-24T20:07:06.000Z","size":132,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-26T18:05:38.102Z","etag":null,"topics":["frontend","javascript","kohana","module","routing"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Invis1ble.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-05-06T20:30:13.000Z","updated_at":"2019-12-25T20:32:20.000Z","dependencies_parsed_at":"2023-04-08T19:22:00.767Z","dependency_job_id":null,"html_url":"https://github.com/Invis1ble/kohana-jsroute","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Invis1ble%2Fkohana-jsroute","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Invis1ble%2Fkohana-jsroute/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Invis1ble%2Fkohana-jsroute/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Invis1ble%2Fkohana-jsroute/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Invis1ble","download_url":"https://codeload.github.com/Invis1ble/kohana-jsroute/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248647257,"owners_count":21139081,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["frontend","javascript","kohana","module","routing"],"created_at":"2024-11-07T17:12:34.153Z","updated_at":"2025-04-12T23:32:13.421Z","avatar_url":"https://github.com/Invis1ble.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JSRoute module\n\n## Wherefore?\n\nThe module allows to generate URIs and URLs based on server-side defined routes.\n\n## Setup\n\nPlace module in `/modules/` and include the call in your bootstrap.\nAlso, you need to include jquery plugin, like this:\n\n```html\n\u003cscript type=\"text/javascript\" src=\"/media/js/jquery.kohana.router-0.3.js\"\u003e\u003c/script\u003e\n```\n\n## Usage Examples\n\n### Generate URIs and URLs\n\nAdd your stuff to `onload` callback and pass it to constructor:\n\n```javascript\nvar onload = function () {\n    this.get('media').uri({file: 'img/logo.png'});   // media/img/logo.png\n    this.url('media', {file: 'img/logo.png'});       // /media/img/logo.png\n    this.url('media', {file: 'img/logo.png'}, true); // http://domain.com/media/img/logo.png\n};\n\nvar router = $.kohanaRouter({\n    onload: onload\n});\n```\n\nor add as property:\n\n```javascript\nrouter.onload = onload;\n```\n\nIt is assumed that on the server the route is set\n\n```php\nRoute::set('media', 'media(/\u003cfile\u003e)', array(\n        'file' =\u003e '.+',\n    ))\n    -\u003edefaults(array(\n        'controller' =\u003e 'foo',\n        'action'     =\u003e 'bar',\n        'file'       =\u003e null,\n    ));\n```\n\nBy defaults router requests all routes (except filtrated, see bellow) from the server. You may specify array of routes that you really need:\n\n```javascript\nvar list = ['foo', 'bar'];\n```\n\nand pass it to constructor:\n\n```javascript\nvar router = $.kohanaRouter({\n    // ...\n    list: list\n    // ...\n});\n```\n\nor define it as defaults:\n\n```javascript\n$.kohanaRouter.defaults.list = list;\n```\n\n### Security and filter\n\nFor security reasons (or for decrease overhead) you may add to the filter some routes, that should not be passed to client.\nFor example, if you have `admin` route\n\n```php\nRoute::set('admin', 'admin/\u003caction\u003e')\n    -\u003edefaults(array(\n        'controller' =\u003e 'baz',\n        'action'     =\u003e 'bat',\n    ));\n```\n\nadd to blacklist it in [config](https://github.com/Invis1ble/kohana-jsroute/blob/master/config/jsroute.php) of the module\n\n```php\n'filter' =\u003e array(\n    // ...\n    'admin', // crackers no need to know this :)\n    // ...\n),\n```\n\n### Customization\n\n#### Callbacks\n\nYou may want to handle AJAX `error` event and you have this ability. Simply you need to specify `onerror` callback like this:\n\n```javascript\nvar onerror = function (jqXHR, textStatus, errorThrown) {\n    // some sode\n};\n```\n\nand pass this function to constructor:\n\n```javascript\nvar router = $.kohanaRouter({\n    // ...\n    onerror: onerror\n    // ...\n});\n```\n\nor add as property:\n\n```javascript\nrouter.onerror = onerror;\n```\n\n#### Controller url\n\nBy defaults url of source is `/jsroute/get` and it correspond to backend, but you can redefine this setting if need:\n\n```javascript\n$.kohanaRouter.defaults.source = '/foo/bar';\n```\n\n## License\n\n[MIT](http://www.opensource.org/licenses/mit-license.php)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finvis1ble%2Fkohana-jsroute","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finvis1ble%2Fkohana-jsroute","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finvis1ble%2Fkohana-jsroute/lists"}