diff --git a/README.md b/README.md index d0d0c18..a977453 100644 --- a/README.md +++ b/README.md @@ -54,3 +54,33 @@ Open `http://127.0.0.1:8000/admin/`. Local mode uses SQLite. Run `python manage. ## Updating Studio v1.0 Keep the same project directory, `.env`, `secrets/`, `data/`, and Docker volumes. After making a database backup, unpack the updated project files into that directory and run `docker compose up -d --build`. Startup applies the migration. It locks the displayed title to SLUMP X LAND and keeps existing chapters, editorial content, and site settings. + +### Pages, chapter samples and Fan Club checkout + +- **Pages → Manage pages**: edit a page title, slug, navigation label/placement, + local destination, or plain-text body. Clear the destination to publish an + original content page. Select a published row and use **Use the selected + published page as homepage** to switch. **Restore the Sol’Terra map as homepage** + restores the map; the map is always available at `/map/`. +- **Chapters**: set **Chapter price (USD)** to $0.50 or more to enable a Stripe + one-time purchase. A paid order unlocks that chapter in the reader for the + signed-in purchaser. A physical book does not automatically unlock the reader. +- **Shop products**: select a **Sample chapter** on a listing. The storefront + links to that published chapter. The newest three published chapters are free in full; older chapters require access. + A physical product with that association appears in the reader's purchase options. +- The migration creates two inactive monthly Fan Club product records: **Early + Access** and **Studio Vault**. Replace the placeholder price with your real + monthly price and optionally set the matching same-mode Stripe recurring + Price ID before making each product active. If using a Price ID, match the + displayed Studio price to the amount charged by Stripe. Both tiers unlock the + published chapter library; member posts still follow tier requirements. +- In Stripe create an endpoint at + `https://slumpxland-official.com/shop/webhooks/stripe/` for + `checkout.session.completed`, `checkout.session.async_payment_succeeded`, + `customer.subscription.updated`, `customer.subscription.deleted`, + `invoice.paid`, `invoice.payment_failed`, and `charge.refunded`. + Set the new endpoint's signing secret in the live `.env` as + `SLX_COMMERCE_STRIPE_WEBHOOK_SECRET`. The existing Stripe API key and + `SLX_STRIPE_ORIGIN` can be reused. A separate endpoint signing secret keeps + the existing legacy checkout endpoint independent. Test in Stripe test mode + before accepting live payments, and don't put payment keys into this ZIP. diff --git a/catalog/admin.py b/catalog/admin.py index 99e6358..a1f41b7 100644 --- a/catalog/admin.py +++ b/catalog/admin.py @@ -39,16 +39,22 @@ class Studio(admin.AdminSite): def each_context(self, request): context = super().each_context(request) channels = [ - ('SLUMP X LAND', [ - ('▤', 'Chapters', 'chapter', None), - ('▧', 'Blog', 'entry', Entry.Kind.NEWS), - ('◎', 'Cast', 'entry', Entry.Kind.CAST), - ('◇', 'World archive', 'entry', Entry.Kind.WORLD), - ]), - ('Community', [('◎', 'Fan memberships', 'fanmembership', None), ('▧', 'Member content', 'memberpost', None), ('◈', 'Verified support', 'supportcredit', None), ('◉', 'Moderate comments', 'discussioncomment', None), ('★', 'Moderate chapter reviews', 'chapterreview', None), ('★', 'Moderate series reviews', 'seriesreview', None), ('◉', 'Stream comments', 'streamcomment', None)]), + ('Publishing', [('▤', 'Chapters', 'chapter', None), ('▧', 'Blog', 'entry', Entry.Kind.NEWS), + ('◎', 'Cast', 'entry', Entry.Kind.CAST), ('◇', 'World archive', 'entry', Entry.Kind.WORLD)]), + ('Website & navigation', [('▤', 'Pages & homepage', 'managedpage', None), + ('◎', 'Map locations', 'maplocation', None), ('↗', 'Link previews', 'pagesharepreview', None)]), + ('Design & artwork', [('▧', 'Page backgrounds', 'pagebackground', None), ('✦', 'Floating artwork', 'floatingartwork', None)]), + ('Shop & orders', [('▤', 'Shop products', 'shop.product', None), ('◈', 'Orders', 'shop.order', None), + ('▤', 'Legacy book listings', 'booklisting', None), ('▧', 'Legacy shop orders', 'shoporder', None), + ('◈', 'Chapter purchases', 'chapterpurchase', None)]), + ('Memberships & collectors', [('◎', 'Subscriptions', 'shop.subscription', None), + ('◎', 'Fan memberships', 'fanmembership', None), ('▧', 'Member content', 'memberpost', None), + ('◈', 'Verified support', 'supportcredit', None), ('◆', 'Collector profiles', 'collectorprofile', None)]), + ('Comments & reviews', [('◉', 'Discussion comments', 'discussioncomment', None), + ('★', 'Chapter reviews', 'chapterreview', None), ('★', 'Series reviews', 'seriesreview', None), + ('◉', 'Stream comments', 'streamcomment', None)]), ('Newsletter', [('✉', 'Campaigns', 'newslettercampaign', None), ('◎', 'Subscribers', 'newslettersubscriber', None)]), - ('Commerce', [('▤', 'Shop products', 'shop.product', None), ('◈', 'Orders', 'shop.order', None), ('◎', 'Subscriptions', 'shop.subscription', None), ('▤', 'Book listings', 'booklisting', None), ('▧', 'Legacy shop orders', 'shoporder', None), ('◈', 'Chapter purchases', 'chapterpurchase', None)]), - ('Studio', [('◈', 'Site settings', 'sitesettings', None), ('▧', 'Page backgrounds', 'pagebackground', None), ('✦', 'Floating artwork', 'floatingartwork', None), ('↗', 'Link previews', 'pagesharepreview', None)]), + ('General settings', [('◈', 'Site settings', 'sitesettings', None)]), ] groups = [] for name, items in channels: @@ -67,6 +73,19 @@ class Studio(admin.AdminSite): if links: groups.append({'name': name, 'links': links}) row = SiteSettings.objects.filter(pk=1).only('site_palette').first() + if self.can_edit_countdown(request, row): + shortcuts = [ + ('Website & navigation', '◉', 'Homepage countdown & map placement', 'homepage_countdown'), + ('Website & navigation', '↗', 'Public menu', 'public_menu'), + ('Design & artwork', '✦', 'Site and Studio colors', 'site_theme'), + ] + for category, icon, title, route in shortcuts: + group = next((group for group in groups if group['name'] == category), None) + if group is None: + group = {'name': category, 'links': []} + groups.append(group) + url = reverse(f'admin:{route}') + group['links'].append({'icon': icon, 'title': title, 'url': url, 'active': request.path == url}) context['studio_theme_vars'] = css_variables(row.site_palette, STUDIO_KEYS) if row else '' context['can_edit_theme'] = self.can_edit_countdown(request, row) context['studio_groups'] = groups @@ -723,3 +742,60 @@ class SupportCreditAdmin(admin.ModelAdmin): def has_delete_permission(self, request, obj=None): return False + + +from .models import ManagedPage + + +@admin.register(ManagedPage, site=studio) +class ManagedPageAdmin(admin.ModelAdmin): + list_display = ('title', 'slug', 'published', 'show_in_menu', 'homepage') + prepopulated_fields = {'slug': ('title',)} + search_fields = ('title', 'slug', 'link') + + actions = ('use_as_homepage', 'use_map_homepage') + + @admin.action(description='Use the selected published page as homepage', permissions=['change']) + def use_as_homepage(self, request, queryset): + if queryset.count() != 1 or not queryset.first().published: + self.message_user(request, 'Select exactly one published page.', level='error') + return + with transaction.atomic(): + ManagedPage.objects.filter(homepage=True).update(homepage=False) + queryset.update(homepage=True) + self.message_user(request, 'Homepage updated.') + + @admin.action(description='Restore the Sol’Terra map as homepage', permissions=['change']) + def use_map_homepage(self, request, queryset): + ManagedPage.objects.filter(homepage=True).update(homepage=False) + self.message_user(request, 'The Sol’Terra map is the homepage.') + + +from .models import MapLocation + + +@admin.register(MapLocation, site=studio) +class MapLocationAdmin(admin.ModelAdmin): + change_form_template = 'admin/catalog/maplocation/change_form.html' + list_display = ('title', 'page', 'path', 'visible', 'position') + list_filter = ('visible',) + search_fields = ('title', 'key', 'path') + prepopulated_fields = {'key': ('title',)} + + class Media: + js = ('studio-map-picker.js',) + +from .models import CollectorProfile + + +@admin.register(CollectorProfile, site=studio) +class CollectorProfileAdmin(admin.ModelAdmin): + list_display = ('user', 'display_name', 'public') + readonly_fields = ('user', 'display_name', 'public', 'photo') + search_fields = ('user__username', 'display_name') + + def has_add_permission(self, request): + return False + + def has_change_permission(self, request, obj=None): + return False diff --git a/catalog/chapter_access.py b/catalog/chapter_access.py new file mode 100644 index 0000000..546e25b --- /dev/null +++ b/catalog/chapter_access.py @@ -0,0 +1,33 @@ +from django.conf import settings +from django.db.models import Q + +from .fans import live +from .models import Chapter + +FREE_ARCHIVE_SIZE = 3 + + +def rolling_chapter_ids(): + return live(Chapter).order_by("-publish_at", "-number").values("pk")[:FREE_ARCHIVE_SIZE] + + +def stripe_live_mode(): + return settings.SLX_STRIPE_SECRET_KEY.startswith(('sk_live_', 'rk_live_')) + + +def full_chapters(user): + from .membership import active_tier + from .models import ChapterPurchase + from shop.models import Order, OrderItem + + chapters = live(Chapter) + if not user.is_authenticated or not user.is_active: + return chapters.filter(pk__in=rolling_chapter_ids()) + if (user.is_staff and user.has_perm('catalog.view_chapter')) or active_tier(user): + return chapters + paid = ChapterPurchase.objects.filter(user=user, mode='sandbox' if settings.SLX_PAYPAL_MODE == 'sandbox' else 'live', + paid_at__isnull=False, revoked=False) + orders = OrderItem.objects.filter(order__user=user, order__gateway=Order.Gateway.STRIPE, + order__stripe_live=stripe_live_mode(), order__status__in=[ + Order.Status.PAID, Order.Status.SHIPPED, Order.Status.DELIVERED]) + return chapters.filter(Q(pk__in=rolling_chapter_ids()) | Q(pk__in=paid.values('chapter_id')) | Q(pk__in=orders.values('chapter_id'))) diff --git a/catalog/collectors.py b/catalog/collectors.py new file mode 100644 index 0000000..fde8658 --- /dev/null +++ b/catalog/collectors.py @@ -0,0 +1,33 @@ +from django import forms +from django.contrib.auth.decorators import login_required +from django.shortcuts import redirect, render +from django.views.decorators.cache import never_cache +from django.views.decorators.http import require_http_methods + +from shop.models import Order +from .models import CollectorProfile + + +def recognized_collectors(): + paid = Order.objects.filter(status__in=[Order.Status.PAID, Order.Status.SHIPPED, Order.Status.DELIVERED]) + return CollectorProfile.objects.filter(public=True, user__is_active=True, + user_id__in=paid.values('user_id')).select_related('user').order_by('display_name', 'pk') + + +class CollectorForm(forms.ModelForm): + class Meta: + model = CollectorProfile + fields = ('public', 'display_name', 'photo') + labels = {'public': 'Show my public name and photo in the collector thank-you section'} + + +@login_required +@never_cache +@require_http_methods(['GET', 'POST']) +def preferences(request): + profile = CollectorProfile.objects.filter(user=request.user).first() or CollectorProfile(user=request.user) + form = CollectorForm(request.POST or None, request.FILES or None, instance=profile) + if request.method == 'POST' and form.is_valid(): + form.save() + return redirect('collector-preferences') + return render(request, 'collector-preferences.html', {'form': form}) diff --git a/catalog/community.py b/catalog/community.py index a12241c..0efce6a 100644 --- a/catalog/community.py +++ b/catalog/community.py @@ -21,14 +21,14 @@ RANKS = ( ) -def rank_for(membership, total, config, now): +def rank_for(membership, total, config, now, stripe_active=False): if (membership and membership.sol_seat) or (config.seat_threshold is not None and total >= config.seat_threshold): return RANKS[4] if total >= config.striker_threshold: return RANKS[3] if total >= config.caster_threshold: return RANKS[2] - if membership and membership.subscriber_until and membership.subscriber_until > now: + if stripe_active or (membership and membership.subscriber_until and membership.subscriber_until > now): return RANKS[1] return RANKS[0] @@ -41,4 +41,9 @@ def load_ranks(ids, config): sums = dict(SupportCredit.objects.filter(user_id__in=ids, voided=False).values('user_id') .annotate(total=Sum('amount')).values_list('user_id', 'total')) now = timezone.now() - return {pk: rank_for(memberships.get(pk), sums.get(pk, Decimal(0)), config, now) for pk in ids} + from .chapter_access import stripe_live_mode + from shop.models import Order, Subscription + active = set(Subscription.objects.filter(user_id__in=ids, gateway=Order.Gateway.STRIPE, + stripe_live=stripe_live_mode(), status=Subscription.Status.ACTIVE, current_period_end__gt=now, + entitlement_tier__isnull=False).values_list('user_id', flat=True)) + return {pk: rank_for(memberships.get(pk), sums.get(pk, Decimal(0)), config, now, pk in active) for pk in ids} diff --git a/catalog/context.py b/catalog/context.py index 13aba62..cb20cfb 100644 --- a/catalog/context.py +++ b/catalog/context.py @@ -4,7 +4,7 @@ from django.urls import reverse from .community import MENU from .fans import unread_count from .backgrounds import SAFE_ROUTES -from .models import FloatingArtwork, PageBackground, TitleFollow +from .models import FloatingArtwork, PageBackground, TitleFollow, ManagedPage from .newsletter import SignupForm, signup_open from .views import settings_row from .theme import HEX_COLOR, css_variables @@ -46,14 +46,24 @@ def site_context(request): hidden = settings.hidden_menu if isinstance(settings.hidden_menu, list) else [] links = [] for key, label, route in MENU: - if key in hidden or (key == 'shop' and not settings.shop_url): + if key in hidden: continue if key in ('library', 'notices') and not request.user.is_authenticated: continue if key == 'account' and request.user.is_authenticated: continue - url = settings.shop_url if key == 'shop' else reverse(route, args=[key] if key in ('cast', 'world') else []) + url = (settings.shop_url or reverse('shop-index')) if key == 'shop' else reverse(route, args=[key] if key in ('cast', 'world') else []) links.append({'key': key, 'label': label, 'url': url, 'active': key == active_nav}) + custom = list(ManagedPage.objects.filter(published=True, show_in_menu=True).order_by('pk')) + replacements = {page.menu_key: page for page in custom if page.menu_key} + for link in links: + page = replacements.pop(link['key'], None) + if page: + link.update(label=page.title, url=page.get_absolute_url(), active=request.path == page.get_absolute_url()) + for page in custom: + if not page.menu_key: + links.append({'key': page.slug, 'label': page.title, 'url': page.get_absolute_url(), + 'active': request.path == page.get_absolute_url()}) context['public_menu'] = links if request.user.is_authenticated: follow = TitleFollow.objects.filter(user=request.user).first() diff --git a/catalog/forms.py b/catalog/forms.py index ce77530..ac71b18 100644 --- a/catalog/forms.py +++ b/catalog/forms.py @@ -78,7 +78,7 @@ class HomepageCountdownForm(forms.ModelForm): class Meta: model = SiteSettings - fields = ['homepage_countdown_enabled', 'homepage_countdown_title', 'homepage_countdown_at', + fields = ['countdown_map_position', 'homepage_countdown_enabled', 'homepage_countdown_title', 'homepage_countdown_at', 'homepage_countdown_start_at', 'homepage_countdown_bar_color', 'homepage_countdown_landing', 'homepage_countdown_cover', 'homepage_countdown_background', 'homepage_countdown_tint', 'homepage_countdown_tint_strength', 'homepage_countdown_note', diff --git a/catalog/membership.py b/catalog/membership.py index e63b5eb..0eb78cb 100644 --- a/catalog/membership.py +++ b/catalog/membership.py @@ -6,23 +6,53 @@ from django.views.decorators.http import require_safe from .models import FanMembership, MemberPost +def active_tier(user): + from .chapter_access import stripe_live_mode + from shop.models import Order, Subscription + + if not user.is_authenticated or not user.is_active: + return 0 + now = timezone.now() + manual = FanMembership.objects.filter(user=user, subscriber_until__gt=now).values_list('member_tier', flat=True).first() + stripe = Subscription.objects.filter(user=user, gateway=Order.Gateway.STRIPE, stripe_live=stripe_live_mode(), + status=Subscription.Status.ACTIVE, current_period_end__gt=now, + entitlement_tier__isnull=False).order_by('-entitlement_tier').values_list('entitlement_tier', flat=True).first() + return max(manual or 0, stripe or 0) + + def accessible_posts(user): if not user.is_authenticated or not user.is_active: return MemberPost.objects.none() if user.is_staff and user.has_perm('catalog.view_memberpost'): return MemberPost.objects.all() now = timezone.now() - tier = FanMembership.objects.filter(user=user, subscriber_until__gt=now).values_list('member_tier', flat=True).first() + tier = active_tier(user) return MemberPost.objects.filter(published=True, publish_at__lte=now, required_tier__lte=tier or 0) @never_cache @require_safe def index(request): - return render(request, 'membership.html', {'posts': accessible_posts(request.user)}) + from shop.models import Product + plans = Product.objects.filter(active=True, kind=Product.Kind.SUBSCRIPTION, member_tier__isnull=False) + return render(request, 'membership.html', {'posts': accessible_posts(request.user), 'plans': plans, 'comparison_rows': comparison_rows(plans)}) @never_cache @require_safe def detail(request, pk): return render(request, 'member-post.html', {'post': get_object_or_404(accessible_posts(request.user), pk=pk)}) + + +def comparison_rows(plans): + rows = {} + plans = list(plans) + for index, plan in enumerate(plans): + defaults = ['Published chapter library: Full access'] + if plan.member_tier >= 2: + defaults.append('Draft pages and process notes: Included') + for line in (plan.comparison.splitlines() if plan.comparison else defaults): + title, sep, value = line.partition(':') + if sep and title.strip() and value.strip(): + rows.setdefault(title.strip(), ['—'] * len(plans))[index] = value.strip() + return list(rows.items()) diff --git a/catalog/migrations/0027_alter_chapter_price_usd_managedpage.py b/catalog/migrations/0027_alter_chapter_price_usd_managedpage.py new file mode 100644 index 0000000..9c8199e --- /dev/null +++ b/catalog/migrations/0027_alter_chapter_price_usd_managedpage.py @@ -0,0 +1,37 @@ +# Generated by Django 5.2.19 on 2026-11-26 11:05 + +import django.core.validators +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('catalog', '0026_member_content'), + ] + + operations = [ + migrations.AlterField( + model_name='chapter', + name='price_usd', + field=models.DecimalField(blank=True, decimal_places=2, help_text='Set at least $0.50 for a Stripe chapter purchase. Leave blank if this chapter is only available to members.', max_digits=7, null=True, validators=[django.core.validators.MinValueValidator(0)], verbose_name='Chapter price (USD)'), + ), + migrations.CreateModel( + name='ManagedPage', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('title', models.CharField(max_length=160)), + ('map_slot', models.CharField(blank=True, editable=False, max_length=50)), + ('slug', models.SlugField(unique=True)), + ('body', models.TextField(blank=True)), + ('link', models.CharField(blank=True, help_text='Optional local destination, such as /shop/. Leave blank to publish the page body.', max_length=240)), + ('menu_key', models.CharField(blank=True, help_text='Optional existing menu key to replace, such as read, blog, or shop.', max_length=32)), + ('published', models.BooleanField(default=False)), + ('show_in_menu', models.BooleanField(default=False)), + ('homepage', models.BooleanField(default=False)), + ], + options={ + 'constraints': [models.UniqueConstraint(condition=models.Q(('homepage', True)), fields=('homepage',), name='slx_single_managed_home')], + }, + ), + ] diff --git a/catalog/migrations/0028_default_managed_pages.py b/catalog/migrations/0028_default_managed_pages.py new file mode 100644 index 0000000..6128def --- /dev/null +++ b/catalog/migrations/0028_default_managed_pages.py @@ -0,0 +1,33 @@ +from django.db import migrations + + +def seed(apps, schema_editor): + Page = apps.get_model('catalog', 'ManagedPage') + rows = [ + ('solterra-map', 'Explore Sol’Terra', '/map/', ''), + ('about', 'Series introduction', '/about/', ''), + ('chapters', 'Read', '/chapters/', 'read'), + ('blog', 'Blog', '/blog/', 'blog'), + ('reviews', 'Reviews', '/reviews/', 'reviews'), + ('upcoming', 'Upcoming', '/upcoming/', 'upcoming'), + ('live', 'SLX Live', '/live/', 'live'), + ('cast', 'Cast', '/cast/', 'cast'), + ('world', 'World archive', '/world/', 'world'), + ('shop', 'Shop', '/shop/', 'shop'), + ('cart', 'Shopping cart', '/shop/cart/', ''), + ('newsletter', 'Newsletter', '/newsletter/', ''), + ('membership', 'Membership', '/membership/', 'membership'), + ('library', 'My library', '/fan/library/', 'library'), + ('countdown', 'Release countdown', '/coming-soon/', ''), + ('djinnii', 'Djinnii', '/djinnii/', ''), + ('community', 'Community', '/community/', 'community'), + ('search', 'Search', '/search/', 'search'), + ] + for slug, title, path, key in rows: + Page.objects.using(schema_editor.connection.alias).get_or_create( + slug=slug, defaults={'title':title, 'link':path, 'published':True, 'menu_key':key, 'map_slot':slug}) + + +class Migration(migrations.Migration): + dependencies = [('catalog','0027_alter_chapter_price_usd_managedpage')] + operations = [migrations.RunPython(seed, migrations.RunPython.noop)] diff --git a/catalog/migrations/0029_map_location.py b/catalog/migrations/0029_map_location.py new file mode 100644 index 0000000..be2857c --- /dev/null +++ b/catalog/migrations/0029_map_location.py @@ -0,0 +1,33 @@ +# Generated by Django 5.2.19 on 2026-11-26 11:24 + +import django.core.validators +import django.db.models.deletion +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('catalog', '0028_default_managed_pages'), + ] + + operations = [ + migrations.CreateModel( + name='MapLocation', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('title', models.CharField(max_length=80)), + ('key', models.SlugField(unique=True)), + ('path', models.CharField(blank=True, help_text='Optional override, e.g. /chapters/9/. Leave blank to follow the selected page.', max_length=240)), + ('fallback_path', models.CharField(blank=True, editable=False, max_length=240)), + ('x', models.DecimalField(decimal_places=5, max_digits=8, validators=[django.core.validators.MinValueValidator(0), django.core.validators.MaxValueValidator(100)])), + ('y', models.DecimalField(decimal_places=5, max_digits=8, validators=[django.core.validators.MinValueValidator(0), django.core.validators.MaxValueValidator(100)])), + ('visible', models.BooleanField(default=True)), + ('position', models.PositiveIntegerField(default=0)), + ('page', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='catalog.managedpage')), + ], + options={ + 'ordering': ['position', 'pk'], + }, + ), + ] diff --git a/catalog/migrations/0030_seed_map_locations.py b/catalog/migrations/0030_seed_map_locations.py new file mode 100644 index 0000000..b9f9a74 --- /dev/null +++ b/catalog/migrations/0030_seed_map_locations.py @@ -0,0 +1,21 @@ +from django.db import migrations + + +ROWS = [('about', 'start', '8.88672', '3.41880', 'Series introduction'), ('upcoming', 'upcoming', '55.46875', '6.58120', 'Next releases'), ('cast', 'cast', '66.65039', '17.09402', 'Meet the cast'), ('world', 'world', '88.47656', '26.66667', 'World archive'), ('blog', 'blog', '13.81836', '39.40171', 'Studio blog'), ('chapters', 'chapters', '35.44922', '43.33333', 'Read chapters'), ('reviews', 'reviews', '53.36914', '48.97436', 'Reader reviews'), ('live', 'live', '62.45117', '60.76923', 'SLX Live'), ('membership', 'membership', '41.55273', '67.43590', 'Membership'), ('shop', 'shop', '74.90234', '73.33333', 'Shop'), ('cart', 'cart', '96.53320', '73.58974', 'Shopping cart'), ('newsletter', 'newsletter', '11.37695', '81.11111', 'Newsletter'), ('library', 'library', '15.18555', '84.87179', 'My library'), ('countdown', 'release', '61.13281', '88.88889', 'Release countdown')] + + +def seed(apps, schema_editor): + Page = apps.get_model('catalog', 'ManagedPage') + Location = apps.get_model('catalog', 'MapLocation') + db = schema_editor.connection.alias + for position, (slot, key, x, y, title) in enumerate(ROWS): + page = Page.objects.using(db).filter(map_slot=slot).first() + fallback = {'cart': '/shop/cart/', 'library': '/fan/library/', 'release': '/coming-soon/'}.get(key, '/' + slot + '/') + Location.objects.using(db).get_or_create(key=key, defaults=dict( + title=title, x=x, y=y, page_id=page.pk if page else None, + fallback_path=fallback, position=position)) + + +class Migration(migrations.Migration): + dependencies = [('catalog', '0029_map_location')] + operations = [migrations.RunPython(seed, migrations.RunPython.noop)] diff --git a/catalog/migrations/0031_sitesettings_countdown_map_position_collectorprofile.py b/catalog/migrations/0031_sitesettings_countdown_map_position_collectorprofile.py new file mode 100644 index 0000000..24d40b8 --- /dev/null +++ b/catalog/migrations/0031_sitesettings_countdown_map_position_collectorprofile.py @@ -0,0 +1,32 @@ +# Generated by Django 5.2.19 on 2026-11-26 12:55 + +import catalog.models +import django.db.models.deletion +from django.conf import settings +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('catalog', '0030_seed_map_locations'), + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ] + + operations = [ + migrations.AddField( + model_name='sitesettings', + name='countdown_map_position', + field=models.CharField(choices=[('above', 'Above countdown content'), ('below', 'Below countdown content')], default='below', max_length=6), + ), + migrations.CreateModel( + name='CollectorProfile', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('display_name', models.CharField(blank=True, max_length=80)), + ('photo', catalog.models.StudioImageField(blank=True, upload_to=catalog.models.image_path, validators=[catalog.models.validate_image])), + ('public', models.BooleanField(default=False)), + ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), + ], + ), + ] diff --git a/catalog/migrations/0032_collector_tier.py b/catalog/migrations/0032_collector_tier.py new file mode 100644 index 0000000..5b6d6b7 --- /dev/null +++ b/catalog/migrations/0032_collector_tier.py @@ -0,0 +1,23 @@ +# Generated by Django 5.2.19 on 2026-11-26 13:54 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('catalog', '0031_sitesettings_countdown_map_position_collectorprofile'), + ] + + operations = [ + migrations.AlterField( + model_name='fanmembership', + name='member_tier', + field=models.PositiveSmallIntegerField(choices=[(1, 'Early Access'), (2, 'Studio Vault'), (3, 'Collector’s Circle')], default=1, verbose_name='Content tier'), + ), + migrations.AlterField( + model_name='memberpost', + name='required_tier', + field=models.PositiveSmallIntegerField(choices=[(1, 'Early Access'), (2, 'Studio Vault'), (3, 'Collector’s Circle')], default=1), + ), + ] diff --git a/catalog/models.py b/catalog/models.py index aa72fd3..951fb5a 100644 --- a/catalog/models.py +++ b/catalog/models.py @@ -120,6 +120,8 @@ class PageSharePreview(models.Model): class SiteSettings(models.Model): + countdown_map_position = models.CharField(max_length=6, default='below', + choices=[('above', 'Above countdown content'), ('below', 'Below countdown content')]) name = models.CharField(max_length=100, default='SLUMP X LAND', editable=False) site_palette = models.JSONField(default=dict, blank=True) hidden_menu = models.JSONField(default=list, blank=True) @@ -228,7 +230,7 @@ class Chapter(models.Model): title = models.CharField(max_length=180) cover = art_field(blank=True) price_usd = models.DecimalField('Chapter price (USD)', max_digits=7, decimal_places=2, null=True, blank=True, - validators=[MinValueValidator(0)], help_text='Leave blank or set to zero for a free chapter.') + validators=[MinValueValidator(0)], help_text='Set at least $0.50 for a Stripe chapter purchase. Leave blank if this chapter is only available to members.') def clean(self): super().clean() @@ -590,7 +592,7 @@ class StreamComment(models.Model): class FanMembership(models.Model): user = models.OneToOneField('auth.User', on_delete=models.CASCADE, related_name='slx_membership') subscriber_until = models.DateTimeField('Subscription active through', null=True, blank=True) - member_tier = models.PositiveSmallIntegerField('Content tier', choices=[(1, 'Early Access'), (2, 'Studio Vault')], default=1) + member_tier = models.PositiveSmallIntegerField('Content tier', choices=[(1, 'Early Access'), (2, 'Studio Vault'), (3, 'Collector’s Circle')], default=1) sol_seat = models.BooleanField('Assign Sol Seat', default=False) class Meta: @@ -604,7 +606,7 @@ class MemberPost(models.Model): title = models.CharField(max_length=160) body = models.TextField(blank=True) kind = models.CharField(max_length=12, choices=[('note','Creator note'),('early','Early chapter'),('draft','Draft pages')], default='note') - required_tier = models.PositiveSmallIntegerField(choices=[(1,'Early Access'),(2,'Studio Vault')],default=1) + required_tier = models.PositiveSmallIntegerField(choices=[(1,'Early Access'),(2,'Studio Vault'),(3,'Collector’s Circle')],default=1) published = models.BooleanField(default=False) publish_at = models.DateTimeField(default=timezone.now) @@ -645,14 +647,27 @@ class TrafficDaily(models.Model): target_id = models.PositiveBigIntegerField(default=0) route = models.CharField(max_length=64) country = models.CharField(max_length=2, blank=True, default='') + region = models.CharField(max_length=120, blank=True, default='') + city = models.CharField(max_length=120, blank=True, default='') source = models.CharField(max_length=255, blank=True, default='') views = models.PositiveBigIntegerField(default=1) class Meta: - constraints = [models.UniqueConstraint(fields=['day', 'kind', 'target_id', 'route', 'country', 'source'], - name='slx_traffic_daily_key')] - indexes = [models.Index(fields=['kind', 'target_id'], name='slx_traffic_item_idx')] - + constraints = [ + models.UniqueConstraint( + fields=[ + 'day', 'kind', 'target_id', 'route', + 'country', 'region', 'city', 'source' + ], + name='slx_traffic_daily_key' + ) + ] + indexes = [ + models.Index( + fields=['kind', 'target_id'], + name='slx_traffic_item_idx' + ) + ] class AIChapterReview(models.Model): chapter = models.OneToOneField(Chapter, on_delete=models.CASCADE, related_name='ai_editorial_review') @@ -730,3 +745,74 @@ class NewsletterDelivery(models.Model): class Meta: constraints = [models.UniqueConstraint(fields=['campaign', 'subscriber'], name='slx_unique_newsletter_delivery')] + + +class ManagedPage(models.Model): + title = models.CharField(max_length=160) + slug = models.SlugField(unique=True) + body = models.TextField(blank=True) + link = models.CharField(max_length=240, blank=True, help_text='Optional local destination, such as /shop/. Leave blank to publish the page body.') + map_slot = models.CharField(max_length=50, blank=True, editable=False) + menu_key = models.CharField(max_length=32, blank=True, help_text='Optional existing menu key to replace, such as read, blog, or shop.') + published = models.BooleanField(default=False) + show_in_menu = models.BooleanField(default=False) + homepage = models.BooleanField(default=False) + + class Meta: + constraints = [models.UniqueConstraint(fields=['homepage'], condition=models.Q(homepage=True), name='slx_single_managed_home')] + + def clean(self): + from urllib.parse import urlsplit + super().clean() + if self.link: + try: + parts = urlsplit(self.link) + except ValueError as exc: + raise ValidationError({'link': 'Enter a valid local path.'}) from exc + if not self.link.startswith('/') or self.link.startswith('//') or parts.netloc or (parts.path == '/' or parts.path.startswith('/pages/')) or '\\' in self.link or any(ord(c)<32 for c in self.link): + raise ValidationError({'link': 'Enter a local path other than the homepage, such as /shop/.'}) + if self.homepage and not self.published: + raise ValidationError({'homepage': 'Publish this page before setting it as the homepage.'}) + + def get_absolute_url(self): + from django.urls import reverse + return reverse('managed-page', args=[self.slug]) + + def __str__(self): + return self.title + + +class MapLocation(models.Model): + title = models.CharField(max_length=80) + key = models.SlugField(max_length=50, unique=True) + path = models.CharField(max_length=240, blank=True, help_text='Optional override, e.g. /chapters/9/. Leave blank to follow the selected page.') + page = models.ForeignKey(ManagedPage, null=True, blank=True, on_delete=models.SET_NULL) + fallback_path = models.CharField(max_length=240, blank=True, editable=False) + x = models.DecimalField(max_digits=8, decimal_places=5, validators=[MinValueValidator(0), MaxValueValidator(100)]) + y = models.DecimalField(max_digits=8, decimal_places=5, validators=[MinValueValidator(0), MaxValueValidator(100)]) + visible = models.BooleanField(default=True) + position = models.PositiveIntegerField(default=0) + + class Meta: + ordering = ['position', 'pk'] + + def clean(self): + super().clean() + if self.path and (not self.path.startswith('/') or self.path.startswith('//') or + '\\' in self.path or any(c.isspace() or ord(c) < 32 for c in self.path)): + raise ValidationError({'path': 'Enter an internal path starting with one slash.'}) + if self.visible and not (self.path or self.page_id or self.fallback_path): + raise ValidationError({'path': 'Choose a page or enter a path.'}) + + def destination(self): + return self.path or (self.page.get_absolute_url() if self.page_id and self.page.published else self.fallback_path) + + def __str__(self): + return self.title + + +class CollectorProfile(models.Model): + user = models.OneToOneField('auth.User', on_delete=models.CASCADE) + display_name = models.CharField(max_length=80, blank=True) + photo = art_field(blank=True) + public = models.BooleanField(default=False) diff --git a/catalog/reporting.py b/catalog/reporting.py index f24f60d..09a5482 100644 --- a/catalog/reporting.py +++ b/catalog/reporting.py @@ -10,25 +10,64 @@ from .models import Chapter, Entry, TrafficDaily def traffic_report(request): days = request.GET.get('days', '30') days = int(days) if days in ('7', '30', '90') else 30 + kind = request.GET.get('kind', 'all') if kind not in ('all', 'chapter', 'blog'): kind = 'all' - qs = TrafficDaily.objects.filter(day__gte=timezone.localdate()-timedelta(days=days-1)) + + qs = TrafficDaily.objects.filter( + day__gte=timezone.localdate() - timedelta(days=days - 1) + ) + if kind != 'all': qs = qs.filter(kind=kind) def grouped(*fields): - return qs.values(*fields).annotate(views=Sum('views')).order_by('-views', *fields) + return qs.values(*fields).annotate( + views=Sum('views') + ).order_by('-views', *fields) + counts = {row['kind']: row['views'] for row in grouped('kind')} + countries = list(grouped('country')) + regions = list(grouped('country', 'region')[:100]) + cities = list(grouped('country', 'region', 'city')[:100]) + sources = grouped('source')[:30] series = list(grouped('day').order_by('day')) - top = list(qs.exclude(target_id=0).values('kind','target_id').annotate(views=Sum('views')).order_by('-views','target_id')[:25]) - chapters = Chapter.objects.in_bulk(row['target_id'] for row in top if row['kind'] == 'chapter') - posts = Entry.objects.in_bulk(row['target_id'] for row in top if row['kind'] == 'blog') + + top = list( + qs.exclude(target_id=0) + .values('kind', 'target_id') + .annotate(views=Sum('views')) + .order_by('-views', 'target_id')[:25] + ) + + chapters = Chapter.objects.in_bulk( + row['target_id'] for row in top if row['kind'] == 'chapter' + ) + posts = Entry.objects.in_bulk( + row['target_id'] for row in top if row['kind'] == 'blog' + ) + for row in top: - obj = (chapters if row['kind'] == 'chapter' else posts).get(row['target_id']) + obj = ( + chapters if row['kind'] == 'chapter' else posts + ).get(row['target_id']) row['title'] = str(obj) if obj else 'Removed content' - return {'days': days, 'kind': kind, 'total': sum(counts.values()), 'chapters': counts.get('chapter', 0), - 'blogs': counts.get('blog', 0), 'countries': countries, 'sources': sources, 'top': top, 'series': series, - 'analytics_enabled': settings.SLX_ANALYTICS, 'geo_configured': bool(settings.SLX_GEOIP_DB)} + + return { + 'days': days, + 'kind': kind, + 'total': sum(counts.values()), + 'chapters': counts.get('chapter', 0), + 'blogs': counts.get('blog', 0), + 'countries': countries, + 'regions': regions, + 'cities': cities, + 'sources': sources, + 'top': top, + 'series': series, + 'analytics_enabled': settings.SLX_ANALYTICS, + 'geo_configured': bool(settings.SLX_GEOIP_DB), + } diff --git a/catalog/templatetags/djinn_sol.py b/catalog/templatetags/djinn_sol.py new file mode 100644 index 0000000..4710ae7 --- /dev/null +++ b/catalog/templatetags/djinn_sol.py @@ -0,0 +1,22 @@ +"""Reusable A–Z spelling in the Djinn-Sol alphabet.""" +from string import ascii_lowercase + +from django import template + +register = template.Library() + + +@register.inclusion_tag("djinn-sol-glyphs.html") +def djinn_sol(text): + return { + "words": [ + [f"djinn-sol/{letter}.png" for letter in word if letter in ascii_lowercase] + for word in str(text).lower().split() + ] + } + + +@register.simple_tag(takes_context=True) +def map_destination(context, slug, default_url): + page = context.get('map_destinations', {}).get(slug) + return page.get_absolute_url() if page else default_url diff --git a/catalog/traffic.py b/catalog/traffic.py index fceadb3..24d1766 100644 --- a/catalog/traffic.py +++ b/catalog/traffic.py @@ -45,20 +45,43 @@ def geo_reader(path): except maxminddb.InvalidDatabaseError as exc: raise ValueError('Invalid country database') from exc +def location_for(request): + empty = {'country': '', 'region': '', 'city': ''} -def country_for(request): if not settings.SLX_GEOIP_DB: - return '' - header = 'HTTP_X_SLX_CLIENT_IP' if settings.SLX_TRUST_CADDY_IP else 'REMOTE_ADDR' + return empty + + header = ( + 'HTTP_X_SLX_CLIENT_IP' + if settings.SLX_TRUST_CADDY_IP + else 'REMOTE_ADDR' + ) + try: ip = ipaddress.ip_address(request.META.get(header, '')) + if not ip.is_global: - return '' + return empty + row = geo_reader(settings.SLX_GEOIP_DB).get(str(ip)) or {} - code = row.get('country', {}).get('iso_code', '') - return code if re.fullmatch(r'[A-Z]{2}', code) else '' + + country = row.get('country', {}).get('iso_code', '') + subdivisions = row.get('subdivisions') or [] + + region = '' + if subdivisions: + region = subdivisions[0].get('names', {}).get('en', '') + + city = row.get('city', {}).get('names', {}).get('en', '') + + return { + 'country': country if re.fullmatch(r'[A-Z]{2}', country) else '', + 'region': region[:120], + 'city': city[:120], + } + except (ValueError, OSError, ImportError, RuntimeError): - return '' + return empty def view_total(kind, ident): @@ -86,12 +109,27 @@ class TrafficMiddleware: or any('prefetch' in request.META.get(header, '').lower() for header in ('HTTP_SEC_PURPOSE', 'HTTP_PURPOSE')) or not request.META.get('HTTP_USER_AGENT') or BOT.search(request.META['HTTP_USER_AGENT'])): return response + kind, target = getattr(request, 'slx_view_target', ('site', 0)) + try: - row, created = TrafficDaily.objects.get_or_create(day=timezone.localdate(), kind=kind, target_id=target, - route=match.url_name, country=country_for(request), source=source_origin(request)) + location = location_for(request) + + row, created = TrafficDaily.objects.get_or_create( + day=timezone.localdate(), + kind=kind, + target_id=target, + route=match.url_name, + country=location['country'], + region=location['region'], + city=location['city'], + source=source_origin(request), + ) + if not created: TrafficDaily.objects.filter(pk=row.pk).update(views=F('views') + 1) + except DatabaseError: logger.warning('SLX traffic could not be recorded.') + return response diff --git a/catalog/views.py b/catalog/views.py index 4a7dda7..e99336a 100644 --- a/catalog/views.py +++ b/catalog/views.py @@ -1,5 +1,6 @@ from math import floor from urllib.parse import urlencode +from django.conf import settings as config from django.contrib.auth.decorators import login_required from django.core.paginator import Paginator from django.db import connection @@ -9,7 +10,8 @@ from django.http import FileResponse, Http404, JsonResponse from django.shortcuts import get_object_or_404, redirect, render from django.utils import timezone from django.views.decorators.cache import never_cache -from django.views.decorators.http import require_safe +from django.views.decorators.http import require_POST, require_safe +from .chapter_access import full_chapters, rolling_chapter_ids from PIL import Image from .models import SiteSettings, Chapter, Page, Entry, BookListing, StreamComment, DiscussionComment, PageBackground, FloatingArtwork, ProductVariant, PageSharePreview, MemberArtwork from .fans import engagement, live @@ -47,7 +49,13 @@ def search(request): chapter_filter = Q(title__icontains=query) | Q(summary__icontains=query) if query.lstrip('#').isascii() and query.lstrip('#').isdigit() and len(query.lstrip('#')) < 10: chapter_filter |= Q(number=int(query.lstrip('#'))) - chapters = live(Chapter).filter(chapter_filter)[:20] + chapters = live(Chapter).filter(chapter_filter).annotate( + first_page_art=Subquery(Page.objects.filter(chapter_id=OuterRef('pk')).order_by('number').values('art')[:1]))[:20] + page_storage = Page._meta.get_field("art").storage + for chapter in chapters: + chapter.search_cover = chapter.cover.url if chapter.cover else ( + page_storage.url(chapter.first_page_art) if chapter.first_upload_is_cover and chapter.first_page_art + and not chapter.publisher_url else '') posts = live(Entry).filter(Q(title__icontains=query) | Q(summary__icontains=query) | Q(category__icontains=query))[:20] return render(request, 'search.html', {'query': query, 'chapters': chapters, 'items': posts}) @@ -91,7 +99,8 @@ def stream(request): @require_safe def community(request): - return render(request, 'community.html') + from .collectors import recognized_collectors + return render(request, 'community.html', {'collectors': recognized_collectors()}) @require_safe @@ -135,50 +144,55 @@ def countdown_progress(site, now): @require_safe def home(request): - settings = settings_row() - now = timezone.now() - homepage_countdown = ( - settings.homepage_countdown_enabled - and settings.homepage_countdown_at - and settings.homepage_countdown_at > now - ) - countdown_context = { - 'countdown_now': now, - 'release_progress': countdown_progress(settings, now) if homepage_countdown else None, - 'countdown_chapters': countdown_chapter_shelf(request.user, now) if homepage_countdown else [], - 'countdown_social_color': settings.homepage_social_color if HEX_COLOR.fullmatch(settings.homepage_social_color) else '#ffdd00', - } - if homepage_countdown and settings.homepage_countdown_landing and settings.homepage_countdown_cover: - tint = settings.homepage_countdown_tint - return render(request, 'countdown-landing.html', { - **countdown_context, 'settings': settings, - 'countdown_tint': tint if HEX_COLOR.fullmatch(tint) else '#0c1020', - 'countdown_tint_strength': min(100, settings.homepage_countdown_tint_strength), - }) - return render(request, 'home.html', { - **countdown_context, 'homepage_countdown': homepage_countdown, - 'chapters': with_views(live(Chapter), 'chapter')[:6], - 'upcoming': upcoming_chapters()[:3], - 'recent_reviews': published_reviews()[:5], - 'news': with_views(live(Entry).filter(kind=Entry.Kind.NEWS), 'blog')[:6], - 'cast': live(Entry).filter(kind=Entry.Kind.CAST)[:3], - 'world': live(Entry).filter(kind=Entry.Kind.WORLD)[:3], - }) + from .models import ManagedPage + page = ManagedPage.objects.filter(published=True, homepage=True).first() + return render_managed_page(request, page) if page else map_landing(request) + + +@require_safe +def map_landing(request): + from .models import MapLocation + + locations = [] + for marker in MapLocation.objects.filter(visible=True).select_related('page'): + if url := marker.destination(): + locations.append({'title': marker.title, 'key': marker.key, 'url': url, + 'x': format(marker.x, 'f'), 'y': format(marker.y, 'f')}) + context = countdown_splash_context(request) + if context: + return render(request, 'countdown-landing.html', {**context, 'map_locations': locations, 'with_world_map': True}) + return render(request, 'home.html', {'map_locations': locations}) + + +def render_managed_page(request, page): + if page.link and page.link.split('?', 1)[0].split('#', 1)[0] != request.path: + return redirect(page.link) + return render(request, 'managed-page.html', {'page': page}) + + +@require_safe +def managed_page(request, slug): + from .models import ManagedPage + return render_managed_page(request, get_object_or_404(ManagedPage, slug=slug, published=True)) + @require_safe def chapters(request): - return render(request, 'chapters.html', {'chapters': with_views(live(Chapter), 'chapter')}) + return render(request, 'chapters.html', {'chapters': with_views(live(Chapter), 'chapter'), 'rolling_free_ids': set(rolling_chapter_ids().values_list('pk', flat=True)), 'show_archive_status': True}) @require_safe @never_cache def chapter(request, number): item = get_object_or_404(live(Chapter), number=number) + if not full_chapters(request.user).filter(pk=item.pk).exists(): + from shop.payments import stripe_ready + return render(request, 'chapter-locked.html', { + 'chapter': item, 'stripe_enabled': stripe_ready() and bool(config.SLX_COMMERCE_STRIPE_WEBHOOK_SECRET), + }) if item.publisher_url: return redirect(item.publisher_url) - if item.price_usd and not entitled_chapters(request.user).filter(pk=item.pk).exists(): - return render(request, 'chapter-locked.html', {'chapter': item, 'paypal_ready': checkout_ready()}) request.slx_view_target = ('chapter', item.pk) item.public_views = view_total('chapter', item.pk) pages = list(item.pages.all()) @@ -187,7 +201,7 @@ def chapter(request, number): page.reactions = groups[page.pk] next_chapter = live(Chapter).filter(number__gt=number).order_by('number').first() next_readable = bool(next_chapter and ( - not next_chapter.price_usd or entitled_chapters(request.user).filter(pk=next_chapter.pk).exists())) + full_chapters(request.user).filter(pk=next_chapter.pk).exists())) next_cover = None if next_readable: next_cover = next_chapter.cover @@ -195,7 +209,11 @@ def chapter(request, number): first_page = next_chapter.pages.first() next_cover = first_page.art if first_page else None previous_chapter = live(Chapter).filter(number__lt=number).first() - return render(request, 'chapter.html', {'chapter': item, 'frames': reading_frames(item, pages), + from shop.models import Product + from shop.payments import stripe_ready + physical = Product.objects.filter(active=True, kind=Product.Kind.PHYSICAL, sample_chapter=item).first() + return render(request, 'chapter.html', {'chapter': item, + 'physical_edition': physical, 'stripe_enabled': stripe_ready() and bool(config.SLX_COMMERCE_STRIPE_WEBHOOK_SECRET), 'frames': reading_frames(item, pages), 'next_chapter': next_chapter, 'next_readable': next_readable, 'next_cover': next_cover, 'previous_chapter': previous_chapter, **chapter_fan_context(request, item)}) @@ -227,9 +245,30 @@ def entry(request, kind, slug): 'share_image': request.build_absolute_uri(item.art.url) if item.art else ''}) +def countdown_splash_context(request): + settings = settings_row() + now = timezone.now() + if (settings.homepage_countdown_enabled and settings.homepage_countdown_landing + and settings.homepage_countdown_cover and settings.homepage_countdown_at + and settings.homepage_countdown_at > now): + tint = settings.homepage_countdown_tint + social = settings.homepage_social_color + return { + 'settings': settings, + 'countdown_now': now, + 'release_progress': countdown_progress(settings, now), + 'countdown_chapters': countdown_chapter_shelf(request.user, now), + 'countdown_social_color': social if HEX_COLOR.fullmatch(social) else '#ffdd00', + 'countdown_tint': tint if HEX_COLOR.fullmatch(tint) else '#0c1020', + 'countdown_tint_strength': min(100, settings.homepage_countdown_tint_strength), + } + return None + + @require_safe def coming_soon(request): - return render(request, 'soon.html') + context = countdown_splash_context(request) + return render(request, 'countdown-landing.html', context) if context else render(request, 'soon.html') @require_safe @@ -237,7 +276,11 @@ def image(request, key): # Chapter pages respect visibility and schedule even if a file URL is shared. name = f'images/{key}' from .membership import accessible_posts + from .collectors import recognized_collectors + from .models import CollectorProfile sources = ( + (recognized_collectors(), 'photo'), + (CollectorProfile.objects.filter(user_id=request.user.pk), 'photo'), (MemberArtwork.objects.filter(post__in=accessible_posts(request.user)), 'art'), (PageSharePreview.objects.all(), 'art'), (PageBackground.objects.filter(enabled=True), 'art'), @@ -257,7 +300,7 @@ def image(request, key): (scheduled_chapters() if settings_row().show_chapter_countdowns else Chapter.objects.none(), 'cover'), (live(Chapter), 'cover'), (live(Entry), 'art'), - (Page.objects.filter(chapter__in=entitled_chapters(request.user), chapter__publisher_url=''), 'art'), + (Page.objects.filter(chapter__in=full_chapters(request.user), chapter__publisher_url=''), 'art'), ) if can_watch_stream(request.user) or (request.user.is_staff and request.user.has_perm('catalog.view_sitesettings')): sources += ((SiteSettings.objects.filter(pk=1), 'stream_cover'),) @@ -295,3 +338,37 @@ def health(request): with connection.cursor() as cursor: cursor.execute('SELECT 1') return JsonResponse({'status': 'ok', 'service': 'slx-studio'}) + + +@require_POST +@login_required +def buy_chapter(request, number): + from django.conf import settings + from django.contrib import messages + from django.db import transaction + from shop.models import Product, Order, OrderItem + from shop.payments import create_stripe_order_session, stripe_ready + + item = get_object_or_404(live(Chapter), number=number, publisher_url='', price_usd__gte='0.50') + if full_chapters(request.user).filter(pk=item.pk).exists(): + return redirect('chapter', number=number) + if not request.user.is_active or not request.user.email or not stripe_ready() or not settings.SLX_COMMERCE_STRIPE_WEBHOOK_SECRET: + messages.error(request, 'Chapter checkout needs an account email and an enabled Stripe checkout.') + return redirect('chapter', number=number) + try: + with transaction.atomic(): + product, _ = Product.objects.get_or_create(slug=f'digital-chapter-{item.pk}', defaults={ + 'kind': Product.Kind.DIGITAL, 'title': item.title[:160], 'sample_chapter': item, + 'price_usd': item.price_usd, 'active': False, 'track_stock': False, + }) + if product.kind != Product.Kind.DIGITAL or product.sample_chapter_id != item.pk: + raise ValueError('Reserved chapter product slug already exists.') + order = Order.objects.create(user=request.user, email=request.user.email, gateway=Order.Gateway.STRIPE, + subtotal_usd=item.price_usd, total_usd=item.price_usd) + OrderItem.objects.create(order=order, product=product, chapter=item, title_snapshot=item.title[:160], + unit_price_usd=item.price_usd) + url = create_stripe_order_session(order) + except Exception: + messages.error(request, 'Checkout could not start. Please try again.') + return redirect('chapter', number=number) + return redirect(url) diff --git a/shop/admin.py b/shop/admin.py index 24a3a2f..2168258 100644 --- a/shop/admin.py +++ b/shop/admin.py @@ -5,16 +5,16 @@ from .models import Order, OrderItem, Product, Subscription @admin.register(Product, site=studio) class ProductAdmin(admin.ModelAdmin): - list_display = ['title', 'kind', 'price_usd', 'stock', 'active', 'featured', 'position'] - list_filter = ['kind', 'active', 'featured'] + list_display = ['title', 'kind', 'price_usd', 'stock', 'active', 'featured', 'verified_by_seller', 'position'] + list_filter = ['kind', 'active', 'featured', 'verified_by_seller'] list_editable = ['price_usd', 'stock', 'active', 'position'] search_fields = ['title', 'summary'] prepopulated_fields = {'slug': ('title',)} fieldsets = [ - ('Product', {'fields': ['title', 'slug', 'kind', 'summary', 'description', 'image', 'price_usd', 'active', 'featured', 'position']}), + ('Product', {'fields': ['title', 'slug', 'kind', 'summary', 'description', 'image', 'price_usd', 'active', 'featured', 'verified_by_seller', 'position']}), ('Physical Inventory & Shipping', {'fields': ['track_stock', 'stock', 'shipping_usd']}), - ('Digital Download', {'fields': ['digital_file']}), - ('Subscription Billing', {'fields': ['billing_interval', 'stripe_price_id', 'paypal_plan_id']}), + ('Digital Download', {'fields': ['digital_file', 'sample_chapter']}), + ('Subscription Billing', {'fields': ['billing_interval', 'stripe_price_id', 'paypal_plan_id', 'member_tier', 'comparison']}), ] diff --git a/shop/migrations/0002_product_verified_by_seller.py b/shop/migrations/0002_product_verified_by_seller.py new file mode 100644 index 0000000..c18dc93 --- /dev/null +++ b/shop/migrations/0002_product_verified_by_seller.py @@ -0,0 +1,18 @@ +# Generated by Django 5.2.19 on 2026-11-26 01:31 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('shop', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='product', + name='verified_by_seller', + field=models.BooleanField(default=False, help_text='Show the Verified by Seller badge on this listing.'), + ), + ] diff --git a/shop/migrations/0003_order_stripe_live_orderitem_chapter_and_more.py b/shop/migrations/0003_order_stripe_live_orderitem_chapter_and_more.py new file mode 100644 index 0000000..96ad7b5 --- /dev/null +++ b/shop/migrations/0003_order_stripe_live_orderitem_chapter_and_more.py @@ -0,0 +1,45 @@ +# Generated by Django 5.2.19 on 2026-11-26 11:05 + +import django.db.models.deletion +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('catalog', '0027_alter_chapter_price_usd_managedpage'), + ('shop', '0002_product_verified_by_seller'), + ] + + operations = [ + migrations.AddField( + model_name='order', + name='stripe_live', + field=models.BooleanField(editable=False, null=True), + ), + migrations.AddField( + model_name='orderitem', + name='chapter', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='catalog.chapter'), + ), + migrations.AddField( + model_name='product', + name='member_tier', + field=models.PositiveSmallIntegerField(blank=True, choices=[(1, 'Early Access'), (2, 'Studio Vault')], null=True), + ), + migrations.AddField( + model_name='product', + name='sample_chapter', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='shop_editions', to='catalog.chapter'), + ), + migrations.AddField( + model_name='subscription', + name='entitlement_tier', + field=models.PositiveSmallIntegerField(editable=False, null=True), + ), + migrations.AddField( + model_name='subscription', + name='stripe_live', + field=models.BooleanField(editable=False, null=True), + ), + ] diff --git a/shop/migrations/0004_fan_club_products.py b/shop/migrations/0004_fan_club_products.py new file mode 100644 index 0000000..edcbee4 --- /dev/null +++ b/shop/migrations/0004_fan_club_products.py @@ -0,0 +1,20 @@ +from decimal import Decimal +from django.db import migrations + + +def seed(apps, schema_editor): + Product = apps.get_model('shop', 'Product') + products = Product.objects.using(schema_editor.connection.alias) + for slug, label, tier in [('slx-monthly-early-access', 'Early Access', 1), + ('slx-monthly-studio-vault', 'Studio Vault', 2)]: + if not products.filter(kind='subscription', member_tier=tier).exists(): + products.get_or_create(slug=slug, defaults={ + 'title': f'Slump X Land Monthly · {label}', 'kind': 'subscription', + 'billing_interval': 'month', 'member_tier': tier, 'price_usd': Decimal('0.50'), + 'track_stock': False, 'active': False, + }) + + +class Migration(migrations.Migration): + dependencies = [('shop', '0003_order_stripe_live_orderitem_chapter_and_more')] + operations = [migrations.RunPython(seed, migrations.RunPython.noop)] diff --git a/shop/migrations/0005_product_comparison.py b/shop/migrations/0005_product_comparison.py new file mode 100644 index 0000000..881d974 --- /dev/null +++ b/shop/migrations/0005_product_comparison.py @@ -0,0 +1,18 @@ +# Generated by Django 5.2.19 on 2026-11-26 12:55 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('shop', '0004_fan_club_products'), + ] + + operations = [ + migrations.AddField( + model_name='product', + name='comparison', + field=models.TextField(blank=True, help_text='One benefit per line, using Feature: Details. Used on the membership comparison chart.', max_length=3000), + ), + ] diff --git a/shop/migrations/0006_collector_tier.py b/shop/migrations/0006_collector_tier.py new file mode 100644 index 0000000..aabc99c --- /dev/null +++ b/shop/migrations/0006_collector_tier.py @@ -0,0 +1,18 @@ +# Generated by Django 5.2.19 on 2026-11-26 13:54 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('shop', '0005_product_comparison'), + ] + + operations = [ + migrations.AlterField( + model_name='product', + name='member_tier', + field=models.PositiveSmallIntegerField(blank=True, choices=[(1, 'Early Access'), (2, 'Studio Vault'), (3, 'Collector’s Circle')], null=True), + ), + ] diff --git a/shop/models.py b/shop/models.py index 9a74cf6..4898208 100644 --- a/shop/models.py +++ b/shop/models.py @@ -24,7 +24,14 @@ class Product(models.Model): image = models.ImageField(upload_to='shop/products/', blank=True) price_usd = models.DecimalField(max_digits=9, decimal_places=2, validators=[MinValueValidator(Decimal('0.50'))]) active = models.BooleanField(default=True) + comparison = models.TextField(blank=True, max_length=3000, + help_text='One benefit per line, using Feature: Details. Used on the membership comparison chart.') featured = models.BooleanField(default=False) + sample_chapter = models.ForeignKey('catalog.Chapter', null=True, blank=True, on_delete=models.SET_NULL, + related_name='shop_editions') + member_tier = models.PositiveSmallIntegerField(choices=[(1, 'Early Access'), (2, 'Studio Vault'), (3, 'Collector’s Circle')], + null=True, blank=True) + verified_by_seller = models.BooleanField(default=False, help_text="Show the Verified by Seller badge on this listing.") position = models.PositiveIntegerField(default=0) # Physical inventory & shipping @@ -96,6 +103,7 @@ class Order(models.Model): # Gateway tracking gateway_session_id = models.CharField(max_length=200, blank=True, db_index=True) gateway_payment_id = models.CharField(max_length=200, blank=True) + stripe_live = models.BooleanField(null=True, editable=False) paid_at = models.DateTimeField(null=True, blank=True) created_at = models.DateTimeField(auto_now_add=True) @@ -113,6 +121,7 @@ class Order(models.Model): class OrderItem(models.Model): order = models.ForeignKey(Order, on_delete=models.CASCADE, related_name='items') product = models.ForeignKey(Product, on_delete=models.PROTECT) + chapter = models.ForeignKey('catalog.Chapter', null=True, blank=True, on_delete=models.PROTECT) title_snapshot = models.CharField(max_length=160) unit_price_usd = models.DecimalField(max_digits=9, decimal_places=2) quantity = models.PositiveIntegerField(default=1) @@ -137,6 +146,8 @@ class Subscription(models.Model): gateway_sub_id = models.CharField(max_length=200, blank=True, db_index=True) gateway_customer_id = models.CharField(max_length=200, blank=True) status = models.CharField(max_length=20, choices=Status.choices, default=Status.PENDING) + stripe_live = models.BooleanField(null=True, editable=False) + entitlement_tier = models.PositiveSmallIntegerField(null=True, editable=False) current_period_end = models.DateTimeField(null=True, blank=True) created_at = models.DateTimeField(auto_now_add=True) diff --git a/shop/payments.py b/shop/payments.py index f5ec03e..f3ac1f3 100644 --- a/shop/payments.py +++ b/shop/payments.py @@ -9,11 +9,12 @@ from django.utils import timezone import stripe from catalog.paypal import CheckoutError, access_token, checkout_origin, request_json, safe_approval_url +from catalog.shop_stripe import origin as stripe_origin from .models import Order, Product, Subscription def stripe_ready(): - return bool(settings.SLX_STRIPE_SECRET_KEY and checkout_origin()) + return bool(settings.SLX_STRIPE_SECRET_KEY and (stripe_origin() or checkout_origin())) def paypal_ready(): @@ -23,7 +24,7 @@ def paypal_ready(): and checkout_origin()) -def fulfill_order(order, payment_id=''): +def fulfill_order(order, payment_id='', stripe_live=None): with transaction.atomic(): order = Order.objects.select_for_update().get(pk=order.pk) if order.status != Order.Status.PENDING: @@ -32,7 +33,8 @@ def fulfill_order(order, payment_id=''): order.paid_at = timezone.now() if payment_id: order.gateway_payment_id = payment_id[:200] - order.save(update_fields=['status', 'paid_at', 'gateway_payment_id']) + order.stripe_live = stripe_live + order.save(update_fields=['status', 'paid_at', 'gateway_payment_id', 'stripe_live']) for item in order.items.select_related('product'): prod = item.product @@ -47,7 +49,7 @@ def fulfill_order(order, payment_id=''): def create_stripe_order_session(order): stripe.api_key = settings.SLX_STRIPE_SECRET_KEY - origin = checkout_origin() + origin = stripe_origin() or checkout_origin() line_items = [] for item in order.items.select_related('product'): line_items.append({ @@ -88,7 +90,7 @@ def create_stripe_order_session(order): def create_stripe_subscription_session(sub): stripe.api_key = settings.SLX_STRIPE_SECRET_KEY - origin = checkout_origin() + origin = stripe_origin() or checkout_origin() prod = sub.product if prod.stripe_price_id: line_item = {'price': prod.stripe_price_id, 'quantity': 1} diff --git a/shop/urls.py b/shop/urls.py index 77fb524..694391f 100644 --- a/shop/urls.py +++ b/shop/urls.py @@ -11,7 +11,7 @@ urlpatterns = [ path('paypal/return//', views.paypal_return, name='shop-paypal-return'), path('order//', views.order_detail, name='shop-order-detail'), path('order//download//', views.download_digital, name='shop-download'), - path('webhooks/stripe/', views.stripe_webhook, name='shop-stripe-webhook'), + path('webhooks/stripe/', views.stripe_webhook, name='commerce-stripe-webhook'), path('webhooks/paypal/', views.paypal_webhook, name='shop-paypal-webhook'), path('/', views.product_detail, name='shop-product'), ] diff --git a/shop/views.py b/shop/views.py index f21ae03..02a5dde 100644 --- a/shop/views.py +++ b/shop/views.py @@ -1,7 +1,10 @@ +from datetime import datetime, timezone as utc from decimal import Decimal import json from django.conf import settings from django.contrib import messages +from django.contrib.auth.decorators import login_required +from django.db import transaction from django.http import FileResponse, Http404, HttpResponse, HttpResponseBadRequest from django.shortcuts import get_object_or_404, redirect, render from django.utils import timezone @@ -76,10 +79,16 @@ def index(request): def product_detail(request, slug): product = get_object_or_404(Product, slug=slug, active=True) cart_count = sum(_get_cart(request).values()) + from catalog.fans import live + from catalog.models import Chapter + chapter = live(Chapter).filter(pk=product.sample_chapter_id, publisher_url='').first() return render(request, 'shop/product.html', { + 'sample_chapter': chapter, + 'editions': Product.objects.filter(active=True, kind=Product.Kind.PHYSICAL, sample_chapter=chapter).exclude(pk=product.pk) if chapter else (), + 'related_products': Product.objects.filter(active=True).exclude(pk=product.pk)[:6], 'product': product, 'cart_count': cart_count, - 'stripe_enabled': stripe_ready(), + 'stripe_enabled': stripe_ready() and bool(settings.SLX_COMMERCE_STRIPE_WEBHOOK_SECRET), 'paypal_enabled': paypal_ready(), }) @@ -173,9 +182,13 @@ def checkout_start(request): @require_POST +@login_required def subscribe_start(request, slug): product = get_object_or_404(Product, slug=slug, active=True, kind=Product.Kind.SUBSCRIPTION) gateway = request.POST.get('gateway', '').lower() + if product.member_tier and (gateway != 'stripe' or not stripe_ready() or not settings.SLX_COMMERCE_STRIPE_WEBHOOK_SECRET): + messages.error(request, 'Fan Club subscriptions require Stripe checkout.') + return redirect('shop-product', slug=slug) email = (request.user.email if request.user.is_authenticated and request.user.email else request.POST.get('email', '')).strip() if not email or '@' not in email: messages.error(request, 'Please enter a valid email address to subscribe.') @@ -184,7 +197,7 @@ def subscribe_start(request, slug): sub = Subscription.objects.create( user=request.user if request.user.is_authenticated else None, email=email, - product=product, + product=product, entitlement_tier=product.member_tier, gateway=gateway if gateway in {'stripe', 'paypal'} else Order.Gateway.STRIPE, ) try: @@ -229,24 +242,27 @@ def download_digital(request, order_id, item_id): @csrf_exempt @require_POST def stripe_webhook(request): - if not settings.SLX_STRIPE_WEBHOOK_SECRET: + if not settings.SLX_COMMERCE_STRIPE_WEBHOOK_SECRET: return HttpResponseBadRequest('Webhook secret not configured') stripe.api_key = settings.SLX_STRIPE_SECRET_KEY sig = request.META.get('HTTP_STRIPE_SIGNATURE', '') try: - event = stripe.Webhook.construct_event(request.body, sig, settings.SLX_STRIPE_WEBHOOK_SECRET) + event = stripe.Webhook.construct_event(request.body, sig, settings.SLX_COMMERCE_STRIPE_WEBHOOK_SECRET) except Exception: return HttpResponseBadRequest('Invalid signature') + from catalog.chapter_access import stripe_live_mode + if event.get('livemode') != stripe_live_mode(): + return HttpResponseBadRequest('Stripe mode mismatch') etype = event['type'] obj = event['data']['object'] - - if etype == 'checkout.session.completed': + if etype in ('checkout.session.completed', 'checkout.session.async_payment_succeeded'): meta = obj.get('metadata') or {} - if meta.get('kind') == 'order' and meta.get('order_id'): - order = Order.objects.filter(order_id=meta['order_id']).first() - if order: - shipping = obj.get('shipping_details') or {} + if meta.get('kind') == 'order' and obj.get('payment_status') == 'paid': + order = Order.objects.filter(gateway=Order.Gateway.STRIPE, gateway_session_id=obj.get('id', '')).first() + if (order and str(order.order_id) == meta.get('order_id') and obj.get('currency') == 'usd' + and obj.get('amount_total') == int(order.total_usd * 100)): + shipping = obj.get('shipping_details') or (obj.get('collected_information') or {}).get('shipping_details') or {} addr = shipping.get('address') or {} if addr: order.full_name = (shipping.get('name') or order.full_name)[:160] @@ -260,23 +276,45 @@ def stripe_webhook(request): 'full_name', 'shipping_line1', 'shipping_line2', 'shipping_city', 'shipping_state', 'shipping_postal', 'shipping_country' ]) - fulfill_order(order, payment_id=obj.get('payment_intent') or obj.get('id', '')) - elif meta.get('kind') == 'subscription' and meta.get('sub_id'): - Subscription.objects.filter(sub_id=meta['sub_id']).update( - status=Subscription.Status.ACTIVE, - gateway_sub_id=obj.get('subscription') or '', - gateway_customer_id=obj.get('customer') or '', - ) + fulfill_order(order, payment_id=obj.get('payment_intent') or obj['id'], stripe_live=event['livemode']) + elif meta.get('kind') == 'subscription' and obj.get('subscription'): + sync_stripe_subscription(obj['subscription'], event['livemode'], meta.get('sub_id')) - elif etype in ('customer.subscription.deleted', 'invoice.payment_failed'): - sub_id = obj.get('id') if etype == 'customer.subscription.deleted' else obj.get('subscription') + elif etype == 'charge.refunded' and obj.get('refunded') and obj.get('payment_intent'): + Order.objects.filter(gateway=Order.Gateway.STRIPE, stripe_live=event['livemode'], + gateway_payment_id=obj['payment_intent']).update(status=Order.Status.REFUNDED) + elif etype in ('customer.subscription.updated', 'customer.subscription.deleted', + 'invoice.paid', 'invoice.payment_failed'): + sub_id = obj.get('id') if etype.startswith('customer.subscription.') else ( + obj.get('subscription') or ((obj.get('parent') or {}).get('subscription_details') or {}).get('subscription')) if sub_id: - new_status = Subscription.Status.CANCELED if etype == 'customer.subscription.deleted' else Subscription.Status.PAST_DUE - Subscription.objects.filter(gateway_sub_id=sub_id).update(status=new_status) - + sync_stripe_subscription(sub_id, event['livemode']) return HttpResponse('ok') +def sync_stripe_subscription(remote_id, live_mode, checkout_ref=None): + with transaction.atomic(): + rows = Subscription.objects.select_for_update().filter(gateway=Order.Gateway.STRIPE) + sub = rows.filter(gateway_sub_id=remote_id, stripe_live=live_mode).first() + if sub is None and checkout_ref: + sub = rows.filter(sub_id=checkout_ref, gateway_sub_id='').first() + if not sub: + return + current = stripe.Subscription.retrieve(remote_id) + if current.get('livemode') != live_mode or (current.get('metadata') or {}).get('sub_id') != str(sub.sub_id): + return + state = current.get('status') + periods = [item.get('current_period_end') for item in (current.get('items') or {}).get('data', [])] + period = current.get('current_period_end') or min((v for v in periods if v), default=None) + sub.status = (Subscription.Status.ACTIVE if state == 'active' else Subscription.Status.CANCELED + if state in {'canceled', 'incomplete_expired'} else Subscription.Status.PAST_DUE) + sub.current_period_end = datetime.fromtimestamp(period, tz=utc.utc) if period else None + sub.gateway_sub_id = remote_id + sub.gateway_customer_id = current.get('customer') or '' + sub.stripe_live = live_mode + sub.save(update_fields=['status', 'current_period_end', 'gateway_sub_id', 'gateway_customer_id', 'stripe_live']) + + @csrf_exempt @require_POST def paypal_webhook(request): diff --git a/siteconfig/urls.py b/siteconfig/urls.py index 43cf67c..0df1757 100644 --- a/siteconfig/urls.py +++ b/siteconfig/urls.py @@ -1,13 +1,17 @@ from django.conf import settings from django.urls import include, re_path from django.views.static import serve +from django.views.generic import TemplateView from django.urls import path from django.contrib.auth import views as auth_views -from catalog import views, fans, reactions, reviews, paypal, streams, newsletter, shop_stripe, membership +from catalog import views, fans, reactions, reviews, paypal, streams, newsletter, shop_stripe, membership, collectors from catalog.admin import studio urlpatterns = [ path('', views.home, name='home'), + path('map/', views.map_landing, name='world-map'), + path('pages//', views.managed_page, name='managed-page'), + path('chapters//buy/', views.buy_chapter, name='buy-chapter'), path('admin/', studio.urls), path('shop/', include('shop.urls')), path('chapters/', views.chapters, name='chapters'), @@ -32,6 +36,7 @@ urlpatterns = [ path('fan/login/', auth_views.LoginView.as_view(template_name='registration/fan-login.html'), name='fan-login'), path('fan/logout/', auth_views.LogoutView.as_view(next_page='home'), name='fan-logout'), path('fan/signup/', fans.signup, name='fan-signup'), + path('fan/collector-preferences/', collectors.preferences, name='collector-preferences'), path('fan/library/', fans.library, name='library'), path('fan/follow/', fans.follow_title, name='fan-follow'), path('fan/notifications/', fans.notices, name='fan-notices'), @@ -53,6 +58,8 @@ urlpatterns = [ path('newsletter/confirm//', newsletter.confirm, name='newsletter-confirm'), path('newsletter/unsubscribe//', newsletter.unsubscribe, name='newsletter-unsubscribe'), path('newsletter/one-click//', newsletter.one_click, name='newsletter-one-click'), + path('about/', TemplateView.as_view(template_name='series-intro.html'), name='series-intro'), + path('djinnii/', TemplateView.as_view(template_name='djinnii.html'), name='djinnii'), path('/', views.entries, name='entries'), path('//', views.entry, name='entry'), ] diff --git a/static/ahkai-map-selected.png b/static/ahkai-map-selected.png new file mode 100644 index 0000000..9d1fc4e Binary files /dev/null and b/static/ahkai-map-selected.png differ diff --git a/static/ahkai-map-ship.png b/static/ahkai-map-ship.png new file mode 100644 index 0000000..571a44f Binary files /dev/null and b/static/ahkai-map-ship.png differ diff --git a/static/ahkai-map-standing.png b/static/ahkai-map-standing.png new file mode 100644 index 0000000..1534a8e Binary files /dev/null and b/static/ahkai-map-standing.png differ diff --git a/static/archive-reminder.js b/static/archive-reminder.js new file mode 100644 index 0000000..581b768 --- /dev/null +++ b/static/archive-reminder.js @@ -0,0 +1,9 @@ +(() => { + const reminder = document.querySelector('[data-archive-reminder]'); + if (!reminder || typeof reminder.showModal !== 'function') return; + try { + if (sessionStorage.getItem('slx-archive-reminder')) return; + sessionStorage.setItem('slx-archive-reminder', 'seen'); + } catch { /* The reminder still works when session storage is unavailable. */ } + if (!document.querySelector('dialog[open]')) reminder.showModal(); +})(); diff --git a/static/countdown-layout.css b/static/countdown-layout.css new file mode 100644 index 0000000..dbe9c03 --- /dev/null +++ b/static/countdown-layout.css @@ -0,0 +1,25 @@ +.release-landing.countdown-showcase{padding:clamp(.75rem,2.5vw,2.25rem)} +.countdown-showcase .compact-release{width:min(100%,72rem);display:grid;grid-template-columns:minmax(0,.84fr) minmax(0,1.16fr);align-items:start;gap:clamp(.75rem,2vw,1.35rem)} +.compact-release .release-stage{grid-column:1/-1;padding:0 .25rem clamp(1rem,3.5vw,2rem)} +.compact-release .release-hover{width:min(100%,61rem);display:grid;justify-items:center} +.compact-release .release-cover{display:block;width:auto;height:auto;max-width:100%;max-height:min(59svh,42rem);object-fit:contain} +.compact-release .release-reflection{display:none} +.compact-release .release-copy,.compact-release .release-message{min-width:0;text-align:left} +.compact-release .release-timer-panel{padding:clamp(.85rem,2vw,1.35rem)} +.compact-release .release-timer-panel h1{font-size:clamp(1.5rem,3.3vw,2.85rem);line-height:1.1;margin:.45rem 0 .7rem} +.compact-release .release-clock .ticker{font-size:clamp(1.1rem,2.6vw,1.65rem)} +.compact-release .release-progress{margin-top:.7rem} +.compact-release .slx-author-note{margin:0;padding:clamp(.85rem,2vw,1.4rem)} +.compact-release .slx-author-note-copy{font-size:clamp(.95rem,1.5vw,1.08rem);line-height:1.5} +.compact-release .slx-author-note-copy p{margin:0 0 .65em} +.compact-release .slx-author-note-signoff{margin-top:.55rem} +.compact-release .slx-author-avatar{width:clamp(44px,6vw,76px);height:auto} +.compact-release .slx-author-signature{max-width:min(38%,9rem)} +@media(max-width:670px){ + .countdown-showcase .compact-release{grid-template-columns:minmax(0,1fr);gap:.65rem} + .compact-release .release-stage{padding-bottom:.6rem} + .compact-release .release-cover{max-height:min(47svh,24rem)} +} +.compact-release .release-reflection{display:grid;justify-items:center;top:100%;height:20%;opacity:.16} +.compact-release .release-reflection img{display:block;width:auto;height:auto;max-width:100%;max-height:min(59svh,42rem);object-fit:contain} +@media(max-width:670px){.compact-release .release-reflection{display:none}} diff --git a/static/djinn-sol/a.png b/static/djinn-sol/a.png new file mode 100644 index 0000000..4052f90 Binary files /dev/null and b/static/djinn-sol/a.png differ diff --git a/static/djinn-sol/b.png b/static/djinn-sol/b.png new file mode 100644 index 0000000..d28a365 Binary files /dev/null and b/static/djinn-sol/b.png differ diff --git a/static/djinn-sol/c.png b/static/djinn-sol/c.png new file mode 100644 index 0000000..c94c268 Binary files /dev/null and b/static/djinn-sol/c.png differ diff --git a/static/djinn-sol/chart.png b/static/djinn-sol/chart.png new file mode 100644 index 0000000..26d0fd4 Binary files /dev/null and b/static/djinn-sol/chart.png differ diff --git a/static/djinn-sol/d.png b/static/djinn-sol/d.png new file mode 100644 index 0000000..028321b Binary files /dev/null and b/static/djinn-sol/d.png differ diff --git a/static/djinn-sol/e.png b/static/djinn-sol/e.png new file mode 100644 index 0000000..294157a Binary files /dev/null and b/static/djinn-sol/e.png differ diff --git a/static/djinn-sol/f.png b/static/djinn-sol/f.png new file mode 100644 index 0000000..b283446 Binary files /dev/null and b/static/djinn-sol/f.png differ diff --git a/static/djinn-sol/g.png b/static/djinn-sol/g.png new file mode 100644 index 0000000..6755a15 Binary files /dev/null and b/static/djinn-sol/g.png differ diff --git a/static/djinn-sol/h.png b/static/djinn-sol/h.png new file mode 100644 index 0000000..1481f47 Binary files /dev/null and b/static/djinn-sol/h.png differ diff --git a/static/djinn-sol/i.png b/static/djinn-sol/i.png new file mode 100644 index 0000000..2d8d573 Binary files /dev/null and b/static/djinn-sol/i.png differ diff --git a/static/djinn-sol/j.png b/static/djinn-sol/j.png new file mode 100644 index 0000000..bcb6c3e Binary files /dev/null and b/static/djinn-sol/j.png differ diff --git a/static/djinn-sol/k.png b/static/djinn-sol/k.png new file mode 100644 index 0000000..8732903 Binary files /dev/null and b/static/djinn-sol/k.png differ diff --git a/static/djinn-sol/l.png b/static/djinn-sol/l.png new file mode 100644 index 0000000..12a3121 Binary files /dev/null and b/static/djinn-sol/l.png differ diff --git a/static/djinn-sol/m.png b/static/djinn-sol/m.png new file mode 100644 index 0000000..bce006e Binary files /dev/null and b/static/djinn-sol/m.png differ diff --git a/static/djinn-sol/n.png b/static/djinn-sol/n.png new file mode 100644 index 0000000..1dc76ed Binary files /dev/null and b/static/djinn-sol/n.png differ diff --git a/static/djinn-sol/o.png b/static/djinn-sol/o.png new file mode 100644 index 0000000..5df67cc Binary files /dev/null and b/static/djinn-sol/o.png differ diff --git a/static/djinn-sol/p.png b/static/djinn-sol/p.png new file mode 100644 index 0000000..d5e65ff Binary files /dev/null and b/static/djinn-sol/p.png differ diff --git a/static/djinn-sol/q.png b/static/djinn-sol/q.png new file mode 100644 index 0000000..e6355b1 Binary files /dev/null and b/static/djinn-sol/q.png differ diff --git a/static/djinn-sol/r.png b/static/djinn-sol/r.png new file mode 100644 index 0000000..050f2cf Binary files /dev/null and b/static/djinn-sol/r.png differ diff --git a/static/djinn-sol/s.png b/static/djinn-sol/s.png new file mode 100644 index 0000000..5a7cb29 Binary files /dev/null and b/static/djinn-sol/s.png differ diff --git a/static/djinn-sol/t.png b/static/djinn-sol/t.png new file mode 100644 index 0000000..bcae08d Binary files /dev/null and b/static/djinn-sol/t.png differ diff --git a/static/djinn-sol/u.png b/static/djinn-sol/u.png new file mode 100644 index 0000000..3c8c934 Binary files /dev/null and b/static/djinn-sol/u.png differ diff --git a/static/djinn-sol/v.png b/static/djinn-sol/v.png new file mode 100644 index 0000000..faa7b3b Binary files /dev/null and b/static/djinn-sol/v.png differ diff --git a/static/djinn-sol/w.png b/static/djinn-sol/w.png new file mode 100644 index 0000000..3895192 Binary files /dev/null and b/static/djinn-sol/w.png differ diff --git a/static/djinn-sol/x.png b/static/djinn-sol/x.png new file mode 100644 index 0000000..aa0f6e7 Binary files /dev/null and b/static/djinn-sol/x.png differ diff --git a/static/djinn-sol/y.png b/static/djinn-sol/y.png new file mode 100644 index 0000000..fce65f2 Binary files /dev/null and b/static/djinn-sol/y.png differ diff --git a/static/djinn-sol/z.png b/static/djinn-sol/z.png new file mode 100644 index 0000000..6ea893b Binary files /dev/null and b/static/djinn-sol/z.png differ diff --git a/static/djinnii.css b/static/djinnii.css new file mode 100644 index 0000000..390d9d1 --- /dev/null +++ b/static/djinnii.css @@ -0,0 +1,4 @@ +header.site-header{position:relative;isolation:isolate} +header.site-header::before{content:"";position:absolute;inset:0;z-index:-1;pointer-events:none;background:url("solterra-map.jpg") center 44%/cover no-repeat;opacity:.16} +.djinnii-page{max-width:68rem;margin-inline:auto;padding-inline:1rem} +.djinnii-chart{display:block;width:100%;height:auto} diff --git a/static/membership-cards.css b/static/membership-cards.css new file mode 100644 index 0000000..e01831d --- /dev/null +++ b/static/membership-cards.css @@ -0,0 +1,33 @@ +.shop-grid .member-plan-with-art { + position: relative; + isolation: isolate; + overflow: hidden; + background: #121928; + color: #fff; +} +.shop-grid .member-plan-with-art > .member-plan-art, +.shop-grid .member-plan-with-art::before { + position: absolute; + inset: 0; + width: 100%; + height: 100%; + pointer-events: none; +} +.shop-grid .member-plan-with-art > .member-plan-art { + display: block; + object-fit: cover; + opacity: .65; + z-index: -2; +} +.shop-grid .member-plan-with-art::before { + content: ""; + background: linear-gradient(90deg, rgb(9 14 25 / .78), rgb(9 14 25 / .44)); + z-index: -1; +} +.shop-grid .member-plan-with-art .member-plan-copy h2, +.shop-grid .member-plan-with-art .member-plan-copy p { + color: #fff; +} +.plan-comparison{width:100%;border-collapse:collapse;text-align:left} +.plan-comparison caption{text-align:left;padding:.5rem} +.plan-comparison :is(th,td){border-bottom:1px solid currentColor;padding:.65rem;text-align:left} diff --git a/static/solterra-map.jpg b/static/solterra-map.jpg new file mode 100644 index 0000000..1f2049b Binary files /dev/null and b/static/solterra-map.jpg differ diff --git a/static/storefront.css b/static/storefront.css new file mode 100644 index 0000000..6a9bca7 --- /dev/null +++ b/static/storefront.css @@ -0,0 +1,10 @@ +.slx-store{--store-ink:#122442;--store-paper:#fff;--store-card:#f1f3f7;color:var(--store-ink);background:var(--store-paper);max-width:76rem;margin:1.5rem auto;padding:clamp(.75rem,3vw,2rem)} +.slx-store a{color:inherit}.store-bar{display:flex;justify-content:space-between;gap:1rem;padding:.4rem 0} +.store-banner{text-align:center;background:var(--store-card);padding:1rem;margin:.5rem 0} +.store-banner h1,.store-detail h1{margin:.3rem 0}.store-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:.5rem} +.store-card{background:var(--store-card);text-align:center;padding:.65rem;display:flex;flex-direction:column;align-items:center;gap:.35rem;min-width:0} +.store-card h2{font-size:1rem;margin:0;line-height:1.25}.store-stock{font-size:.85rem;margin:auto 0 0;padding-top:.35rem}.store-cover{width:100%;display:grid;place-items:center;aspect-ratio:3/4;overflow:hidden;background:#e5e9f2}.store-cover img{width:100%;height:100%;object-fit:contain} +.store-card form{width:100%;margin:0}.slx-store .store-button{display:inline-block;color:#fff;background:#092951;border:0;border-radius:.2rem;padding:.4rem .75rem;cursor:pointer;font:inherit;text-decoration:none}.store-card .store-button{width:100%} +.store-detail{display:grid;grid-template-columns:minmax(9rem,1fr) minmax(13rem,1.8fr) minmax(8rem,1fr);gap:1.5rem;align-items:start;margin:1rem 0 2rem} +.store-product-info form{display:flex;flex-wrap:wrap;gap:.5rem;align-items:center}.store-product-info input[type=number]{width:4rem}.store-price{font-size:1.35rem;font-weight:800}.store-format{padding:1rem;background:var(--store-card)}.store-format h2{font-size:1rem;margin:0}.store-section>h2{border-bottom:1px solid #092951;padding-bottom:.3rem}.store-sample details{margin:.5rem 0}.store-sample summary{cursor:pointer;font-weight:700}.store-sample img{display:block;max-width:min(100%,42rem);height:auto;margin:.5rem auto} +@media(max-width:720px){.store-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.store-detail{grid-template-columns:minmax(7rem,1fr) minmax(0,1.5fr);gap:.75rem}.store-format{grid-column:1/-1}} diff --git a/static/studio-map-picker.js b/static/studio-map-picker.js new file mode 100644 index 0000000..19ea257 --- /dev/null +++ b/static/studio-map-picker.js @@ -0,0 +1,24 @@ +document.addEventListener('DOMContentLoaded', () => { + const map = document.querySelector('[data-studio-map-picker]'); + const pin = document.querySelector('[data-studio-map-pin]'); + const x = document.getElementById('id_x'); + const y = document.getElementById('id_y'); + if (!map || !pin || !x || !y) return; + const refresh = () => { + pin.hidden = ![x, y].every(field => field.value !== '' && Number(field.value) >= 0 && Number(field.value) <= 100); + if (!pin.hidden) { + pin.style.left = x.value + '%'; + pin.style.top = y.value + '%'; + } + }; + map.addEventListener('click', event => { + const box = map.getBoundingClientRect(); + const percent = (value, size) => Math.max(0, Math.min(100, 100 * value / size)).toFixed(5); + x.value = percent(event.clientX - box.left, box.width); + y.value = percent(event.clientY - box.top, box.height); + refresh(); + }); + x.addEventListener('input', refresh); + y.addEventListener('input', refresh); + refresh(); +}); diff --git a/static/world-map.css b/static/world-map.css new file mode 100644 index 0000000..e4abf24 --- /dev/null +++ b/static/world-map.css @@ -0,0 +1,61 @@ +.slx-world-map,.slx-world-resources{position:relative;max-width:72rem;margin:2rem auto;padding:1rem;box-sizing:border-box} +.slx-world-map h2{margin:.25rem 0} +.slx-world-stage{position:relative;isolation:isolate} +.slx-world-stage img{display:block;width:100%;height:auto;border:0;filter:none;opacity:1} +.slx-world-marker{position:absolute;left:var(--x);top:var(--y);transform:translate(-50%,-50%);width:clamp(25px,4vw,44px);aspect-ratio:1;display:grid;place-items:center;border-radius:50%;color:#ffe141} +.slx-world-marker::before,.slx-world-marker::after{content:"";grid-area:1/1;border:2px solid currentColor;border-radius:50%;width:48%;aspect-ratio:1;box-shadow:0 0 4px #161009;pointer-events:none} +.slx-world-marker::after{animation:slx-map-scan 2.4s ease-out infinite} +.slx-world-marker:nth-of-type(even)::after{animation-delay:-1.2s} +.slx-world-marker:is(:hover,:focus-visible,[aria-current])::before{width:75%;border-width:3px} +.slx-world-marker:focus-visible{outline:2px solid currentColor;outline-offset:1px} +.slx-world-directory{display:flex;flex-wrap:wrap;gap:.4rem .85rem;list-style:none;margin:1rem 0 0;padding:0} +.slx-world-directory a{display:inline-block;padding:.3rem 0;text-decoration:underline} +.slx-world-resources{display:grid;gap:.65rem;grid-template-columns:repeat(auto-fit,minmax(min(100%,12rem),1fr))} +[id^="map-"]{scroll-margin-top:6rem} +[id^="map-"]:target{outline:2px solid #dfb900;outline-offset:3px} +@keyframes slx-map-scan{from{transform:scale(1);opacity:.9}to{transform:scale(1.8);opacity:0}} +@media(prefers-reduced-motion:reduce){.slx-world-marker::after{animation:none;display:none}} +.slx-world-stage{container-type:inline-size} +.slx-world-marker .slx-map-label{position:absolute;top:calc(50% + clamp(7px,1.1cqw,13px));left:50%;transform:translateX(-50%);display:grid;justify-items:center;gap:.2rem;width:max-content;max-width:21cqw;font-size:clamp(4px,1.05cqw,12px);padding:.2rem .3rem;background:#101522ed;border-radius:.3em;line-height:1} +.slx-world-marker[data-map-destination="cart"] .slx-map-label{left:calc(50% + 2.8cqw);transform:translateX(-100%)} +.slx-world-marker[data-map-destination="start"] .slx-map-label{left:calc(50% - 8.2cqw);transform:none} +.djinn-sol-word{display:inline-flex;align-items:center;gap:.11em} +.slx-world-stage img.djinn-sol-glyph{width:.62em;height:.81em;object-fit:contain;image-rendering:pixelated} + +.slx-world-marker .djinn-sol-spelling{display:flex;gap:.28em;justify-content:center;flex-wrap:wrap} +.slx-map-english{color:#fff;font-size:clamp(9px,1.25cqw,14px);font-weight:700;text-align:center;line-height:1.1;text-wrap:balance} +.slx-world-marker:is(:hover,:focus-visible){z-index:2} +.slx-world-marker[data-map-destination="start"] .slx-map-label{left:calc(50% - 8.2cqw)} +@container (max-width: 540px){ + .slx-world-marker[data-map-destination="newsletter"] .slx-map-label{left:calc(50% - 10cqw);transform:none} + .slx-world-marker[data-map-destination="library"] .slx-map-label{left:calc(50% + 6cqw);transform:none} +} +body.map-landing{margin:0;min-height:100svh;display:flex;flex-direction:column;background:#090e1a} +.map-landing .slx-page-backdrop{display:none} +.map-landing .site-header{flex:none} +.map-landing-main{flex:1;display:flex;flex-direction:column;min-width:0} +.map-landing .slx-world-map{flex:1;display:flex;flex-direction:column;width:100%;max-width:none;margin:0;padding:0;color:#f5f7ff} +.slx-map-controls{display:flex;align-items:center;justify-content:space-between;gap:.6rem;padding:.45rem 1rem} +.slx-map-controls h1{font-size:clamp(1rem,3vw,1.6rem);margin:0;color:inherit} +.slx-map-controls button,.slx-map-list summary{color:#f5f7ff;background:#192339;border:1px solid #61708b;border-radius:.35rem;padding:.3rem .6rem;cursor:pointer} +.slx-map-controls button[aria-pressed="false"]{opacity:.72} +.slx-map-viewport{flex:1;display:grid;place-items:center;min-width:0;container-type:inline-size} +.map-landing .slx-world-stage{width:min(100cqw,140svh);margin:auto} +.slx-map-list{padding:.35rem 1rem} +.slx-map-list summary{width:max-content} +.slx-map-list a{color:#fff} +@media(min-aspect-ratio: 4/3){.map-landing .slx-world-stage{width:min(100cqw,calc((100svh - 9rem) * 1.7504))}} +body.map-landing{height:100svh} +.map-landing .slx-map-viewport{container-type:size;min-height:10rem} +.map-landing .slx-world-stage{width:min(100cqw,175.04cqh)} +.map-landing .slx-map-list[open] .slx-world-directory{max-height:26svh;overflow:auto} +.slx-world-stage .slx-map-avatar{width:auto;height:clamp(39px,7cqw,77px);position:absolute;z-index:5;transform:translate(-50%,-94%);pointer-events:none;filter:drop-shadow(0 0 5px #b3eaff) drop-shadow(0 0 10px #3387ff);image-rendering:pixelated} +.slx-world-stage .slx-map-avatar[hidden]{display:none} +.slx-world-stage.has-avatar-pointer,.slx-world-stage.has-avatar-pointer .slx-world-marker{cursor:none} +.slx-world-marker{background:radial-gradient(circle at center,#e22118 0 3px,transparent 4px)} +.countdown-showcase .slx-world-map{position:relative;isolation:isolate;color:#f5f7ff;background:#090e1a;border-radius:1rem} + +/* The embedded map takes its size from its image, not a fixed viewport. */ +.countdown-showcase .slx-map-viewport{display:block;width:100%;container-type:normal} +.countdown-showcase .slx-world-stage{width:100%;aspect-ratio:2048 / 1170} +.countdown-showcase .slx-world-stage > img:first-child{width:100%;height:auto} diff --git a/static/world-map.js b/static/world-map.js new file mode 100644 index 0000000..31e47e9 --- /dev/null +++ b/static/world-map.js @@ -0,0 +1,78 @@ +(() => { + const map = document.querySelector('.slx-world-map'); + const Audio = window.AudioContext || window.webkitAudioContext; + if (!map) return; + const stage = map.querySelector('.slx-world-stage'); + const standing = stage.querySelector('.slx-map-avatar:not(.slx-map-avatar-selected)'); + const selected = stage.querySelector('.slx-map-avatar-selected'); + if (!standing || !selected) return; + let landed = false; + const move = (x,y) => { + const avatar = landed ? selected : standing; + avatar.style.left = x; + avatar.style.top = y; + avatar.hidden = false; + }; + stage.addEventListener('pointermove', event => { + if (landed || event.pointerType === 'touch') return; + const bounds = stage.getBoundingClientRect(); + move(`${event.clientX-bounds.left}px`, `${event.clientY-bounds.top}px`); + stage.classList.add('has-avatar-pointer'); + }); + stage.addEventListener('pointerleave', () => { + standing.hidden = true; + stage.classList.remove('has-avatar-pointer'); + }); + addEventListener('pageshow', () => { landed = false; standing.hidden = selected.hidden = true; stage.classList.remove('has-avatar-pointer'); }); + + const toggle = map.querySelector('[data-map-sound]'); + let enabled = true; + try { enabled = localStorage.getItem('slx-map-sound') !== 'off'; } catch {} + const reflect = () => toggle.setAttribute('aria-pressed', String(enabled)); + reflect(); + toggle.hidden = !Audio; + toggle.addEventListener('click', () => { + enabled = !enabled; + reflect(); + try { localStorage.setItem('slx-map-sound', enabled ? 'on' : 'off'); } catch {} + }); + let audio, navigating = false; + map.addEventListener('click', event => { + const link = event.target.closest('.slx-world-marker'); + if (!link || event.defaultPrevented || event.button !== 0 || + event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return; + event.preventDefault(); + if (navigating) return; + navigating = true; + landed = true; + standing.hidden = true; + move(link.style.getPropertyValue('--x'), link.style.getPropertyValue('--y')); + let timeout; + const go = () => { + if (!navigating) return; + clearTimeout(timeout); + navigating = false; + location.assign(link.href); + }; + timeout = setTimeout(go, enabled && Audio ? 420 : 280); + if (!enabled || !Audio) return; + try { + audio ||= new Audio(); + audio.resume().then(() => { + if (!navigating) return; + const now = audio.currentTime; + const tone = audio.createOscillator(); + const gain = audio.createGain(); + tone.frequency.setValueAtTime(1090, now); + tone.frequency.exponentialRampToValueAtTime(510, now + .12); + gain.gain.setValueAtTime(.001, now); + gain.gain.exponentialRampToValueAtTime(.17, now + .014); + gain.gain.exponentialRampToValueAtTime(.001, now + .14); + tone.connect(gain).connect(audio.destination); + tone.onended = () => setTimeout(go, 130); + tone.start(now); + tone.stop(now + .15); + }).catch(() => {}); + } catch { /* The navigation timer still runs without audio. */ } + }); +})(); diff --git a/templates/admin/catalog/maplocation/change_form.html b/templates/admin/catalog/maplocation/change_form.html new file mode 100644 index 0000000..1cb55a1 --- /dev/null +++ b/templates/admin/catalog/maplocation/change_form.html @@ -0,0 +1,10 @@ +{% extends "admin/change_form.html" %} +{% load static %} +{% block after_field_sets %} +

