-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
158 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
use Illuminate\Support\Str; | ||
use Psr\Http\Message\UriInterface; | ||
use Spatie\Crawler\CrawlProfiles\CrawlProfile; | ||
|
||
class CustomCrawlProfile extends CrawlProfile | ||
{ | ||
public function shouldCrawl(UriInterface $url): bool | ||
{ | ||
if ($url->getQuery() !== '' | ||
|| Str::isMatch('/\/prenoms\/\d+\/\w+/', $url->getPath())) { | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace App\Http\Middleware; | ||
|
||
use Closure; | ||
use Illuminate\Http\RedirectResponse; | ||
use Illuminate\Http\Request; | ||
use Pirsch\Facades\Pirsch; | ||
|
||
class TrackPageview | ||
{ | ||
public function handle(Request $request, Closure $next): mixed | ||
{ | ||
$response = $next($request); | ||
|
||
if ($response instanceof RedirectResponse) { | ||
return $response; | ||
} | ||
|
||
// If app is down, don't track pageviews. | ||
if (app()->isDownForMaintenance()) { | ||
return $response; | ||
} | ||
|
||
Pirsch::track(); | ||
|
||
return $response; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
use App\Console\Commands\CustomCrawlProfile; | ||
use GuzzleHttp\RequestOptions; | ||
|
||
return [ | ||
|
||
/* | ||
* These options will be passed to GuzzleHttp\Client when it is created. | ||
* For in-depth information on all options see the Guzzle docs: | ||
* | ||
* http://docs.guzzlephp.org/en/stable/request-options.html | ||
*/ | ||
'guzzle_options' => [ | ||
|
||
/* | ||
* Whether or not cookies are used in a request. | ||
*/ | ||
RequestOptions::COOKIES => true, | ||
|
||
/* | ||
* The number of seconds to wait while trying to connect to a server. | ||
* Use 0 to wait indefinitely. | ||
*/ | ||
RequestOptions::CONNECT_TIMEOUT => 10, | ||
|
||
/* | ||
* The timeout of the request in seconds. Use 0 to wait indefinitely. | ||
*/ | ||
RequestOptions::TIMEOUT => 10, | ||
|
||
/* | ||
* Describes the redirect behavior of a request. | ||
*/ | ||
RequestOptions::ALLOW_REDIRECTS => false, | ||
], | ||
|
||
/* | ||
* The sitemap generator can execute JavaScript on each page so it will | ||
* discover links that are generated by your JS scripts. This feature | ||
* is powered by headless Chrome. | ||
*/ | ||
'execute_javascript' => false, | ||
|
||
/* | ||
* The package will make an educated guess as to where Google Chrome is installed. | ||
* You can also manually pass its location here. | ||
*/ | ||
'chrome_binary_path' => null, | ||
|
||
/* | ||
* The sitemap generator uses a CrawlProfile implementation to determine | ||
* which urls should be crawled for the sitemap. | ||
*/ | ||
'crawl_profile' => CustomCrawlProfile::class, | ||
|
||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
User-agent: * | ||
Disallow: | ||
Sitemap: /sitemap.xml | ||
Sitemap: /sitemap/sitemap.xml |
File renamed without changes.