Merge pull request #199 from jedahan/content-warning-publish

Add content warning publishing, fixes #191
This commit is contained in:
Christian Bundy 2020-02-11 19:31:51 -08:00 committed by GitHub
commit f70dae3f0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 3 deletions

View File

@ -150,6 +150,19 @@ input {
border-radius: var(--common-radius);
}
.contentWarning {
background-color: var(--bg);
box-sizing: border-box;
display: block;
font-size: var(--whole);
padding: var(--whole);
width: 100%;
margin: var(--whole) 0;
border: var(--pico) solid var(--bg-selection);
border-radius: var(--common-radius);
color: var(--fg);
}
textarea {
background-color: var(--bg);
box-sizing: border-box;

View File

@ -490,16 +490,19 @@ router
})
.post("/publish/", koaBody(), async ctx => {
const text = String(ctx.request.body.text);
const publish = async ({ text }) => {
const contentWarning = String(ctx.request.body.contentWarning);
const publish = async ({ text, contentWarning }) => {
const mentions =
ssbMentions(text).filter(mention => mention != null) || undefined;
return post.root({
text,
mentions
mentions,
contentWarning
});
};
ctx.body = await publish({ text });
ctx.body = await publish({ text, contentWarning });
ctx.redirect("/");
})
.post("/follow/:feed", koaBody(), async ctx => {

View File

@ -444,6 +444,13 @@ exports.publishView = () => {
i18n.publishLabel({ markdownUrl, linkTarget: "_blank" })
),
textarea({ required: true, name: "text" }),
label({ for: "contentWarning" }, i18n.contentWarningLabel),
input({
name: "contentWarning",
type: "text",
class: "contentWarning",
placeholder: "Optional warning for the post"
}),
button({ type: "submit" }, i18n.submit)
)
)