Skip to content

Commit

Permalink
remove amp-toolbox for now
Browse files Browse the repository at this point in the history
  • Loading branch information
ArroWsGM committed Mar 9, 2022
1 parent a3d4811 commit dcc5c59
Show file tree
Hide file tree
Showing 7 changed files with 2 additions and 111 deletions.
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
],
"minimum-stability": "dev",
"require": {
"ampproject/amp-toolbox": "^0.2",
"ampproject/amp-wp": "dev-main",
"ext-libxml": "*",
"ext-dom": "*",
Expand Down
5 changes: 0 additions & 5 deletions config/amped.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,8 @@
use Arrowsgm\Amped\AmpUtils\Sanitizers\TagAndAttributeSanitizer;
use Arrowsgm\Amped\AmpUtils\Sanitizers\IframeSanitizer;
use Arrowsgm\Amped\AmpUtils\Sanitizers\VideoSanitizer;
use Arrowsgm\Amped\Http\Middleware\OptimizeAmp;

return [
'middleware' => [
'amped.optimize' => OptimizeAmp::class,
],

'amp_custom_css_path' => public_path('css'),

'amp_custom_css_max_size' => 75000,
Expand Down
29 changes: 1 addition & 28 deletions src/Amped.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
namespace Arrowsgm\Amped;


use AmpProject\Optimizer\ErrorCollection;
use AmpProject\Optimizer\TransformationEngine;
use Arrowsgm\Amped\AmpUtils\AmpContent;
use Arrowsgm\Amped\Exceptions\ConfigNotLoadedException;
use Illuminate\Support\Facades\File;
Expand Down Expand Up @@ -109,29 +107,4 @@ public function isDevParam() :string
{
return env('APP_DEBUG') ? '#development=1' : '';
}

/**
* Optimize amp-html
* TODO: Errors?
*
* @param mixed $html_page
*
* @return string
*/
public function optimize($html_page): string
{
if (! is_string($html_page) || !$html_page) {
return $html_page;
}

$transformationEngine = new TransformationEngine();
$errorCollection = new ErrorCollection;

$optimizedHtml = $transformationEngine->optimizeHtml(
$html_page,
$errorCollection
);

return $optimizedHtml ?: $html_page;
}
}
}
21 changes: 1 addition & 20 deletions src/AmpedLaravelServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use AMP_Autoloader;
use Arrowsgm\Amped\Exceptions\AmpPluginNotFoundException;
use Illuminate\Foundation\AliasLoader;
use Illuminate\Routing\Router;
use Illuminate\Support\ServiceProvider;
use Arrowsgm\Amped\Facades\Amped;

Expand All @@ -30,7 +29,7 @@ public function register()
* Bootstrap services.
*
* @return void
* @throws AmpPluginNotFoundException|\Illuminate\Contracts\Container\BindingResolutionException
* @throws AmpPluginNotFoundException
*/
public function boot()
{
Expand All @@ -42,7 +41,6 @@ public function boot()

$this->registerFacades();
$this->registerConfig();
$this->registerMiddleware();
}

/**
Expand Down Expand Up @@ -107,21 +105,4 @@ private function registerConfig()
Amped::sanitizers(config('amped.sanitizers'));
Amped::args(config('amped.args'));
}

/**
* Register any default fields to the app.
*
* @return void
* @throws \Illuminate\Contracts\Container\BindingResolutionException
*/
private function registerMiddleware()
{
$router = $this->app->make(Router::class);

foreach(config('amped.middleware', []) as $name => $class ){
if($name || class_exists($class)) {
$router->aliasMiddleware($name, $class);
}
}
}
}
1 change: 0 additions & 1 deletion src/Facades/Amped.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
* @method static string convert(string $html)
* @method static string inlineCss(string $css_file, string $attr = 'amp-custom')
* @method static string isDevParam()
* @method static mixed optimize(mixed $html)
*/

use Illuminate\Support\Facades\Facade;
Expand Down
27 changes: 0 additions & 27 deletions src/Http/Middleware/OptimizeAmp.php

This file was deleted.

29 changes: 0 additions & 29 deletions tests/Feature/AmpOptimizerTest.php

This file was deleted.

0 comments on commit dcc5c59

Please sign in to comment.