diff --git a/common/templates/_sidebar.html b/common/templates/_sidebar.html
index 66285a4f..b142253b 100644
--- a/common/templates/_sidebar.html
+++ b/common/templates/_sidebar.html
@@ -46,46 +46,7 @@
{% trans 'Popular Posts' %}
-
- {% for post in popular_posts %}
-
-
-
- {# {{ post.created|date }} #}
- {% include "action_reply_post.html" %}
- {% include "action_like_post.html" %}
- {% include "action_boost_post.html" %}
- {% include "action_open_post.html" %}
-
-
-
- {{ post.author.name }}
-
-
{{ post.summary|default:'' }}
-
-
- {% for attachment in post.attachments.all %}
- {% if attachment.is_image %}
-

- {% endif %}
- {% endfor %}
-
- {{ post.content|bleach:"a,p,span,br,div,img"|default:"" }}
-
-
-
-
- {% empty %}
-
{% trans "nothing so far." %}
- {% endfor %}
-
+ {% include "posts.html" with posts=popular_posts %}
@@ -273,6 +234,16 @@
{% endif %}
+ {% if recent_posts is not None %}
+
+
+
+ {% trans 'Recent Posts' %}
+ {% include "posts.html" with posts=recent_posts %}
+
+
+
+ {% endif %}
{% if sidebar_template %}
{% include sidebar_template %}
{% endif %}
diff --git a/journal/templates/posts.html b/journal/templates/posts.html
new file mode 100644
index 00000000..16ca04de
--- /dev/null
+++ b/journal/templates/posts.html
@@ -0,0 +1,41 @@
+{% load bleach_tags %}
+{% load humanize %}
+{% load i18n %}
+{% for post in posts %}
+
+
+
+ {# {{ post.created|date }} #}
+ {% include "action_reply_post.html" %}
+ {% include "action_like_post.html" %}
+ {% include "action_boost_post.html" %}
+ {% include "action_open_post.html" %}
+
+
+
+ {{ post.author.name }}
+
+
{{ post.summary|default:'' }}
+
+
+ {% for attachment in post.attachments.all %}
+ {% if attachment.is_image %}
+

+ {% endif %}
+ {% endfor %}
+
+ {{ post.content|bleach:"a,p,span,br,div,img"|default:"" }}
+
+
+
+
+{% empty %}
+
{% trans "nothing so far." %}
+{% endfor %}
diff --git a/journal/views/profile.py b/journal/views/profile.py
index bb303229..14e52f1f 100644
--- a/journal/views/profile.py
+++ b/journal/views/profile.py
@@ -7,6 +7,7 @@ from django.views.decorators.http import require_http_methods
from catalog.models import *
from common.utils import AuthedHttpRequest
+from takahe.utils import Takahe
from ..forms import *
from ..models import *
@@ -17,10 +18,8 @@ from .common import profile_identity_required, target_identity_required
@profile_identity_required
def profile(request: AuthedHttpRequest, user_name):
target = request.target_identity
-
- if not request.user.is_authenticated and (
- not target.local or not target.anonymous_viewable
- ):
+ anonymous = not request.user.is_authenticated
+ if anonymous and (not target.local or not target.anonymous_viewable):
return render(
request,
"users/home_anonymous.html",
@@ -95,6 +94,10 @@ def profile(request: AuthedHttpRequest, user_name):
year = today.year - 1
else:
year = None
+ if anonymous:
+ recent_posts = None
+ else:
+ recent_posts = Takahe.get_recent_posts(target.pk, request.user.identity.pk)[:10]
return render(
request,
"profile.html",
@@ -103,6 +106,7 @@ def profile(request: AuthedHttpRequest, user_name):
"identity": target,
"me": me,
"top_tags": top_tags,
+ "recent_posts": recent_posts,
"shelf_list": shelf_list,
"collections": collections[:10],
"collections_count": collections.count(),
diff --git a/takahe/migrations/0001_initial.py b/takahe/migrations/0001_initial.py
index b977fe6e..daf13a04 100644
--- a/takahe/migrations/0001_initial.py
+++ b/takahe/migrations/0001_initial.py
@@ -850,6 +850,12 @@ class Migration(migrations.Migration):
default=True, help_text="Also follow boosts from this user"
),
),
+ (
+ "notify",
+ models.BooleanField(
+ default=False, help_text="Notify about posts from this user"
+ ),
+ ),
("uri", models.CharField(blank=True, max_length=500, null=True)),
("note", models.TextField(blank=True, null=True)),
("state", models.CharField(default="unrequested", max_length=100)),
diff --git a/takahe/models.py b/takahe/models.py
index 6c583d6a..0faa0972 100644
--- a/takahe/models.py
+++ b/takahe/models.py
@@ -751,6 +751,9 @@ class Follow(models.Model):
boosts = models.BooleanField(
default=True, help_text="Also follow boosts from this user"
)
+ notify = models.BooleanField(
+ default=False, help_text="Notify about posts from this user"
+ )
uri = models.CharField(blank=True, null=True, max_length=500)
note = models.TextField(blank=True, null=True)
diff --git a/takahe/utils.py b/takahe/utils.py
index a9bc23d8..01bab0a5 100644
--- a/takahe/utils.py
+++ b/takahe/utils.py
@@ -985,3 +985,16 @@ class Takahe:
.filter(num_interactions__gt=0)
.order_by("-num_interactions", "-published")[:limit]
)
+
+ @staticmethod
+ def get_recent_posts(author_pk: int, viewer_pk: int | None = None):
+ qs = (
+ Post.objects.exclude(state__in=["deleted", "deleted_fanned_out"])
+ .filter(author_id=author_pk)
+ .order_by("-published")
+ )
+ if viewer_pk and Takahe.get_is_following(viewer_pk, author_pk):
+ qs = qs.exclude(visibility=3)
+ else:
+ qs = qs.filter(visibility__in=[0, 1, 4])
+ return qs.prefetch_related("attachments", "author")