Method: Origen::Generator::Compiler::DocHelpers::Disqus#disqus_comments

Defined in:
lib/origen_doc_helpers/helpers.rb

#disqus_comments(options = {}) ⇒ Object

[View source]

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

  "<div style=\"position: relative\">\n  <hr>\n  <h4>Comments</h4>\n</div>\n<div id=\"disqus_thread\"></div>\n<script type=\"text/javascript\">\n    /* * * CONFIGURATION VARIABLES * * */\n    var disqus_shortname = '\#{options[:disqus_shortname]}';\n    var disqus_title;\n    var disqus_url = 'http://' + window.location.hostname + window.location.pathname;\n\n    disqus_title = $(\"h1\").text();\n    if (disqus_title.length == 0) {\n      disqus_title = $(\"h2\").text();\n    }\n    if (disqus_title.length == 0) {\n      disqus_title = $(\"h3\").text();\n    }\n    if (disqus_title.length == 0) {\n      disqus_title = $(\"title\").text();\n    } else {\n      disqus_title = disqus_title + ' (' + $(\"title\").text() + ')';\n    }\n\n    /* * * DON'T EDIT BELOW THIS LINE * * */\n    (function() {\n        var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;\n        dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';\n        (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);\n    })();\n</script>\n<noscript>Please enable JavaScript to view the <a href=\"https://disqus.com/?ref_noscript\" rel=\"nofollow\">comments powered by Disqus.</a></noscript>\n"
end