News:

Wondering if this will always be free?  See why free is better.

Main Menu

AMP4SMF

Started by Antes, July 27, 2020, 04:43:04 PM

Previous topic - Next topic

Antes

Link to the mod

Adds very basic AMP support for your SMF forum... Only supported structure is topics.

SMF2: v0.0.1 (same code as SMF 2.1 version just less hooks due to core-software limitations)
SMF2.1: v0.0.3

You can support me via Twitch Prime* or Patreon.

Changelog
v0.0.3 (SMF 2.1 version only)
- Img bbcode and Code bbcode disabled.
- Poll related code removed.
v0.0.2 (SMF 2.1 version only)
! Small code adapts & more hooks
v0.0.1
! First release

-Rock Lee-

I will test it to see how it works, even if it is basic it can fulfill its function well. I saw some advertising agencies implement it in some highly modified SMF but the performance worsened (I don't know why).


Regards!
¡Regresando como cual Fenix! ~ Bomber Code
Ayudas - Aportes - Tutoriales - Y mucho mas!!!

diegolyanky


Didn't worked on 2 of my sites. SMF 2.0.17

SMF ... SimpleMachines ... Simple, but complete if you want it ;)

Arantor

Quote from: diegolyanky on July 27, 2020, 07:55:17 PM

Didn't worked on 2 of my sites. SMF 2.0.17



How did it not work? Do you go to the doctor when you are unwell and just say "I'm ill", no, you provide details. Please do so here.

diegolyanky


haha... Sorry, you're right.

I installed without problem, all fine and no errors. When I tested the AMP under search console, said: NO AMP DETECTED.

That's all...

Maybe I am doing something wrong (IDK)

Thanks a lot for your quick reply
SMF ... SimpleMachines ... Simple, but complete if you want it ;)

Antes

Quote from: diegolyanky on July 28, 2020, 08:56:12 AM

haha... Sorry, you're right.

I installed without problem, all fine and no errors. When I tested the AMP under search console, said: NO AMP DETECTED.

That's all...

Maybe I am doing something wrong (IDK)

Thanks a lot for your quick reply

There are few things;

The mod does not make your entire site AMP Valid. Its only for topics. When I try to validate a page in AMPValidator it fails but tells me that this page redirects to AMP version (weird that validator itself is not self-redirecting).

Once I tell the page that show me the redirected (AMP) results: https://search.google.com/test/amp?skip_amp_follow=true&id=APQM6j9Ket1IaCc4aCaiEA

To validate your page if it has valid AMP version... Navigate to the topic, check source file and you should see something like...

<link rel="amphtml" href="https://www.yoursite.tld/index.php?action=amp;topic=id">

if the code is there your page (SHOULD) be fine... as again we don't know how well the system works but according to their Docs, this is the way to redirect search engine (Google) to AMP page... If the following code does not exist in your page, either you didn't install the mod's edits to your custom theme or something else -which I don't know-.

-Rock Lee-

It works as it should although I thought it causes problems with the nice url, so far it works fine. But when there are citations or the code bbcode fails in the validation, not everywhere but in some specific points related to php (I have to do more tests). Left where that error marks me:

Quote<a href="" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code">SET xdate = %date: ~ -10,2%% date: ~ -7,2%% date: ~ -4,4%</code><br /><div class="codeheader">Código: (Windows) <a href="" onclick="return smfSelectText(this);" class="codeoperation">[Seleccionar]</a></div><code class="bbc_code">@echo on<br />

Try one 2.0.15 and two 2.0.17... In all of them something similar happens to me when I put [code][/code] with lines in php/bach/bash (I have to try more).


Regards!

