Skip to content

Commit

Permalink
Too long sentences check (#38)
Browse files Browse the repository at this point in the history
* wip

* Improvements

* Fix styling

* Update README

* Add pregmatch to make exploding sentences more accurate

* Fix styling

* Add tests

* wip

* Fix styling

* If more than 20% of the sentences is too long, fail check

* Update README

* Fix styling

* Improve TooLongSentenceCheck and make Action trait

* Fix styling

* Fix test

* Improve information

* Fix counting bug, should never be 0

* Update README

---------

Co-authored-by: Baspa <Baspa@users.noreply.github.com>
  • Loading branch information
Baspa and Baspa authored Aug 17, 2023
1 parent 57abf96 commit 889178e
Show file tree
Hide file tree
Showing 7 changed files with 373 additions and 348 deletions.
160 changes: 3 additions & 157 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

## Introduction

This package is your guidance to get a better SEO score on search engines. Laravel SEO Scanner scans your code and crawls the routes from your app. The package has 23 checks that will check on performance, configurations, use of meta tags and content quality.
This package is your guidance to get a better SEO score on search engines. Laravel SEO Scanner scans your code and crawls the routes from your app. The package has 24 checks that will check on performance, configurations, use of meta tags and content quality.

Easily configure which routes to scan, exclude or include specific checks or even add your own checks! Completing checks will further improve the SEO score and thus increase the chance of ranking higher at the search engines.

Expand Down Expand Up @@ -80,162 +80,7 @@ php artisan migrate
php artisan vendor:publish --tag="seo-config"
```

This will be the contents of the published config file:

```php
return [
/*
|--------------------------------------------------------------------------
| Cache
|--------------------------------------------------------------------------
|
| The following array lists the cache options for the application.
|
*/
'cache' => [
// Only drivers that support tags are supported.
// These are: array, memcached and redis.
'driver' => 'array',
],

/*
|--------------------------------------------------------------------------
| Check classes
|--------------------------------------------------------------------------
|
| The following array lists the "check" classes that will be registered
| with Laravel Seo. These checks run an check on the application via
| various methods. Feel free to customize it.
|
| An example of a check class:
| \Vormkracht10\Seo\Checks\Content\BrokenLinkCheck::class
|
*/
'checks' => ['*'],

// If you wish to skip running some checks, list the classes in the array below.
'exclude_checks' => [],

/*
|--------------------------------------------------------------------------
| Check paths
|--------------------------------------------------------------------------
|
| The following array lists the "checks" paths that will be searched
| recursively to find check classes. This option will only be used
| if the checks option above is set to the asterisk wildcard. The
| key is the base namespace to resolve the class name.
|
*/
'check_paths' => [
'Vormkracht10\\Seo\\Checks' => base_path('vendor/vormkracht10/laravel-seo-scanner-scanner/src/Checks'),
],

/*
|--------------------------------------------------------------------------
| Routes
|--------------------------------------------------------------------------
|
| The following array lists the "checkable" routes that will be registered
| with Laravel Seo. These routes will be checked for SEO. Feel free to
| customize it. To check for specific routes, use the route name.
|
| An example of a checkable route:
| 'blog.index'
|
*/
'check_routes' => true,
'routes' => ['*'],

// If you wish to skip running some checks on some routes, list the routes
// in the array below by using the route name. For example:
// 'blog.index'
'exclude_routes' => [],

// If you wish to skip running some checks on some paths, list the paths
// in the array below.
'exclude_paths' => [
'admin/*',
'nova/*',
'horizon/*',
'vapor-ui/*',
],

/*
|--------------------------------------------------------------------------
| Database
|--------------------------------------------------------------------------
|
| Here you can specify database related configurations like the connection
| that will be used to save the SEO scores. When you set the save
| option to true, the SEO score will be saved to the database.
|
*/
'database' => [
'connection' => 'mysql',
'save' => true,
'prune' => [
'older_than_days' => 30,
]
],

/*
|--------------------------------------------------------------------------
| Models
|--------------------------------------------------------------------------
|
| Here you can specify which models you want to check. When you specify a
| model, the SEO score will be saved to the database. This way you can
| check the SEO score of a specific page.
|
| An example of a model:
| \App\Models\BlogPost::class
|
*/
'models' => [],

'http' => [
/*
|--------------------------------------------------------------------------
| Http client options
|--------------------------------------------------------------------------
|
| Here you can specify the options of the http client. For example, in a
| local development environment you may want to disable the SSL
| certificate integrity check.
|
| An example of a http option:
| 'verify' => false
|
*/
'options' => [],

/*
|--------------------------------------------------------------------------
| Http headers
|--------------------------------------------------------------------------
|
| Here you can specify custom headers of the http client.
|
*/
'headers' => [
'User-Agent' => 'Laravel SEO Scanner/1.0',
],
],

/*
|--------------------------------------------------------------------------
| Javascript rendering
|--------------------------------------------------------------------------
|
| If your website uses javascript to render the content, you can enable
| javascript rendering. This will use a headless browser to render
| the content.
|
*/
'javascript' => false,
];
```
Click here to see the [config file](https://github.com/vormkracht10/laravel-seo-scanner/blob/too-long-sentences-check/config/seo.php).

## Available checks

Expand All @@ -255,6 +100,7 @@ These checks are available in the package. You can add or remove checks in the c
✅ The page contains no broken links. <br>
✅ The page contains no broken images. <br>
✅ Length of the content is at least 2100 characters. <br>
✅ No more than 20% of the content contains too long sentences (more than 20 words). <br>
✅ A minimum of 30% of the sentences contain a transition word or phrase. <br>

> Note: To change the locale of the transition words, you can publish the config file and change the locale in the config file. The default locale is `null` which uses the language of your `app` config. If set to `nl` or `en`, the transition words will be in Dutch or English. If you want to add more locales, you can create a pull request.
Expand Down
144 changes: 72 additions & 72 deletions resources/lang/en.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,26 @@
{
"accordingly": "accordingly",
"additionally": "additionally",
"admittedly": "admittedly",
"after": "after",
"afterward": "afterward",
"all in all": "all in all",
"although": "although",
"an example of this is": "an example of this is",
"as a result": "as a result",
"as well as": "as well as",
"because": "because",
"before": "before",
"besides": "besides",
"but also": "but also",
"certainly": "certainly",
"compared to": "compared to",
"consequently": "consequently",
"conversely": "conversely",
"due to": "due to",
"during": "during",
"even though": "even though",
"eventually": "eventually",
"failed.configuration.nofollow.meta": "The page contains a nofollow meta tag, while it should not.",
"failed.configuration.nofollow.tag": "The page contains a nofollow tag, while it should not.",
"failed.configuration.noindex.meta": "The page contains a noindex meta tag, while it should not.",
Expand All @@ -15,9 +37,12 @@
"failed.content.no_heading": "The page does not contain any h1 tag, while it should.",
"failed.content.no_title": "The page does not contain a title tag, while it should.",
"failed.content.title_length": "The page title is :actualValue characters long. It should be max :expectedValue characters long.",
"failed.content.too_long_sentence": "The page has :actualValue too long sentences which exceeds 20% of the total sentences. Rectify :neededToFix sentences to meet the 20% limit.",
"failed.content.transition_words_ratio_check.no_phrases_found": "The page does not contain any transition words.",
"failed.content.transition_words_ratio_check.too_few_transition_words": "The page contains too few transition words. The recommended minimum is 30%, while the actual number is :actualValue%.",
"failed.meta.description": "The page does not contain a description meta tag, while it should.",
"failed.meta.keyword_in_title_check": "The page title does not contain the focus keyword, while it should.",
"failed.meta.keyword_in_first_paragraph_check": "The page does not contain the focus keyword in the first paragraph, while it should.",
"failed.meta.keyword_in_title_check": "The page title does not contain the focus keyword, while it should.",
"failed.meta.no_lang": "The page does not contain a lang attribute, while it should.",
"failed.meta.open_graph_image": "The page does not contain an open graph image, while it should.",
"failed.meta.open_graph_image.broken": "The page contains a broken open graph image. This image was found: :actualValue.",
Expand All @@ -31,87 +56,62 @@
"failed.performance.response": "The page returned a response code other than :expectedValue. The actual response code was :actualValue.",
"failed.performance.ttfb": "The page took too long to load (max :expectedValuems). The actual time was :actualValuems.",
"failed.performance.ttfb.missing_url": "We could not get the TTFB for this page.",
"failed.content.transition_words_ratio_check.too_few_transition_words": "The page contains too few transition words. The recommended minimum is 30%, while the actual number is :actualValue%.",
"failed.content.transition_words_ratio_check.no_phrases_found": "The page does not contain any transition words.",
"additionally": "additionally",
"moreover": "moreover",
"finally": "finally",
"first": "first",
"for example": "for example",
"for instance": "for instance",
"furthermore": "furthermore",
"in addition": "in addition",
"not only": "not only",
"but also": "but also",
"as well as": "as well as",
"besides": "besides",
"what's more": "what's more",
"granted": "granted",
"however": "however",
"nevertheless": "nevertheless",
"on the other hand": "on the other hand",
"in addition": "in addition",
"in comparison": "in comparison",
"in conclusion": "in conclusion",
"in contrast": "in contrast",
"conversely": "conversely",
"although": "although",
"while": "while",
"yet": "yet",
"even though": "even though",
"in other words": "in other words",
"in particular": "in particular",
"in summary": "in summary",
"in the future": "in the future",
"in the meantime": "in the meantime",
"in the past": "in the past",
"in this case": "in this case",
"indeed": "indeed",
"just as": "just as",
"likewise": "likewise",
"meanwhile": "meanwhile",
"moreover": "moreover",
"naturally": "naturally",
"nevertheless": "nevertheless",
"next": "next",
"nonetheless": "nonetheless",
"not only": "not only",
"of course": "of course",
"on the other hand": "on the other hand",
"overall": "overall",
"owing to": "owing to",
"second": "second",
"similarly": "similarly",
"likewise": "likewise",
"in comparison": "in comparison",
"just as": "just as",
"compared to": "compared to",
"similarly to": "similarly to",
"therefore": "therefore",
"thus": "thus",
"consequently": "consequently",
"as a result": "as a result",
"because": "because",
"since": "since",
"so": "so",
"due to": "due to",
"owing to": "owing to",
"accordingly": "accordingly",
"indeed": "indeed",
"certainly": "certainly",
"of course": "of course",
"undoubtedly": "undoubtedly",
"without a doubt": "without a doubt",
"naturally": "naturally",
"for example": "for example",
"for instance": "for instance",
"soon": "soon",
"specifically": "specifically",
"subsequently": "subsequently",
"such as": "such as",
"to illustrate": "to illustrate",
"in particular": "in particular",
"first": "first",
"second": "second",
"third": "third",
"next": "next",
"that is to say": "that is to say",
"then": "then",
"afterward": "afterward",
"finally": "finally",
"in the meantime": "in the meantime",
"subsequently": "subsequently",
"in conclusion": "in conclusion",
"therefore": "therefore",
"third": "third",
"thus": "thus",
"to clarify": "to clarify",
"to demonstrate": "to demonstrate",
"to illustrate": "to illustrate",
"to sum up": "to sum up",
"ultimately": "ultimately",
"in summary": "in summary",
"all in all": "all in all",
"overall": "overall",
"meanwhile": "meanwhile",
"before": "before",
"after": "after",
"during": "during",
"undoubtedly": "undoubtedly",
"until": "until",
"eventually": "eventually",
"soon": "soon",
"in the past": "in the past",
"in the future": "in the future",
"in other words": "in other words",
"that is to say": "that is to say",
"specifically": "specifically",
"to clarify": "to clarify",
"in this case": "in this case",
"an example of this is": "an example of this is",
"to demonstrate": "to demonstrate",
"admittedly": "admittedly",
"granted": "granted",
"while it is true": "while it is true"
}

"what's more": "what's more",
"while": "while",
"while it is true": "while it is true",
"without a doubt": "without a doubt",
"yet": "yet"
}
Loading

0 comments on commit 889178e

Please sign in to comment.