Place the marker

+

Click or tap the map to set the position, or enter X and Y above as percentages.

+
+ Sol’Terra map + +
+{% endblock %} diff --git a/templates/admin/homepage-countdown.html b/templates/admin/homepage-countdown.html index 6f561ad..14db2a1 100644 --- a/templates/admin/homepage-countdown.html +++ b/templates/admin/homepage-countdown.html @@ -3,7 +3,7 @@ {% block breadcrumbs %}{% endblock %} {% block content %}
-

Show the timer beneath your hero or switch to a dedicated cover landing page. Both display your released chapters first. This does not change the separate Coming Soon page or schedule any chapters.

+

Enable the countdown cover landing and upload a cover to combine it with the Sol’Terra map. Choose whether the map appears above or below the countdown content.

{% csrf_token %} {{ form.non_field_errors }} {% for hidden in form.hidden_fields %}{{ hidden }}{% endfor %} diff --git a/templates/admin/traffic.html b/templates/admin/traffic.html index 90c68aa..2ce54a3 100644 --- a/templates/admin/traffic.html +++ b/templates/admin/traffic.html @@ -15,7 +15,7 @@

Where readers are

-{% if not geo_configured %}

Connect a GeoLite Country database to locate new visits by country. Earlier and unresolved visits appear as Unknown.

