diff --git a/thinks/migrations/0005_think_last_edited.py b/thinks/migrations/0005_think_last_edited.py new file mode 100644 index 0000000..be97c55 --- /dev/null +++ b/thinks/migrations/0005_think_last_edited.py @@ -0,0 +1,18 @@ +# Generated by Django 5.0.3 on 2025-04-26 07:50 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('thinks', '0004_think_creation_time'), + ] + + operations = [ + migrations.AddField( + model_name='think', + name='last_edited', + field=models.DateTimeField(blank=True, null=True), + ), + ] diff --git a/thinks/models.py b/thinks/models.py index ecc6336..f50ddad 100644 --- a/thinks/models.py +++ b/thinks/models.py @@ -13,6 +13,7 @@ class Think(models.Model): slug = models.SlugField() category = models.CharField(max_length=100, blank=True, null=True) creation_time = models.DateTimeField(auto_now_add=True) + last_edited = models.DateTimeField(blank=True, null=True) is_template = models.BooleanField(default=False) diff --git a/thinks/static/thinks/think-editor.css b/thinks/static/thinks/think-editor.css index 7dd587a..8050f8f 100644 --- a/thinks/static/thinks/think-editor.css +++ b/thinks/static/thinks/think-editor.css @@ -33,7 +33,8 @@ body { display: grid; grid-template-rows: auto 1fr; - min-height: 100vh; + min-height: 100svh; + max-height: 100svh; margin: 0; padding: var(--half-spacing); @@ -128,8 +129,8 @@ input[type="file"] { overflow: hidden; --col-1-width: auto; grid-template: - "nav editor preview" min-content - "log editor preview" 1fr + "nav editor preview" 1fr + "log log log" min-content / var(--col-1-width) var(--editor-size) var(--preview-size) ; diff --git a/thinks/templates/thinks/think_form.html b/thinks/templates/thinks/think_form.html new file mode 100644 index 0000000..93826c3 --- /dev/null +++ b/thinks/templates/thinks/think_form.html @@ -0,0 +1,9 @@ + + +
+{% csrf_token %} +{{form}} + +
+ + diff --git a/thinks/views.py b/thinks/views.py index bbb1dc1..e952471 100644 --- a/thinks/views.py +++ b/thinks/views.py @@ -4,6 +4,7 @@ from django.http import HttpResponse, JsonResponse from django.shortcuts import render, redirect from django.views import generic from django.urls import reverse +from django.utils.timezone import now from itertools import groupby import json import mimetypes @@ -41,7 +42,7 @@ class IndexView(ThinkMixin, generic.ListView): context['templates'] = Think.objects.filter(is_template=True) - context['recent_thinks'] = Think.objects.filter(is_template=False).order_by('-creation_time')[:3] + context['recent_thinks'] = Think.objects.all().order_by('-last_edited', '-creation_time')[:3] context['thinks'] = sorted(Think.objects.filter(is_template=False), key=lambda t: (t.category if t.category else '', -t.creation_time.timestamp())) @@ -100,6 +101,9 @@ class ThinkView(ThinkMixin, generic.DetailView): think = self.object + think.last_edited = now() + think.save(update_fields=('last_edited',)) + root = think.root strpath = self.request.GET.get('path')