Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Disqus discussion support

if config.diqus_shortname is set, discussion is showed on every page
  • Loading branch information...
commit 20fc115c37c472c8c5d3c3541825e794d5631577 1 parent afdaa65
@Pajk Pajk authored
View
11 app/views/apipie/apipies/_disqus.html.erb
@@ -0,0 +1,11 @@
+<div id="disqus_thread"></div>
+<script type="text/javascript">
+ var disqus_shortname = "<%= Apipie.configuration.disqus_shortname %>";
+ (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">comments powered by <span class="logo-disqus">Disqus</span></a>
View
1  app/views/layouts/apipie/apipie.html.erb
@@ -15,6 +15,7 @@
<div class="row">
<div id='container'>
<%= yield %>
+ <%= render 'disqus' if Apipie.configuration.use_disqus? %>
</div>
</div>
<hr>
View
7 lib/apipie/apipie_module.rb
@@ -26,7 +26,7 @@ def self.configuration
end
class Configuration
- attr_accessor :app_name, :app_info, :copyright, :markup,
+ attr_accessor :app_name, :app_info, :copyright, :markup, :disqus_shortname,
:validate, :api_base_url, :doc_base_url, :required_by_default, :layout
alias_method :validate?, :validate
@@ -88,6 +88,10 @@ def generated_doc_disclaimer
@generated_doc_disclaimer ||= "# DOC GENERATED AUTOMATICALLY: REMOVE THIS LINE TO PREVENT REGENARATING NEXT TIME"
end
+ def use_disqus?
+ !@disqus_shortname.blank?
+ end
+
def app_info
Apipie.markup_to_html(@app_info)
end
@@ -102,6 +106,7 @@ def initialize
@api_base_url = ""
@doc_base_url = "/apipie"
@layout = "apipie/apipie"
+ @disqus_shortname = nil
end
end
View
1  spec/dummy/app/views/layouts/application.html.erb
@@ -9,6 +9,7 @@
<div class="row">
<div id='container' style='background-color: white;padding:10px;box-shadow:0px 0px 10px rgba(68,68,68,0.6);'>
<%= yield %>
+ <%= render 'disqus' if Apipie.configuration.use_disqus? %>
</div>
</div>
<hr>
View
6 spec/dummy/config/initializers/apipie.rb
@@ -34,7 +34,13 @@
config.required_by_default = false
# use custom layout
+ # use Apipie.include_stylesheets and Apipie.include_javascripts
+ # to include apipies css and js
config.layout = "application"
+
+ # specify disqus site shortname to show discusion on each page
+ # to show it in custom layout, use `render 'disqus' if Apipie.configuration.use_disqus?`
+ # config.disqus_shortname = 'paveltest'
end
Please sign in to comment.
Something went wrong with that request. Please try again.