{% endif %} +{% if not geo_configured %}

Connect a GeoLite2 City database to locate new visits by country. Earlier and unresolved visits appear as Unknown.

{% endif %}

Select a highlighted country to see its pageviews.

{{ countries|json_script:"country-traffic" }} @@ -24,6 +24,34 @@ Map boundaries: Natural Earth. Location is approximate.
+
+

Regions and states

+ + + +{% for row in regions %} + +{% empty %} + +{% endfor %} + +
CountryRegion / StateViews
{{ row.country|default:'Unknown' }}{{ row.region|default:'Unknown' }}{{ row.views }}
No region data available yet.
+
+
+

Cities

+ + + +{% for row in cities %} + +{% empty %} + +{% endfor %} + +
CityRegionCountryViews
{{ row.city|default:'Unknown' }}{{ row.region|default:'Unknown' }}{{ row.country|default:'Unknown' }}{{ row.views }}
No city data available yet.
+
+
+

Traffic sources

Referring origins only. Direct visits and missing referrers are grouped together.

{% for row in sources %}{% empty %}{% endfor %} diff --git a/templates/archive-reminder.html b/templates/archive-reminder.html new file mode 100644 index 0000000..a361aed --- /dev/null +++ b/templates/archive-reminder.html @@ -0,0 +1,15 @@ +{% load static %} + + +
+

