diff options
author | Achilleas Pipinellis <axil@gitlab.com> | 2021-02-12 19:31:01 +0300 |
---|---|---|
committer | Achilleas Pipinellis <axil@gitlab.com> | 2021-02-12 19:34:16 +0300 |
commit | 7e9a260ec67441d862ac85a76ef52ef35d891852 (patch) | |
tree | 9051a7a12fc456024c7826b0514e5de425413e3f /layouts | |
parent | bf749319950c74ef601d71f012fd4b8f0de0c659 (diff) |
Make Disqus snippet appear inline
We have defined the Disqus snippet in an immutable file
(assets/javascripts/disqus.js), but the snippet needs to
be present in the HTML body in order to take the
right values (the disqus_identifier takes into account
the name of the file).
Diffstat (limited to 'layouts')
-rw-r--r-- | layouts/comments.html | 24 | ||||
-rw-r--r-- | layouts/feedback.html | 2 |
2 files changed, 25 insertions, 1 deletions
diff --git a/layouts/comments.html b/layouts/comments.html new file mode 100644 index 00000000..70110e4d --- /dev/null +++ b/layouts/comments.html @@ -0,0 +1,24 @@ +<% if production_and_default_branch? %> +var disqus_config = function () { + this.page.url = '<%= @config[:base_url] %><%= @item.identifier.without_ext + '.html' %>'; + this.page.title = '<%= @item.key?(:title) ? "#{item[:title]} - GitLab Documentation" : "GitLab Documentation" %>'; +<% if @item[:disqus_identifier] %> + this.page.identifier = '<%= @item[:disqus_identifier] %>'; +<% else %> + this.page.identifier = '<%= @config[:base_url] %><%= @item.identifier.without_ext + '.html' %>'; +<% end %> +}; + +var is_disqus_loaded = false; +window.loadDisqus = function() { + if (!is_disqus_loaded){ + is_disqus_loaded = true; + var disqusThread = document.getElementById('disqus_thread'); + var d = document, s = d.createElement('script'); + disqusThread.innerHTML = ''; + s.src = 'https://gitlab-docs.disqus.com/embed.js'; + s.setAttribute('data-timestamp', +new Date()); + (d.head || d.body).appendChild(s); + } +}; +<% end %> diff --git a/layouts/feedback.html b/layouts/feedback.html index 415d1d8d..5e6897a4 100644 --- a/layouts/feedback.html +++ b/layouts/feedback.html @@ -118,7 +118,7 @@ <div id="disqus_thread" class="disqus-comments-gitlab"></div> -<script src="<%= @items['/assets/javascripts/disqus.*'].path %>"></script> +<%= render '/comments.*' %> <script src="<%= @items['/frontend/feedback/feedback.*'].path %>"></script> <noscript >Please enable JavaScript to view the |