diff --git a/guncadindex/urls.py b/guncadindex/urls.py index 3c3bbdd..5af5083 100644 --- a/guncadindex/urls.py +++ b/guncadindex/urls.py @@ -19,6 +19,6 @@ from django.urls import include, path from odyseescraper.views import OdyseeReleaseListView urlpatterns = [ - path('odysee/', include("odyseescraper.urls")), + path('', include("odyseescraper.urls")), path('admin/', admin.site.urls), ] diff --git a/odyseescraper/admin.py b/odyseescraper/admin.py index 3a4993e..a53963e 100644 --- a/odyseescraper/admin.py +++ b/odyseescraper/admin.py @@ -1,8 +1,8 @@ from django.contrib import admin -from .models import OdyseeChannel, OdyseeRelease - -admin.site.register(OdyseeChannel) -admin.site.register(OdyseeRelease) +from .models import OdyseeChannel, OdyseeRelease, Tag # Register your models here. +admin.site.register(OdyseeChannel) +admin.site.register(OdyseeRelease) +admin.site.register(Tag) diff --git a/odyseescraper/migrations/0004_tag_alter_odyseechannel_id_alter_odyseerelease_id_and_more.py b/odyseescraper/migrations/0004_tag_alter_odyseechannel_id_alter_odyseerelease_id_and_more.py new file mode 100644 index 0000000..6647394 --- /dev/null +++ b/odyseescraper/migrations/0004_tag_alter_odyseechannel_id_alter_odyseerelease_id_and_more.py @@ -0,0 +1,37 @@ +# Generated by Django 5.1.5 on 2025-01-24 02:02 + +import uuid +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('odyseescraper', '0003_odyseerelease_thumbnail'), + ] + + operations = [ + migrations.CreateModel( + name='Tag', + fields=[ + ('id', models.CharField(db_index=True, default=uuid.uuid4, editable=False, max_length=512, primary_key=True, serialize=False)), + ('name', models.CharField(max_length=256)), + ('description', models.TextField()), + ], + ), + migrations.AlterField( + model_name='odyseechannel', + name='id', + field=models.UUIDField(db_index=True, default=uuid.uuid4, editable=False, primary_key=True, serialize=False), + ), + migrations.AlterField( + model_name='odyseerelease', + name='id', + field=models.CharField(db_index=True, default=uuid.uuid4, editable=False, max_length=512, primary_key=True, serialize=False), + ), + migrations.AddField( + model_name='odyseerelease', + name='tags', + field=models.ManyToManyField(to='odyseescraper.tag'), + ), + ] diff --git a/odyseescraper/models.py b/odyseescraper/models.py index d43fb2a..d910491 100644 --- a/odyseescraper/models.py +++ b/odyseescraper/models.py @@ -2,8 +2,13 @@ import uuid from django.db import models from . import odysee +class Tag(models.Model): + id = models.CharField(primary_key=True, max_length=512, default=uuid.uuid4, editable=False, db_index=True) + name = models.CharField(max_length=256) + description = models.TextField() + class OdyseeChannel(models.Model): - id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) + id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False, db_index=True) name = models.CharField(max_length=1024) handle = models.CharField(max_length=1024) @@ -28,9 +33,11 @@ class OdyseeChannel(models.Model): return class OdyseeRelease(models.Model): - id = models.CharField(primary_key=True, max_length=512, default=uuid.uuid4, editable=False) - channel = models.ForeignKey(OdyseeChannel, on_delete=models.CASCADE) + id = models.CharField(primary_key=True, max_length=512, default=uuid.uuid4, editable=False, db_index=True) + channel = models.ForeignKey(OdyseeChannel, on_delete=models.CASCADE, db_index=True) name = models.CharField(max_length=1024) description = models.TextField() url = models.URLField(max_length=512) thumbnail = models.URLField(max_length=512) + + tags = models.ManyToManyField(Tag) diff --git a/odyseescraper/templates/channel_list.html b/odyseescraper/templates/channel_list.html new file mode 100644 index 0000000..237ccc4 --- /dev/null +++ b/odyseescraper/templates/channel_list.html @@ -0,0 +1,15 @@ +{% extends "base.html" %} + +{% block content %} +

Channels

+

If you'd like to browse all releases, click here.

+
+ {% for channel in object_list %} +
+ +

{{ channel.name }}

+

{{ channel.handle }}

+
+ {% endfor %} +
+{% endblock content %} diff --git a/odyseescraper/urls.py b/odyseescraper/urls.py index 5ad33f8..17787f2 100644 --- a/odyseescraper/urls.py +++ b/odyseescraper/urls.py @@ -4,5 +4,6 @@ from django.urls import path from . import views urlpatterns = [ - path("", views.OdyseeReleaseListView.as_view(), name="index"), + path("", views.OdyseeChannelListView.as_view(), name="channels"), + path("allreleases", views.OdyseeReleaseListView.as_view(), name="allreleases"), ] diff --git a/odyseescraper/views.py b/odyseescraper/views.py index 1589f0a..fc365d9 100644 --- a/odyseescraper/views.py +++ b/odyseescraper/views.py @@ -6,3 +6,7 @@ from odyseescraper.models import OdyseeChannel, OdyseeRelease class OdyseeReleaseListView(ListView): model = OdyseeRelease template_name = 'release_list.html' + +class OdyseeChannelListView(ListView): + model = OdyseeChannel + template_name = 'channel_list.html' diff --git a/static/styles.css b/static/styles.css index 6bb7719..64e1c5f 100644 --- a/static/styles.css +++ b/static/styles.css @@ -60,6 +60,9 @@ div.cardcontainer { grid-gap: 1em; grid-template-columns: 1fr 1fr 1fr; } +div.widecardcontainer { + grid-template-columns: 1fr; +} div.cardcontainer div.card { background: var(--background-bright); border-radius: 8px;