Slump X Land Monthly

+

Read the entire archive

+

The newest three chapters are free to read in full. Create an account and join Slump X Land Monthly to unlock every chapter, new and old, as they’re published.

+
+
+ diff --git a/templates/base.html b/templates/base.html index ba94917..c2aa93d 100644 --- a/templates/base.html +++ b/templates/base.html @@ -1,4 +1,4 @@ -{% load static slx_brand share_meta %}{% block title %}SLUMP X LAND · Official{% endblock %}{% share_metadata %}{% block meta %}{% endblock %}{% block scripts %}{% endblock %}{% if floating_top_art or floating_bottom_art %}{% endif %}{% if newsletter_popup_form %}{% endif %} +{% load static slx_brand share_meta %}{% block title %}SLUMP X LAND · Official{% endblock %}{% share_metadata %}{% block meta %}{% endblock %}{% block scripts %}{% endblock %}{% if floating_top_art or floating_bottom_art %}{% endif %}{% if newsletter_popup_form %}{% endif %} {% if page_backdrop %} + diff --git a/templates/chapter-locked.html b/templates/chapter-locked.html index db34fab..34104ca 100644 --- a/templates/chapter-locked.html +++ b/templates/chapter-locked.html @@ -2,18 +2,12 @@ {% block title %}{{ chapter.title }} · SLUMP X LAND{% endblock %} {% block content %}
-

Chapter {{ chapter.number }} · Paid chapter

{{ chapter.title|slx_brand }}

+

#{{ chapter.number|stringformat:"03d" }} · Rolling archive

+

{{ chapter.title|slx_brand }}

{% if chapter.cover %}{% endif %} {% if chapter.summary %}

{{ chapter.summary|slx_brand }}

{% endif %} -

${{ chapter.price_usd|floatformat:2 }} USD · One-time purchase

-{% if paypal_ready %} -{% if user.is_authenticated %} -
{% csrf_token %} - -

PayPal will show the payment methods available to you.

-{% else %}Sign in to buy -

New to SLX? Create a reader account.

{% endif %} -{% else %}

Online checkout is currently unavailable.

{% endif %} -

Fan discussion · All chapters

+

The newest three chapters are free. Sign in with an active Slump X Land Monthly membership to read the full archive.

+
{% include 'chapter-access-actions.html' %}{% if not user.is_authenticated %}Create an accountSign in{% endif %}
+

See the latest free chapters →

{% endblock %} diff --git a/templates/collector-preferences.html b/templates/collector-preferences.html new file mode 100644 index 0000000..186cd34 --- /dev/null +++ b/templates/collector-preferences.html @@ -0,0 +1,4 @@ +{% extends 'base.html' %} +{% block title %}Collector recognition · SLUMP X LAND{% endblock %} +{% block content %}

Collector recognition

After a paid shop order, you can choose to appear on the public thank-you list. Leave the display name blank to use your username.

+
{% csrf_token %}{{ form.as_p }}
{% endblock %} diff --git a/templates/collector-thanks.html b/templates/collector-thanks.html new file mode 100644 index 0000000..177b806 --- /dev/null +++ b/templates/collector-thanks.html @@ -0,0 +1,6 @@ +

Thank You To Our Collectors, Investors & Readers

+{% if collectors %}
    +{% for collector in collectors %}
  • +{% if collector.photo %}{% else %}{% endif %} +{{ collector.display_name|default:collector.user.username }}
  • {% endfor %}
{% endif %} +{% if user.is_authenticated %}

Manage your collector recognition →

{% endif %}
diff --git a/templates/community.html b/templates/community.html index 1b771c9..ef6bf9c 100644 --- a/templates/community.html +++ b/templates/community.html @@ -22,5 +22,5 @@

Sol Seat

{% if settings.seat_threshold %}${{ settings.seat_threshold|floatformat:2 }} in verified support, or designated by Studio.{% else %}Designated by Studio.{% endif %}

- +{% include 'collector-thanks.html' %} {% endblock %} diff --git a/templates/countdown-chapter-shelf.html b/templates/countdown-chapter-shelf.html index 42102a6..81cb259 100644 --- a/templates/countdown-chapter-shelf.html +++ b/templates/countdown-chapter-shelf.html @@ -1,8 +1,8 @@ {% load slx_brand %} {% if countdown_chapters %} -
+
-

{{ "SLUMP X LAND"|slx_brand }}

Current chapters

+

{{ "SLUMP X LAND"|slx_brand }}

Latest Chapters

Chapter archive {% endif %} + {% if with_world_map and settings.countdown_map_position == 'above' %}{% include 'world-map.html' %}{% endif %} {% include 'countdown-chapter-shelf.html' %} + {% include 'floating-artwork.html' with band=floating_top_art position='top' only %} -
+
Chapter cover @@ -23,18 +25,23 @@
-
+

{{ "SLUMP X LAND"|slx_brand }} · UPCOMING RELEASE

{{ settings.homepage_countdown_title|default:"Next release"|slx_brand }}

{% include 'countdown-progress.html' %}
- {% include 'author-comment.html' with comment=settings.homepage_countdown_note %} {% include 'countdown-social.html' %} {% if settings.homepage_countdown_cta_url %}{{ settings.homepage_countdown_cta_label|default:"Join the mailing list" }} →{% elif newsletter_signup_open %}Join the newsletter{% endif %}
{% include 'read-manaa.html' %}
+ {% if settings.homepage_countdown_note %}
+ {% include 'author-comment.html' with comment=settings.homepage_countdown_note %} +
{% endif %}
+ + +{% if with_world_map and settings.countdown_map_position != 'above' %}{% include 'world-map.html' %}{% endif %} {% endblock %} diff --git a/templates/djinn-sol-glyphs.html b/templates/djinn-sol-glyphs.html new file mode 100644 index 0000000..b1a0950 --- /dev/null +++ b/templates/djinn-sol-glyphs.html @@ -0,0 +1 @@ +{% load static %} diff --git a/templates/djinnii.html b/templates/djinnii.html new file mode 100644 index 0000000..66421dd --- /dev/null +++ b/templates/djinnii.html @@ -0,0 +1,12 @@ +{% extends "base.html" %} +{% load static %} +{% block title %}Djinnii · SLUMP X LAND{% endblock %} +{% block content %} +
+

