Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for content warnings in posts #8

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ public class StatusEntity {
@Column(nullable = false, length = 500)
public String status;

@Column(length = 500)
public String contentWarning;

//

@Transient()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ public StatusEntity publish(StatusEntity status) {
data.put("media_ids", status.media.stream().map((media) -> media.id).toList());
}

if (status.contentWarning != null) {
data.put("sensitive", true);
data.put("spoiler_text", status.contentWarning);
}

if (status.group.threaded) {
var prev = statusRepository //
.findTopByGroupAndDateBeforeAndIdIsNotNullOrderByDateDesc(status.group, status.date);
Expand Down
20 changes: 20 additions & 0 deletions src/main/resources/templates/forms/status.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,26 @@
<label class="form-label">Content for the Status</label>
</div>
</div>
<div class="accordion mb-3" id="advanced-options-accordion">
<div class="accordion-item">
<h2 class="accordion-header" id="heading-advanced-options">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapse-advanced-options" aria-expanded="false" aria-controls="collapse-advanced-options">
Advanced Options
</button>
</h2>
<div id="collapse-advanced-options" class="accordion-collapse collapse" aria-labelledby="heading-advanced-options" data-bs-parent="#advanced-options-accordion">
<div class="accordion-body">
<div class="col-md-6 mb-3">
<label class="form-label fw-bold" for="content-warning">Status Content Warning</label>
<div class="form-floating">
<textarea placeholder th:field="*{contentWarning}" class="form-control" maxlength="500"></textarea>
<label class="form-label">Content Warning for the Status</label>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="accordion-footer d-flex flex-row-reverse">
<button th:text="*{uuid} ? 'Update' : 'Create'" class="btn btn-outline-primary"></button>
Expand Down