From 0bced8fe174de24ebd3823c93997cb2d2347dfe9 Mon Sep 17 00:00:00 2001
From: Andrew Godwin
Date: Mon, 28 Nov 2022 22:14:52 -0700
Subject: A few hashtag fixups
---
activities/models/hashtag.py | 3 ++-
activities/models/post.py | 14 ++++++++++++++
activities/views/timelines.py | 2 +-
static/css/style.css | 9 +++++++--
templates/activities/_menu.html | 5 ++++-
5 files changed, 28 insertions(+), 5 deletions(-)
diff --git a/activities/models/hashtag.py b/activities/models/hashtag.py
index a5754f7..7085b15 100644
--- a/activities/models/hashtag.py
+++ b/activities/models/hashtag.py
@@ -8,6 +8,7 @@ from django.db import models
from django.utils import timezone
from django.utils.safestring import mark_safe
+from core.html import strip_html
from core.models import Config
from stator.models import State, StateField, StateGraph, StatorModel
@@ -174,7 +175,7 @@ class Hashtag(StatorModel):
Return a parsed and sanitized of hashtags found in content without
leading '#'.
"""
- hashtag_hits = cls.hashtag_regex.findall(content)
+ hashtag_hits = cls.hashtag_regex.findall(strip_html(content))
hashtags = sorted({tag[1].lower() for tag in hashtag_hits})
return list(hashtags)
diff --git a/activities/models/post.py b/activities/models/post.py
index f3b1879..eecce04 100644
--- a/activities/models/post.py
+++ b/activities/models/post.py
@@ -77,6 +77,17 @@ class PostStates(StateGraph):
class PostQuerySet(models.QuerySet):
+ def public(self, include_replies: bool = False):
+ query = self.filter(
+ visibility__in=[
+ Post.Visibilities.public,
+ Post.Visibilities.local_only,
+ ],
+ )
+ if not include_replies:
+ return query.filter(in_reply_to__isnull=True)
+ return query
+
def local_public(self, include_replies: bool = False):
query = self.filter(
visibility__in=[
@@ -104,6 +115,9 @@ class PostManager(models.Manager):
def get_queryset(self):
return PostQuerySet(self.model, using=self._db)
+ def public(self, include_replies: bool = False):
+ return self.get_queryset().public(include_replies=include_replies)
+
def local_public(self, include_replies: bool = False):
return self.get_queryset().local_public(include_replies=include_replies)
diff --git a/activities/views/timelines.py b/activities/views/timelines.py
index ffe329c..694039e 100644
--- a/activities/views/timelines.py
+++ b/activities/views/timelines.py
@@ -80,7 +80,7 @@ class Tag(ListView):
def get_queryset(self):
return (
- Post.objects.local_public()
+ Post.objects.public()
.tagged_with(self.hashtag)
.select_related("author")
.prefetch_related("attachments")
diff --git a/static/css/style.css b/static/css/style.css
index ebbedb0..fb41646 100644
--- a/static/css/style.css
+++ b/static/css/style.css
@@ -92,6 +92,7 @@ td a {
--color-text-duller: #5f6983;
--color-text-dull: #99a;
--color-text-main: #fff;
+ --color-text-link: rgb(176, 194, 206);
--color-input-border: #000;
--color-input-border-active: #444b5d;
@@ -451,6 +452,7 @@ form .field .label-input {
form .field.stats {
width: 100%;
}
+
form .field.stats table {
width: 50%;
}
@@ -907,11 +909,14 @@ table.metadata td.name {
width: 16px;
}
-.post a.hashtag, .post.mini a.hashtag {
+.post a.hashtag,
+.post.mini a.hashtag {
text-decoration: none;
+ color: var(--color-text-link);
}
-.post a.hashtag:hover, .post.mini a.hashtag:hover {
+.post a.hashtag:hover,
+.post.mini a.hashtag:hover {
text-decoration: underline;
}
diff --git a/templates/activities/_menu.html b/templates/activities/_menu.html
index 58295a9..a912090 100644
--- a/templates/activities/_menu.html
+++ b/templates/activities/_menu.html
@@ -6,9 +6,12 @@
Notifications
+ {% comment %}
+ Not sure we want to show this quite yet
Explore
+ {% endcomment %}
Local
@@ -30,7 +33,7 @@
Settings
- {% else %}
+ {% else %}
Local Posts
--
cgit v1.2.3