Skip to content

Add capability to generate AMP-only content (AMP-as-Canonical)#668

Closed
amedina wants to merge 22 commits intomasterfrom
amedina/amp-canonical
Closed

Add capability to generate AMP-only content (AMP-as-Canonical)#668
amedina wants to merge 22 commits intomasterfrom
amedina/amp-canonical

Conversation

@amedina
Copy link
Copy Markdown
Member

@amedina amedina commented Mar 23, 2017

New PR with changes in #425.
Incorporated pending review requests
Created a new branch because to avoid conflicts and continue the work on new branch

Add additional postprocessing actions to remove validation errors.
@amedina
Copy link
Copy Markdown
Member Author

amedina commented Mar 26, 2017

Currently the plugin generates an AMP canonical page with the 2017 Theme; there is one validation error regarding the size of the amp-custom styles; the strategy followed right now is to take the theme styles and inline them as an amp-custom style element but the size of the styles exceed the 50KB limit.

amp.php Outdated
require_once( AMP__DIR__ . '/includes/settings/class-amp-customizer-design-settings.php' );
require_once( AMP__DIR__ . '/includes/utils/class-amp-dom-utils.php');
require_once( AMP__DIR__ . '/option.php' );
require_once(AMP__DIR__ . '/post-processing/class-amp-sanitize-tweentyseventeen-theme-plain.php');
Copy link
Copy Markdown
Contributor

@paulschreiber paulschreiber Apr 28, 2017

Choose a reason for hiding this comment

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

Add spaces inside parentheses.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Definitely; will do.

@htrex
Copy link
Copy Markdown

htrex commented Dec 11, 2017

I'm not sure but with a first look at the PR code it seems this implementation wouldn't allow to create a Progressive Web AMP website (see #778) which I think is the most important real world use case.

The next week I'll have some time to experiment with it and will report back, sorry if I'm missing something at the moment! ;)

I'll try to explain the use case concept first:
I'm building a WP theme directly with an AMP codebase and want to serve almost the same page markup for both the "canonical" non valid AMP page and the valid "amphtml" AMP page.

On the "canonical" AMP page, the thunder symbol must not be declared inside the <html> tag so that it doesn't throw validation errors when the page is progressively enhanced loading additional assets. On this "canonical" page, the_content still needs to be sanitized so that every basic AMP feature works on the page.

The valid "amphtml" version of page may be served from an AMP cache and it'll miss all the progressive enhancements, but it could use amp-install-serviceworker to preload all the additional JS, CSS and other assets needed from the PWAMP.

As the AMP Cache doesn't modify the page link urls, they can link to canonical versions of the page so that the PWAMP will be shown about instantly at the second page view from the same site.

Hope I've been clear enough... ;)

@htrex
Copy link
Copy Markdown

htrex commented Dec 15, 2017

@amedina woah, I've tried to merge your branch with develop and couldn't solve the conflicts, could you please update the patches?

@westonruter
Copy link
Copy Markdown
Member

We're going to be creating a new PR for canonical support. See discussion after #827 (comment)

@westonruter
Copy link
Copy Markdown
Member

(We'll be gleaning the relevant parts from this PR.)

// Remove comments
$minified_css = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $minified_css);
// Remove space after colons
$minified_css = str_replace(': ', ':', $minified_css);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Instead of lines 12 and 14 why not just this?

$minified_css = preg_replace( '#\s+#ms', '', $minified_css);`

return;
}
$index = 0;
error_log("Recording styles...");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we be filling up error_log() with informational messages?

private $content;
private $amp_content = '';
private $amp_scripts = array();
public $amp_scripts = array();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why is this made public and exposed?

@@ -0,0 +1,38 @@
<?php

class PairedModeActions {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why is class name not prefixed with AMP_?

@schlessera schlessera deleted the amedina/amp-canonical branch March 7, 2020 06:24
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.

5 participants