Sphinx extension for plausible.io
This extension adds the https://plausible.io script to a Sphinx project by using standard Sphinx javascript insertion tools. It doesn't change the template, and it should work with any template (that uses the standard Sphinx javascript insertion, which seems to be most of them).
This is a relatively new project (but being used), so please verify it does the correct thing in your case and suggest improvements.
Plausible without this extension
Actually, this extension isn't needed, you can directly add a script with the required tags by doing the following. This uses the same insertion mechanism as this extension, and thus should work with any well-designed theme with no modifications:
html_js_files = [
('https://plausible.io/js/script.js', {"data-domain": "yourdomain.com", "defer": "defer"}),
]
Installation
Install the Python package: on PyPI it is sphinx-plausible:
pip install sphinx-plausible
Usage
Add sphinx_plausible to extensions. Example config:
extensions = [
"sphinx_plausible",
]
plausible_domain = "my.domain.org"
If you want Plausible to only be enabled when your site is deployed by
Github Actions on the main branch in your own repository (remember
to update organization/repo-name):
import os
plausible_enabled = (
'GITHUB_ACTION' in os.environ
and os.environ.get('GITHUB_REPOSITORY', '').lower() == 'organization-name/repo-name'
and os.environ.get('GITHUB_REF') == 'refs/heads/main'
)
Configuration options:
-
plausible_domain(required): The domain name, likemy.domain.org. Can be a list which will be joined by commas. -
plausible_script(defaulthttps://plausible.io/js/script.js): The URL to the script to load. If you want to use embed the script, download the script and put it inhtml_static_pathand add the filename (relative tohtml_static_path) here instead of a URL. -
plausible_enabled(defaultTrue): Should plausible be active? You might want to disable it on all you test deployments and so on, so you can add some logic to enable/disable as needed.
Status and development
Beta but works as of 2022 - improvements and feature requests are still welcome! I would be happy for a group maintenance home for this.
See also
Metadata
Release files for sphinx-plausible 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sphinx-plausible-0.1.2.tar.gz | 5.6 kB | Without provenance | Details for sphinx-plausible-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sphinx_plausible-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for sphinx_plausible-0.1.2-py3-none-any.whl |
Total release size: 9.7 kB
Release files / sphinx-plausible-0.1.2.tar.gz
| Download URL | sphinx-plausible-0.1.2.tar.gz |
|---|---|
| Size | 5.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
052ff1828cd64f0ee7909b7bc29d2450d70cf87e2bb32baca3b9acbd36b25b65
|
|
BLAKE2b-256 checksum How to use checksums |
ec3eee77a5a6ccd686618f82975d6a0975b1a099c31618837ecfffae9dba9206
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.28.1
|
Release files / sphinx_plausible-0.1.2-py3-none-any.whl
| Download URL | sphinx_plausible-0.1.2-py3-none-any.whl |
|---|---|
| Size | 4.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
11110f2e60c4024506d39eb389096890b37d03ca7f9b9c1293eef5a494c7d1dd
|
|
BLAKE2b-256 checksum How to use checksums |
2916d2cfee69a898d5bd970736bfdf29a14049318244463c33deaa18afed0163
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.28.1
|
Security for sphinx-plausible 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.