Cleanup code from plausible and django-assets references
This commit is contained in:
parent
10edbe2d14
commit
4ceaeadbaa
12 changed files with 49 additions and 64 deletions
|
@ -62,7 +62,6 @@ ENV DB_BASE_DIR "/db"
|
|||
#ENV SHORTPIXEL_API_KEY='YOURAPIKEY'
|
||||
#ENV SHORTPIXEL_RESIZE_WIDTH='750'
|
||||
#ENV SHORTPIXEL_RESIZE_HEIGHT='10000'
|
||||
#ENV PLAUSIBLE_DOMAIN='url-of-your-blog.example.com'
|
||||
#ENV GOATCOUNTER_DOMAIN='blog.goatcounter.example.com'
|
||||
#ENV MEMCACHED_LOCATION='memcached:11211'
|
||||
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
from django_assets import Bundle, register
|
||||
|
||||
public_no_code = Bundle(
|
||||
"vendor/newcss.css",
|
||||
"public.css",
|
||||
"admonitions.css",
|
||||
filters="rcssmin",
|
||||
output="public_bundled.css",
|
||||
)
|
||||
public_with_code = Bundle(
|
||||
"vendor/newcss.css",
|
||||
"vendor/codehilite.css",
|
||||
"public.css",
|
||||
"admonitions.css",
|
||||
filters="rcssmin",
|
||||
output="public_code_bundled.css",
|
||||
)
|
||||
register("public_no_code", public_no_code)
|
||||
register("public_with_code", public_with_code)
|
|
@ -36,7 +36,6 @@ def git_version(request):
|
|||
|
||||
def analytics(request):
|
||||
return {
|
||||
"plausible_domain": settings.PLAUSIBLE_DOMAIN,
|
||||
"goatcounter_domain": settings.GOATCOUNTER_DOMAIN,
|
||||
}
|
||||
|
||||
|
|
|
@ -1,25 +1,17 @@
|
|||
{% load static compress %}
|
||||
|
||||
{% if not user.is_authenticated %}
|
||||
{% if plausible_domain is not None %}
|
||||
<script async defer data-domain="{{ plausible_domain }}"
|
||||
src="https://plausible.augendre.info/js/plausible.js">
|
||||
{% if not user.is_authenticated and goatcounter_domain is not None %}
|
||||
{% compress js inline %}
|
||||
<script>
|
||||
window.goatcounter = {
|
||||
endpoint: 'https://{{ goatcounter_domain }}/count',
|
||||
allow_local: true,
|
||||
}
|
||||
</script>
|
||||
{% endif %}
|
||||
|
||||
{% if goatcounter_domain is not None %}
|
||||
{% compress js inline %}
|
||||
<script>
|
||||
window.goatcounter = {
|
||||
endpoint: 'https://{{ goatcounter_domain }}/count',
|
||||
allow_local: true,
|
||||
}
|
||||
</script>
|
||||
<script async defer src="{% static "vendor/goatcounter.js" %}"></script>
|
||||
{% endcompress %}
|
||||
<noscript>
|
||||
<img src="https://{{ goatcounter_domain }}/count?p={{ request.get_full_path }}"
|
||||
alt="GoatCounter tracking pixel">
|
||||
</noscript>
|
||||
{% endif %}
|
||||
<script async defer src="{% static "vendor/goatcounter.js" %}"></script>
|
||||
{% endcompress %}
|
||||
<noscript>
|
||||
<img src="https://{{ goatcounter_domain }}/count?p={{ request.get_full_path }}"
|
||||
alt="GoatCounter tracking pixel">
|
||||
</noscript>
|
||||
{% endif %}
|
||||
|
|
|
@ -1,9 +1,3 @@
|
|||
{% if not user.is_authenticated %}
|
||||
{% if plausible_domain is not None %}
|
||||
<link rel="preconnect" href="https://plausible.augendre.info">
|
||||
{% endif %}
|
||||
|
||||
{% if goatcounter_domain is not None %}
|
||||
<link rel="preconnect" href="https://{{ goatcounter_domain }}">
|
||||
{% endif %}
|
||||
{% if not user.is_authenticated and goatcounter_domain is not None %}
|
||||
<link rel="preconnect" href="https://{{ goatcounter_domain }}">
|
||||
{% endif %}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import os
|
||||
import uuid
|
||||
|
||||
import pytest
|
||||
|
|
|
@ -102,29 +102,31 @@ def test_user_can_access_drafts_list(
|
|||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_has_plausible_if_set(client: Client, settings):
|
||||
settings.PLAUSIBLE_DOMAIN = "gabnotes.org"
|
||||
def test_has_goatcounter_if_set(client: Client, settings):
|
||||
settings.GOATCOUNTER_DOMAIN = "gc.gabnotes.org"
|
||||
res = client.get(reverse("articles-list"))
|
||||
content = res.content.decode("utf-8")
|
||||
assert "https://plausible.augendre.info/js/plausible.js" in content
|
||||
assert 'data-domain="gabnotes.org"' in content
|
||||
assert "window.goatcounter" in content
|
||||
assert f"{settings.GOATCOUNTER_DOMAIN}/count" in content
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_doesnt_have_plausible_if_unset(client: Client, settings):
|
||||
settings.PLAUSIBLE_DOMAIN = None
|
||||
def test_doesnt_have_goatcounter_if_unset(client: Client, settings):
|
||||
settings.GOATCOUNTER_DOMAIN = None
|
||||
res = client.get(reverse("articles-list"))
|
||||
content = res.content.decode("utf-8")
|
||||
assert "https://plausible.augendre.info/js/plausible.js" not in content
|
||||
assert "window.goatcounter" not in content
|
||||
assert f"{settings.GOATCOUNTER_DOMAIN}/count" not in content
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_logged_in_user_doesnt_have_plausible(client: Client, author: User, settings):
|
||||
def test_logged_in_user_doesnt_have_goatcounter(client: Client, author: User, settings):
|
||||
client.force_login(author)
|
||||
settings.PLAUSIBLE_DOMAIN = "gabnotes.org"
|
||||
settings.GOATCOUNTER_DOMAIN = "gc.gabnotes.org"
|
||||
res = client.get(reverse("articles-list"))
|
||||
content = res.content.decode("utf-8")
|
||||
assert "https://plausible.augendre.info/js/plausible.js" not in content
|
||||
assert "window.goatcounter" not in content
|
||||
assert f"{settings.GOATCOUNTER_DOMAIN}/count" not in content
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
|
|
|
@ -205,7 +205,6 @@ SHORTPIXEL_API_KEY = os.getenv("SHORTPIXEL_API_KEY")
|
|||
SHORTPIXEL_RESIZE_WIDTH = int(os.getenv("SHORTPIXEL_RESIZE_WIDTH", 750))
|
||||
SHORTPIXEL_RESIZE_HEIGHT = int(os.getenv("SHORTPIXEL_RESIZE_HEIGHT", 10000))
|
||||
|
||||
PLAUSIBLE_DOMAIN = os.getenv("PLAUSIBLE_DOMAIN")
|
||||
GOATCOUNTER_DOMAIN = os.getenv("GOATCOUNTER_DOMAIN")
|
||||
|
||||
LOGIN_URL = "admin:login"
|
||||
|
|
|
@ -42,7 +42,7 @@ server {
|
|||
}
|
||||
|
||||
add_header Content-Security-Policy "frame-ancestors 'none'; default-src 'none'; img-src 'self' https:; script-src 'self'
|
||||
https://plausible.augendre.info; connect-src https://plausible.augendre.info; style-src 'self' 'unsafe-inline';
|
||||
https://gc.gabnotes.org; connect-src https://gc.gabnotes.org; style-src 'self' 'unsafe-inline';
|
||||
font-src 'self'; manifest-src 'self';" always;
|
||||
add_header X-Frame-Options "DENY" always;
|
||||
add_header X-XSS-Protection "1; mode=block" always;
|
||||
|
|
|
@ -43,7 +43,7 @@ server {
|
|||
}
|
||||
|
||||
add_header Content-Security-Policy "frame-ancestors 'none'; default-src 'none'; img-src https:; script-src 'self'
|
||||
https://plausible.augendre.info; connect-src https://plausible.augendre.info; style-src 'self' 'unsafe-inline';
|
||||
https://gc.gabnotes.org; connect-src https://gc.gabnotes.org; style-src 'self' 'unsafe-inline';
|
||||
font-src 'self'; manifest-src 'self';" always;
|
||||
add_header X-Frame-Options "DENY" always;
|
||||
add_header X-XSS-Protection "1; mode=block" always;
|
||||
|
|
16
poetry.lock
generated
16
poetry.lock
generated
|
@ -457,6 +457,17 @@ pytest = ">=3.6"
|
|||
docs = ["sphinx", "sphinx-rtd-theme"]
|
||||
testing = ["django", "django-configurations (>=2.0)", "six"]
|
||||
|
||||
[[package]]
|
||||
name = "pytest-env"
|
||||
version = "0.6.2"
|
||||
description = "py.test plugin that allows you to add environment variables."
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = "*"
|
||||
|
||||
[package.dependencies]
|
||||
pytest = ">=2.6.0"
|
||||
|
||||
[[package]]
|
||||
name = "pytest-recording"
|
||||
version = "0.11.0"
|
||||
|
@ -644,7 +655,7 @@ multidict = ">=4.0"
|
|||
[metadata]
|
||||
lock-version = "1.1"
|
||||
python-versions = "^3.8"
|
||||
content-hash = "54f79231676e4ef08e19081303d6bdf9c18bd2db967b7df46bc489a056046d41"
|
||||
content-hash = "474725a38a18e88a99712701d8558105c9466aaddf5a309afda23b04c3a7741f"
|
||||
|
||||
[metadata.files]
|
||||
appdirs = [
|
||||
|
@ -967,6 +978,9 @@ pytest-django = [
|
|||
{file = "pytest-django-3.10.0.tar.gz", hash = "sha256:4de6dbd077ed8606616958f77655fed0d5e3ee45159475671c7fa67596c6dba6"},
|
||||
{file = "pytest_django-3.10.0-py2.py3-none-any.whl", hash = "sha256:c33e3d3da14d8409b125d825d4e74da17bb252191bf6fc3da6856e27a8b73ea4"},
|
||||
]
|
||||
pytest-env = [
|
||||
{file = "pytest-env-0.6.2.tar.gz", hash = "sha256:7e94956aef7f2764f3c147d216ce066bf6c42948bb9e293169b1b1c880a580c2"},
|
||||
]
|
||||
pytest-recording = [
|
||||
{file = "pytest-recording-0.11.0.tar.gz", hash = "sha256:deea1ae6a129c9d8f8669ed7d12539748f00c8f9ef4de4f563055263e47bed08"},
|
||||
{file = "pytest_recording-0.11.0-py3-none-any.whl", hash = "sha256:c2cc321f93ceffb2146ead0c51198e4ce86986723265ce6d4a87d3b16071eb85"},
|
||||
|
|
|
@ -13,6 +13,9 @@ testpaths = [
|
|||
"blog",
|
||||
"attachments",
|
||||
]
|
||||
env = [
|
||||
"GOATCOUNTER_DOMAIN=gc.gabnotes.org"
|
||||
]
|
||||
|
||||
[tool.poetry]
|
||||
name = "blog"
|
||||
|
@ -45,6 +48,7 @@ model-bakery = "^1.1"
|
|||
pytest-cov = "^2.10.1"
|
||||
pytest-recording = "^0.11.0"
|
||||
pytest-rerunfailures = "^9.1.1"
|
||||
pytest-env = "^0.6.2"
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core>=1.0.0"]
|
||||
|
|
Reference in a new issue