Skip to content

Commit 0eaae43

Browse files
committed
Merge branch 'develop'
2 parents e3987fd + 6bccd87 commit 0eaae43

File tree

6 files changed

+39
-26
lines changed

6 files changed

+39
-26
lines changed

README.md

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,11 @@ If you want the middleware to be run only on specific routes, add the class in t
4242
'tidy' => 'Stolz\HtmlTidy\Middleware',
4343
];
4444

45-
Now in your `routes.php` file you can use
45+
Now you can use it in your `routes.php` file
4646

47-
get('some/url', [
48-
'middleware' => 'tidy',
49-
function() {
50-
return view('hello');
51-
}
52-
]);
47+
get('some/url', ['middleware' => 'tidy', function() {
48+
return view('home');
49+
}]);
5350

5451
Conversely if you want the middleware to be run on every HTTP request to your application, add the class in the `$middleware` property of your `app/Http/Kernel.php` file.
5552

@@ -58,6 +55,21 @@ Conversely if you want the middleware to be run on every HTTP request to your ap
5855
'Stolz\HtmlTidy\Middleware',
5956
];
6057

58+
## Laravel 4
59+
60+
If you are still using Laravel 4 instead of loading `Stolz\HtmlTidy\ServiceProvider` use `Stolz\HtmlTidy\LegacyServiceProvider` and then in your `routes.php` file use something like this
61+
62+
// Register filter
63+
Route::filter('tidy', function($route, $request, $response) {
64+
return app('stolz.tidy')->handle($request, $response);
65+
});
66+
67+
// Use as an 'after' filter
68+
Route::get('/', ['after' => 'tidy', function() {
69+
return View::make('home');
70+
}]);
71+
72+
6173
## License
6274

6375
MIT License

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
}
1111
],
1212
"require": {
13-
"php": ">=5.3.0",
13+
"php": ">=5.4",
1414
"ext-tidy": "*",
1515
"illuminate/support": "5.*",
1616
"illuminate/http": "5.*"

phpcodesniffer

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ fi
2929
# Run PHP_CodeSniffer
3030

3131
cd "$DIR"
32-
./vendor/bin/phpcs --report-width=100 --tab-width=4 --standard=phpcodesniffer.xml,PHPCompatibility src/ -as --runtime-set testVersion 5.3
32+
./vendor/bin/phpcs --report-width=100 --tab-width=4 --standard=phpcodesniffer.xml,PHPCompatibility src/ -as --runtime-set testVersion 5.4
3333

3434
exit 0

src/LegacyServiceProvider.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ class LegacyServiceProvider extends IlluminateServiceProvider
1212
public function boot()
1313
{
1414
// Register the package namespace
15-
$this->package('stolz/laravel-html-tidy', 'html-tidy');
15+
//$this->package('stolz/tidy', 'tidy'); // Only valid if config file is at src/config/config.php
16+
$this->app->config->package('stolz/tidy', __DIR__, 'tidy');
1617

1718
// Read settings from config file
18-
$config = $this->app->config->get('html-tidy::config', array());
19+
$config = $this->app->config->get('tidy::config', []);
1920

2021
// Apply config settings
2122
$this->app['stolz.tidy']->config($config);
@@ -30,7 +31,7 @@ public function register()
3031
{
3132
// Bind 'stolz.tidy' shared component to the IoC container
3233
$this->app->singleton('stolz.tidy', function ($app) {
33-
return new Middleware();
34+
return new Tidy();
3435
});
3536
}
3637
}

src/Tidy.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class Tidy
5454
* Please read http://tidy.sourceforge.net/docs/quickref.html
5555
* @var array
5656
*/
57-
protected $tidy_options = array(
57+
protected $tidy_options = [
5858
'output-xhtml' => true,
5959
'char-encoding' => 'utf8',
6060
//'hide-comments' => true,
@@ -67,13 +67,13 @@ class Tidy
6767
'doctype' => 'omit', //The filter will add the configured doctype later
6868
'new-blocklevel-tags' => 'article,aside,canvas,dialog,embed,figcaption,figure,footer,header,hgroup,nav,output,progress,section,video',
6969
'new-inline-tags' => 'audio,bdi,command,datagrid,datalist,details,keygen,mark,meter,rp,rt,ruby,source,summary,time,track,wbr',
70-
);
70+
];
7171

7272
/**
7373
* Errors that match these regexs won't be displayed
7474
* @var array
7575
*/
76-
protected $ignored_errors = array(
76+
protected $ignored_errors = [
7777
// workaround to hide errors related to HTML5
7878
"/line.*proprietary attribute \"data-.*\n?/",
7979
"/line.*proprietary attribute \"placeholder.*\n?/",
@@ -86,15 +86,15 @@ class Tidy
8686
"/line.*<script> inserting \"type\" attribute\n?/",
8787
"/line.*<input> proprietary attribute \"autocomplete\"\n?/",
8888
"/line.*<input> proprietary attribute \"autofocus\"\n?/",
89-
);
89+
];
9090

9191
/**
9292
* Class constructor.
9393
*
9494
* @param array $options
9595
* @return void
9696
*/
97-
public function __construct(array $options = array())
97+
public function __construct(array $options = [])
9898
{
9999
if($options)
100100
$this->config($options);

src/config.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
| For more info please visit https://github.com/Stolz/laravel-html-tidy
1111
|
1212
*/
13-
return array(
13+
return [
1414

1515
// Enable if PHP has tidy extension support
1616
'enabled' => extension_loaded('tidy'),
1717

18-
/*// Filter AJAX requests
18+
// Process AJAX requests
1919
'ajax' => false,
2020

2121
// Encoding of your original documents. This refers to the encoding that you original documents have,
@@ -35,7 +35,7 @@
3535
'container_close_tag' => '</div>',
3636

3737
// Options passed to HTML Tidy parseString() function. Docs: http://tidy.sourceforge.net/docs/quickref.html
38-
'tidy_options' => array(
38+
'tidy_options' => [
3939
'output-xhtml' => true,
4040
'char-encoding' => 'utf8',
4141
'wrap' => 0,
@@ -45,12 +45,12 @@
4545

4646
// HTML5 workarounds
4747
'doctype' => 'omit', //The filter will add the configured doctype later
48-
'new-blocklevel-tags' => 'article,aside,canvas,dialog,embed,figcaption,figure,footer,header,hgroup,nav,output,progress,section,video',
48+
'new-blocklevel-tags' => 'article,aside,canvas,dialog,embed,figcaption,figure,footer,header,hgroup,nav,output,progress,section,video',
4949
'new-inline-tags' => 'audio,bdi,command,datagrid,datalist,details,keygen,mark,meter,rp,rt,ruby,source,summary,time,track,wbr',
50-
),
50+
],
5151

5252
// Errors that match these regexs wont be displayed
53-
'ignored_errors' => array(
53+
'ignored_errors' => [
5454
// workaround to hide errors related to HTML5
5555
"/line.*proprietary attribute \"data-.*\n?/",
5656
"/line.*proprietary attribute \"placeholder.*\n?/",
@@ -63,6 +63,6 @@
6363
"/line.*<script> inserting \"type\" attribute\n?/",
6464
"/line.*<input> proprietary attribute \"autocomplete\"\n?/",
6565
"/line.*<input> proprietary attribute \"autofocus\"\n?/",
66-
),
67-
*/
68-
);
66+
],
67+
68+
];

0 commit comments

Comments
 (0)