commit e4b3162713d80db2fb2eba1c126de935150e356f
parent 17d4f9e46822bfcaa7cc60c956da2a9d84c35a7b
Author: William Casarin <jb55@jb55.com>
Date: Fri, 11 Nov 2022 11:28:59 -0800
web: allow creation of posts with content warnings
Diffstat:
3 files changed, 45 insertions(+), 14 deletions(-)
diff --git a/webv2/damus.css b/webv2/damus.css
@@ -16,6 +16,15 @@
width: 60px;
}
+#content-warning-input {
+ width: 100%;
+}
+
+#content-warning-input-container {
+ width: 100%;
+ margin-bottom: 10px;
+}
+
.deleted-comment {
border: 2px dashed white;
border-radius: 10px;
@@ -94,9 +103,18 @@ details {
border-radius: 20px;
}
-textarea, input {
+input {
background-color: rgba(255,255,255,0.2);
border: 0;
+ height: 30px;
+ color: white;
+ border-radius: 5px;
+}
+
+textarea {
+ background-color: rgba(255,255,255,0.2);
+ border: 0;
+ width: 100%;
height: 40px;
color: white;
border-radius: 5px;
@@ -104,15 +122,23 @@ textarea, input {
#newpost {
margin: 0 auto 20px auto;
- width: 100%
+ width: 80%
}
::placeholder {
color: rgba(255,255,255,0.7);
}
-#post-input {
- width: 80%;
+.post-group {
+ display: flex;
+}
+
+#post-button {
+ width: 50px;
+}
+
+.post-group > textarea {
+ margin-right: 10px;
}
.small-txt {
@@ -135,15 +161,11 @@ textarea, input {
margin-right: 14px;
}
-textarea {
- width: 100%;
-}
-
button {
border: 0;
padding: 5px;
color: white;
- background-color: #C073EB;
+ background-color: #9202e2;
border-radius: 5px;
}
diff --git a/webv2/damus.js b/webv2/damus.js
@@ -554,11 +554,13 @@ function redraw_home_view(model) {
async function send_post() {
const input_el = document.querySelector("#post-input")
+ const cw_el = document.querySelector("#content-warning-input")
+ const cw = cw_el.value
const content = input_el.value
const created_at = Math.floor(new Date().getTime() / 1000)
const kind = 1
- const tags = []
+ const tags = cw? [["content-warning", cw]] : []
const pubkey = await get_pubkey()
const {pool} = DSTATE
@@ -570,6 +572,7 @@ async function send_post() {
pool.send(["EVENT", post])
input_el.value = ""
+ cw_el.value = ""
}
async function sign_event(ev) {
@@ -590,8 +593,14 @@ async function sign_event(ev) {
function render_home_view(model) {
return `
<div id="newpost">
- <textarea placeholder="What's on your mind?" id="post-input"></textarea>
- <button onclick="send_post(this)" id="post-button">Post</button>
+ <div id="content-warning-input-container">
+ <input id="content-warning-input" type="text" placeholder="Content Warning (nsfw, politics, etc)"></input>
+ </div>
+
+ <div class="post-group">
+ <textarea placeholder="What's on your mind?" id="post-input"></textarea>
+ <button onclick="send_post(this)" id="post-button">Post</button>
+ </div>
</div>
<div id="events">
</div>
diff --git a/webv2/index.html b/webv2/index.html
@@ -6,7 +6,7 @@
<title>Damus</title>
- <link rel="stylesheet" href="damus.css?v=18">
+ <link rel="stylesheet" href="damus.css?v=19">
</head>
<body>
<section class="header">
@@ -41,7 +41,7 @@
<script src="noble-secp256k1.js?v=1"></script>
<script src="bech32.js?v=1"></script>
<script src="nostr.js?v=6"></script>
- <script src="damus.js?v=55"></script>
+ <script src="damus.js?v=56"></script>
<script>
// I have to delay loading to wait for nos2x
const relay = setTimeout(damus_web_init, 100)