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
|
|
@ -3,9 +3,10 @@ const { form, button, div, h2, p, section, input, label, br, a, span, textarea,
|
|||
const { renderCommentsSection: renderSharedCommentsSection, renderCommentsLink } = require("./comments_view");
|
||||
|
||||
const moment = require("../server/node_modules/moment");
|
||||
const { template, i18n, renderOpinionsVoting, renderEngagement, userLink, renderSpreadButton, renderEcoTax, renderLifespanChip, renderContentActions , renderSpreadEditWarning } = require("./main_views");
|
||||
const { renderLicenseChip, renderLicenseSelect, renderReachChip, renderClearnetSelector, renderClearnetSwitch, renderTribeOriginChip } = require('./clearnet_view');
|
||||
const { clearnetItemHref, template, i18n, renderOpinionsVoting, renderEngagement, userLink, renderSpreadButton, renderEcoTax, renderLifespanChip, renderContentActions , renderSpreadEditWarning, renderModuleStats, moduleIsEmpty, contentDeleteAction, paged } = require("./main_views");
|
||||
const { config } = require("../server/SSB_server.js");
|
||||
const { renderUrl } = require("../backend/renderUrl");
|
||||
const { renderStyledText } = require("../backend/renderStyledText");
|
||||
|
||||
const userId = config.keys.id;
|
||||
|
||||
|
|
@ -28,36 +29,12 @@ const renderTags = (tags) => {
|
|||
const list = safeArr(tags).map((t) => String(t || "").trim()).filter(Boolean);
|
||||
return list.length
|
||||
? div(
|
||||
{ class: "card-tags" },
|
||||
{ class: "tribe-side-tags" },
|
||||
list.map((tag) => a({ href: `/search?query=%23${encodeURIComponent(tag)}`, class: "tag-link" }, `#${tag}`))
|
||||
)
|
||||
: null;
|
||||
};
|
||||
|
||||
const renderDocumentActions = (filter, doc, params = {}) => {
|
||||
const returnTo = buildReturnTo(filter, params);
|
||||
const isAuthor = String(doc.author) === String(userId);
|
||||
const hasOpinions = Object.keys(doc.opinions || {}).length > 0;
|
||||
|
||||
return isAuthor
|
||||
? div(
|
||||
{ class: "bookmark-actions" },
|
||||
!hasOpinions
|
||||
? form(
|
||||
{ method: "GET", action: `/documents/edit/${encodeURIComponent(doc.key)}` },
|
||||
input({ type: "hidden", name: "returnTo", value: returnTo }),
|
||||
button({ class: "update-btn", type: "submit" }, i18n.documentUpdateButton)
|
||||
)
|
||||
: null,
|
||||
form(
|
||||
{ method: "POST", action: `/documents/delete/${encodeURIComponent(doc.key)}` },
|
||||
input({ type: "hidden", name: "returnTo", value: returnTo }),
|
||||
button({ class: "delete-btn", type: "submit" }, i18n.documentDeleteButton)
|
||||
)
|
||||
)
|
||||
: null;
|
||||
};
|
||||
|
||||
const renderDocumentCommentsSection = (documentKey, rootId, comments = [], returnTo = null) => {
|
||||
return renderSharedCommentsSection({
|
||||
action: `/documents/${encodeURIComponent(documentKey)}/comments`,
|
||||
|
|
@ -75,34 +52,35 @@ const renderDocumentList = exports.renderDocumentList = (documents, filter, para
|
|||
const title = safeText(doc.title);
|
||||
const pdfId = safeDomId("pdf-container-", doc.key);
|
||||
|
||||
const topbarLeft =
|
||||
doc.author && String(doc.author) !== String(userId)
|
||||
? form(
|
||||
{ method: "GET", action: "/pm" },
|
||||
input({ type: "hidden", name: "recipients", value: doc.author }),
|
||||
button({ type: "submit", class: "filter-btn" }, i18n.documentMessageAuthorButton)
|
||||
)
|
||||
: null;
|
||||
|
||||
const isOwn = doc.author && String(doc.author) === String(userId);
|
||||
const headerActions = typeof params.headerActions === "function"
|
||||
? params.headerActions(doc)
|
||||
: doc.tribeOrigin
|
||||
? renderContentActions(null, doc.tribeOrigin.href)
|
||||
: renderContentActions(doc.key, `/documents/${encodeURIComponent(doc.key)}`, { spread: (params.spreadMap && params.spreadMap.get(doc.key)) || params.spreads || null, author: doc.author, favKind: 'documents', torrentFrom: { blobId: doc.url, name: doc.title }, isFavorite: doc.isFavorite, reportTitle: doc.title, deleteAction: isOwn ? contentDeleteAction('document', doc.key) : undefined, returnTo });
|
||||
const titleHref = typeof params.headerActions === "function" ? null : doc.tribeOrigin ? doc.tribeOrigin.href : `/documents/${encodeURIComponent(doc.key)}`;
|
||||
const engagement = typeof params.engagement === "function"
|
||||
? params.engagement(doc)
|
||||
: doc.tribeOrigin ? null : renderEngagement(doc.key,
|
||||
renderOpinionsVoting('/documents/opinions', doc.key, doc.opinions, returnTo, doc.opinions_inhabitants),
|
||||
renderCommentsLink({ href: `/documents/${encodeURIComponent(doc.key)}`, count: commentCount })
|
||||
);
|
||||
return div(
|
||||
{ class: "trending-card document-card" + (isOwn ? " own-content" : "") },
|
||||
div(
|
||||
{ class: "card-header activity-card-header" },
|
||||
span(),
|
||||
renderContentActions(doc.key, `/documents/${encodeURIComponent(doc.key)}`, { spread: (params.spreadMap && params.spreadMap.get(doc.key)) || params.spreads || null, author: doc.author, favKind: 'documents', isFavorite: doc.isFavorite, reportTitle: doc.title })
|
||||
headerActions
|
||||
),
|
||||
div(
|
||||
{ class: "card-section document-card-body" },
|
||||
title ? h2(title) : null,
|
||||
div({ class: "shop-title-row" }, title ? h2(titleHref ? a({ href: titleHref, class: "card-title-link" }, title) : title) : null, doc.tribeOrigin ? renderTribeOriginChip(doc.tribeOrigin) : doc.clearnet === true ? renderReachChip(true, i18n, clearnetItemHref('documents', doc.title, doc.key)) : null, renderLicenseChip(doc.license), ...(typeof params.titleChips === "function" ? params.titleChips(doc) : [])),
|
||||
doc.lifetime ? div({ class: "card-chips-row" }, renderLifespanChip(doc.lifetime, i18n)) : null,
|
||||
doc?.url
|
||||
? div({ id: pdfId, class: "pdf-viewer-container", "data-pdf-url": `/blob/${encodeURIComponent(doc.url)}` })
|
||||
: p(i18n.documentNoFile),
|
||||
renderEngagement(doc.key,
|
||||
renderOpinionsVoting('/documents/opinions', doc.key, doc.opinions, returnTo, doc.opinions_inhabitants),
|
||||
renderCommentsLink({ href: `/documents/${encodeURIComponent(doc.key)}`, count: commentCount })
|
||||
),
|
||||
...(typeof params.bodyExtra === "function" ? params.bodyExtra(doc) : []),
|
||||
engagement,
|
||||
br(),
|
||||
(() => {
|
||||
const createdTs = doc.createdAt ? new Date(doc.createdAt).getTime() : NaN;
|
||||
|
|
@ -111,7 +89,7 @@ const renderDocumentList = exports.renderDocumentList = (documents, filter, para
|
|||
|
||||
return p(
|
||||
{ class: "card-footer" },
|
||||
span({ class: "date-link" }, `${moment(doc.createdAt).format("YYYY/MM/DD HH:mm")} ${i18n.performed} `),
|
||||
span({ class: "date-link" }, `${moment(doc.createdAt).format("YYYY/MM/DD HH:mm")}`),
|
||||
userLink(doc.author),
|
||||
showUpdated
|
||||
? span(
|
||||
|
|
@ -153,18 +131,32 @@ const renderDocumentForm = (filter, documentId, docToEdit, params = {}) => {
|
|||
br(),
|
||||
label(i18n.documentDescriptionLabel),
|
||||
br(),
|
||||
textarea({ name: "description", placeholder: i18n.documentDescriptionPlaceholder, rows: "4" }, docToEdit?.description || ""),
|
||||
textarea({ maxlength: "5000", name: "description", placeholder: i18n.documentDescriptionPlaceholder, rows: "4" }, docToEdit?.description || ""),
|
||||
br(),
|
||||
label(i18n.documentTagsLabel),
|
||||
br(),
|
||||
input({ type: "text", name: "tags", placeholder: i18n.documentTagsPlaceholder, value: tagsValue }),
|
||||
br(),
|
||||
...renderLicenseSelect(docToEdit?.license, i18n),
|
||||
br(),
|
||||
renderClearnetSelector(filter === "edit" ? !!docToEdit?.clearnet : false, i18n),
|
||||
br(),
|
||||
button({ type: "submit" }, filter === "edit" ? i18n.documentUpdateButton : i18n.documentCreateButton)
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
const mediaChipFor = (filter, censusM) => (mode) => {
|
||||
if (mode === filter) return true;
|
||||
if (!Array.isArray(censusM)) return true;
|
||||
if (mode === "top") return censusM.some((x) => !x.tribeOrigin);
|
||||
if (mode === "mine") return censusM.some((x) => String(x.author) === String(userId));
|
||||
if (mode === "recent") return censusM.length > 0;
|
||||
if (mode === "favorites") return censusM.some((x) => x.isFavorite);
|
||||
if (mode === "bcs") return censusM.some((x) => String(x.title || "").toUpperCase().startsWith("BCS-"));
|
||||
return true;
|
||||
};
|
||||
|
||||
exports.documentView = async (documents, filter = "all", documentId = null, params = {}) => {
|
||||
if (filter === "edit") params = { ...params, spreadWarning: await renderSpreadEditWarning(documentId) };
|
||||
const title = i18n.documentTitle;
|
||||
|
|
@ -173,35 +165,33 @@ exports.documentView = async (documents, filter = "all", documentId = null, para
|
|||
const sort = safeText(params.sort || "recent");
|
||||
|
||||
const list = safeArr(documents);
|
||||
const emptyMod = moduleIsEmpty(list, filter, "all", q);
|
||||
const mediaChip = mediaChipFor(filter, Array.isArray(params.censusList) ? params.censusList : list);
|
||||
const docToEdit = documentId ? list.find((d) => d.key === documentId) : null;
|
||||
|
||||
const tpl = template(
|
||||
title,
|
||||
section(
|
||||
div({ class: "tags-header" },
|
||||
div({ class: "tags-header module-header-line" },
|
||||
h2(title),
|
||||
p(i18n.documentDescription)
|
||||
),
|
||||
(() => {
|
||||
const { renderReachChip } = require('./clearnet_view');
|
||||
const isClearnet = !!(params.viewerPrefs && params.viewerPrefs.clearnetDocuments);
|
||||
return div({ class: "shop-title-row" }, renderReachChip(isClearnet, i18n));
|
||||
})(),
|
||||
br(),
|
||||
div(
|
||||
{ class: "filters" },
|
||||
form(
|
||||
{ method: "GET", action: "/documents", class: "ui-toolbar ui-toolbar--filters" },
|
||||
input({ type: "hidden", name: "q", value: q }),
|
||||
input({ type: "hidden", name: "sort", value: sort }),
|
||||
...(emptyMod ? [] : [
|
||||
button({ type: "submit", name: "filter", value: "all", class: filter === "all" ? "filter-btn active" : "filter-btn" }, String(i18n.documentFilterAll).toUpperCase()),
|
||||
button({ type: "submit", name: "filter", value: "mine", class: filter === "mine" ? "filter-btn active" : "filter-btn" }, String(i18n.documentFilterMine).toUpperCase()),
|
||||
button({ type: "submit", name: "filter", value: "recent", class: filter === "recent" ? "filter-btn active" : "filter-btn" }, String(i18n.documentFilterRecent).toUpperCase()),
|
||||
button(
|
||||
...(mediaChip("recent") ? [button({ type: "submit", name: "filter", value: "recent", class: filter === "recent" ? "filter-btn active" : "filter-btn" }, String(i18n.documentFilterRecent).toUpperCase())] : []),
|
||||
...(mediaChip("mine") ? [button({ type: "submit", name: "filter", value: "mine", class: filter === "mine" ? "filter-btn active" : "filter-btn" }, String(i18n.documentFilterMine).toUpperCase())] : []),
|
||||
...(mediaChip("favorites") ? [button(
|
||||
{ type: "submit", name: "filter", value: "favorites", class: filter === "favorites" ? "filter-btn active" : "filter-btn" },
|
||||
String(i18n.documentFilterFavorites).toUpperCase()
|
||||
),
|
||||
button({ type: "submit", name: "filter", value: "top", class: filter === "top" ? "filter-btn active" : "filter-btn" }, String(i18n.documentFilterTop).toUpperCase()),
|
||||
)] : []),
|
||||
...(mediaChip("top") ? [button({ type: "submit", name: "filter", value: "top", class: filter === "top" ? "filter-btn active" : "filter-btn" }, String(i18n.documentFilterTop).toUpperCase())] : []),
|
||||
]),
|
||||
button({ type: "submit", name: "filter", value: "create", class: "create-button" }, i18n.documentCreateButton)
|
||||
)
|
||||
)
|
||||
|
|
@ -210,8 +200,9 @@ exports.documentView = async (documents, filter = "all", documentId = null, para
|
|||
filter === "create" || filter === "edit"
|
||||
? renderDocumentForm(filter, documentId, docToEdit || {}, { ...params, filter })
|
||||
: section(
|
||||
div(
|
||||
{ class: "documents-search" },
|
||||
emptyMod ? null : div(
|
||||
{ class: "documents-search activity-filter-chips activity-toolbar-row" },
|
||||
renderModuleStats(list.length),
|
||||
form(
|
||||
{ method: "GET", action: "/documents", class: "filter-box" },
|
||||
input({ type: "hidden", name: "filter", value: filter }),
|
||||
|
|
@ -228,15 +219,16 @@ exports.documentView = async (documents, filter = "all", documentId = null, para
|
|||
)
|
||||
)
|
||||
),
|
||||
div({ class: "documents-list" }, renderDocumentList(list, filter, { q, sort }))
|
||||
div({ class: "documents-list" }, renderDocumentList(paged(list), filter, { q, sort, spreadMap: params.spreadMap }))
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
return `${tpl}<script type="module" src="/js/pdf.min.mjs"></script><script src="/js/pdf-viewer.js"></script>`;
|
||||
return `${tpl}<script type="module" src="/js/pdf-viewer.js?v=102"></script>`;
|
||||
};
|
||||
|
||||
exports.singleDocumentView = async (doc, filter = "all", comments = [], params = {}) => {
|
||||
const mediaChip = mediaChipFor(filter, Array.isArray(params.censusList) ? params.censusList : null);
|
||||
const q = safeText(params.q || "");
|
||||
const sort = safeText(params.sort || "recent");
|
||||
const returnTo = safeText(params.returnTo) || buildReturnTo(filter, { q, sort });
|
||||
|
|
@ -245,8 +237,7 @@ exports.singleDocumentView = async (doc, filter = "all", comments = [], params =
|
|||
const pdfId = safeDomId("pdf-container-", doc.key);
|
||||
const isAuthor = String(doc.author) === String(userId);
|
||||
const hasOpinions = Object.keys(doc.opinions || {}).length > 0;
|
||||
const { renderReachChip } = require('./clearnet_view');
|
||||
const isClearnet = !!(params.authorPrefs && params.authorPrefs.clearnetDocuments);
|
||||
const isClearnet = !!doc.clearnet;
|
||||
|
||||
const chips = [
|
||||
renderLifespanChip(doc.lifetime, i18n),
|
||||
|
|
@ -254,13 +245,6 @@ exports.singleDocumentView = async (doc, filter = "all", comments = [], params =
|
|||
].filter(Boolean);
|
||||
|
||||
const sideActions = [];
|
||||
if (doc.author && String(doc.author) !== String(userId)) {
|
||||
sideActions.push(form(
|
||||
{ method: "GET", action: "/pm" },
|
||||
input({ type: "hidden", name: "recipients", value: doc.author }),
|
||||
button({ type: "submit", class: "filter-btn" }, i18n.documentMessageAuthorButton)
|
||||
));
|
||||
}
|
||||
if (isAuthor && !hasOpinions) {
|
||||
sideActions.push(form(
|
||||
{ method: "GET", action: `/documents/edit/${encodeURIComponent(doc.key)}` },
|
||||
|
|
@ -268,35 +252,31 @@ exports.singleDocumentView = async (doc, filter = "all", comments = [], params =
|
|||
button({ class: "update-btn", type: "submit" }, i18n.documentUpdateButton)
|
||||
));
|
||||
}
|
||||
if (isAuthor) {
|
||||
sideActions.push(form(
|
||||
{ method: "POST", action: `/documents/delete/${encodeURIComponent(doc.key)}` },
|
||||
input({ type: "hidden", name: "returnTo", value: returnTo }),
|
||||
button({ class: "delete-btn", type: "submit" }, i18n.documentDeleteButton)
|
||||
));
|
||||
}
|
||||
|
||||
const tagsNode = renderTags(doc.tags);
|
||||
|
||||
const detailActions = div({ class: "card-header activity-card-header" },
|
||||
renderContentActions(doc.key, null, {
|
||||
renderContentActions(doc.key, `/documents/${encodeURIComponent(doc.key)}`, {
|
||||
author: doc.author,
|
||||
favKind: 'documents',
|
||||
favKind: 'documents', torrentFrom: { blobId: doc.url, name: doc.title },
|
||||
isFavorite: doc.isFavorite,
|
||||
spread: params.spreads || null,
|
||||
returnTo,
|
||||
reportTitle: doc.title
|
||||
returnTo: buildReturnTo(filter, { q, sort }),
|
||||
reportTitle: doc.title,
|
||||
deleteAction: isAuthor ? contentDeleteAction('document', doc.key) : undefined
|
||||
})
|
||||
);
|
||||
|
||||
const docSide = div({ class: "tribe-side" },
|
||||
div({ class: "shop-title-row" },
|
||||
title ? h2({ class: "tribe-card-title" }, title) : null,
|
||||
renderReachChip(isClearnet, i18n)
|
||||
renderReachChip(isClearnet, i18n, isClearnet ? clearnetItemHref('documents', doc.title, doc.key) : null),
|
||||
isAuthor ? renderClearnetSwitch('documents', doc.rootId || doc.key, isClearnet) : null,
|
||||
renderLicenseChip(doc.license)
|
||||
),
|
||||
chips.length ? div({ class: "card-chips-row" }, ...chips) : null,
|
||||
safeText(doc.description)
|
||||
? p({ class: "tribe-side-description" }, ...renderUrl(doc.description))
|
||||
? p({ class: "tribe-side-description" }, ...renderStyledText(doc.description))
|
||||
: null,
|
||||
tagsNode,
|
||||
sideActions.length ? div({ class: "tribe-side-actions" }, ...sideActions) : null
|
||||
|
|
@ -314,7 +294,7 @@ exports.singleDocumentView = async (doc, filter = "all", comments = [], params =
|
|||
|
||||
return p(
|
||||
{ class: "card-footer" },
|
||||
span({ class: "date-link" }, `${moment(doc.createdAt).format("YYYY/MM/DD HH:mm")} ${i18n.performed} `),
|
||||
span({ class: "date-link" }, `${moment(doc.createdAt).format("YYYY/MM/DD HH:mm")}`),
|
||||
userLink(doc.author),
|
||||
showUpdated
|
||||
? span(
|
||||
|
|
@ -333,7 +313,7 @@ exports.singleDocumentView = async (doc, filter = "all", comments = [], params =
|
|||
const tpl = template(
|
||||
i18n.documentTitle,
|
||||
section(
|
||||
div({ class: "tags-header" },
|
||||
div({ class: "tags-header module-header-line" },
|
||||
h2(i18n.documentAllSectionTitle || i18n.documentTitle),
|
||||
p(i18n.documentDescription)
|
||||
),
|
||||
|
|
@ -344,12 +324,12 @@ exports.singleDocumentView = async (doc, filter = "all", comments = [], params =
|
|||
input({ type: "hidden", name: "q", value: q }),
|
||||
input({ type: "hidden", name: "sort", value: sort }),
|
||||
button({ type: "submit", name: "filter", value: "all", class: filter === "all" ? "filter-btn active" : "filter-btn" }, String(i18n.documentFilterAll).toUpperCase()),
|
||||
button({ type: "submit", name: "filter", value: "mine", class: filter === "mine" ? "filter-btn active" : "filter-btn" }, String(i18n.documentFilterMine).toUpperCase()),
|
||||
button({ type: "submit", name: "filter", value: "recent", class: filter === "recent" ? "filter-btn active" : "filter-btn" }, String(i18n.documentFilterRecent).toUpperCase()),
|
||||
button(
|
||||
...(mediaChip("recent") ? [button({ type: "submit", name: "filter", value: "recent", class: filter === "recent" ? "filter-btn active" : "filter-btn" }, String(i18n.documentFilterRecent).toUpperCase())] : []),
|
||||
...(mediaChip("mine") ? [button({ type: "submit", name: "filter", value: "mine", class: filter === "mine" ? "filter-btn active" : "filter-btn" }, String(i18n.documentFilterMine).toUpperCase())] : []),
|
||||
...(mediaChip("favorites") ? [button(
|
||||
{ type: "submit", name: "filter", value: "favorites", class: filter === "favorites" ? "filter-btn active" : "filter-btn" },
|
||||
String(i18n.documentFilterFavorites).toUpperCase()
|
||||
),
|
||||
)] : []),
|
||||
button({ type: "submit", name: "filter", value: "top", class: filter === "top" ? "filter-btn active" : "filter-btn" }, String(i18n.documentFilterTop).toUpperCase()),
|
||||
button({ type: "submit", name: "filter", value: "create", class: "create-button" }, i18n.documentCreateButton)
|
||||
)
|
||||
|
|
@ -358,6 +338,6 @@ exports.singleDocumentView = async (doc, filter = "all", comments = [], params =
|
|||
)
|
||||
);
|
||||
|
||||
return `${tpl}<script type="module" src="/js/pdf.min.mjs"></script><script src="/js/pdf-viewer.js"></script>`;
|
||||
return `${tpl}<script type="module" src="/js/pdf-viewer.js?v=102"></script>`;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue