Small improvements and fix

This commit is contained in:
Rogerio Chaves 2020-04-08 20:04:11 +02:00
parent 20d5e83994
commit 6253d7f910
No known key found for this signature in database
GPG Key ID: E6AF5440509B1D94
3 changed files with 17 additions and 8 deletions

View File

@ -26,17 +26,19 @@ Client(ssbSecret, ssbConfig, async (err, server) => {
console.log("SSB Client ready");
});
let profileUrl = (id, path = "") => {
if (id.includes("/")) {
return `/profile/${encodeURIComponent(id)}${path}`;
}
return `/profile/${id}${path}`;
};
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.set("view engine", "ejs");
app.use(express.static("public"));
app.use((_req, res, next) => {
res.locals.profileUrl = (id, path = "") => {
if (id.includes("/")) {
return `/profile/${encodeURIComponent(id)}${path}`;
}
return `/profile/${id}${path}`;
};
res.locals.profileUrl = profileUrl;
res.locals.imageUrl = (blob) => {
const imageHash = blob && typeof blob == "object" ? blob.link : blob;
@ -126,7 +128,7 @@ router.post("/profile/:id/publish", async (req, res) => {
});
}
res.redirect("/profile/" + id);
res.redirect(profileUrl(id));
});
router.get("/pubs", async (_req, res) => {

View File

@ -1,3 +1,9 @@
let escCallback = () => {};
document.onkeydown = (e) => {
const isEsc = e.key === "Escape" || e.key === "Esc";
if (isEsc) escCallback();
};
const messages = document.querySelectorAll(".vanishing-message");
messages.forEach((message) => {
message.addEventListener("click", () => {
@ -18,5 +24,6 @@ messages.forEach((message) => {
overlay.addEventListener("click", onClose);
closeButton.addEventListener("click", onClose);
escCallback = onClose;
});
});

View File

@ -27,7 +27,7 @@
<form action="<%= profileUrl(profile.id, "/publish") %>" method="POST">
<div>
<label>
<input type="radio" name="visibility" value="public">
<input type="radio" name="visibility" value="public" checked=checked>
Public
</label>
<label>