Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add ignore_uri #66

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions config/laroute.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php

return [

/*
* The destination path for the javascript file.
*/
Expand Down Expand Up @@ -48,11 +47,15 @@
* with them.
*/
'template' => 'vendor/lord/laroute/src/templates/laroute.js',

/*
* Appends a prefix to URLs. By default the prefix is an empty string.
*
*/
'prefix' => '',

/*
* ignore routes with certain urls through regex
*/
'ignore_uri' => '',
];
46 changes: 24 additions & 22 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,24 @@ Install the usual [composer](https://getcomposer.org/) way.
###### composer.json
```json
{
"require" : {
"lord/laroute" : "2.*"
}
"require" : {
"lord/laroute" : "2.*"
}
}
```

n.b Laravel 4.x users, check out [version 1.3.2](https://github.com/aaronlord/laroute/tree/v1.3.2)

###### app/config/app.php
```php
...
'providers' => array(
...
Lord\Laroute\LarouteServiceProvider::class,
],
...
...

'providers' => array(
...
Lord\Laroute\LarouteServiceProvider::class,
],

...
```

### Configure (optional)
Expand Down Expand Up @@ -95,16 +95,20 @@ return [
* with them.
*/
'template' => 'vendor/lord/laroute/src/templates/laroute.js',

/*
* Appends a prefix to URLs. By default the prefix is an empty string.
*
*/
'prefix' => '',

/*
* ignore routes with certain urls through regex
*/
'ignore_uri' => '',

];


```

### Generate the `laroute.js`
Expand All @@ -127,13 +131,12 @@ With the default configuration, this will create a `public/js/laroute.js` file t

By default, all of the functions are under the `laroute` namespace. This documentation will stick with this convention.


### action

Generate a URL for a given controller action.
Generate a URL for a given controller action.

```js
/**
/**
* laroute.action(action, [parameters = {}])
*
* action : The action to route to.
Expand All @@ -154,7 +157,7 @@ Generate a URL for a given named route.
* name : The name of the route to route to.
* parameters : Optional. key:value object literal of route parameters.
*/

laroute.route('Hello.{planet}', { planet : 'world' });
```

Expand All @@ -169,7 +172,7 @@ Generate a fully qualified URL to the given path.
* name : The name of the route to route to.
* parameters : Optional. value array of route parameters.
*/

laroute.url('foo/bar', ['aaa', 'bbb']); // -> /foo/bar/aaa/bbb
```

Expand All @@ -185,7 +188,7 @@ Generate a html link to the given url.
* title : Optional. The anchor text to display
* attributes : Optional. key:value object literal of additional html attributes.
*/

laroute.link_to('foo/bar', 'Foo Bar', { style : "color:#bada55;" });
```

Expand All @@ -202,7 +205,7 @@ Generate a html link to the given route.
* parameters : Optional. key:value object literal of route parameters.
* attributes : Optional. key:value object literal of additional html attributes.
*/

laroute.link_to_route('home', 'Home');
```

Expand All @@ -219,7 +222,7 @@ Generate a html link to the given action.
* parameters : Optional. key:value object literal of route parameters.
* attributes : Optional. key:value object literal of additional html attributes.
*/

laroute.link_to_action('HelloController@planet', undefined, { planet : 'world' });
```

Expand All @@ -242,7 +245,6 @@ Route::group(['laroute' => false], function () {

```


## Licence

[View the licence in this repo.](https://github.com/aaronlord/laroute/blob/master/LICENSE)
9 changes: 7 additions & 2 deletions src/Routes/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,13 @@ protected function guardAgainstZeroRoutes(RouteCollection $routes)
*/
protected function getRouteInformation(Route $route, $filter, $namespace)
{
$host = $route->domain();
if (!empty(config('laroute.ignore_uri'))) {
if (preg_match(config('laroute.ignore_uri'), $route->uri())) {
return;
}
}

$host = $route->domain();
$methods = $route->methods();
$uri = $route->uri();
$name = $route->getName();
Expand All @@ -87,5 +93,4 @@ protected function getRouteInformation(Route $route, $filter, $namespace)

return compact('host', 'methods', 'uri', 'name', 'action');
}

}