Skip to content

Commit

Permalink
move account_css to account header component, fix css change on navig…
Browse files Browse the repository at this point in the history
…ation
  • Loading branch information
sneakers-the-rat committed Sep 1, 2024
1 parent 033d0ab commit 45fb596
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 8 deletions.
1 change: 1 addition & 0 deletions app/javascript/flavours/glitch/api_types/accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@ export interface ApiAccountJSON {
limited?: boolean;
memorial?: boolean;
hide_collections: boolean;
account_css?: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import PropTypes from 'prop-types';
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';

import classNames from 'classnames';
import { Helmet } from 'react-helmet';
import { withRouter } from 'react-router-dom';
import {Helmet} from 'react-helmet';
import {withRouter} from 'react-router-dom';

import ImmutablePropTypes from 'react-immutable-proptypes';
import ImmutablePureComponent from 'react-immutable-pure-component';
Expand Down Expand Up @@ -405,6 +405,11 @@ class Header extends ImmutablePureComponent {
<title>{titleFromAccount(account)}</title>
<meta name='robots' content={(isLocal && isIndexable) ? 'all' : 'noindex'} />
<link rel='canonical' href={account.get('url')} />
{account.account_css && (
<style id={"account-css"} nonce={document.querySelector('meta[name=style-nonce]').content}>
{account.account_css}
</style>
)}
</Helmet>
</div>
);
Expand Down
39 changes: 38 additions & 1 deletion app/javascript/flavours/glitch/models/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,43 @@ export interface AccountShape

export type Account = RecordOf<AccountShape>;

export const accountDefaultValues: AccountShape = {
export const accountDefaultValues: {
note: string;
hidden: boolean;
bot: boolean;
roles: Immutable.List<AccountRole>;
moved: null;
indexable: boolean;
created_at: string;
header_static: string;
account_css: string;
hide_collections: boolean;
id: string;
memorial: boolean;
locked: boolean;
display_name_html: string;
group: boolean;
emojis: Immutable.List<CustomEmoji>;
noindex: boolean;
limited: boolean;
avatar: string;
display_name: string;
note_plain: string;
uri: string;
url: string;
suspended: boolean;
following_count: number;
discoverable: boolean;
last_status_at: string;
statuses_count: number;
followers_count: number;
note_emojified: string;
header: string;
avatar_static: string;
fields: Immutable.List<AccountField>;
acct: string;
username: string;
} = {
acct: '',
avatar: '',
avatar_static: '',
Expand Down Expand Up @@ -95,6 +131,7 @@ export const accountDefaultValues: AccountShape = {
limited: false,
moved: null,
hide_collections: false,
account_css: '',
};

const AccountFactory = ImmutableRecord<AccountShape>(accountDefaultValues);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#account_account_css {
font-family: $font-monospace;
height: 15em;
}
3 changes: 2 additions & 1 deletion app/serializers/rest/account_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ class REST::AccountSerializer < ActiveModel::Serializer

attributes :id, :username, :acct, :display_name, :locked, :bot, :discoverable, :indexable, :group, :created_at,
:note, :url, :uri, :avatar, :avatar_static, :header, :header_static,
:followers_count, :following_count, :statuses_count, :last_status_at, :hide_collections
:followers_count, :following_count, :statuses_count, :last_status_at, :hide_collections,
:account_css

has_one :moved_to_account, key: :moved, serializer: REST::AccountSerializer, if: :moved_and_not_nested?

Expand Down
4 changes: 0 additions & 4 deletions app/views/accounts/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@
- @account.fields.select(&:verifiable?).each do |field|
%link{ rel: 'me', type: 'text/html', href: field.value }/

- if @account.account_css?
%style{ nonce: request.content_security_policy_nonce }
= @account.account_css

= opengraph 'og:type', 'profile'
= render 'og', account: @account, url: short_account_url(@account, only_path: false)

Expand Down

0 comments on commit 45fb596

Please sign in to comment.