The languages of Sol’Terra

+

Djinnii

+

Djinnii is the spoken language. Djinn-Sol is its written alphabet. Use the chart to decode the lettering on the Sol’Terra map.

+ Djinn-Sol Pixel 12 alphabet decoder, showing the glyph for each letter from A to Z. +

← Back to the Sol’Terra map

+
+{% endblock %} diff --git a/templates/home-map-content.html b/templates/home-map-content.html new file mode 100644 index 0000000..79ab6e9 --- /dev/null +++ b/templates/home-map-content.html @@ -0,0 +1,20 @@ +{% load slx_community slx_brand %} +
+{% if perms.catalog.watch_slx_live and settings.stream_status != 'offline' and settings.stream_provider %}

SLX Live

{{ settings.get_stream_status_display }}

{{ settings.stream_title|default:'Behind the pages, live' }}

{% if settings.stream_starts_at and settings.stream_status == 'upcoming' %}

{% endif %}

Open the watch page →

{% endif %} +{% if news %}

Latest from the blog

View all →
{% include "entry-cards.html" with items=news %}
{% endif %} +{% if not countdown_chapters and not chapters %}

Chapters

View all →
{% include "chapter-cards.html" %}
{% endif %} +{% if upcoming %}
{% include 'upcoming-cards.html' %}
{% endif %} +{% if cast %}

Meet the cast

View all →
{% include "entry-cards.html" with items=cast %}
{% endif %} +{% if world %}

World archive

View all →
{% include "entry-cards.html" with items=world %}
{% endif %} +
+
diff --git a/templates/home.html b/templates/home.html index 0b03e9a..420ec15 100644 --- a/templates/home.html +++ b/templates/home.html @@ -1,53 +1,8 @@ -{% extends "base.html" %}{% load slx_community slx_brand static %} -{% block scripts %}{% if homepage_countdown %}{% endif %}{% endblock %} +{% extends "base.html" %}{% load static %} +{% block body_class %} map-landing{% endblock %} +{% block scripts %}{% endblock %} {% block floating_top %}{% endblock %} -{% block content %} -
-{% if countdown_chapters %} - {% include 'countdown-chapter-shelf.html' %} -{% elif chapters %} -
-

Released chapters

View all →
- {% include "chapter-cards.html" %} -
-{% endif %} -{% include 'floating-artwork.html' with band=floating_top_art position='top' only %} -
-{% if settings.hero_art and not page_backdrop %}{% endif %} -

{{ settings.tagline|slx_brand }}

{{ "SLUMP X LAND"|slx_brand }}

{{ settings.credit|slx_brand }}

{% if settings.intro %}

{{ settings.intro|slx_brand|linebreaksbr }}

{% endif %} -
{% include 'read-manaa.html' %}{% if settings.publisher_url %}Read on ONSOL-GO!{% endif %}{% if settings.next_release_at %}Upcoming release{% endif %}{% if following_title %}My SLX library{% else %}Follow {{ "SLUMP X LAND"|slx_brand }}{% endif %}
-
-{% if homepage_countdown %} -
-
-

{{ "SLUMP X LAND"|slx_brand }} · COUNTDOWN

{{ settings.homepage_countdown_title|default:"Next release"|slx_brand }}

-
- - -
- {% include 'countdown-progress.html' %} -
- {% if settings.homepage_countdown_note %}
{% include 'author-comment.html' with comment=settings.homepage_countdown_note %}
{% endif %} - {% include 'countdown-social.html' %} -
-{% endif %} -
-{% if perms.catalog.watch_slx_live and settings.stream_status != 'offline' and settings.stream_provider %}

SLX Live

{{ settings.get_stream_status_display }}

{{ settings.stream_title|default:'Behind the pages, live' }}

{% if settings.stream_starts_at and settings.stream_status == 'upcoming' %}

{% endif %}

Open the watch page →

{% endif %} -{% if news %}

Latest from the blog

View all →
{% include "entry-cards.html" with items=news %}
{% endif %} -{% if not countdown_chapters and not chapters %}

Chapters

View all →
{% include "chapter-cards.html" %}
{% endif %} -{% if upcoming %}
{% include 'upcoming-cards.html' %}
{% endif %} -{% if cast %}

Meet the cast

View all →
{% include "entry-cards.html" with items=cast %}
{% endif %} -{% if world %}

World archive

View all →
{% include "entry-cards.html" with items=world %}
{% endif %} -
-
-
{% endblock %} +{% block floating_bottom %}{% endblock %} +{% block footer %}{% endblock %} +{% block popups %}{% endblock %} +{% block content %}
{% include "world-map.html" %}
{% endblock %} diff --git a/templates/library.html b/templates/library.html index efa8854..88ba9f8 100644 --- a/templates/library.html +++ b/templates/library.html @@ -1,5 +1,6 @@ {% extends 'base.html' %}{% load slx_community slx_brand %}{% block title %}Your library · SLUMP X LAND{% endblock %} {% block content %}

The fan corner

Your library

Signed in as {{ user.username }} {% rank_badge user %}. View your reader profile →

+

Collector recognition settings →

{% for message in messages %}

{{ message|slx_brand }}

{% endfor %}
{% csrf_token %} diff --git a/templates/managed-page.html b/templates/managed-page.html new file mode 100644 index 0000000..61e30e4 --- /dev/null +++ b/templates/managed-page.html @@ -0,0 +1,3 @@ +{% extends "base.html" %} +{% block title %}{{ page.title }} · SLUMP X LAND{% endblock %} +{% block content %}

{{ page.title }}

{{ page.body|linebreaks }}
{% endblock %} diff --git a/templates/membership.html b/templates/membership.html index 33030a2..f288ac9 100644 --- a/templates/membership.html +++ b/templates/membership.html @@ -1,17 +1,17 @@ -{% extends 'base.html' %} +{% extends 'base.html' %}{% load static %} +{% block scripts %}{% endblock %} {% block title %}Slump X Land Monthly{% endblock %} {% block content %}

MEMBER EDITION

Slump X Land Monthly

+

Both tiers unlock the full chapter library. Studio Vault also includes selected draft pages and process notes.

-

Early Access

Read new chapters before the public drop and get occasional creator notes.

- {% if settings.member_scout_url %}Choose Early Access{% endif %}
-

Studio Vault

Everything in Early Access, plus a curated selection of draft pages and process notes.

- {% if settings.member_vault_url %}Choose Studio Vault{% endif %}
+ {% for plan in plans %}
{% if plan.image %}{% endif %}

{{ plan.title }}

${{ plan.price_usd }} / {{ plan.billing_interval }}

View plan
+ {% empty %}

Online membership checkout is not open yet.

{% endfor %}
- {% if settings.member_vault_url or settings.member_scout_url %} -

Access is activated by the studio after payment is verified. Enter your SLX username at checkout if prompted.

- {% endif %} + {% if comparison_rows %}

Compare plans

SourceViews
{% if row.source == 'internal' %}SLX site{% elif row.source %}{{ row.source }}{% else %}Direct / unavailable{% endif %}{{ row.views }}
No sources in this range yet.
+ {% for plan in plans %}{% endfor %} + {% for feature, values in comparison_rows %}{% for value in values %}{% endfor %}{% endfor %}
Benefits by membership plan
Benefit{{ plan.title }}
${{ plan.price_usd }} / {{ plan.billing_interval }}
{{ feature }}{{ value }}
{% endif %} {% if not user.is_authenticated %}

Sign in or create an SLX account.

{% endif %} {% if posts %}

Your member content

    {% for post in posts %}
  • {{ post.get_kind_display }} · {{ post.title }}
  • {% endfor %}
{% endif %} diff --git a/templates/series-intro.html b/templates/series-intro.html new file mode 100644 index 0000000..93c95d7 --- /dev/null +++ b/templates/series-intro.html @@ -0,0 +1,8 @@ +{% extends "base.html" %}{% load slx_brand %} +{% block title %}Series introduction · SLUMP X LAND{% endblock %} +{% block content %}
+{% if settings.hero_art and not page_backdrop %}{% endif %} +

{{ settings.tagline|slx_brand }}

{{ "SLUMP X LAND"|slx_brand }}

{{ settings.credit|slx_brand }}

{% if settings.intro %}

{{ settings.intro|slx_brand|linebreaksbr }}

{% endif %} +
{% include 'read-manaa.html' %}{% if settings.publisher_url %}Read on ONSOL-GO!{% endif %}{% if settings.next_release_at %}Upcoming release{% endif %}{% if following_title %}My SLX library{% else %}Follow {{ "SLUMP X LAND"|slx_brand }}{% endif %}
+
+
{% endblock %} diff --git a/templates/shop/_seller_badge.html b/templates/shop/_seller_badge.html new file mode 100644 index 0000000..eadd38a --- /dev/null +++ b/templates/shop/_seller_badge.html @@ -0,0 +1,3 @@ +{% if product.verified_by_seller %} + Verified by Seller +{% endif %} diff --git a/templates/shop/card.html b/templates/shop/card.html new file mode 100644 index 0000000..8a1fb51 --- /dev/null +++ b/templates/shop/card.html @@ -0,0 +1,10 @@ +
+ {% if product.image %}{{ product.title }}{% else %}SLX{% endif %} +

{{ product.title }}

+ {{ product.get_kind_display }} + {% include 'shop/_seller_badge.html' %} +

{% if product.kind == 'physical' %}{% if product.in_stock %}In stock{% else %}Sold out{% endif %}{% elif product.kind == 'digital' %}Digital edition{% else %}Fan Club{% endif %}

+ ${{ product.price_usd }}{% if product.kind == 'subscription' %} / {{ product.billing_interval }}{% endif %} + {% if product.kind != 'subscription' and product.in_stock %}{% csrf_token %} + {% else %}View details{% endif %} +
diff --git a/templates/shop/index.html b/templates/shop/index.html index 6f6b394..89749e0 100644 --- a/templates/shop/index.html +++ b/templates/shop/index.html @@ -1,40 +1,9 @@ -{% extends 'base.html' %} +{% extends 'base.html' %}{% load static %} +{% block scripts %}{% endblock %} {% block title %}Shop · SLUMP X LAND{% endblock %} {% block content %} -
-
-

Shop

- Cart ({{ cart_count }}) -
- - {% if request.GET.subscribed %} -

Thank you! Your subscription is processing and will activate momentarily.

- {% endif %} - -
- {% for product in products %} - - {% empty %} -

No shop items are live yet. Check back soon.

- {% endfor %} -
-
+
+

Slump X Land Shop

Books, digital editions, and the Monthly Fan Club.

+{% if request.GET.subscribed %}

Your access will update after Stripe confirms the subscription.

{% endif %} +
{% for product in products %}{% include 'shop/card.html' %}{% empty %}

No products are available yet.

{% endfor %}
{% endblock %} diff --git a/templates/shop/order.html b/templates/shop/order.html index 2463bd8..27be1ff 100644 --- a/templates/shop/order.html +++ b/templates/shop/order.html @@ -10,12 +10,13 @@ {% for item in order.items.all %}
  • {{ item.quantity }} × {{ item.title_snapshot }} (${{ item.line_total }}) - {% if item.product.kind == 'digital' and order.status in 'paid,shipped,delivered' %} + {% if item.chapter %} — Open chapter reader{% elif item.product.digital_file and order.status in 'paid,shipped,delivered' %} — Download File {% endif %}
  • {% endfor %} + {% if user.is_authenticated and order.user_id == user.pk %}

    Choose how you appear on the collector thank-you list →

    {% endif %}

    ← Return to Shop

    {% endblock %} diff --git a/templates/shop/product.html b/templates/shop/product.html index 0beda79..cc977eb 100644 --- a/templates/shop/product.html +++ b/templates/shop/product.html @@ -1,45 +1,28 @@ -{% extends 'base.html' %} +{% extends 'base.html' %}{% load static %} +{% block scripts %}{% endblock %} {% block title %}{{ product.title }} · Shop · SLUMP X LAND{% endblock %} {% block content %} -
    -

    ← Back to Shop

    -
    - {% if product.image %} -
    {{ product.title }}
    - {% endif %} -
    - {{ product.get_kind_display }} -

    {{ product.title }}

    -

    ${{ product.price_usd }}{% if product.kind == 'subscription' %} / {{ product.billing_interval }}{% endif %}

    - {% if product.description %}
    {{ product.description|linebreaks }}
    {% endif %} - - {% if product.kind == 'subscription' %} -
    - {% csrf_token %} - {% if not request.user.is_authenticated or not request.user.email %} - - {% endif %} - {% if stripe_enabled %} - - {% endif %} - {% if paypal_enabled and product.paypal_plan_id %} - - {% endif %} -
    - {% else %} - {% if product.in_stock %} -
    - {% csrf_token %} - - -
    - {% else %} -

    Sold Out

    - {% endif %} - {% endif %} -
    -
    +
    + +
    +
    {% if product.image %}{{ product.title }}{% else %}SLX{% endif %}
    +

    {{ product.title }}

    {{ product.get_kind_display }}

    {% include "shop/_seller_badge.html" %} +

    {{ product.summary }}

    ${{ product.price_usd }}{% if product.kind == 'subscription' %} / {{ product.billing_interval }}{% endif %}

    + {% if product.kind == 'subscription' %} +

    Compare Fan Club plans →

    + {% if not user.is_authenticated %}Sign in to subscribe + {% else %}
    {% csrf_token %} + {% if not user.email %}{% endif %} + {% if stripe_enabled %}{% endif %} + {% if not product.member_tier and paypal_enabled and product.paypal_plan_id %}{% endif %} +
    {% endif %} + {% elif product.in_stock %} +
    {% csrf_token %}
    + {% else %}

    Sold out

    {% endif %} +
    + +
    +{% if product.description %}

    Overview

    {{ product.description|linebreaks }}
    {% endif %} +{% if related_products %}

    You may also like

    {% for product in related_products %}{% include 'shop/card.html' %}{% endfor %}
    {% endif %}
    {% endblock %} diff --git a/templates/world-map-links.html b/templates/world-map-links.html new file mode 100644 index 0000000..0d79c14 --- /dev/null +++ b/templates/world-map-links.html @@ -0,0 +1,13 @@ +
    + {% if not upcoming %}{% endif %} + {% if not cast %}{% endif %} + {% if not world %}{% endif %} + {% if not news %}{% endif %} + {% if perms.catalog.watch_slx_live and settings.stream_status != 'offline' and settings.stream_provider %}{% else %}{% endif %} + + + + {% if not newsletter_signup_open %}
    Newsletter signup is currently closed.
    {% endif %} + + {% if not homepage_countdown %}{% endif %} +
    diff --git a/templates/world-map.html b/templates/world-map.html new file mode 100644 index 0000000..78b8038 --- /dev/null +++ b/templates/world-map.html @@ -0,0 +1,16 @@ +{% load static djinn_sol %} +