ADD: Apparently the error occurs because the "onclick" attribute cannot appear in the "a" tag (it's an AMP rule from what I read). It's time to do a little more research! :P
¡Regresando como cual Fenix! ~ Bomber Code
Ayudas - Aportes - Tutoriales - Y mucho mas!!!

marcosbr


I only have this error on topics with image from the RSS Feed Poster. (I use this mod)
AMP validator: "The tag 'img' may only appear as a descendant of tag 'noscript'. Did you mean 'amp-img'? Debug. Learn more..."


Remaining OK!
Nothing in life is absolute. We are always learning... Did you know that?
https://amigosdaeletronica.com.br

Antes

Quote from: Rock Lee on July 28, 2020, 02:47:03 PM
It works as it should although I thought it causes problems with the nice url, so far it works fine. But when there are citations or the code bbcode fails in the validation, not everywhere but in some specific points related to php (I have to do more tests). Left where that error marks me:

Quote<a href="" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code">SET xdate = %date: ~ -10,2%% date: ~ -7,2%% date: ~ -4,4%</code><br /><div class="codeheader">Código: (Windows) <a href="" onclick="return smfSelectText(this);" class="codeoperation">[Seleccionar]</a></div><code class="bbc_code">@echo on<br />

Try one 2.0.15 and two 2.0.17... In all of them something similar happens to me when I put [code][/code] with lines in php/bach/bash (I have to try more).


Regards!

ADD: Apparently the error occurs because the "onclick" attribute cannot appear in the "a" tag (it's an AMP rule from what I read). It's time to do a little more research! :P

Quote from: marcosbr on July 28, 2020, 10:25:35 PM

I only have this error on topics with image from the RSS Feed Poster. (I use this mod)
AMP validator: "The tag 'img' may only appear as a descendant of tag 'noscript'. Did you mean 'amp-img'? Debug. Learn more..."


Remaining OK!

That's expected... BBCodes are using different type of goodies to become alive and AMP by design is very limited system... The solution is not editing your post, please do not do that.

-Rock Lee-

I did not even think about editing topics for this error, I will look for another solution if it exists, although the impression that smf already brings cannot be used? Isn't it similar in the sense it has to be as simple as possible?

https://www.simplemachines.org/community/index.php?action=printpage;topic=574227.0 < It is even more direct than AMP or so it seems to me.


Regards!
¡Regresando como cual Fenix! ~ Bomber Code
Ayudas - Aportes - Tutoriales - Y mucho mas!!!

Arantor

Yes but it doesn't use the magical markup that Google tells you to use, so it can better make money out of your content.

Antes

Quote from: Rock Lee on July 29, 2020, 02:06:21 PM
I did not even think about editing topics for this error, I will look for another solution if it exists, although the impression that smf already brings cannot be used? Isn't it similar in the sense it has to be as simple as possible?

https://www.simplemachines.org/community/index.php?action=printpage;topic=574227.0 < It is even more direct than AMP or so it seems to me.


Regards!

The system is built based on printpage to keep the simplicity, the reality is AMP is a horrid spawn of Google... The only reason I wrote this mod because a) it was relatively easy to do b) I had time. Solution to BBCode may not be simple, I need to make some research because I honestly think, someone shouldn't just hook-into parseBBC and replace BBCodes with other ones...

Another reality is... ResponsiveCurve is 100000000000000 (0 to infinity) better than AMP can ever be, because Responsive design does not limit your functionality UNLIKE this horrid spawn of Google... The mod will become obsolete, once Google says, "okay I' f'd up... this system is not working" -which is relatively soon- because we know that they are removing limitation of promoting sites (to upper story parts) to AMP.

Quote from: Arantor on July 29, 2020, 02:19:14 PM
Yes but it doesn't use the magical markup that Google tells you to use, so it can better make money out of your content.

also +1

-Rock Lee-

Quote from: Arantor on July 29, 2020, 02:19:14 PM
Yes but it doesn't use the magical markup that Google tells you to use, so it can better make money out of your content.

If it is something I notice and more in these times, I never thought to make a site profitable because I think it loses the sense of fun when editing something and becomes an obligation. Added you need 100000000 visits to win 1USD... There are better and easier ways to get money (that's what I think).

Quote from: Antes on July 29, 2020, 02:26:02 PM
The system is built based on printpage to keep the simplicity, the reality is AMP is a horrid spawn of Google... The only reason I wrote this mod because a) it was relatively easy to do b) I had time. Solution to BBCode may not be simple, I need to make some research because I honestly think, someone shouldn't just hook-into parseBBC and replace BBCodes with other ones...

Another reality is... ResponsiveCurve is 100000000000000 (0 to infinity) better than AMP can ever be, because Responsive design does not limit your functionality UNLIKE this horrid spawn of Google... The mod will become obsolete, once Google says, "okay I' f'd up... this system is not working" -which is relatively soon- because we know that they are removing limitation of promoting sites (to upper story parts) to AMP.

It is the truth that for a while they will use AMP and then change everything, after all they must generate their profit. To see how it works it is not badly, it does not add or subtract having it installed (in forum normal operation).


Regards!
¡Regresando como cual Fenix! ~ Bomber Code
Ayudas - Aportes - Tutoriales - Y mucho mas!!!

Arantor

No, it's not about making *your* site profitable. It's about Google making money from you.

-Rock Lee-

Now that you mention it you are right and many want google to look at their websites, a perfect cycle.
¡Regresando como cual Fenix! ~ Bomber Code
Ayudas - Aportes - Tutoriales - Y mucho mas!!!

AllMassive

Sorry, but:
What is AMP ?

efk

Quote from: AllMassive on August 10, 2020, 07:48:11 PM
Sorry, but:
What is AMP ?
Probably 99%+ members and guests will have exactly the same question. Even google fails to answer  :D
Edit: Got an idea what it could be since I saw many Amplifiers in google store in past, so it has to be Amplifier but still no clue for what since there is no info about mod.

-Rock Lee-

¡Regresando como cual Fenix! ~ Bomber Code
Ayudas - Aportes - Tutoriales - Y mucho mas!!!

Arantor

A way of making your site easier for Google to scrape and display content from without having to send users to you / a way of displaying ads better without all the other stuff on your site.

pocttopus

Does AMP stands for Accelerated Mobile Pages?

Antes


Xpresskonami

Quote from: Antes on August 21, 2020, 02:52:32 PM
Yes

Thanks for the mod. Is this working with pretty url and how can i get the link for it

Xpresskonami



-Rock Lee-

Quote from: Xpresskonami on August 26, 2020, 11:41:27 PM
Thanks for the mod. Is this working with pretty url and how can i get the link for it

I use it with the pretty urls without problems, just add at the end "?action=amp"


Regards!
¡Regresando como cual Fenix! ~ Bomber Code
Ayudas - Aportes - Tutoriales - Y mucho mas!!!

Antes

You don't need any URLs, by default Google will detect the page without needing your support. Also if you are going to use that page for your users, don't... just get a Responsive Theme.

njtweb

I'eve read through and have a couple questions.

First, I see this is helpful for Google speed which is very helpful for adsense. That would be the only reason I'd want to leverage this mod. However I also read it strips image tags in mobile devices. Is this accurate? I need my users mobile experience to be the same as on a computer.

Thank you I look forward to your response.

Antes

Quote from: njtweb on September 02, 2020, 07:14:02 AM
I'eve read through and have a couple questions.

First, I see this is helpful for Google speed which is very helpful for adsense. That would be the only reason I'd want to leverage this mod. However I also read it strips image tags in mobile devices. Is this accurate? I need my users mobile experience to be the same as on a computer.

Thank you I look forward to your response.

That's not even remotely possible with AMP. AMP is just yet another pumped project from Google, the only reason this mod exist because people should leverage off of these cherries on the top. To have proper mobile experience you should get a properly designed Responsive Theme (or RCurve if you are on default theme).

To address the BBCode issue, Unfortunately I don't have much time to spend on SMF for now. I'd love to fix at least image issue in the mod and possibly disable rest of the BBCodes in that specific mod.

njtweb

Thank you, I do use default theme and responsive curve 1.1.0. I didn't update to 1.0.1 because you didn't think it was necessary, (I commented in your dcurve thread).

Antes

SMF 2.1 ONLY - v0.0.3 released, added a nice neat hook to disable some BBCodes. Backporting this may not happen due to lack of hooks... I'll try to work-around the hooks to ensure same code backported but no promises.

spiros

Amazing work, Antes, I see you did it for SMF 2 and I installed it. A strange thing, pages validate via https://validator.ampproject.org but when I access them with my Android phone (Chrome browser), I get "sorry this page is not valid amp html" and get redirected to the forum home page. When I try with any other browser, I see the amp page.

Example pages:
https://www.translatum.gr/forum/index.php?action=amp;topic=987010
https://www.translatum.gr/forum/index.php?action=amp;topic=985701.0

spiros

#31
I got this reply:

QuoteLooking at the URL in the search result, it has a URL with parts of the query string escaped.

Original URL:
https://www.translatum.gr/forum/index.php?action=amp;topic=987010

URL in Search:
https://www.translatum.gr/forum/index.php?action=amp%3Btopic%3D985701

Using that escaped URL with both validator.amp.dev and the Chrome Extension it shows that the returned HTML is not valid AMP and is not declared as AMP.

There are two potential solutions for you, though this is outside of the scope of AMP itself.

Use & instead of ; for different query params.
Update the server for this domain to handle escaped query params for %3B (which is ;).
https://github.com/ampproject/amphtml/issues/31063

Not clear on either of these suggestions really...

This is what I can see in the way the page is linked in google search results:

<a class="C8nzq BmP5tf amp_r" data-amp="https://www.translatum.gr/forum/index.php?action=amp;topic%3D985701" data-amp-cur="https://www.translatum.gr/forum/index.php?action=amp;topic=985701" data-amp-title="translatum.gr" data-amp-vgi="8458557019360116853" href="https://www.translatum.gr/forum/index.php?action=amp;topic=985701" data-ved="2ahUKEwim8cXvrvvsAhXCMewKHYUJDfEQFjAAegQIARAB" ping="/url?sa=i&amp;source=web&amp;rct=j&amp;url=https://www.translatum.gr/forum/index.php%3Faction%3Damp%3Btopic%3D985701&amp;ved=2ahUKEwim8cXvrvvsAhXCMewKHYUJDfEQFjAAegQIARAB&amp;psig=AOvVaw3Zumwox_YowxhDDwIehV-e&amp;ust=1605214160452451&amp;ampcf=1"><div class="abuKkc IhfN8d MUxGbd lyLwlc aLF0Z"><img class="eqA2re" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAABnRSTlMAAAAAAABupgeRAAAAMklEQVR4AWMY5OD/TIb/aZgIl+o0XAinanSdBAGFGmbS0gZMLxGrgSirCAQrYT2DHwAAv0tHhsJpXPsAAAAASUVORK5CYII=" alt="Image" aria-hidden="true" data-atf="1" width="16" height="16"><span class="Zu0yb UGIkD qzEoUe">www.translatum.gr<span class="kbNtnf Jzkcjd"> › forum</span></span><span jsname="zYLzN" class="ZseVEf QzoJOb" aria-label="AMP logo"></span></div><h2 class="Uo8X3b">Web results</h2><div class="PpBGzd YcUVQe MUxGbd v0nnCb" aria-level="3" role="heading"><div class="V7Sr0 p5AXld PpBGzd YcUVQe">pre-owned -&gt; μεταχειρισμένος, δεύτερο χέρι, που είχε προηγούμενο ιδιοκτήτη, προϊδιόκτητος - Translatum</div></div></a>

Antes

I can't be sure what is causing this... Google redirects with "%3Btopic%3D985701" and either mod or server fails to redirect...

spiros

Well, apparently this does not occur on canonical URLs which have similar parameter separators. It could be a clue. For what it's worth, I tested it on 2 different sites (same server).

This is what I see when searching from Chrome desktop, which, for some strange reason, only lists the AMP page, and happily directs to it when clicked.

<a href="https://www.translatum.gr/forum/index.php?action=amp;topic=985701" ping="/url?sa=t&amp;source=web&amp;rct=j&amp;url=https://www.translatum.gr/forum/index.php%3Faction%3Damp%3Btopic%3D985701&amp;ved=2ahUKEwji8ujg-vzsAhVBsKQKHY6VDrsQFjAAegQIAxAC"><br><h3 class="LC20lb DKV0Md"><span>pre-owned -&gt; %u03BC%u03B5%u03C4%u03B1%u03C7%u03B5%u03B9%u03C1%u03B9%u03C3%u03BC%u03AD%u03BD%u03BF%u03C2, %u03B4%u03B5%u03CD%u03C4%u03B5%u03C1%u03BF %u03C7%u03AD%u03C1%u03B9, %u03C0%u03BF%u03C5 ... - Translatum</span></h3><div class="TbwUpd NJjxre"><cite class="iUh30 Zu0yb qLRx3b tjvcx">www.translatum.gr<span class="dyjrff qzEoUe"><span> %u203A forum</span></span></cite></div></a>

When I spoof the user agent to mobile from Chrome desktop, I get this (which presents the issue, apparently, it is just the = sign which is mangled there? "topic%3D985701"):

<a class="C8nzq BmP5tf amp_r" data-amp="https://www.translatum.gr/forum/index.php?action=amp;topic%3D985701" data-amp-cur="https://www.translatum.gr/forum/index.php?action=amp;topic=985701" data-amp-title="translatum.gr" data-amp-vgi="8458557019360116853" href="/url?sa=t&amp;source=web&amp;rct=j&amp;url=https://www.translatum.gr/forum/index.php%3Faction%3Damp%3Btopic%3D985701&amp;ved=2ahUKEwibmLWs-_zsAhUDKuwKHUYaB2EQFjAAegQIBBAC&amp;usg=AOvVaw1svqtelcNJFRHy1kuYwYAy&amp;ampcf=1" data-ved="2ahUKEwibmLWs-_zsAhUDKuwKHUYaB2EQFjAAegQIBBAC" oncontextmenu="google.ctpacw.cm(this)"><div class="abuKkc IhfN8d MUxGbd lyLwlc aLF0Z"><img class="eqA2re" height="16" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAABnRSTlMAAAAAAABupgeRAAAAMklEQVR4AWMY5OD/TIb/aZgIl+o0XAinanSdBAGFGmbS0gZMLxGrgSirCAQrYT2DHwAAv0tHhsJpXPsAAAAASUVORK5CYII=" width="16" alt="Image" aria-hidden="true" data-atf="1"><span class="Zu0yb UGIkD qzEoUe">www.translatum.gr<span class="kbNtnf Jzkcjd"> %u203A forum</span></span><span jsname="zYLzN" class="ZseVEf QzoJOb" aria-label="AMP logo"></span></div><h2 class="Uo8X3b">Web results</h2><div class="PpBGzd YcUVQe MUxGbd v0nnCb" aria-level="3" role="heading"><div class="V7Sr0 p5AXld PpBGzd YcUVQe">pre-owned -&gt; %u03BC%u03B5%u03C4%u03B1%u03C7%u03B5%u03B9%u03C1%u03B9%u03C3%u03BC%u03AD%u03BD%u03BF%u03C2, %u03B4%u03B5%u03CD%u03C4%u03B5%u03C1%u03BF %u03C7%u03AD%u03C1%u03B9, %u03C0%u03BF%u03C5 %u03B5%u03AF%u03C7%u03B5 %u03C0%u03C1%u03BF%u03B7%u03B3%u03BF%u03CD%u03BC%u03B5%u03BD%u03BF %u03B9%u03B4%u03B9%u03BF%u03BA%u03C4%u03AE%u03C4%u03B7, %u03C0%u03C1%u03BF%u03CA%u03B4%u03B9%u03CC%u03BA%u03C4%u03B7%u03C4%u03BF%u03C2 - Translatum</div></div></a>

I am guessing here that it is the data-amp value which matters when it comes to linking to the result.

Would be interesting to see if anybody else is using the mod and has amp results listed in Google, to double check.

Antes

Interesting part is;

/index.php?action=amp%3Btopic%3D985701

this is how I send to header

<link rel="amphtml" href="'. $scripturl . '?action=amp;topic=' . $topic .'">


the first "=" sign does not change, but after that ";" and "=" both changes... I'll research this further, unless Arantor comes around and gives the answer :P

spiros

I can see <link rel="amphtml" href="'. $scripturl . '?action=amp;topic=' . $topic .'"> in modification.xml. But if one wanted to change URL parameters for the AMP URL formation, this could not be done here, correct?

This part /index.php?action=amp%3Btopic%3D985701 is in the ping tag. It exists in Desktop search results too which are not affected by this issue.

gorbi


SusanTN

Google Notified me of an error with amp generated by this plugin.

The attribute 'type' may not appear in tag 'li'.

Here is google's amp specification

https://amp.dev/documentation/guides-and-tutorials/websites/learn/spec/amphtml?redirected


Advertisement: