Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recent Sphinx fixes, latest disqus.js #15

Merged
merged 1 commit into from
Jun 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

- Support for Sphinx 3.x and 4.x ([#7](https://github.com/Robpol86/sphinx-disqus/pull/7))
- Fixed docutils warning for `traverse()` ([#14](https://github.com/Robpol86/sphinx-disqus/pull/14))
- Re-licensed from MIT to BSD 2-Clause.
- Dropped Python 2.7 and <3.6 support.
### Added

- Support for `file://` ([#15](https://github.com/Robpol86/sphinx-disqus/pull/15))

### Removed

- Dropped Python 2.7 and <3.6 support

### Fixed

- Support for Sphinx 1.6+ ([#7](https://github.com/Robpol86/sphinx-disqus/pull/7))
- Fixed new html_static_path append and timing ([#15](https://github.com/Robpol86/sphinx-disqus/pull/15))

### Changed

- Re-licensed from MIT to BSD 2-Clause
- Renamed project from `sphinxcontrib-disqus` to `sphinx-disqus`
- Updated disqus.js with their latest universal code

## [1.1.0] - 2016-08-04

Expand Down
31 changes: 21 additions & 10 deletions sphinx_disqus/_static/disqus.js
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();
});
11 changes: 4 additions & 7 deletions sphinx_disqus/disqus.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""Sphinx extension that embeds Disqus comments in documents.
https://sphinxcontrib-disqus.readthedocs.org
https://github.com/Robpol86/sphinxcontrib-disqus
https://pypi.python.org/pypi/sphinxcontrib-disqus
https://sphinx-disqus.readthedocs.io
https://github.com/Robpol86/sphinx-disqus
https://pypi.org/project/sphinx-disqus
"""
import os
import re
Expand Down Expand Up @@ -122,9 +122,6 @@ def setup(app: Sphinx) -> Dict[str, str]:
app.add_config_value("disqus_shortname", None, True)
app.add_directive("disqus", DisqusDirective)
app.add_node(DisqusNode, html=(DisqusNode.visit, DisqusNode.depart))
try:
app.config.html_static_path.append(os.path.relpath(STATIC_DIR, app.confdir))
except ValueError:
app.config.html_static_path.append(STATIC_DIR)
app.connect("builder-inited", lambda app_: app_.config.html_static_path.append(STATIC_DIR))
app.connect("html-page-context", event_html_page_context)
return dict(version=__version__)