Disqus评论无法加载localhost?

我想使用通用代码,并且在完成最基本的function时遇到了困难。

我想创建一个测试的短名称和一个我的部署 ,我从Disqus管理面板。

这是我的show动作中的disqus代码:

# inside show.html.erb  # partial "comments" 
var disqus_shortname = ''; var disqus_identifier = ''; var disqus_url = ''; (function() { var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js'; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); })(); Please enable JavaScript to view the comments powered by Disqus. blog comments powered by Disqus

在我的模型中,我定义了Post ,我定义了我的短名称,如下所示:

  DISQUS_SHORTNAME = if Rails.env.development? "dev-shortname".freeze else "shortname".freeze end 

我可以确认加载微调器正在运行,但就是这样。 我错过了一些明显的东西吗 当我尝试在我的url_for调用中包含only_path: false作为第二个选项时,我得到一个exception,说明我已经提供了该方法的许多参数。 否则我的disqus就会挂起。

你应该设置它使其工作:

 var disqus_developer = 1; // this would set it to developer mode 

参考: http : //ray247.wordpress.com/2009/09/02/how-to-develop-with-disqus-on-localhost/

截至2013年9月,上述解决方案均无效。

为了使它工作,我不得不将localhost添加到此页面上的“可信域”列表中:

http:// [disqus_shortname] .disqus.com / admin / settings / advanced /

并使用下面的“通用代码”将其嵌入我的博文:

http:// [disqus_shortname] .disqus.com / admin / settings / universalcode /

它的工作原理! 🙂

尝试设置disqus_url以匹配您注册的站点URL。

http://kenhirakawa.com/load-disqus-on-localhost/

推荐的解决方案似乎是注册多个短名称,即网站。 这对我有用。 例如, balloonsballoons-dev

如果要根据您的环境动态设置您正在使用的网站,请务必修改他们为您提供的Javascript以替换关于“不要修改”的评论下面的行中的短名称(例如, "balloons" if not settings.DEBUG else "balloons-dev" )。

https://help.disqus.com/customer/portal/articles/1053796-best-practices-for-staging-development-and-preview-sites

据我所知,Disqus在localhost上不起作用。 它一直只为我的生产现场工作。 我相信它会根据注册的主机名检查主机名。

Interesting Posts