collective / collective.behavior.amp

Support for Accelerated Mobile Pages (AMP) in Plone.
5 stars 2 forks source link

Validate AMP pages #16

Open hvelarde opened 8 years ago

hvelarde commented 8 years ago

It would be nice to run validation in CI.

See: https://www.ampproject.org/docs/guides/validate.html

kakshay21 commented 7 years ago

These are my findings in Validating AMP pages : 1.Command Line tool 2.amphtml-validator 3.gulp-amphtml-validator

  1. WebUI In all the first 3 methods, the validation status is piped out to the console. WebUI provides a server which is built on Go language and this is considered to be good alternative of WebUI. So If we have to consider between 2 and 3 I'd choose 2 because it has more releases and the releases are more often than 3. And since all first three provides the error status to console, so it hardly matters between 1 and 2. But considering the use cases with Plone, clients would prefer 4 than any other option. But still option 4 is in development. So If we have to make choice of choosing the best one now, then I would go with amphtml-validator i.e option 2.
rodfersou commented 7 years ago

My comments about references:

  1. This is a tutorial to show how to use second reference.
  2. This is the actual working validator.
  3. This is just another way to use the same validator (with gulp)
  4. Is the same validator served with Golang backend. If I understand correctly reading the code, it points to a javascript file inside the server.

So, all the magic happen just in reference number 2, and to integrate with Plone we can follow something like what we did at collective.behavior.featuredimage 1, 2, 3 where we add phanthomjs binary in the environment and call it from python, the only difference is that we need to call the validator command and read the output to show the errors, what can be done with subprocess module.

hvelarde commented 7 years ago

I found an easier solution using Cloudflare's AMP linter API.

please create an event subscriber and bind it to the creation and modification events to check the AMP output using this service; if the code is not valid we should display a warning to the user.