mirror of
https://github.com/jointakahe/takahe.git
synced 2024-11-25 16:51:00 +00:00
parent
c9f7a06fe5
commit
d32a686eb1
5 changed files with 23 additions and 5 deletions
|
@ -9,7 +9,7 @@ from django.contrib.postgres.indexes import GinIndex
|
||||||
from django.db import models, transaction
|
from django.db import models, transaction
|
||||||
from django.template import loader
|
from django.template import loader
|
||||||
from django.template.defaultfilters import linebreaks_filter
|
from django.template.defaultfilters import linebreaks_filter
|
||||||
from django.utils import timezone
|
from django.utils import text, timezone
|
||||||
|
|
||||||
from activities.models.emoji import Emoji
|
from activities.models.emoji import Emoji
|
||||||
from activities.models.fan_out import FanOut
|
from activities.models.fan_out import FanOut
|
||||||
|
@ -388,6 +388,14 @@ class Post(StatorModel):
|
||||||
"""
|
"""
|
||||||
return self.safe_content(local=False)
|
return self.safe_content(local=False)
|
||||||
|
|
||||||
|
def summary_class(self) -> str:
|
||||||
|
"""
|
||||||
|
Returns a CSS class name to identify this summary value
|
||||||
|
"""
|
||||||
|
if not self.summary:
|
||||||
|
return ""
|
||||||
|
return "summary-" + text.slugify(self.summary, allow_unicode=True)
|
||||||
|
|
||||||
### Async helpers ###
|
### Async helpers ###
|
||||||
|
|
||||||
async def afetch_full(self) -> "Post":
|
async def afetch_full(self) -> "Post":
|
||||||
|
|
|
@ -120,6 +120,7 @@ class Compose(FormView):
|
||||||
initial["visibility"] = Post.Visibilities.unlisted
|
initial["visibility"] = Post.Visibilities.unlisted
|
||||||
else:
|
else:
|
||||||
initial["visibility"] = self.reply_to.visibility
|
initial["visibility"] = self.reply_to.visibility
|
||||||
|
initial["content_warning"] = self.reply_to.summary
|
||||||
# Build a set of mentions for the content to start as
|
# Build a set of mentions for the content to start as
|
||||||
mentioned = {self.reply_to.author}
|
mentioned = {self.reply_to.author}
|
||||||
mentioned.update(self.reply_to.mentions.all())
|
mentioned.update(self.reply_to.mentions.all())
|
||||||
|
|
|
@ -246,5 +246,6 @@ class Config(models.Model):
|
||||||
|
|
||||||
# wellness Options
|
# wellness Options
|
||||||
visible_reaction_counts: bool = True
|
visible_reaction_counts: bool = True
|
||||||
|
expand_linked_cws: bool = True
|
||||||
|
|
||||||
custom_css: str | None
|
custom_css: str | None
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{% load static %}
|
{% load static %}
|
||||||
{% load activity_tags %}
|
{% load activity_tags %}
|
||||||
<div class="post {% if reply %}reply{% endif %}" data-takahe-id="{{ post.id }}" role="article" tabindex="0">
|
<div class="post {% if reply %}reply{% endif %} {{ post.summary_class }}" data-takahe-id="{{ post.id }}" role="article" tabindex="0">
|
||||||
|
|
||||||
<a href="{{ post.author.urls.view }}" tabindex="-1">
|
<a href="{{ post.author.urls.view }}" tabindex="-1">
|
||||||
<img src="{{ post.author.local_icon_url.relative }}" class="icon" loading="lazy">
|
<img src="{{ post.author.local_icon_url.relative }}" class="icon" loading="lazy">
|
||||||
|
@ -30,12 +30,16 @@
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
{% if post.summary %}
|
{% if post.summary %}
|
||||||
<div class="summary" _="on click toggle .enabled then toggle .hidden on the next .content then halt">
|
{% if config_identity.expand_linked_cws %}
|
||||||
|
<div class="summary" _="on click toggle .enabled on <.{{ post.summary_class }} .summary/> then toggle .hidden on <.{{ post.summary_class }} .content/> then halt">
|
||||||
|
{% else %}
|
||||||
|
<div class="summary" _="on click toggle .enabled then toggle .hidden on the next .content then halt">
|
||||||
|
{% endif %}
|
||||||
{{ post.summary }}
|
{{ post.summary }}
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<div class="content {% if post.summary %}hidden{% endif %}">
|
<div class="content {% if post.summary %}hidden {% endif %}">
|
||||||
{{ post.safe_content_local }}
|
{{ post.safe_content_local }}
|
||||||
|
|
||||||
{% if post.attachments.exists %}
|
{% if post.attachments.exists %}
|
||||||
|
|
|
@ -25,10 +25,14 @@ class InterfacePage(SettingsPage):
|
||||||
"help_text": "Theme the website however you'd like, just for you. You should probably not use this unless you know what you're doing.",
|
"help_text": "Theme the website however you'd like, just for you. You should probably not use this unless you know what you're doing.",
|
||||||
"display": "textarea",
|
"display": "textarea",
|
||||||
},
|
},
|
||||||
|
"expand_linked_cws": {
|
||||||
|
"title": "Expand linked Content Warnings",
|
||||||
|
"help_text": "Expands all CWs of the same type at once, rather than one at a time.",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
layout = {
|
layout = {
|
||||||
"Posting": ["toot_mode", "default_post_visibility"],
|
"Posting": ["toot_mode", "default_post_visibility"],
|
||||||
"Wellness": ["visible_reaction_counts"],
|
"Wellness": ["visible_reaction_counts", "expand_linked_cws"],
|
||||||
"Appearance": ["custom_css"],
|
"Appearance": ["custom_css"],
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue