docker env vars, selenium docker simplified, favicon, settings clean
This commit is contained in:
@@ -75,7 +75,7 @@ class Meta:
|
||||
|
||||
* Deploy
|
||||
```
|
||||
# Check environments variables on docker-compose.yml
|
||||
# Check environments variables on .env file
|
||||
|
||||
# Remove previous instances
|
||||
docker compose down -v
|
||||
|
||||
@@ -20,17 +20,13 @@ BASE_DIR = Path(__file__).resolve().parent.parent
|
||||
# Quick-start development settings - unsuitable for production
|
||||
|
||||
# SECURITY WARNING: keep the secret key used in production secret!
|
||||
SECRET_KEY = os.getenv("DJANGO_SECRET_KEY", 'django-insecure-54mqLbW5NlO8OlVDsT3fcbg3Vf6C8Fgcoj8H0hXv3Pr8bpgqvOuiaeqvGn34sGwt')
|
||||
SECRET_KEY = os.getenv("DJANGO_SECRET_KEY", 'django-insecure-EtKpy7t84GvU4gBwX9z3xKPBXMS75IAV0dkzN7dXVUsMSqy6a5rjY6WNCw3CcRH5')
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = (os.environ.get('DJANGO_DEBUG') == "True")
|
||||
|
||||
ALLOWED_HOSTS = os.environ.get('DJANGO_ALLOWED_HOSTS', "*").split(",")
|
||||
|
||||
CSRF_TRUSTED_ORIGINS = os.environ.get('DJANGO_ALLOWED_ORIGINS', "*").split(",")
|
||||
#CSRF_TRUSTED_ORIGINS = ["https://fetcher.matitos.org"]
|
||||
#CSRF_ALLOWED_ORIGINS = ["https://fetcher.matitos.org"]
|
||||
#CORS_ORIGINS_WHITELIST = ["https://fetcher.matitos.org"]
|
||||
|
||||
# Application definition
|
||||
|
||||
@@ -55,6 +51,7 @@ MIDDLEWARE = [
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||
'fetcher.middleware.login_required.LoginRequiredMiddleware',
|
||||
'fetcher.middleware.favicon.FaviconMiddleware',
|
||||
]
|
||||
|
||||
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
|
||||
|
||||
23
app_urls/fetcher/middleware/favicon.py
Normal file
23
app_urls/fetcher/middleware/favicon.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from django.utils.deprecation import MiddlewareMixin
|
||||
|
||||
'''
|
||||
class FaviconMiddleware(MiddlewareMixin):
|
||||
def process_response(self, request, response):
|
||||
if 'text/html' in response.get('Content-Type', '') and b'</head>' in response.content:
|
||||
icon_link = b'<link rel="icon" type="image/png" href="/static/img/mate-icon.png">\n'
|
||||
response.content = response.content.replace(b'</head>', icon_link + b'</head>')
|
||||
return response
|
||||
'''
|
||||
|
||||
class FaviconMiddleware(MiddlewareMixin):
|
||||
def process_response(self, request, response):
|
||||
if 'text/html' in response.get('Content-Type', '') and b'</head>' in response.content:
|
||||
icon_link = (
|
||||
b"<link rel='icon' href=\"data:image/svg+xml,"
|
||||
b"<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 120'>"
|
||||
b"<text y='96' font-size='96'>\xf0\x9f\xa7\x89</text></svg>\">"
|
||||
b"\n"
|
||||
)
|
||||
# (UTF-8 encoded 🧉 = \xf0\x9f\xa7\x89 in bytes)
|
||||
response.content = response.content.replace(b'</head>', icon_link + b'</head>')
|
||||
return response
|
||||
@@ -3,12 +3,10 @@ from django.conf import settings
|
||||
from django.urls import reverse
|
||||
|
||||
EXEMPT_URLS = [
|
||||
# reverse('login'), # or the name of your login view
|
||||
reverse('admin:login'),
|
||||
reverse('admin:index'),
|
||||
# reverse('logout'), # optional
|
||||
'/admin/', # allow full access to admin
|
||||
settings.STATIC_URL, # allow static files
|
||||
'/admin/', # Allow full access to admin
|
||||
settings.STATIC_URL, # Allow static files
|
||||
# path('scheduler/', include('scheduler.urls')),
|
||||
]
|
||||
|
||||
|
||||
@@ -295,7 +295,6 @@ def filtered_urls(request):
|
||||
####################################################################################################
|
||||
|
||||
def content_generation(request):
|
||||
# https://fetcher.matitos.org/urls/?per_page=100&days=1&valid_content=True&min_sources=1&search=13&status=all&language=all&source=all
|
||||
'''
|
||||
# Get list of URLs ID
|
||||
selected_urls = request.GET.getlist('urls', [])
|
||||
|
||||
@@ -21,8 +21,17 @@ def link_list(request):
|
||||
[ os.path.join(app_url, "admin"), os.path.join(app_url, "urls") ] + \
|
||||
[ os.path.join(app_url, "logs", log_type) for log_type in ["database", "debug", "info", "warning"] ] + \
|
||||
[ os.path.join(app_url, "task", l) for l in links_fetch + links_process ]
|
||||
# Json
|
||||
return JsonResponse({"links": list_links })
|
||||
|
||||
# Links tuple
|
||||
links = [(l, l) for l in list_links]
|
||||
# HTML
|
||||
html = "<html><head><title>Links</title></head><body><h1>Links</h1><ul>"
|
||||
for text, url in links:
|
||||
html += f'<li><a href="{url}" target="_blank">{text}</a></li>'
|
||||
html += "</ul></body></html>"
|
||||
|
||||
return HttpResponse(html)
|
||||
|
||||
|
||||
####################################################################################################
|
||||
def logs(request, log_type):
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
"queue": "low",
|
||||
"repeat": null,
|
||||
"at_front": false,
|
||||
"timeout": null,
|
||||
"timeout": 1800,
|
||||
"result_ttl": 86400,
|
||||
"cron_string": null,
|
||||
"scheduled_time": "2025-01-01T00:00:00+00:00",
|
||||
@@ -30,7 +30,7 @@
|
||||
"queue": "low",
|
||||
"repeat": null,
|
||||
"at_front": false,
|
||||
"timeout": null,
|
||||
"timeout": 1800,
|
||||
"result_ttl": 86400,
|
||||
"cron_string": null,
|
||||
"scheduled_time": "2025-01-01T00:00:00+00:00",
|
||||
@@ -51,7 +51,7 @@
|
||||
"queue": "default",
|
||||
"repeat": null,
|
||||
"at_front": false,
|
||||
"timeout": null,
|
||||
"timeout": 1800,
|
||||
"result_ttl": 86400,
|
||||
"cron_string": null,
|
||||
"scheduled_time": "2025-01-01T00:00:00+00:00",
|
||||
@@ -72,7 +72,7 @@
|
||||
"queue": "default",
|
||||
"repeat": null,
|
||||
"at_front": false,
|
||||
"timeout": 3600,
|
||||
"timeout": 7200,
|
||||
"result_ttl": 86400,
|
||||
"cron_string": null,
|
||||
"scheduled_time": "2025-01-01T00:00:00+00:00",
|
||||
@@ -93,7 +93,7 @@
|
||||
"queue": "default",
|
||||
"repeat": null,
|
||||
"at_front": false,
|
||||
"timeout": null,
|
||||
"timeout": 1800,
|
||||
"result_ttl": 86400,
|
||||
"cron_string": null,
|
||||
"scheduled_time": "2025-01-01T00:00:00+00:00",
|
||||
@@ -114,7 +114,7 @@
|
||||
"queue": "default",
|
||||
"repeat": null,
|
||||
"at_front": false,
|
||||
"timeout": null,
|
||||
"timeout": 3600,
|
||||
"result_ttl": 86400,
|
||||
"cron_string": null,
|
||||
"scheduled_time": "2025-01-01T00:00:00+00:00",
|
||||
@@ -156,7 +156,7 @@
|
||||
"queue": "default",
|
||||
"repeat": null,
|
||||
"at_front": false,
|
||||
"timeout": null,
|
||||
"timeout": 1800,
|
||||
"result_ttl": 86400,
|
||||
"cron_string": null,
|
||||
"scheduled_time": "2025-01-01T00:00:00+00:00",
|
||||
@@ -177,7 +177,7 @@
|
||||
"queue": "default",
|
||||
"repeat": null,
|
||||
"at_front": false,
|
||||
"timeout": 3600,
|
||||
"timeout": 7200,
|
||||
"result_ttl": 86400,
|
||||
"cron_string": null,
|
||||
"scheduled_time": "2025-01-01T00:00:00+00:00",
|
||||
|
||||
Reference in New Issue
Block a user