Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: Implementing AMP pages in Textpattern
Check out this forked version of mkp_amp plugin
Patrick.
Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.
Offline
Re: Implementing AMP pages in Textpattern
The latest version 3.3 simulates the feature in use within “The Guardian” website which redirects to the same article’s URL onto the subdomain (default: amp): mkp_if_amp plugin
Patrick.
Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.
Offline
Re: Implementing AMP pages in Textpattern
Hi there,
implemented amp on my news site with the help of mkp_if_amp. Thanks a lot Michael!!
One small problem still exists. In tables I use textile commands to format them like this:
|^.
|_<. xyz|_>. 2002|_>. 2003|_>. 2004|_>. 2005|_>. 2006|_>. 2007|_>. 2008|_>. 2009|_>. 2010|
|-.
|<. xzy|>. 5,8|>. 9,3|>. 13,1|>. 5,1|>. 4,8|>. 10,6|>. 8,5|>. -19,6|>. 4,5|
This ends up in html code like that: th style="text-align:right;">2003</th>
. And the AMP tester from Google complains The attribute 'style' may not appear in tag 'th'.
for th and td about these style attributes.
Is there a quick solution not to render textile under these circumstances for table attributes or do I have to filter these attributes with something like etc_query to get a amp standard conform page?
Offline
Re: Implementing AMP pages in Textpattern
I found a solution. Replace the <txp:body />
tag in your amp form for articles with something like that:
<txp:php>
$text=preg_replace('/(<[^>]+) style=".*?"/i','$1',body());
echo $text;
</txp:php>
Offline
Re: Implementing AMP pages in Textpattern
I’m building an AMP template for blog articles as part of the new Textpattern.com site – AMP mockup here (obviously should be viewed on mobile as intended) – thanks for the suggestions in this topic. I’ll eventually share the code I’m using via GitHub.
Offline
Re: Implementing AMP pages in Textpattern
oh cool …
For embedding videos or other embedded stuff you have to make a test, because Google is complaining about unused amp-scripts.
For example for Youtube videos I use the following in head:
<txp:php>
$text=preg_replace('/(<[^>]+) style=".*?"/i','$1',body());
if (strpos($text, 'amp-youtube') !== false) {variable( array('name' => 'video-tag', 'value' => 'yes') );}
variable(array ('name' => 'article', 'value' => $text));
</txp:php>
<txp:if_variable name="video-tag">
<script async custom-element="amp-youtube" src="https://cdn.ampproject.org/v0/amp-youtube-0.1.js"></script>
</txp:if_variable>
And then <txp:php>echo $text;</txp:php>
instead of <txp:body />
. Of course your video plugin should be adapted to use amp-youtube as a tag, when used on a amp page.
Last edited by whocarez (2017-02-10 17:27:49)
Offline
Re: Implementing AMP pages in Textpattern
@whocares
Yes I can see that being tricky but your solution is interesting thanks – you’d think they would provide an easy way to conditionally load the video JS if the page actually has a video on it, since they are being so particular about code reduction.
Offline
Re: Implementing AMP pages in Textpattern
I don’t know. At the moment Google webmasters warns you, there is a youtube/facebook/twitter script embedded, but the interpreter can’t find any of the related tags. But it says also, that the will treat it in the future as an error.
All amp tags/components are here:
https://www.ampproject.org/docs/reference/components
Actually I use amp-analytics, amp-ad, amp-social-share and under conditions amp-youtube with a modified the_video plugin and this trick above.
Last edited by whocarez (2017-02-10 19:22:53)
Offline
Re: Implementing AMP pages in Textpattern
Yeah I’m just using amp-sidebar on Textpattern.com AMP pages, although I may add analytics as well. amp-ad only seems to work with a select few advertisers as far as I’ve researched so far, but haven’t delved too far into ads just yet.
Offline
Re: Implementing AMP pages in Textpattern
One of the problems publishers face today in making their content more readable on mobile devices is that there are multiple, competing formats available for this purpose. Facebook has Instant Articles, Google is spearheading the AMP (Accelerated Mobile Pages) project, and the Apple News Format optimizes content for iOS devices. Facebook is today taking a crack at a solution to this problem by rolling out support for both AMP and soon Apple News as a part of its open source Instant Articles software development kit. – Facebook’s Instant Articles platform to support Google AMP, Apple News
Offline
Re: Implementing AMP pages in Textpattern
@michaelkpate
on the flip side: Scott Gilbertson: Kill Google AMP before it KILLS the web (via gruber).
Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
Offline
Re: Implementing AMP pages in Textpattern
phiw13 wrote #305765:
@michaelkpate
on the flip side: Scott Gilbertson: Kill Google AMP before it KILLS the web (via gruber).
I don’t trust google.
…. texted postive
Offline