-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Recent Sphinx fixes, latest disqus.js
Updated disqus.js with their latest universal code. Recent Sphinx versions moved html_static_path insertion from the bottom of HTML documents to the top, causing disqus.js to run before the `<div />` has been loaded. Fixing this by using `$(document).ready()`. Recent Sphinx versions also started ignoring prior html_static_path.append() during `setup(app)` call. Fixed this by appending during `builder-inited` event.
- Loading branch information
Showing
3 changed files
with
43 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,21 @@ | ||
var disqus_shortname; | ||
var disqus_identifier; | ||
(function() {{ | ||
var disqus_thread = $("#disqus_thread"); | ||
disqus_shortname = disqus_thread.data('disqus-shortname'); | ||
disqus_identifier = disqus_thread.data('disqus-identifier'); | ||
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); | ||
}})(); | ||
var disqus_config; // Accessed by embed.js | ||
const SphinxDisqus = { | ||
init: function () { | ||
let disqus_thread = $("#disqus_thread"); // Disqus <div /> | ||
let disqus_shortname = disqus_thread.data('disqus-shortname'); | ||
let disqus_identifier = disqus_thread.data('disqus-identifier'); | ||
|
||
// Disqus universal code below: https://disqus.com/admin/install/platforms/universalcode/ | ||
disqus_config = function () { | ||
this.page.identifier = disqus_identifier; | ||
}; | ||
let d = document, s = d.createElement('script'); | ||
s.src = 'https://' + disqus_shortname + '.disqus.com/embed.js'; | ||
s.setAttribute('data-timestamp', +new Date()); | ||
(d.head || d.body).appendChild(s); | ||
}, | ||
}; | ||
|
||
$(document).ready(function () { | ||
SphinxDisqus.init(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters