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
|
|
@ -2,10 +2,11 @@ const { form, button, div, h2, p, section, input, label, textarea, br, a, span,
|
|||
require("../server/node_modules/hyperaxe");
|
||||
const { renderCommentsSection: renderSharedCommentsSection, renderCommentsLink } = require("./comments_view");
|
||||
|
||||
const { template, i18n, renderOpinionsVoting, renderEngagement, userLink, renderSpreadButton, renderEcoTax, renderLifespanChip, renderContentActions, renderSpreadEditWarning } = require("./main_views");
|
||||
const { clearnetItemHref, template, i18n, renderOpinionsVoting, renderEngagement, userLink, renderSpreadButton, renderEcoTax, renderLifespanChip, renderContentActions, renderSpreadEditWarning, renderModuleStats, moduleIsEmpty, contentDeleteAction, paged } = require("./main_views");
|
||||
const { renderReachChip, renderClearnetSelector, renderClearnetSwitch, renderTribeOriginChip } = require("./clearnet_view");
|
||||
const moment = require("../server/node_modules/moment");
|
||||
const { config } = require("../server/SSB_server.js");
|
||||
const { renderUrl } = require("../backend/renderUrl");
|
||||
const { renderStyledText, safeExternalHref } = require("../backend/renderStyledText");
|
||||
|
||||
const userId = config.keys.id;
|
||||
|
||||
|
|
@ -34,30 +35,6 @@ const renderPMButton = (recipient, className = "filter-btn") => {
|
|||
);
|
||||
};
|
||||
|
||||
const renderBookmarkActions = (filter, bookmark, params = {}) => {
|
||||
const returnTo = buildReturnTo(filter, params);
|
||||
const isAuthor = String(bookmark.author) === String(userId);
|
||||
const hasOpinions = Object.keys(bookmark.opinions || {}).length > 0;
|
||||
|
||||
return isAuthor
|
||||
? div(
|
||||
{ class: "bookmark-actions" },
|
||||
!hasOpinions
|
||||
? form(
|
||||
{ method: "GET", action: `/bookmarks/edit/${encodeURIComponent(bookmark.id)}` },
|
||||
input({ type: "hidden", name: "returnTo", value: returnTo }),
|
||||
button({ class: "update-btn", type: "submit" }, i18n.bookmarkUpdateButton)
|
||||
)
|
||||
: null,
|
||||
form(
|
||||
{ method: "POST", action: `/bookmarks/delete/${encodeURIComponent(bookmark.id)}` },
|
||||
input({ type: "hidden", name: "returnTo", value: returnTo }),
|
||||
button({ class: "delete-btn", type: "submit" }, i18n.bookmarkDeleteButton)
|
||||
)
|
||||
)
|
||||
: null;
|
||||
};
|
||||
|
||||
const renderBookmarkCommentsSection = (bookmarkId, rootId, comments = [], returnTo = null) => {
|
||||
return renderSharedCommentsSection({
|
||||
action: `/bookmarks/${encodeURIComponent(bookmarkId)}/comments`,
|
||||
|
|
@ -83,7 +60,7 @@ const renderTags = (tags) => {
|
|||
: null;
|
||||
};
|
||||
|
||||
const renderBookmarkList = (filteredBookmarks, filter, params = {}) => {
|
||||
const renderBookmarkList = exports.renderBookmarkList = (filteredBookmarks, filter, params = {}) => {
|
||||
const returnTo = buildReturnTo(filter, params);
|
||||
|
||||
return filteredBookmarks.length
|
||||
|
|
@ -97,28 +74,40 @@ const renderBookmarkList = (filteredBookmarks, filter, params = {}) => {
|
|||
: i18n.noLastVisit;
|
||||
|
||||
const urlLink = bookmark.url
|
||||
? a({ href: bookmark.url, target: "_blank", rel: "noreferrer noopener", class: "bookmark-url" }, bookmark.url)
|
||||
? a({ href: safeExternalHref(bookmark.url), target: "_blank", rel: "noreferrer noopener", class: "bookmark-url" }, bookmark.url)
|
||||
: i18n.noUrl;
|
||||
|
||||
const isOwn = bookmark.author && String(bookmark.author) === String(userId);
|
||||
const reachChip = bookmark.tribeOrigin ? renderTribeOriginChip(bookmark.tribeOrigin) : bookmark.clearnet === true ? renderReachChip(true, i18n, clearnetItemHref("bookmarks", bookmark.title || bookmark.url, bookmark.id)) : null;
|
||||
const extraChips = typeof params.titleChips === "function" ? params.titleChips(bookmark).filter(Boolean) : [];
|
||||
const headerActions = typeof params.headerActions === "function"
|
||||
? params.headerActions(bookmark)
|
||||
: bookmark.tribeOrigin
|
||||
? renderContentActions(null, bookmark.tribeOrigin.href)
|
||||
: renderContentActions(bookmark.id, `/bookmarks/${encodeURIComponent(bookmark.id)}`, { spread: (params.spreadMap && params.spreadMap.get(bookmark.id)) || params.spreads || null, author: bookmark.author, favKind: 'bookmarks', isFavorite: bookmark.isFavorite, reportTitle: bookmark.title, deleteAction: isOwn ? contentDeleteAction('bookmark', bookmark.id) : undefined, returnTo });
|
||||
const titleHref = typeof params.headerActions === "function" ? null : bookmark.tribeOrigin ? bookmark.tribeOrigin.href : `/bookmarks/${encodeURIComponent(bookmark.id)}`;
|
||||
const engagement = typeof params.engagement === "function"
|
||||
? params.engagement(bookmark)
|
||||
: bookmark.tribeOrigin ? null : renderEngagement(bookmark.id,
|
||||
renderOpinionsVoting('/bookmarks/opinions', bookmark.id, bookmark.opinions, returnTo, bookmark.opinions_inhabitants),
|
||||
renderCommentsLink({ href: `/bookmarks/${encodeURIComponent(bookmark.id)}`, count: commentCount })
|
||||
);
|
||||
return div(
|
||||
{ class: "trending-card bookmark-card" + (isOwn ? " own-content" : "") },
|
||||
div(
|
||||
{ class: "card-header activity-card-header" },
|
||||
span(),
|
||||
renderContentActions(bookmark.id, `/bookmarks/${encodeURIComponent(bookmark.id)}`, { spread: (params.spreadMap && params.spreadMap.get(bookmark.id)) || params.spreads || null, author: bookmark.author, favKind: 'bookmarks', isFavorite: bookmark.isFavorite, reportTitle: bookmark.title })
|
||||
headerActions
|
||||
),
|
||||
div(
|
||||
{ class: "card-section bookmark-card-body" },
|
||||
h2({ class: "bookmark-title" }, bookmark.url ? urlLink : (bookmark.title || "")),
|
||||
bookmark.lifetime ? div({ class: "card-chips-row" }, renderLifespanChip(bookmark.lifetime, i18n)) : null,
|
||||
bookmark.title && bookmark.url ? p({ class: "bookmark-subtitle" }, bookmark.title) : null,
|
||||
renderCardField(i18n.bookmarkLastVisitLabel + ":", lastVisitTxt),
|
||||
h2({ class: "bookmark-title" }, titleHref ? a({ href: titleHref, class: "card-title-link" }, bookmark.title || bookmark.url || "") : (bookmark.url ? urlLink : (bookmark.title || ""))),
|
||||
bookmark.lifetime || reachChip || extraChips.length ? div({ class: "card-chips-row" }, renderLifespanChip(bookmark.lifetime, i18n), reachChip, ...extraChips) : null,
|
||||
titleHref ? (bookmark.title && bookmark.url ? p({ class: "bookmark-subtitle" }, urlLink) : null) : (bookmark.title && bookmark.url ? p({ class: "bookmark-subtitle" }, bookmark.title) : null),
|
||||
params.hideLastVisit ? null : renderCardField(i18n.bookmarkLastVisitLabel + ":", lastVisitTxt),
|
||||
...(typeof params.bodyExtra === "function" ? params.bodyExtra(bookmark) : []),
|
||||
br,
|
||||
renderEngagement(bookmark.id,
|
||||
renderOpinionsVoting('/bookmarks/opinions', bookmark.id, bookmark.opinions, returnTo, bookmark.opinions_inhabitants),
|
||||
renderCommentsLink({ href: `/bookmarks/${encodeURIComponent(bookmark.id)}`, count: commentCount })
|
||||
),
|
||||
engagement,
|
||||
(() => {
|
||||
const createdTs = bookmark.createdAt ? new Date(bookmark.createdAt).getTime() : NaN;
|
||||
const updatedTs = bookmark.updatedAt ? new Date(bookmark.updatedAt).getTime() : NaN;
|
||||
|
|
@ -126,7 +115,7 @@ const renderBookmarkList = (filteredBookmarks, filter, params = {}) => {
|
|||
|
||||
return p(
|
||||
{ class: "card-footer" },
|
||||
span({ class: "date-link" }, `${moment(bookmark.createdAt).format("YYYY/MM/DD HH:mm")} ${i18n.performed} `),
|
||||
span({ class: "date-link" }, `${moment(bookmark.createdAt).format("YYYY/MM/DD HH:mm")}`),
|
||||
userLink(bookmark.author),
|
||||
showUpdated
|
||||
? span(
|
||||
|
|
@ -199,11 +188,24 @@ const renderBookmarkForm = (filter, bookmarkId, bookmarkToEdit, tags, params = {
|
|||
}),
|
||||
br(),
|
||||
br(),
|
||||
renderClearnetSelector(filter === "edit" ? !!bookmarkToEdit.clearnet : false, i18n),
|
||||
br(),
|
||||
button({ type: "submit" }, filter === "edit" ? i18n.bookmarkUpdateButton : i18n.bookmarkCreateButton)
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
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.bookmarkView = async (bookmarks, filter = "all", bookmarkId = null, params = {}) => {
|
||||
const bookmarkEditWarning = filter === "edit" ? await renderSpreadEditWarning(bookmarkId) : null;
|
||||
const title = i18n.bookmarkTitle;
|
||||
|
|
@ -212,30 +214,28 @@ exports.bookmarkView = async (bookmarks, filter = "all", bookmarkId = null, para
|
|||
const sort = safeText(params.sort || "recent");
|
||||
|
||||
const list = safeArr(bookmarks);
|
||||
const emptyMod = moduleIsEmpty(list, filter, "all", q);
|
||||
const mediaChip = mediaChipFor(filter, Array.isArray(params.censusList) ? params.censusList : list);
|
||||
const bookmarkToEdit = bookmarkId ? list.find((b) => b.id === bookmarkId) : null;
|
||||
const tags = bookmarkToEdit && Array.isArray(bookmarkToEdit.tags) ? bookmarkToEdit.tags : [];
|
||||
|
||||
return template(
|
||||
title,
|
||||
section(
|
||||
div({ class: "tags-header" }, h2(title), p(i18n.bookmarkDescription)),
|
||||
(() => {
|
||||
const { renderReachChip } = require('./clearnet_view');
|
||||
const isClearnet = !!(params.viewerPrefs && params.viewerPrefs.clearnetBookmarks);
|
||||
return div({ class: "shop-title-row" }, renderReachChip(isClearnet, i18n));
|
||||
})(),
|
||||
br(),
|
||||
div({ class: "tags-header module-header-line" }, h2(title), p(i18n.bookmarkDescription)),
|
||||
div(
|
||||
{ class: "filters" },
|
||||
form(
|
||||
{ method: "GET", action: "/bookmarks", 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.bookmarkFilterAll).toUpperCase()),
|
||||
button({ type: "submit", name: "filter", value: "mine", class: filter === "mine" ? "filter-btn active" : "filter-btn" }, String(i18n.bookmarkFilterMine).toUpperCase()),
|
||||
button({ type: "submit", name: "filter", value: "recent", class: filter === "recent" ? "filter-btn active" : "filter-btn" }, String(i18n.bookmarkFilterRecent).toUpperCase()),
|
||||
button({ type: "submit", name: "filter", value: "favorites", class: filter === "favorites" ? "filter-btn active" : "filter-btn" }, String(i18n.bookmarkFilterFavorites).toUpperCase()),
|
||||
button({ type: "submit", name: "filter", value: "top", class: filter === "top" ? "filter-btn active" : "filter-btn" }, String(i18n.bookmarkFilterTop).toUpperCase()),
|
||||
...(mediaChip("recent") ? [button({ type: "submit", name: "filter", value: "recent", class: filter === "recent" ? "filter-btn active" : "filter-btn" }, String(i18n.bookmarkFilterRecent).toUpperCase())] : []),
|
||||
...(mediaChip("mine") ? [button({ type: "submit", name: "filter", value: "mine", class: filter === "mine" ? "filter-btn active" : "filter-btn" }, String(i18n.bookmarkFilterMine).toUpperCase())] : []),
|
||||
...(mediaChip("favorites") ? [button({ type: "submit", name: "filter", value: "favorites", class: filter === "favorites" ? "filter-btn active" : "filter-btn" }, String(i18n.bookmarkFilterFavorites).toUpperCase())] : []),
|
||||
...(mediaChip("top") ? [button({ type: "submit", name: "filter", value: "top", class: filter === "top" ? "filter-btn active" : "filter-btn" }, String(i18n.bookmarkFilterTop).toUpperCase())] : []),
|
||||
]),
|
||||
button({ type: "submit", name: "filter", value: "create", class: "create-button" }, i18n.bookmarkCreateButton)
|
||||
)
|
||||
)
|
||||
|
|
@ -244,8 +244,9 @@ exports.bookmarkView = async (bookmarks, filter = "all", bookmarkId = null, para
|
|||
filter === "edit" || filter === "create"
|
||||
? renderBookmarkForm(filter, bookmarkId, bookmarkToEdit || {}, tags, { ...params, filter, spreadWarning: bookmarkEditWarning })
|
||||
: section(
|
||||
div(
|
||||
{ class: "bookmarks-search" },
|
||||
emptyMod ? null : div(
|
||||
{ class: "bookmarks-search activity-filter-chips activity-toolbar-row" },
|
||||
renderModuleStats(list.length),
|
||||
form(
|
||||
{ method: "GET", action: "/bookmarks", class: "filter-box" },
|
||||
input({ type: "hidden", name: "filter", value: filter }),
|
||||
|
|
@ -262,21 +263,21 @@ exports.bookmarkView = async (bookmarks, filter = "all", bookmarkId = null, para
|
|||
)
|
||||
)
|
||||
),
|
||||
div({ class: "bookmark-list" }, renderBookmarkList(list, filter, { q, sort }))
|
||||
div({ class: "bookmark-list" }, renderBookmarkList(paged(list), filter, { q, sort, spreadMap: params.spreadMap }))
|
||||
)
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
exports.singleBookmarkView = async (bookmark, 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 = params.returnTo || buildReturnTo(filter, { q, sort });
|
||||
|
||||
const isAuthor = String(bookmark.author) === String(userId);
|
||||
const hasOpinions = Object.keys(bookmark.opinions || {}).length > 0;
|
||||
const { renderReachChip } = require('./clearnet_view');
|
||||
const isClearnet = !!(params.authorPrefs && params.authorPrefs.clearnetBookmarks);
|
||||
const isClearnet = !!bookmark.clearnet;
|
||||
|
||||
const lastVisit = bookmark.lastVisit ? moment(bookmark.lastVisit) : null;
|
||||
const lastVisitTxt =
|
||||
|
|
@ -285,7 +286,7 @@ exports.singleBookmarkView = async (bookmark, filter = "all", comments = [], par
|
|||
: i18n.noLastVisit;
|
||||
|
||||
const urlLink = bookmark.url
|
||||
? a({ href: bookmark.url, target: "_blank", rel: "noreferrer noopener", class: "bookmark-url" }, bookmark.url)
|
||||
? a({ href: safeExternalHref(bookmark.url), target: "_blank", rel: "noreferrer noopener", class: "bookmark-url" }, bookmark.url)
|
||||
: i18n.noUrl;
|
||||
|
||||
const chips = [
|
||||
|
|
@ -302,36 +303,31 @@ exports.singleBookmarkView = async (bookmark, filter = "all", comments = [], par
|
|||
button({ class: "update-btn", type: "submit" }, i18n.bookmarkUpdateButton)
|
||||
));
|
||||
}
|
||||
if (isAuthor) {
|
||||
sideActions.push(form(
|
||||
{ method: "POST", action: `/bookmarks/delete/${encodeURIComponent(bookmark.id)}` },
|
||||
input({ type: "hidden", name: "returnTo", value: returnTo }),
|
||||
button({ class: "delete-btn", type: "submit" }, i18n.bookmarkDeleteButton)
|
||||
));
|
||||
}
|
||||
|
||||
const tagsNode = renderTags(bookmark.tags);
|
||||
|
||||
const detailActions = div({ class: "card-header activity-card-header" },
|
||||
renderContentActions(bookmark.id, null, {
|
||||
renderContentActions(bookmark.id, `/bookmarks/${encodeURIComponent(bookmark.id)}`, {
|
||||
author: bookmark.author,
|
||||
favKind: 'bookmarks',
|
||||
isFavorite: bookmark.isFavorite,
|
||||
spread: params.spreads || null,
|
||||
returnTo,
|
||||
reportTitle: bookmark.title
|
||||
reportTitle: bookmark.title,
|
||||
deleteAction: isAuthor ? contentDeleteAction('bookmark', bookmark.id) : undefined
|
||||
})
|
||||
);
|
||||
|
||||
const bookmarkSide = div({ class: "tribe-side" },
|
||||
div({ class: "shop-title-row" },
|
||||
h2({ class: "tribe-card-title" }, bookmark.url ? urlLink : (bookmark.title || "")),
|
||||
renderReachChip(isClearnet, i18n)
|
||||
renderReachChip(isClearnet, i18n, isClearnet ? clearnetItemHref("bookmarks", bookmark.title || bookmark.url, bookmark.id) : null)
|
||||
),
|
||||
isAuthor ? renderClearnetSwitch("bookmarks", bookmark.rootId || bookmark.id, isClearnet) : null,
|
||||
bookmark.title && bookmark.url ? p({ class: "bookmark-subtitle" }, bookmark.title) : null,
|
||||
chips.length ? div({ class: "card-chips-row" }, ...chips) : null,
|
||||
safeText(bookmark.description)
|
||||
? p({ class: "tribe-side-description" }, ...renderUrl(bookmark.description))
|
||||
? p({ class: "tribe-side-description" }, ...renderStyledText(bookmark.description))
|
||||
: null,
|
||||
tagsNode,
|
||||
sideActions.length ? div({ class: "tribe-side-actions" }, ...sideActions) : null
|
||||
|
|
@ -346,7 +342,7 @@ exports.singleBookmarkView = async (bookmark, filter = "all", comments = [], par
|
|||
const showUpdated = Number.isFinite(updatedTs) && (!Number.isFinite(createdTs) || updatedTs !== createdTs);
|
||||
return p(
|
||||
{ class: "card-footer" },
|
||||
span({ class: "date-link" }, `${moment(bookmark.createdAt).format("YYYY/MM/DD HH:mm")} ${i18n.performed} `),
|
||||
span({ class: "date-link" }, `${moment(bookmark.createdAt).format("YYYY/MM/DD HH:mm")}`),
|
||||
userLink(bookmark.author),
|
||||
showUpdated
|
||||
? span(
|
||||
|
|
@ -365,7 +361,7 @@ exports.singleBookmarkView = async (bookmark, filter = "all", comments = [], par
|
|||
return template(
|
||||
i18n.bookmarkTitle,
|
||||
section(
|
||||
div({ class: "tags-header" },
|
||||
div({ class: "tags-header module-header-line" },
|
||||
h2(i18n.bookmarkAllSectionTitle || i18n.bookmarkTitle),
|
||||
p(i18n.bookmarkDescription)
|
||||
),
|
||||
|
|
@ -376,9 +372,9 @@ exports.singleBookmarkView = async (bookmark, filter = "all", comments = [], par
|
|||
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.bookmarkFilterAll).toUpperCase()),
|
||||
button({ type: "submit", name: "filter", value: "mine", class: filter === "mine" ? "filter-btn active" : "filter-btn" }, String(i18n.bookmarkFilterMine).toUpperCase()),
|
||||
button({ type: "submit", name: "filter", value: "recent", class: filter === "recent" ? "filter-btn active" : "filter-btn" }, String(i18n.bookmarkFilterRecent).toUpperCase()),
|
||||
button({ type: "submit", name: "filter", value: "favorites", class: filter === "favorites" ? "filter-btn active" : "filter-btn" }, String(i18n.bookmarkFilterFavorites).toUpperCase()),
|
||||
...(mediaChip("recent") ? [button({ type: "submit", name: "filter", value: "recent", class: filter === "recent" ? "filter-btn active" : "filter-btn" }, String(i18n.bookmarkFilterRecent).toUpperCase())] : []),
|
||||
...(mediaChip("mine") ? [button({ type: "submit", name: "filter", value: "mine", class: filter === "mine" ? "filter-btn active" : "filter-btn" }, String(i18n.bookmarkFilterMine).toUpperCase())] : []),
|
||||
...(mediaChip("favorites") ? [button({ type: "submit", name: "filter", value: "favorites", class: filter === "favorites" ? "filter-btn active" : "filter-btn" }, String(i18n.bookmarkFilterFavorites).toUpperCase())] : []),
|
||||
button({ type: "submit", name: "filter", value: "top", class: filter === "top" ? "filter-btn active" : "filter-btn" }, String(i18n.bookmarkFilterTop).toUpperCase()),
|
||||
button({ type: "submit", name: "filter", value: "create", class: "create-button" }, i18n.bookmarkCreateButton)
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue