-
Notifications
You must be signed in to change notification settings - Fork 28
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
Simpler AMP install - maybe :) #3
Comments
Nice! 👍 Can you try use https github pages? |
Good call! Here it is: https://cdn.rawgit.com/maxxeight/disqusAMP/master/disqus-amp.html |
I'm almost getting crazy trying to figure out |
Job DONE 😃 The final Universal HTML: <div id="disqus_thread"></div>
<script>
window.addEventListener('message', receiveMessage, false);
function receiveMessage(event)
{
if (event.data) {
var msg;
try {
msg = JSON.parse(event.data);
} catch (err) {
// Do nothing
}
if (!msg)
return false;
if (msg.name === 'resize') {
window.parent.postMessage({
sentinel: 'amp',
type: 'embed-size',
height: msg.data.height
}, '*');
}
}
}
</script>
<script>
function getQueryVariable(variable) {
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=");
if(pair[0] == variable){return pair[1];}
}
return(false);
}
var disqus_config = function () {
this.page.url = decodeURIComponent(getQueryVariable("url")); // Replace PAGE_URL with your page's canonical URL variable
this.page.identifier = decodeURIComponent(getQueryVariable("identifier")); // Replace PAGE_IDENTIFIER with your page's unique identifier variable
};
(function() { // DON'T EDIT BELOW THIS LINE
var d = document, s = d.createElement('script');
s.src = '//myuserloginindisqus.disqus.com/embed.js';
s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s);
})();
</script> And as I'm using AMP Plugin for Wordpress I've added a call inside my if ( ! function_exists( 'add_disqus' ) ) {
function add_disqus( $content ) {
if(is_amp_endpoint()) {
$post = get_post();
$content .= '
<amp-iframe width=600 height=140
layout="responsive"
sandbox="allow-scripts allow-same-origin allow-modals allow-popups"
resizable
frameborder="0"
src="https://mysecondeurl/disqus-amp.html?url='.urlencode(get_permalink()).'&identifier='.urlencode($post->ID . ' ' . $post->guid).'"
>
<div overflow tabindex=0 role=button aria-label="Comentários">Comentários</div>
</amp-iframe>';
}
return $content;
}
}
add_action( 'the_content', 'add_disqus' ); |
@maxxeight I still stack on blogger canonical post url |
@cassianotartari In your universal HTML you still seem to have |
This is almost working for me with the same setup cassianotartari . However, there is something not right with the functions part. When I use this all the content on my non-amp pages vanishes. Any ideas? |
DONE for Blogger, thanks @maxxeight Here is working disqus amp on Blogger https://kompidesign.blogspot.co.id/2015/06/mauris-ornare-pretium-orci-faucibus.html |
Example:
|
@erikdubbelboer that's your Disqus username.
@Rushster I've updated the |
Thanks @cassianotartari ! |
Look to your console, it's throwing:
You should get a ssl certificate. If you own the server you can try Let's Encrypt. As @maxxeight said:
|
Thanks @cassianotartari ! |
Pay atention @rubenalonsoes, you should use different domains:
And your Universal html is running in the same domain: |
Yes @cassianotartari but this is a subdomain and using the property 'allow-same-origin'. |
Nice @rubenalonsoes ! I didn't check what is this solution. |
I use @KompiAjaib page amp2 - all good 👍 |
Done, thanks @maxxeight, |
With the new update of AMP plugin for WordPress, the Disqus amp-iframe appears twice in the content. One just after the featured image (into tag) and another at the end of the content... |
@rubenalonsoes better you talk about this in the proper channel: https://wordpress.org/support/topic/v0-4-whats-new-and-possible-breaking-changes/ I'm not going to update before read change log and how this could affect the content, as he is saying in this link. |
Thanks @cassianotartari ! |
Nice @rubenalonsoes! Can you give more details here how to achieve that? I didn't had time yet to better read AMP plugin documentation. |
Yes @cassianotartari !
` That's all! :) Update: |
@maxxeight Wonderful, you did a grand job: The above link validates OK according to Google Chrome's AmpHtml Extension... ...also stored in Google's Cache! I will wait until I resurrect my HTTPS domain before I implement Disqus on every page. Thank you! |
There is a way to find out how many/which comments are coming from AMP pages? |
Hi guys. I'm currently using the following code, but I'm getting an error when the comments attempt to load in. Any idea how to resolve this? I replace disqususername with our disqus shortname.
|
I've fixed my code because I can't comment from AMP pages. Into the sandbox property of the amp-iframe you have to add the "allow-forms". And now I can comment from AMP pages. :) |
Hello! I made a guide that's probably a little easier to follow. |
@neerajkumar Tell to disqus what the title with code var disqus_shortname = "shortname"; var disqus_config = function () { this.page.url = "<data:blog.canonicalUrl/>"; this.page.identifier = ""; this.page.title = "<data:blog.pageName/>"; }; |
Wow! I have already make it work on my AMP page on https://prexblog.com It's awesome and it lazyload... |
It is amazing how frustrating it is trying to get this to work. The closest I got was with @cassianotartari's code. If I use his code exactly, it works! Of course, it also brings up his comment page because his No big deal, I copied and pasted the file to my own (but different from the calling page) domain and changed the display name to my own. #fatality If I leave it as cassianotartari's display name, it works fine. If I change it to my own display name, I get the massively unhelpful "We were unable to load Disqus. If you are a moderator please see our troubleshooting guide." Why would it work with his display name and not mine? I have both the source page domain and the amp page domain whitelisted in Disqus > Settings > Advanced. Why doesn't Disqus provide any debugging info in the console?!?! Why don't they have a link to their own damn AMP HTML?? DISQUS: You really should put some time into developing an official, well-documented and easy-to-link solution like those proposed/used here... except universally effective. 😠 |
We need help with two sites here: |
Finally, I did it! thanks, guys. |
thanks thepleh |
Thanks for the guides but i have not been able to make it work on my page BravoTechArena |
If I leave it as cassianotartari's display name, it works fine. If I change it to my own display name, I get the massively unhelpful "We were unable to load Disqus. If you are a moderator please see our troubleshooting guide." |
We are very grateful to the admin |
This error is specific to the internal amp inside your pioneer deck,either your output wires leaving the radio are touching together somewhere ... |
thank for sharing bro, i will try by Selembar |
Thanks to bro
Pada tanggal Sab, 18 Des 2021 04.38, Ridlomuhammad ***@***.***>
menulis:
… thank for sharing bro, i will try
by Selembar <https://selembar.com>
—
Reply to this email directly, view it on GitHub
<#3 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AGHID7BQKZSG4WM6UW4M3N3UROUWPANCNFSM4CQESAKA>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Thanks you brooooow. iam Teknisi Blogger |
With the new update of AMP plugin for WordPress, the Disqus amp-iframe appears twice in the content. One just after the featured image (into tag) and another at the end of the content... Toko Bangunan |
thanks a lot saged |
Thanks a lot for the information on "How to make valid disqus comments with amp" |
You’ve picked up the perfect dog-friendly grooming kit from the local pet Tutorial Technology |
work!! thank e lot, see my amp web- pacifa |
thank you, it work in my site pooc |
Wow, amazing block structure! How long Jeparaupdate Inc. NEtwork Jpr. News Jeparaupdate Inc. NEtwork Jpr. Inet Jeparaupdate Inc. NEtwork Jpr. Loker Jeparaupdate Inc. NEtwork Jpr. |
If I leave it as cassianotartari's display name, it works fine. If I change it to my own display name, I get the massively unhelpful "We were unable to load Disqus. If you are a moderator please see our troubleshooting guide." ujian blog |
Thanks for the directions but I have not been able to make it work on my The ISP Family page. Can you please help me? |
Bro.. There is a way to find out how many/which comments are coming from AMP pages? I want to switch to using amp on my blog Droppbuy |
I've been following and troubleshooting https://github.com/disqus/disqus-install-examples/tree/master/google-amp over the past few days. However, the solution is effective in my situation; there is only one problem, though. When I hover over one Disqus Comments Page, the correct URL of the page that received the remark is displayed, even though the page's title should be displayed there instead. Is there a way to display the eTransferMoney page title as well? |
Thanks for Informasi |
Hi there,
Thanks for your work on making Disqus AMP-friendly. I implemented it on technicalseo.com and here are the issues/suggestions that I have:
1-- I couldn't make it work without adding an overflow child element. It seems to be required as a fall back if AMP can't automatically load the iframe: https://github.com/ampproject/amphtml/blob/master/extensions/amp-iframe/amp-iframe.md#iframe-resizing
I also added frameborder=0 for design purposes.
My working code looks as follow:
2-- As specified in your instructions, the "external_html_file" MUST be hosted on a different domain, but it also MUST be hosted on a secure (HTTPS) domain. This might be challenging for most (having access to another secure domain, buying another SLL certificate, etc.).
I am hosting the file on Github secure CDN: https://cdn.rawgit.com/maxxeight/disqusAMP/master/disqus-amp.html
3-- I tweaked the scripts within this file (also attached as a .txt) so all variables (shortname and canonical URL - where the comments live) can be passed through parameters in the iframe src URL
src="https://cdn.rawgit.com/maxxeight/disqusAMP/master/disqus-amp.html?shortname=[disqus_shortname]&url=[canonical_url]"
=> this way, the external html file can be the same ALL Disqus users. This leads to my last suggestion: could you guys host the file for all users? :) So nobody is dependant of my Github account?
Note: I did not have to "Add the new domain [cdn.rawgit.com] as a Trusted Domain" in my Disqus settings for this implementation to work.
Here is a working AMP URL with all of the above in place: https://technicalseo.com/rank-serp/duplicate-content/amp.html
Thanks again and please let me know if you have any questions!
Max
disqus-amp.txt
The text was updated successfully, but these errors were encountered: