Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
217 views
in Technique[技术] by (71.8m points)

javascript - Disqus comments fails to load on localhost?

I would like to use the universal code and have ran into difficulties getting the most basic functionality done.

I would like to create a shortname for test and one for my deployment, which I did from the Disqus admin panel.

Here is the disqus code in my show action:

# inside show.html.erb
<%= render raw 'comments' %>

# partial "comments"

  <div id="disqus_thread"></div>
    <script type="text/javascript">
      var disqus_shortname = '<%= Post::DISQUS_SHORTNAME %>';
      var disqus_identifier = '<%= @post.id %>';
      var disqus_url = '<%= url_for([:blog, @topic, @post])%>';
        (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);
        })();
    </script>
    <noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
    <a href="http://disqus.com" class="dsq-brlink">blog comments powered by <span class="logo-disqus">Disqus</span></a>

In my model I define Post, I define my short name like so:

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

I can confirm the loading spinner is functioning but that is it. Am I missing something obvious? When I try to include only_path: false as a second option in my url_for call, I get an exception stating I have supplied to many arguments to the method. Otherwise my disqus just hangs.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

you should set this to make it work:

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

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...