-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 1cc26cb
Showing
10 changed files
with
127 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.vscode/* | ||
.idea/* | ||
dist/* |
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2021 Antti Rummukainen | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
## Django Simple Plausible | ||
|
||
A dead simple package to add Plausible Analytics html tag to your HTML. Tested with Python 2.7 and 3.8. Tested with Django 1.11 and 3.2. | ||
|
||
### Usage | ||
|
||
1. Install package: `pip install django_simple_plausible` | ||
|
||
2. Add `django_simple_plausible` to your `INSTALLED_APPS` in settings.py | ||
|
||
3. ADD `PLAUSIBLE_SITES` and `PLAUSIBLE_SCRIPT_URL` keys and values to your settings.py. Without these settings, default values for Plausible will be used. | ||
``` | ||
... | ||
PLAUSIBLE_SITES = "example.com" | ||
PLAUSIBLE_SCRIPT_URL = "https://example.com/js/plausible.js" | ||
... | ||
``` | ||
|
||
4. add the following template tags to your site html: | ||
``` | ||
{% load plausible %} | ||
{% plausible %} | ||
``` | ||
|
||
--- | ||
|
||
### Configuring details | ||
|
||
- PLAUSIBLE_SITES can be a comma separated list without spaces, if you want to use that feature of Plausible | ||
|
||
``` | ||
PLAUSIBLE_SITES = "example.com,yoursite.com" | ||
``` | ||
|
||
- Systemwide settings can be overridden giving the template tag some optional parameters: | ||
|
||
``` | ||
{% plausible plausible_sites="mysite.com" script_url="https://mysite.com/plausible.js" %} | ||
``` |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
python -m build | ||
rm -rf *.egg-info | ||
echo "Upload to TestPyPi: python -m twine upload --repository testpypi dist/*" | ||
printf "Upload to PyPi: python -m twine upload dist/*\n\n" |
Empty file.
Empty file.
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from django import template | ||
from django.conf import settings | ||
from django.forms.utils import flatatt | ||
from django.utils.safestring import mark_safe | ||
|
||
register = template.Library() | ||
|
||
|
||
@register.simple_tag() | ||
def plausible(site_domains=None, script_url=None): | ||
if site_domains is None: | ||
site_domains = getattr(settings, "PLAUSIBLE_SITES", "plausible.io") | ||
if script_url is None: | ||
script_url = getattr(settings, "PLAUSIBLE_SCRIPT_URL", "https://plausible.io/js/plausible.js") | ||
|
||
attrs = { | ||
"data-domain": site_domains, | ||
"src": script_url, | ||
} | ||
|
||
return mark_safe("<script defer{}></script>".format(flatatt(attrs))) |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[build-system] | ||
requires = [ | ||
"setuptools>=42", | ||
"wheel" | ||
] | ||
build-backend = "setuptools.build_meta" |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
build | ||
twine |
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import codecs | ||
import setuptools | ||
|
||
with codecs.open("README.md", "r", encoding="utf-8") as fh: | ||
long_description = fh.read() | ||
|
||
setuptools.setup( | ||
name="django_simple_plausible", | ||
# name="django_simple_plausible-T-101-0.0.2-3", | ||
version="0.0.3", | ||
author="T-101", | ||
description="A simple Django package to render Plausible Analytics html tag", | ||
long_description=long_description, | ||
long_description_content_type="text/markdown", | ||
url="https://github.com/T-101/django-simple-plausible", | ||
project_urls={}, | ||
classifiers=[ | ||
"Programming Language :: Python :: 2", | ||
"Programming Language :: Python :: 3", | ||
"License :: OSI Approved :: MIT License", | ||
"Operating System :: OS Independent", | ||
"Framework :: Django", | ||
"Environment :: Web Environment", | ||
], | ||
packages=setuptools.find_packages(exclude=["tests"]), | ||
python_requires=">=2.7", | ||
options={"bdist_wheel": {"universal": True}}, | ||
) |