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

Make sure the Distributor admin bar works correctly when loading via AMP #665

Merged
merged 8 commits into from
Nov 17, 2020

Conversation

dkotter
Copy link
Collaborator

@dkotter dkotter commented Nov 10, 2020

Description of the Change

When using the official AMP WP plugin, if you have the front-end of your site set to always use AMP and you're logged in, the Distributor admin bar item shows but does not work. The issue lies with AMP removing the assets we rely on, as well as mangling the templates we output.

This PR ensures all of our assets are loaded via amp-dev-mode, so they don't get removed. It also changes our template system too utilizing Mustache, which AMP supports.

Alternate Designs

None

Benefits

Front-end distribution will now work properly when using AMP

Possible Drawbacks

We now have two different template systems: one used only for AMP and the previous one we use elsewhere. Ideally we would use the same templates for both but for now, I think it's safer to keep those separate.

Verification Process

  1. Install the AMP WP plugin and get that set up
  2. Ensure you are logged in and visit the frontend view of a single post
  3. Hover over the Distributor admin bar item and make sure it loads
  4. Choose a connection to distribute to and make sure that works

Checklist:

  • I have read the CONTRIBUTING document.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests passed.

Applicable Issues

Closes #658

Darin Kotter and others added 4 commits November 5, 2020 08:14
… This allows us to load the templates in the mustache format, which AMP better supports. Move our templates to a new templates directory, for cleaner code organization. Modify our push JS to account for this new template format
… mustache templates. Only show search bar if we have more than 5 connections. Change the name we show for each connection depending on if it is internal or external. Make sure disabled attribute is set correctly
@dkotter dkotter self-assigned this Nov 10, 2020
@jeffpaul jeffpaul added this to the 1.7.0 milestone Nov 10, 2020
@jeffpaul
Copy link
Member

Something looks off from Travis, haven't dug in yet to see what's erroring there but may need to if this fails testing with @rickalee.

@jeffpaul jeffpaul modified the milestones: 1.7.0, 1.6.1 Nov 10, 2020
@rickalee
Copy link

@dkotter Great work so far. Looks like we still need to address jQuery compatibility. Screenshot is AMP Validation errors.

https://rickal.ee/DOu9pBBp

After I 'Kept' jQuery in AMP Validation, I was able to successfully push to External Location from frontend.

@dkotter
Copy link
Collaborator Author

dkotter commented Nov 12, 2020

@dkotter Great work so far. Looks like we still need to address jQuery compatibility. Screenshot is AMP Validation errors.

https://rickal.ee/DOu9pBBp

After I 'Kept' jQuery in AMP Validation, I was able to successfully push to External Location from frontend.

@rickalee Thanks for the review! I do add the dev mode attribute to the jQuery script but am currently looking for a script with an id of jquery-core-js, whereas your screenshot is showing an id of jquery-js.

The former was what I was seeing when testing so I'll look at this again and see if there's a more resilient way to look for jQuery that will work even if that ID changes (though I'm not sure why the ID is different, something else I can look at)

Darin Kotter added 2 commits November 13, 2020 08:22
…ake it less fragile if the IDs of those elements change
…ms WordPress uses that if you request just jquery. Make sure we don't load our mustache templates in the admin
@dkotter
Copy link
Collaborator Author

dkotter commented Nov 13, 2020

@rickalee I've added some code that I think makes the handling of dependencies (in our case, jQuery and underscores) a bit more resilient. I couldn't ever reproduce a scenario that gave me a jQuery file with the ID of jquery-js, it was always jquery-core-js, so I wasn't able to fully test the scenario you ran into so if you could test again and let me know if this now works properly, that would be great.

@rickalee
Copy link

@dkotter Confirmed that Distributing is working on frontend and not getting any AMP Validation errors. Also confirmed jQuery isn't added to frontend for non-logged in users.

I think we are set with this feature. However found another character encoding bug with apostrophe/single quote with titles but will open a different ticket.

https://rickal.ee/KouwpQ59

@jeffpaul jeffpaul merged commit b99d11a into develop Nov 17, 2020
@jeffpaul jeffpaul deleted the feature/amp-adminbar-support branch November 17, 2020 19:00
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.

Support for AMP - amp-dev-mode
4 participants