diff --git a/api/src/api/accounts.js b/api/src/api/accounts.js index 1e20b13..107f238 100644 --- a/api/src/api/accounts.js +++ b/api/src/api/accounts.js @@ -21,6 +21,29 @@ const ATTACHMENTS = { return v.substr(0, 30) return v }, + fedilove_pcolors: (v) => { + let colors + v = v.replaceAll(/<[^<>]+>/g, '').trim() + if (v === '') + return {} + if (v.includes(',')) + colors = v.split(',') + else colors = [v] + if (colors.length > 2) + colors.splice(2) + for (var i = colors.length -1; i >= 0; i--) { + colors[i] = colors[i].trim() + if (!colors[i].match(/^#?[a-zA-Z0-9]{3,16}$/)) { + delete colors[i] + continue + } + } + if (colors.length === 2) + return { bg: colors[0], fg: colors[1] } + if (colors.length === 1) + return { bg: colors[0] } + return {} + }, } diff --git a/web/src/_templates/app/js.php b/web/src/_templates/app/js.php index 8919e91..2e9cd12 100644 --- a/web/src/_templates/app/js.php +++ b/web/src/_templates/app/js.php @@ -13,7 +13,10 @@ var app = { defaults: { icon: '/assets/images/default_profile.png', meet: { - text_bgcolor: '#93227ce8', + item_pcolors: { + bg: '#93227ce8', + fg: '#fff', + }, }, }, }, diff --git a/web/src/app/js/pages/meet.js b/web/src/app/js/pages/meet.js index a7d255a..cd489a7 100644 --- a/web/src/app/js/pages/meet.js +++ b/web/src/app/js/pages/meet.js @@ -16,11 +16,23 @@ app.pages.meet = { if (k === 'date') return dayjs(v).fromNow(true); }); var item = json[i]; - var textClr = item.text_color; - if (textClr === undefined) - textClr = app.vars.defaults.meet.text_bgcolor; + if (item.props === undefined) + item.props = { pcolors: {} } + if (item.account.props.pcolors === undefined) + item.account.props.pcolors = {}; + + var postFgColor = item.account.props.pcolors.fg + || app.vars.defaults.meet.item_pcolors.fg; + var postBgColor = item.account.props.pcolors.bg + || app.vars.defaults.meet.item_pcolors.bg; + if (item.props.pcolors.fg !== undefined) + postFgColor = item.props.pcolors.fg; + if (item.props.pcolors.bg !== undefined) + postBgColor = item.props.pcolors.bg; + tpl = tpl.replaceAll('{actionsHeight}', '6em'); - tpl = tpl.replaceAll('{textColor}', htmlescape(textClr)); + tpl = tpl.replaceAll('{postFgColor}', htmlescape(postFgColor)); + tpl = tpl.replaceAll('{postBgColor}', htmlescape(postBgColor)); dom.innerHTML += tpl; } }; _(); diff --git a/web/src/app/js/templates/meet/item.html b/web/src/app/js/templates/meet/item.html index 5e8e818..19c04b8 100644 --- a/web/src/app/js/templates/meet/item.html +++ b/web/src/app/js/templates/meet/item.html @@ -21,8 +21,10 @@
-

{.text}

+ style="background: {postBgColor};"> +
+

{.text}

+