Change default avatar, add default header

merge-requests/1109/head
Alex Gleason 2022-03-17 15:21:55 -05:00
rodzic 7c6c373eb2
commit 19e8751178
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
5 zmienionych plików z 48 dodań i 109 usunięć

Plik binarny nie jest wyświetlany.

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 14 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 4.0 KiB

Wyświetl plik

@ -1,116 +1,30 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
inkscape:export-ydpi="240"
inkscape:export-xdpi="240"
inkscape:export-filename="/home/alex/Projects/docker-tribe/avi.png"
sodipodi:docname="avatar.svg"
width="120"
height="120"
viewBox="0 0 31.75 31.750001"
height="100px"
width="100px"
fill="#000000"
version="1.1"
id="svg8"
inkscape:version="1.1.1 (3bf5ae0d25, 2021-09-20)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
x="0px"
y="0px"
viewBox="0 0 95 95"
enable-background="new 0 0 95 95"
xml:space="preserve"
id="svg4"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<defs
id="defs2" />
<sodipodi:namedview
inkscape:window-maximized="1"
inkscape:window-y="30"
inkscape:window-x="0"
inkscape:window-height="1019"
inkscape:window-width="1920"
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="4.3194033"
inkscape:cx="79.987899"
inkscape:cy="64.129228"
inkscape:document-units="px"
inkscape:current-layer="layer1"
inkscape:document-rotation="0"
showgrid="false"
units="px"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0"
inkscape:snap-bbox="true"
inkscape:object-paths="true"
inkscape:snap-intersection-paths="true"
inkscape:snap-smooth-nodes="true"
inkscape:snap-midpoints="true"
inkscape:snap-object-midpoints="true"
inkscape:snap-center="true"
inkscape:snap-global="false"
inkscape:pagecheckerboard="0" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0.80272198,1.2346106)">
<rect
style="fill:#10b3d1;fill-opacity:1;stroke:none;stroke-width:1.53052;stroke-miterlimit:4;stroke-dasharray:none"
id="rect853"
width="31.75"
height="31.75"
x="-0.80272198"
y="-1.2346106" />
<path
id="path857"
style="fill:#f4962a;fill-opacity:1;stroke:#000000;stroke-width:1.48265;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 15.051525,3.9344041 A 10.434797,10.434797 0 0 0 4.6372555,14.368944 a 10.434797,10.434797 0 0 0 0,0.02075 v 0.03137 a 1.7839264,2.3625556 0 0 0 -0.9503056,-0.363423 1.7839264,2.3625556 0 0 0 -1.7838141,2.362493 1.7839264,2.3625556 0 0 0 1.7838141,2.362491 1.7839264,2.3625556 0 0 0 0.9503056,-0.363423 v 23.74268 H 25.507302 v -23.74268 a 1.7839264,2.3625556 0 0 0 0.950305,0.363423 1.7839264,2.3625556 0 0 0 1.783814,-2.362491 1.7839264,2.3625556 0 0 0 -1.783814,-2.362493 1.7839264,2.3625556 0 0 0 -0.950305,0.362941 v -0.05164 A 10.434797,10.434797 0 0 0 15.072278,3.9344041 a 10.434797,10.434797 0 0 0 -0.02075,0 z" />
<circle
style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.900495;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path881-6"
cx="11.218504"
cy="13.292331"
r="1.3086123" />
<circle
style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.900495;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path881-7"
cx="18.926052"
cy="13.292331"
r="1.3086123" />
<ellipse
style="fill:#f2f2f2;fill-opacity:1;stroke:#000000;stroke-width:0.88959;stroke-miterlimit:4;stroke-dasharray:none"
id="path917"
cx="15.072279"
cy="18.343904"
rx="7.1666903"
ry="4.0659413" />
<path
id="path957"
style="fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.88959;stroke-miterlimit:4;stroke-dasharray:none"
d="m 21.900069,17.108362 a 7.1666903,4.0659412 0 0 1 -6.82779,2.8304 7.1666903,4.0659412 0 0 1 -6.8277959,-2.830413" />
<path
id="path1003"
style="fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.88959;stroke-miterlimit:4;stroke-dasharray:none"
inkscape:transform-center-y="-0.79831289"
d="m 13.062455,16.997512 c 0.457808,-1.227486 1.336486,-2.475611 2.009822,-2.475611 0.673338,0 1.552013,1.248125 2.009824,2.475611" />
<path
style="fill:none;stroke:#000000;stroke-width:0.79375;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 24.842957,6.3249745 c -1.070225,-0.4344716 -2.309802,0.1182843 -2.464817,1.0590207 0,0 -1.627232,-1.9230616 1.219705,-3.5847621"
id="path1030"
sodipodi:nodetypes="ccc" />
</g>
</svg>
xmlns:dc="http://purl.org/dc/elements/1.1/"><metadata
id="metadata10"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><defs
id="defs8" /><rect
style="opacity:1;vector-effect:none;fill:#f2f2f2;fill-opacity:1;stroke:none;stroke-width:3.79999995;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect819"
width="95"
height="95"
x="0"
y="0" /><path
d="m 74.797528,31.305083 c 0,-6.160943 -4.994325,-11.155269 -11.155268,-11.155269 -6.130227,0 -11.101359,4.946683 -11.150255,11.064999 l -9.000067,1.203603 c -1.129004,-3.458478 -4.374972,-5.95909 -8.209576,-5.95909 -4.769905,0 -8.637734,3.867202 -8.637734,8.637734 0,3.824574 2.488074,7.063018 5.932134,8.198919 l -1.269425,9.24455 c -6.137749,0.02821 -11.103865,5.009371 -11.103865,11.152762 0,6.160942 4.994325,11.155895 11.155268,11.155895 6.147779,0 11.130822,-4.973638 11.152762,-11.115149 l 10.417436,-1.439935 c 1.139662,3.438419 4.374972,5.922103 8.195786,5.922103 4.769903,0 8.637732,-3.867202 8.637732,-8.637733 0,-3.967502 -2.678644,-7.301859 -6.323932,-8.314891 l 0.786104,-8.832065 c 5.889506,-0.305288 10.5729,-5.16233 10.5729,-11.126433 z M 52.506424,59.187928 42.075823,60.630371 c -1.05566,-3.697944 -3.965621,-6.6054 -7.66482,-7.657925 l 1.269425,-9.257087 c 4.440795,-0.203734 7.998945,-3.751856 8.216472,-8.18889 l 9.013859,-1.205483 c 1.090765,3.890396 4.23267,6.91445 8.19077,7.837838 l -0.786104,8.822035 c -4.26088,0.396186 -7.614044,3.888516 -7.809001,8.207069 z"
id="path2"
style="fill:#0482d8;fill-opacity:1;stroke-width:0.62687665;opacity:0.3" /></svg>

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 4.8 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 2.2 KiB

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 81 B

Wyświetl plik

@ -3,6 +3,7 @@ import { Record as ImmutableRecord, fromJS } from 'immutable';
import { normalizeAccount } from '../account';
const AVATAR_MISSING = require('images/avatar-missing.png');
const HEADER_MISSING = require('images/header-missing.png');
describe('normalizeAccount()', () => {
it('adds base fields', () => {
@ -13,6 +14,7 @@ describe('normalizeAccount()', () => {
expect(result.acct).toEqual('');
expect(result.note).toEqual('');
expect(result.avatar).toEqual(AVATAR_MISSING);
expect(result.header_static).toEqual(HEADER_MISSING);
});
it('normalizes a mention', () => {
@ -149,4 +151,14 @@ describe('normalizeAccount()', () => {
expect(field.value_emojified).toBe('<a href="https://soapbox.pub" rel="ugc">https://soapbox.pub</a> <img draggable="false" class="emojione" alt=":soapbox:" title=":soapbox:" src="https://gleasonator.com/emoji/Gleasonator/soapbox.png" />');
expect(field.value_plain).toBe('https://soapbox.pub :soapbox:');
});
it('adds default avatar and banner to GoToSocial account', () => {
const account = require('soapbox/__fixtures__/gotosocial-account.json');
const result = normalizeAccount(account);
expect(result.avatar).toEqual(AVATAR_MISSING);
expect(result.avatar_static).toEqual(AVATAR_MISSING);
expect(result.header).toEqual(HEADER_MISSING);
expect(result.header_static).toEqual(HEADER_MISSING);
});
});

Wyświetl plik

@ -97,6 +97,18 @@ const normalizeAvatar = (account: ImmutableMap<string, any>) => {
});
};
// Add header, if missing
const normalizeHeader = (account: ImmutableMap<string, any>) => {
const header = account.get('header');
const headerStatic = account.get('header_static');
const missing = require('images/header-missing.png');
return account.withMutations(account => {
account.set('header', header || headerStatic || missing);
account.set('header_static', headerStatic || header || missing);
});
};
// Normalize custom fields
const normalizeFields = (account: ImmutableMap<string, any>) => {
return account.update('fields', ImmutableList(), fields => fields.map(FieldRecord));
@ -189,6 +201,7 @@ export const normalizeAccount = (account: Record<string, any>): IAccount => {
normalizePleromaLegacyFields(account);
normalizeEmojis(account);
normalizeAvatar(account);
normalizeHeader(account);
normalizeFields(account);
normalizeVerified(account);
normalizeBirthday(account);