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 AMP Optimizer library #4019

Merged
merged 153 commits into from
Mar 7, 2020
Merged
Show file tree
Hide file tree
Changes from 143 commits
Commits
Show all changes
153 commits
Select commit Hold shift + click to select a range
95bf0a7
Initial structure with engine, errorcollection, exception and tests
schlessera Jan 2, 2020
06a1ba5
Flesh out Transformer\ServerSideRendering
schlessera Jan 2, 2020
3b31720
Complete ServerSideRendering implementation
schlessera Jan 3, 2020
bd30bd0
Add all ServerSideRendering tests from the Google Cache implementation
schlessera Jan 3, 2020
68fc604
Add TransformedIdentifier transformer and test
schlessera Jan 3, 2020
72e9f33
Remove travis envs for PHP < 5.6
schlessera Jan 3, 2020
3585c73
Add amp-story to render-delaying extensions
schlessera Jan 7, 2020
9dde002
Repackage code into external libraries as needed
schlessera Jan 8, 2020
b54dfc5
Use PSR-12 instead of PSR-2
schlessera Jan 8, 2020
89a6270
Fix PHPCS issues
schlessera Jan 8, 2020
d5986f1
Normalize Composer files
schlessera Jan 8, 2020
3791053
Add further branch aliases to fix resolution within PR
schlessera Jan 8, 2020
1b1db57
Fix coverage annotations
schlessera Jan 8, 2020
1c9d066
Fix PHPUnit deprecation warning
schlessera Jan 8, 2020
7df6c66
Add compat code for PHPUnit's assertStringContainsString
schlessera Jan 8, 2020
3f81197
Remove accidental "gd" insertion
schlessera Jan 8, 2020
7408d77
Add version commit hashes from source files
schlessera Jan 8, 2020
af3a6c8
Use class (with namespace stripped) as error code
schlessera Jan 8, 2020
8eb3d78
Add tests for document smart properties
schlessera Jan 8, 2020
1515c0b
Improve ampElements property test
schlessera Jan 8, 2020
43d3517
Fix tests that relied on ::CODE
schlessera Jan 8, 2020
a766a53
Lint all test files
schlessera Jan 8, 2020
409df5d
Fix old PHP compat for DOMNodeList counting test
schlessera Jan 8, 2020
13f8bdc
Use faster parallel linter
schlessera Jan 8, 2020
bab6f9d
Improve string contains compat to remove last deprecation warning
schlessera Jan 8, 2020
f1b8145
Merge branch 'develop' into add/958-amp-optimizer
schlessera Jan 21, 2020
541e865
Add script to pull spec files from amp toolbox
schlessera Jan 21, 2020
0fab775
Add ReorderHead transformer and adapt spec tests
schlessera Jan 22, 2020
d1d4902
Add Amp object with constants
schlessera Jan 22, 2020
7a89ded
Make more use of constants
schlessera Jan 22, 2020
c24c61a
Reinsert erroneously removed deduplication of nodes
schlessera Jan 22, 2020
0684038
Fix most of the spec tests
schlessera Jan 22, 2020
67e7794
Adapt common constants
schlessera Jan 22, 2020
ce7c6d0
Exclude lib/* from eslint for now
schlessera Jan 23, 2020
2c0d769
Fix ExtensionTest constant
schlessera Jan 23, 2020
b5da00e
Adapt const array access syntax to make it compatible with PHP 5.6
schlessera Jan 23, 2020
adfad9f
Test libs with PHP 7.3 for now, PHP 7.4 is missing ext-zip
schlessera Jan 23, 2020
2faf336
Move CssLengthTest out of Dom folder
schlessera Jan 23, 2020
c75ff0e
Add ReorderHead test (from Go)
schlessera Jan 23, 2020
0010dae
Refactor structure and improve tests
schlessera Jan 24, 2020
e2d245a
Complete Amp class tests
schlessera Jan 24, 2020
51a1e15
Refresh test files after link reorder PR merge
schlessera Jan 24, 2020
3515823
Make link prioritisation case-insensitive
schlessera Jan 24, 2020
0ddc323
Make even more use of constants to deduplicate strings
schlessera Jan 30, 2020
6e845a8
Use marker interface to identify configurable transformers
schlessera Jan 30, 2020
7ac2693
Update spec files
schlessera Jan 30, 2020
9f39c1c
Fix broken tests
schlessera Jan 30, 2020
32d56e7
Add docblocks for constants in TransformedIdentifier
schlessera Jan 31, 2020
f131057
Add RemoteRequest and RuntimeVersion helpers
schlessera Feb 2, 2020
d91ec13
Add AmpRuntimeCss and AmpBoilerplate transformers
schlessera Feb 3, 2020
5417b29
Remove unneeded comment in ReorderHeadTest
schlessera Feb 3, 2020
e7969dc
Add support for SSR with intrinsic layout
schlessera Feb 3, 2020
63a338e
Bump PHPCS compatibility checks to PHP 5.6+
schlessera Feb 4, 2020
bf99b2a
Initial optimizer integration into the WP plugin
schlessera Feb 4, 2020
26592cd
Use constant for RuntimeVersion canaray option
schlessera Feb 6, 2020
d873f22
Fix property docblock
schlessera Feb 6, 2020
4c0aa05
Add AmpSchemaOrgMetadata transformer
schlessera Feb 6, 2020
858238a
Move schemaOrg test
schlessera Feb 6, 2020
e83c24d
Skip tests depending on title tag order
schlessera Feb 6, 2020
bdcc5c0
Fix spec tests
schlessera Feb 6, 2020
45c3c9a
Skip broken style order test
schlessera Feb 6, 2020
d645b60
Add imlpementation for AmpRuntimeCss::linkCss()
schlessera Feb 7, 2020
297548d
Merge branch 'develop' into add/958-amp-optimizer
schlessera Feb 7, 2020
e871d98
Refresh spec tests
schlessera Feb 7, 2020
e9201f4
Remove left-overs from merge
schlessera Feb 7, 2020
2a996f2
Merge normalizeHtmlAttributes change
schlessera Feb 7, 2020
46d12ae
Merge "parse malformed meta charset tag" change
schlessera Feb 7, 2020
3125da5
Update Composer lock file
schlessera Feb 7, 2020
2e62f25
Account for deprecated notice when testing Amp boilerplate helpers
schlessera Feb 7, 2020
240a8fb
Fix ReorderHead node<=>document attribution
schlessera Feb 7, 2020
38c280a
Test should respect charset case
schlessera Feb 7, 2020
4c25c4a
Add test set descriptions to meta sanitizer test
schlessera Feb 7, 2020
b5a51ae
Deduplicate tags in meta sanitizer
schlessera Feb 7, 2020
2df5fbb
Adapt positioning of the optimizer
schlessera Feb 7, 2020
1af6765
Make use of common constants in amp-theme-support
schlessera Feb 8, 2020
f458848
Add configuration filters for the transformation engine
schlessera Feb 8, 2020
a20b209
Fix PHPCS issues
schlessera Feb 8, 2020
098aa67
Prioritize Amp resource links higher in head
schlessera Feb 8, 2020
5b54c97
Disable optimizer for script deduplication test
schlessera Feb 8, 2020
b6b8aae
Fix extension script ordering
schlessera Feb 8, 2020
85c1146
Fix PHPCS issues
schlessera Feb 8, 2020
a007e67
Merge branch 'develop' into add/958-amp-optimizer
schlessera Feb 8, 2020
78c091d
Improve spec test import
schlessera Feb 8, 2020
6af5a58
Allow for lightning bolt emoji variation
schlessera Feb 12, 2020
7502963
Ensure multiple calls to saveHTML cannot corrupt the DOM
schlessera Feb 12, 2020
1c56a4a
Fix alternate emoji treatment and tests
schlessera Feb 13, 2020
902010d
Merge branch 'develop' into add/958-amp-optimizer
schlessera Feb 13, 2020
8ea6c4b
Add clarifying parentheses for array cast
schlessera Feb 13, 2020
1e629af
Remove unneeded node import
schlessera Feb 13, 2020
c3b8a5e
Merge branch 'develop' into add/958-amp-optimizer
schlessera Feb 16, 2020
2443e76
Merge branch 'develop' into add/958-amp-optimizer
schlessera Feb 21, 2020
c28b86f
Merge branch 'add/958-amp-optimizer' of https://github.com/ampproject…
schlessera Feb 21, 2020
c9f3fe5
Remove empty DOM DOcument tests file
schlessera Feb 22, 2020
e10d028
Fix merge error
schlessera Feb 22, 2020
53e4d6f
Remove unused regex pattern constants
schlessera Feb 25, 2020
24c4416
Adapt test coverage annotations
schlessera Feb 25, 2020
3fd1c0e
Remove unneeded default value assignment
schlessera Feb 25, 2020
8cb4f49
Merge branch 'add/958-amp-optimizer' of https://github.com/ampproject…
schlessera Feb 25, 2020
ed34169
Suggest ext-mbstring via Composer
schlessera Feb 25, 2020
a02acb2
Copy amp libraries into vendor instead of symlinking
schlessera Feb 25, 2020
d3608b0
Adapt test coverage annotation
schlessera Feb 25, 2020
9fdfdd4
Make sure npm run build can access lib dependencies
schlessera Mar 2, 2020
9106d23
Merge branch 'develop' into add/958-amp-optimizer
schlessera Mar 2, 2020
eabfdd8
Fix logic in disabling SSR when WP_DEBUG true
schlessera Mar 2, 2020
77e8a55
Add tweak to fix SSR SVGs
schlessera Mar 2, 2020
e9dde83
Fix SVG source attribute encoding fix for it to actually fix
schlessera Mar 3, 2020
158741c
Use correct boundaries for containsWord check
schlessera Mar 4, 2020
2c63754
Document filters
schlessera Mar 4, 2020
dbb9eae
Remove homepage metadata in Composer files
schlessera Mar 4, 2020
ff4348b
Remove double blank lines
schlessera Mar 4, 2020
ba50cf1
Use seconds as unit for cache expiry
schlessera Mar 4, 2020
00da366
Use a private property for storing whether tweak was already added
schlessera Mar 4, 2020
6a6a500
Skip checking for exceptions on curl requests
schlessera Mar 4, 2020
031a238
Use correct require/suggest in amp/common
schlessera Mar 4, 2020
38971ac
Rename RemoteRequest::fetch() into RemoteGetRequest::get()
schlessera Mar 4, 2020
1d6e4ab
Add retry functionality to CurlRemoteGetRequest
schlessera Mar 4, 2020
6d7e69d
Add default empty array argument to $tweaks property
schlessera Mar 4, 2020
b32f10c
Fix inverted logic to add SSR tweak
schlessera Mar 4, 2020
11f5729
Use filesystem-based fallbacks for remote request to ensure the conte…
schlessera Mar 5, 2020
e2bb7f9
Merge branch 'develop' into add/958-amp-optimizer
schlessera Mar 5, 2020
7064c53
Change lib packages to be pulled in as symlinks again
schlessera Mar 5, 2020
4beaa70
Remove "Tweaks" concept again and integrate directly into Dom\Document
schlessera Mar 5, 2020
179b49b
Remove Filter interface with constants and switch back to string lite…
schlessera Mar 5, 2020
5e2b218
Fix shell:composer_install handling of vendor symlinks
westonruter Mar 5, 2020
138fa29
Break up composer_install command into array
westonruter Mar 5, 2020
81a5fd8
Use cp instead of rsync for undoing symlink
westonruter Mar 5, 2020
6bb191c
Add vendor/amp/optimizer/bin to exclusion list
westonruter Mar 5, 2020
b39aa43
Remove tweaks missed in 4beaa70c
westonruter Mar 6, 2020
bce8b38
Add .editorconfig for nested libs
westonruter Mar 6, 2020
b9740c4
Add type hint for customElementScript
westonruter Mar 6, 2020
93d85af
Ignore lib from stylelint; fix phpcs errors
westonruter Mar 6, 2020
12f8bab
Exclude sub-project vendor directories from ZIP build
westonruter Mar 6, 2020
1d58223
Merge branch 'add/958-amp-optimizer' of https://github.com/ampproject…
schlessera Mar 6, 2020
902fd12
Introduce Response object to pass headers together with body for remo…
schlessera Mar 6, 2020
ea5bd61
Add cache-control support
schlessera Mar 6, 2020
158dd53
Fix validation errors when optimizer is disabled
schlessera Mar 6, 2020
c783efb
Remove node deduplication in meta sanitizer
schlessera Mar 6, 2020
19775c0
Undeprecate boilerplate stylesheet functions
schlessera Mar 6, 2020
42d5f3f
Fix tests for meta sanitizer and bug in Dom/Document
schlessera Mar 6, 2020
a4bb586
Capitalize AMP
schlessera Mar 6, 2020
81366f9
Revert deprecation expectation in helper tests for stylesheet functions
schlessera Mar 6, 2020
938bbf4
Fix removal of namespace when deriving error code from class name
westonruter Mar 6, 2020
24b6f8f
Improve robustness of getting error code from class after 938bbf49
westonruter Mar 7, 2020
5fa93bd
Remove dead boilerplate code from AMP_Meta_Sanitizer
westonruter Mar 7, 2020
5cd2e4a
Add angle brackets to ElementDump output
westonruter Mar 7, 2020
779be91
Omit AmpRuntimeCss transformer if SSR is not enabled
westonruter Mar 7, 2020
7b37383
Expose AMP optimizer errors in HTML comment at end of head
westonruter Mar 7, 2020
4a7b5a0
Remove obsolete Amp\AmpWP\Filter missed in 179b49b
westonruter Mar 7, 2020
e41c7eb
Add curl_getinfo() and curl_errno() to list of required cURL functions
westonruter Mar 7, 2020
afbe9f0
Improve phpdoc, formatting, and return value
westonruter Mar 7, 2020
933dab8
Improve static analysis of Document::normalizeHtmlAttributes()
westonruter Mar 7, 2020
502c732
Fix static analysis of expiry param
westonruter Mar 7, 2020
8559dfc
Remove need to iterate over nodesToRemove a second time
westonruter Mar 7, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
**/assets/js/*.js
!assets/js/amp-service-worker-runtime-precaching.js
build/*
lib/*
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ built
/amphtml
.env
.idea/
/lib/*/vendor/
/lib/*/composer.lock
2 changes: 2 additions & 0 deletions .stylelintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
/build
/tests
/vendor
/lib/optimizer
/lib/common
18 changes: 18 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,21 @@ jobs:
- bash <(curl -s https://codecov.io/bash) -cF php -f /tmp/wordpress/src/wp-content/plugins/amp/build/logs/clover.xml
- npm run test:js -- --collectCoverage
- bash <(curl -s https://codecov.io/bash) -cF javascript -f build/logs/lcov.info

- name: Libraries that are meant to be externalized (5.6)
php: "5.6"
install:
- composer --working-dir=lib/common install
- composer --working-dir=lib/optimizer install
script:
- composer --working-dir=lib/common test
- composer --working-dir=lib/optimizer test

- name: Libraries that are meant to be externalized (7.3)
php: "7.3"
install:
- composer --working-dir=lib/common install
- composer --working-dir=lib/optimizer install
script:
- composer --working-dir=lib/common test
- composer --working-dir=lib/optimizer test
14 changes: 13 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ module.exports = function( grunt ) {
const productionVendorExcludedFilePatterns = [
'composer.*',
'patches',
'lib',
'vendor/*/*/.editorconfig',
'vendor/*/*/.git',
'vendor/*/*/.gitignore',
Expand All @@ -40,7 +41,10 @@ module.exports = function( grunt ) {
'vendor/*/*/*.yml',
'vendor/*/*/.*.yml',
'vendor/*/*/tests',
'vendor/amp/optimizer/bin',
'vendor/bin',
'vendor/amp/common/vendor',
'vendor/amp/optimizer/vendor',
];

grunt.initConfig( {
Expand Down Expand Up @@ -70,7 +74,14 @@ module.exports = function( grunt ) {
command: 'php bin/verify-version-consistency.php',
},
composer_install: {
command: 'if [ ! -e build ]; then echo "Run grunt build first."; exit 1; fi; cd build; composer install --no-dev -o && composer remove cweagans/composer-patches --update-no-dev -o && rm -r ' + productionVendorExcludedFilePatterns.join( ' ' ),
command: [
'if [ ! -e build ]; then echo "Run grunt build first."; exit 1; fi',
'cd build',
'composer install --no-dev -o',
'for symlinksource in $(find vendor/amp -type l); do symlinktarget=$(readlink "$symlinksource") && rm "$symlinksource" && cp -r "vendor/amp/$symlinktarget" "$symlinksource"; done',
'composer remove cweagans/composer-patches --update-no-dev -o',
'rm -r ' + productionVendorExcludedFilePatterns.join( ' ' )
].join( ' && ' ),
},
create_build_zip: {
command: 'if [ ! -e build ]; then echo "Run grunt build first."; exit 1; fi; if [ -e amp.zip ]; then rm amp.zip; fi; cd build; zip -r ../amp.zip .; cd ..; echo; echo "ZIP of build: $(pwd)/amp.zip"',
Expand Down Expand Up @@ -150,6 +161,7 @@ module.exports = function( grunt ) {
} );

paths.push( 'composer.*' ); // Copy in order to be able to do run composer_install.
paths.push( 'lib/**' );
paths.push( 'assets/js/*.js' ); // @todo Also include *.map files?
paths.push( 'assets/js/*.asset.php' );
paths.push( 'assets/css/*.css' );
Expand Down
20 changes: 19 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
"ext-iconv": "*",
"ext-libxml": "*",
"ext-spl": "*",
"amp/common": "^1",
"amp/optimizer": "^1",
"cweagans/composer-patches": "1.6.7",
"fasterimage/fasterimage": "1.5.0",
"sabberworm/php-css-parser": "dev-master#134f4e6"
Expand Down Expand Up @@ -58,10 +60,26 @@
}
},
"repositories": [
{
"type": "path",
"url": "lib/common",
"options": {
"symlink": true
}
},
{
"type": "path",
"url": "lib/optimizer",
"options": {
"symlink": true
}
},
{
"type": "vcs",
"url": "https://github.com/sabberworm/PHP-CSS-Parser.git",
"no-api": true
}
]
],
"minimum-stability": "dev",
"prefer-stable": true
}
Loading