Module: Origen::Generator::Compiler::DocHelpers::Disqus

Included in:
Origen::Generator::Compiler::DocHelpers
Defined in:
lib/origen_doc_helpers/helpers.rb

Instance Method Summary collapse

Instance Method Details

#disqus_comments(options = {}) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/origen_doc_helpers/helpers.rb', line 55

def disqus_comments(options = {})
  options = {
    disqus_shortname: Origen.app.config.disqus_shortname || 'origen-sdk'
  }.merge(options)

  # Created this other channel in error, don't use it
  if options[:disqus_shortname].to_s == 'origensdk'
    options[:disqus_shortname] = 'origen-sdk'
  end

  <<END
<div style="position: relative">
  <hr>
  <h4>Comments</h4>
</div>
<div id="disqus_thread"></div>
<script type="text/javascript">
    /* * * CONFIGURATION VARIABLES * * */
    var disqus_shortname = '#{options[:disqus_shortname]}';
    var disqus_title;
    var disqus_url = 'http://' + window.location.hostname + window.location.pathname;

    disqus_title = $("h1").text();
    if (disqus_title.length == 0) {
      disqus_title = $("h2").text();
    }
    if (disqus_title.length == 0) {
      disqus_title = $("h3").text();
    }
    if (disqus_title.length == 0) {
      disqus_title = $("title").text();
    } else {
      disqus_title = disqus_title + ' (' + $("title").text() + ')';
    }

    /* * * DON'T EDIT BELOW THIS LINE * * */
    (function() {
        var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
        dsq.src = '//' + 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="https://disqus.com/?ref_noscript" rel="nofollow">comments powered by Disqus.</a></noscript>
END
end