upstream: integrar Oasis 1.3.1
Base del merge a tres bandas: git 0.9.5 de epsylon, esta rama y el src de la
APK oficial 1.3.1 (la variante movil: OASIS_MOBILE, regex sin \p{}, audio y
video de Android). Corre en el mismo nodejs-mobile 18.20.4 que ya usabamos.
Se conserva de la rama: Karvan, identidades y multicuenta, topbar y barra
inferior, borrado de EXIF sin sharp, filtro hot del foro, RTC sin STUN y los
modulos apagados en movil (wallet, banking, torrents).
Se toma de upstream lo que ya hace de serie: respuesta citada en chats, ssb-lan
en movil, configuracion en ~/.ssb/oasis (sobrevive a reinstalar el backend).
El asistente de bienvenida deja elegir workflow tambien en movil.
This commit is contained in:
parent
8d838dd8b1
commit
c332afd6ea
265 changed files with 80970 additions and 29167 deletions
|
|
@ -1,16 +1,21 @@
|
|||
const { div, p, h2, span, a, form, input, textarea, button, label, br, details, summary } = require("../server/node_modules/hyperaxe");
|
||||
const { TEXT_CAP } = require('../backend/long_text');
|
||||
const moment = require("../server/node_modules/moment");
|
||||
const { i18n, userLink } = require("./main_views");
|
||||
const { renderUrl } = require("../backend/renderUrl");
|
||||
const { config } = require("../server/SSB_server.js");
|
||||
const { renderStyledText } = require("../backend/renderStyledText");
|
||||
|
||||
const COMMENT_ICON = "✑";
|
||||
|
||||
let commentsOpenByDefault = false;
|
||||
const setCommentsOpen = (value) => { commentsOpenByDefault = !!value; };
|
||||
|
||||
const visibleComments = (comments) => (Array.isArray(comments) ? comments : []).filter(c => {
|
||||
const t = c && c.value && c.value.content && c.value.content.text;
|
||||
return t && String(t).trim();
|
||||
});
|
||||
|
||||
const renderCommentCard = (c) => {
|
||||
const renderCommentCard = (c, extra = null) => {
|
||||
const author = (c && c.value && c.value.author) || "";
|
||||
const ts = (c && c.value && c.value.timestamp) || (c && c.timestamp);
|
||||
const absDate = ts ? moment(ts).format("YYYY/MM/DD HH:mm") : "";
|
||||
|
|
@ -18,43 +23,51 @@ const renderCommentCard = (c) => {
|
|||
const content = (c && c.value && c.value.content) || {};
|
||||
const rootId = content.fork || content.root || null;
|
||||
const text = content.text || "";
|
||||
const own = !!author && !!(config && config.keys) && author === config.keys.id;
|
||||
|
||||
return div({ class: "votations-comment-card", id: c && c.key ? c.key : undefined },
|
||||
return div({ class: own ? "votations-comment-card own-comment" : "votations-comment-card", id: c && c.key ? c.key : undefined },
|
||||
own && c.key
|
||||
? form({ method: "POST", action: `/comments/delete/${encodeURIComponent(c.key)}`, class: "comment-delete-form" },
|
||||
button({ type: "submit", class: "btn-singleview btn-delete", title: i18n.chatDelete }, "✕"))
|
||||
: null,
|
||||
span({ class: "created-at" },
|
||||
span(i18n.createdBy),
|
||||
author ? userLink(author) : span("(unknown)"),
|
||||
absDate ? span(" | ") : "",
|
||||
absDate ? span({ class: "votations-comment-date" }, absDate) : "",
|
||||
relDate ? span({ class: "votations-comment-date" }, " | ", i18n.sendTime) : "",
|
||||
relDate && rootId ? a({ href: `/thread/${encodeURIComponent(rootId)}#${encodeURIComponent(c.key)}` }, relDate) : ""
|
||||
),
|
||||
p({ class: "votations-comment-text" }, ...renderUrl(String(text)))
|
||||
p({ class: "votations-comment-text" }, ...renderStyledText(String(text), { zoomImages: true })),
|
||||
extra
|
||||
);
|
||||
};
|
||||
|
||||
const renderCommentsSection = ({ action, comments = [], returnTo = null, closedNote = null, extraClass = "" } = {}) => {
|
||||
const renderCommentsSection = ({ action, comments = [], returnTo = null, closedNote = null, extraClass = "", open = false, commentExtra = null } = {}) => {
|
||||
const list = visibleComments(comments);
|
||||
return details({ class: "comments-collapse" + (extraClass ? ` ${extraClass}` : "") },
|
||||
return details({ class: "comments-collapse" + (extraClass ? ` ${extraClass}` : ""), ...((open || commentsOpenByDefault) ? { open: true } : {}), ...(process.env.OASIS_MOBILE === '1' ? { id: "comments" } : {}) },
|
||||
summary({ class: list.length > 0 ? "comments-summary engage-on" : "comments-summary" },
|
||||
span({ class: "comments-summary-icon" }, COMMENT_ICON),
|
||||
span({ class: "comments-summary-count" }, `(${list.length})`)
|
||||
),
|
||||
div({ class: "vote-comments-section" },
|
||||
list.length
|
||||
? div({ class: "comments-list" }, ...list.map((c, i) => {
|
||||
const card = renderCommentCard(c, typeof commentExtra === "function" ? commentExtra(c) : null);
|
||||
return i === list.length - 1 ? div({ id: "comments-latest", class: "comments-latest-anchor" }, card) : card;
|
||||
}))
|
||||
: (closedNote ? null : p({ class: "votations-no-comments" }, i18n.voteNoCommentsYet)),
|
||||
closedNote
|
||||
? p({ class: "muted" }, closedNote)
|
||||
: div({ class: "comment-form-wrapper" },
|
||||
h2({ class: "comment-form-title" }, i18n.voteNewCommentLabel),
|
||||
form({ method: "POST", action, class: "comment-form", enctype: "multipart/form-data" },
|
||||
returnTo ? input({ type: "hidden", name: "returnTo", value: returnTo }) : null,
|
||||
textarea({ name: "text", rows: 4, class: "comment-textarea", placeholder: i18n.voteNewCommentPlaceholder }),
|
||||
textarea({ name: "text", rows: 4, maxlength: String(TEXT_CAP), class: "comment-textarea", placeholder: i18n.voteNewCommentPlaceholder, required: true }),
|
||||
div({ class: "comment-file-upload" }, label(i18n.uploadMedia), input({ type: "file", name: "blob" })),
|
||||
br(),
|
||||
button({ type: "submit", class: "comment-submit-btn" }, i18n.voteNewCommentButton)
|
||||
)
|
||||
),
|
||||
list.length
|
||||
? div({ class: "comments-list" }, ...list.map(renderCommentCard))
|
||||
: (closedNote ? null : p({ class: "votations-no-comments" }, i18n.voteNoCommentsYet))
|
||||
)
|
||||
)
|
||||
);
|
||||
};
|
||||
|
|
@ -62,7 +75,8 @@ const renderCommentsSection = ({ action, comments = [], returnTo = null, closedN
|
|||
const renderCommentsLink = ({ href, count = 0 } = {}) => {
|
||||
if (!href) return null;
|
||||
const total = Number(count) || 0;
|
||||
return a({ href, class: total > 0 ? "comments-summary engage-on comments-link" : "comments-summary comments-link" },
|
||||
const target = process.env.OASIS_MOBILE === '1' ? `${href}#comments` : href;
|
||||
return a({ href: target, class: total > 0 ? "comments-summary engage-on comments-link" : "comments-summary comments-link" },
|
||||
span({ class: "comments-summary-icon" }, COMMENT_ICON),
|
||||
span({ class: "comments-summary-count" }, `(${total})`)
|
||||
);
|
||||
|
|
@ -73,5 +87,6 @@ module.exports = {
|
|||
renderCommentsLink,
|
||||
visibleComments,
|
||||
renderCommentCard,
|
||||
renderCommentsSection
|
||||
renderCommentsSection,
|
||||
setCommentsOpen
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue