-
Notifications
You must be signed in to change notification settings - Fork 385
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
Extract post-processor logic into CMS-agnostic PHP library #2315
Comments
Hi Weston, I think we should go with a "amp-php-migrator-engine" package or so. This could be ideally prepared for PHP 7+ but still support PHP 5.6 for WP - for now I'm fine coding the PHP 5.6-way. We could then create "adapters" for each CMS as separate packages IMHO. Do you have more docs on the amp-wp package, otherwise I can start migrating and look into a proper API so WP works with it. |
Yes, agreed. The CMS-agnostic library would be in a separate package, naming TBD. The AMP plugin for WordPress would then use the package as it would adapt the library for a WordPress context, just as there would be similar adapters for other CMSes, like Typo3.
The docs so far are almost all inline with the code. Part of this effort is to flesh out the documentation and better explain how it works, and clean up some technical debt. This would be an important part of the refactoring so that it is easier for you to integrate. You can see an example of @marcelovani experimenting with integrating the WordPress plugin's code into the AMP library used by the Drupal module here: Lullabot/amp-library#231 (comment). |
I opened an issue specifically for the extraction of the CSS sanitizer (including the tree shaker): #5602. |
For people following this specific issue, I'd like to note that the work for this issue is already underway under the https://github.com/ampproject/amp-toolbox-php/ repository. |
Specifically, see ampproject/amp-toolbox-php#194 and ampproject/amp-toolbox-php#195. Other issues (e.g. embed handlers) can be filed as issues in amp-toolbox-php as well. |
There is need in Drupal, Joomla!, Typo3 among other PHP-based CMSes for an official library to do what the AMP WordPress plugin does in its post-processor phase. The Drupal AMP module is currently using
amp-library
for this purpose. but it is very out of date and it needs to be overhauled (see Lullabot/amp-library#231). A library which is maintained by the AMP project is needed to ensure it is kept up to date.Such a library should include:
img
toamp-img
).This would essentially be extracting the entirety of the
AMP_Theme_Support::prepare_response()
method, minus the parts that are WordPress-specific. The extracted functionality would need to be configurable to plug in to any CMS, including the way it handles script dependencies and object caching.As part of this effort, we should take the opportunity to refactor the sanitizers to clean up some legacy cruft and embrace a more modern PHP 5.6 world (which is WordPress's new minimum version). Likewise, the
AMP_Theme_Support::ensure_required_markup()
should be converted into a sanitizer, and a new sanitizer for implementing optimized/transformed AMP can be introduced (#958).While not part of the post-processor phase, there would also be value in extracting the the oEmbed handling, defining a mapping of oEmbed URLs to how they should be converted into AMP.
The text was updated successfully, but these errors were encountered: