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

Implement validation using Cloudflare's AMP linter API endpoint #59

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hvelarde
Copy link
Member

@hvelarde hvelarde commented Aug 3, 2017

WIP

  • document feature on README
  • validate on publishing item
  • validate on editing of published item
  • show details on validation errors
  • don't break on package uninstalled
  • add option on configlet to enable/disable validation
  • add upgrade step

closes #16

@hvelarde hvelarde requested a review from rodfersou August 4, 2017 20:57
@hvelarde
Copy link
Member Author

hvelarde commented Aug 4, 2017

@ale-rt are you using AMP? do you want to help reviewing this?

@kakshay21 this is what I was expecting just as a beginning.

@ale-rt
Copy link
Member

ale-rt commented Aug 14, 2017

@hvelarde I am interested in the project but unluckily I had no chance to use it and inspect the code in detail.
Unluckily this is a bad period for adding new tasks to my todo list!

"""Validate @@amp view using Cloudflare's AMP linter API endpoint."""
request = obj.REQUEST

if event.status['review_state'] not in ('published', ):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if event.status['review_state'] != 'published':

return

# remove the scheme from the URL
url = ''.join(urlparse(obj.absolute_url())[1:])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

url = obj.absolute_url() # http://site/myobject
url_no_scheme = ''.join(urlparse(url))[1:] # site/myobject

# remove the scheme from the URL
url = ''.join(urlparse(obj.absolute_url())[1:])

r = requests.get('https://amp.cloudflare.com/q/' + url + '/@@amp')
Copy link
Member

@rodfersou rodfersou Aug 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rodfersou
rodfersou previously approved these changes Aug 18, 2017
Copy link
Member

@rodfersou rodfersou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just pointed some code review. But it looks good the way it is

@hvelarde hvelarde dismissed rodfersou’s stale review August 18, 2017 13:06

I have finished 1 of the 7 things needed here; a review at this point is useless.

logger.info(msg)
api.portal.show_message(message=msg, request=request, type='info')
else:
msg = u'Not a valid AMP page'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not include the error in the warning message?

        for error in validation['errors']:
            msg = msg + str(error)

@rodfersou @hvelarde

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I get it it would be difficult in writing the test case then right? @hvelarde

kakshay21
kakshay21 previously approved these changes Dec 11, 2017
@hvelarde hvelarde dismissed kakshay21’s stale review December 11, 2017 13:25

this is far from complete

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Validate AMP pages
4 participants