Merge branch 'main' into narl.io

This commit is contained in:
nvrl committed 2026-02-18 14:25:44 +01:00
commit 21128660d0
5 files changed
+93

No files matched your search

@@ -0,0 +1,57 @@
from django.core.management.base import BaseCommand
from api.models import Banner
import os
import json
class Command(BaseCommand):
help = 'Seeds banner models and missing settings from JSON files in backend/banners/'
def handle(self, *args, **options):
# Determine the banners directory relative to the project root
project_root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
banners_dir = os.path.join(project_root, 'banners')
if not os.path.exists(banners_dir):
self.stdout.write(self.style.WARNING(f"Banners directory not found at {banners_dir}"))
return
for filename in os.listdir(banners_dir):
if filename.endswith('.json'):
filepath = os.path.join(banners_dir, filename)
try:
with open(filepath, 'r') as f:
data = json.load(f)
slug = data.get('slug')
if not slug:
continue
banner, created = Banner.objects.get_or_create(
slug=slug,
defaults={
'name': data.get('name', slug),
'description': data.get('description', ''),
'settings': data.get('settings', {})
}
)
if not created:
# Sync missing settings from JSON to DB without overwriting existing keys
db_settings = banner.settings or {}
json_settings = data.get('settings', {})
updated = False
for key, value in json_settings.items():
if key not in db_settings:
db_settings[key] = value
updated = True
if updated:
banner.settings = db_settings
banner.save()
self.stdout.write(self.style.SUCCESS(f"Synced new settings for banner '{slug}' from {filename}"))
else:
self.stdout.write(self.style.SUCCESS(f"Created new banner '{slug}' from {filename}"))
except Exception as e:
self.stdout.write(self.style.ERROR(f"Failed to sync banner from {filename}: {e}"))
+11
View File
@@ -0,0 +1,11 @@
{
"name": "Generative Web",
"slug": "generative-web",
"description": "The original complex web interactive banner.",
"settings": {
"nodeCountBase": 60,
"connectionDist": 140,
"speed": 0.005,
"opacity": 0.35
}
}
+8
View File
@@ -0,0 +1,8 @@
{
"name": "Matrix Code",
"slug": "matrix",
"description": "A matrix-style falling code banner using the username.",
"settings": {
"opacity": 0.6
}
}
+13
View File
@@ -0,0 +1,13 @@
{
"name": "Nebula Cloud",
"slug": "nebula",
"description": "An interactive space-themed nebular cloud with fluid movement.",
"settings": {
"particleCount": 300,
"speed": 0.005,
"opacity": 0.8,
"attractionForce": 0.25,
"cloudSize": 14,
"returnSpeed": 0.02
}
}
+4
View File
@@ -29,6 +29,10 @@ python manage.py sync_flavors
echo "Seeding legacy flavors..."
python manage.py seed_legacy_flavors
# Auto-sync banner models and settings from JSON files
echo "Syncing banner configurations..."
python manage.py seed_banners
# Start the server using Gunicorn
echo "Starting Gunicorn..."
exec gunicorn holy_backend.wsgi:application --bind 0.0.0.0:8000 --workers 3 --timeout 120