diff --git a/.gitignore b/.gitignore index 3853bb5..2a5c47b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ *.psql *.sqlite3 .venv +/media/ notes.md diff --git a/activities/models/post.py b/activities/models/post.py index caa2981..25afdda 100644 --- a/activities/models/post.py +++ b/activities/models/post.py @@ -27,8 +27,10 @@ class PostStates(StateGraph): """ post = await instance.afetch_full() # Non-local posts should not be here + # TODO: This seems to keep happening. Work out how? if not post.local: - raise ValueError(f"Trying to run handle_new on a non-local post {post.pk}!") + print(f"Trying to run handle_new on a non-local post {post.pk}!") + return cls.fanned_out # Build list of targets - mentions always included targets = set() async for mention in post.mentions.all(): diff --git a/core/uploads.py b/core/uploads.py new file mode 100644 index 0000000..ef235f0 --- /dev/null +++ b/core/uploads.py @@ -0,0 +1,15 @@ +import base64 +import os +import uuid + +from django.utils import timezone + + +def upload_namer(prefix, instance, filename): + """ + Names uploaded images, obscuring their original name with a random UUID. + """ + now = timezone.now() + _, old_extension = os.path.splitext(filename) + new_filename = base64.b32encode(uuid.uuid4().bytes).decode("ascii") + return f"{prefix}/{now.year}/{now.month}/{now.day}/{new_filename}{old_extension}" diff --git a/static/css/style.css b/static/css/style.css index 3c1ef49..b3495b5 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -449,6 +449,11 @@ form .button.delete { background: var(--color-delete); } +form button.secondary, +form .button.secondary { + background: var(--color-bg-menu); +} + form button.toggle, form .button.toggle { background: var(--color-bg-main); @@ -475,6 +480,13 @@ h1.identity { margin: 15px 0 20px 15px; } +h1.identity .banner { + width: 870px; + height: auto; + display: block; + margin: 0 0 20px 0; +} + h1.identity .icon { width: 80px; height: 80px; diff --git a/takahe/settings/base.py b/takahe/settings/base.py index e45133d..b98b9a0 100644 --- a/takahe/settings/base.py +++ b/takahe/settings/base.py @@ -107,3 +107,6 @@ STATICFILES_DIRS = [ ] ALLOWED_HOSTS = ["*"] + +MEDIA_ROOT = BASE_DIR / "media" +MEDIA_URL = "/media/" diff --git a/takahe/urls.py b/takahe/urls.py index 638dabd..5f5d5c5 100644 --- a/takahe/urls.py +++ b/takahe/urls.py @@ -1,5 +1,9 @@ +import re + +from django.conf import settings as djsettings from django.contrib import admin as djadmin -from django.urls import path +from django.urls import path, re_path +from django.views.static import serve from activities.views import posts, timelines from core import views as core @@ -18,6 +22,11 @@ urlpatterns = [ settings.SettingsRoot.as_view(), name="settings", ), + path( + "settings/profile/", + settings.ProfilePage.as_view(), + name="settings_profile", + ), path( "settings/interface/", settings.InterfacePage.as_view(), @@ -87,4 +96,10 @@ urlpatterns = [ path(".stator/runner/", stator.RequestRunner.as_view()), # Django admin path("djadmin/", djadmin.site.urls), + # Media files + re_path( + r"^%s(?P.*)$" % re.escape(djsettings.MEDIA_URL.lstrip("/")), + serve, + kwargs={"document_root": djsettings.MEDIA_ROOT}, + ), ] diff --git a/templates/activities/_post.html b/templates/activities/_post.html index 9d8db3b..14b1cbf 100644 --- a/templates/activities/_post.html +++ b/templates/activities/_post.html @@ -2,11 +2,7 @@ {% load activity_tags %}
- {% if post.author.icon_uri %} - - {% else %} - - {% endif %} +