2023-05-28 09:38:10 -05:00
import PropTypes from 'prop-types' ;
2023-05-28 07:18:23 -05:00
import { PureComponent } from 'react' ;
2023-05-28 09:38:10 -05:00
2022-10-13 07:42:37 -05:00
import { defineMessages , injectIntl , FormattedMessage } from 'react-intl' ;
2023-05-28 09:38:10 -05:00
import classNames from 'classnames' ;
2022-10-04 13:13:23 -05:00
import { Helmet } from 'react-helmet' ;
2023-05-28 09:38:10 -05:00
import ImmutablePropTypes from 'react-immutable-proptypes' ;
import { connect } from 'react-redux' ;
2022-10-13 07:42:37 -05:00
import { fetchServer , fetchExtendedDescription , fetchDomainBlocks } from 'flavours/glitch/actions/server' ;
2023-05-28 09:38:10 -05:00
import Column from 'flavours/glitch/components/column' ;
2023-05-08 20:11:56 -05:00
import { Icon } from 'flavours/glitch/components/icon' ;
2023-05-09 16:08:28 -05:00
import { ServerHeroImage } from 'flavours/glitch/components/server_hero_image' ;
2023-05-28 09:38:10 -05:00
import { Skeleton } from 'flavours/glitch/components/skeleton' ;
import Account from 'flavours/glitch/containers/account_container' ;
import LinkFooter from 'flavours/glitch/features/ui/components/link_footer' ;
2022-10-04 13:13:23 -05:00
const messages = defineMessages ( {
title : { id : 'column.about' , defaultMessage : 'About' } ,
2022-10-13 07:42:37 -05:00
rules : { id : 'about.rules' , defaultMessage : 'Server rules' } ,
blocks : { id : 'about.blocks' , defaultMessage : 'Moderated servers' } ,
silenced : { id : 'about.domain_blocks.silenced.title' , defaultMessage : 'Limited' } ,
silencedExplanation : { id : 'about.domain_blocks.silenced.explanation' , defaultMessage : 'You will generally not see profiles and content from this server, unless you explicitly look it up or opt into it by following.' } ,
suspended : { id : 'about.domain_blocks.suspended.title' , defaultMessage : 'Suspended' } ,
suspendedExplanation : { id : 'about.domain_blocks.suspended.explanation' , defaultMessage : 'No data from this server will be processed, stored or exchanged, making any interaction or communication with users from this server impossible.' } ,
2022-10-04 13:13:23 -05:00
} ) ;
2022-10-13 07:42:37 -05:00
const severityMessages = {
silence : {
title : messages . silenced ,
explanation : messages . silencedExplanation ,
} ,
suspend : {
title : messages . suspended ,
explanation : messages . suspendedExplanation ,
} ,
} ;
const mapStateToProps = state => ( {
server : state . getIn ( [ 'server' , 'server' ] ) ,
extendedDescription : state . getIn ( [ 'server' , 'extendedDescription' ] ) ,
domainBlocks : state . getIn ( [ 'server' , 'domainBlocks' ] ) ,
} ) ;
2023-05-28 07:18:23 -05:00
class Section extends PureComponent {
2022-10-13 07:42:37 -05:00
static propTypes = {
title : PropTypes . string ,
children : PropTypes . node ,
open : PropTypes . bool ,
onOpen : PropTypes . func ,
} ;
state = {
collapsed : ! this . props . open ,
} ;
handleClick = ( ) => {
const { onOpen } = this . props ;
const { collapsed } = this . state ;
this . setState ( { collapsed : ! collapsed } , ( ) => onOpen && onOpen ( ) ) ;
2023-02-03 13:52:07 -06:00
} ;
2022-10-13 07:42:37 -05:00
render ( ) {
const { title , children } = this . props ;
const { collapsed } = this . state ;
return (
< div className = { classNames ( 'about__section' , { active : ! collapsed } ) } >
2023-04-04 09:33:44 -05:00
< div className = 'about__section__title' role = 'button' tabIndex = { 0 } onClick = { this . handleClick } >
2022-10-13 07:42:37 -05:00
< Icon id = { collapsed ? 'chevron-right' : 'chevron-down' } fixedWidth / > { title }
< / div >
{ ! collapsed && (
< div className = 'about__section__body' > { children } < / div >
) }
< / div >
) ;
}
}
2023-05-28 07:18:23 -05:00
class About extends PureComponent {
2022-10-04 13:13:23 -05:00
static propTypes = {
2022-10-13 07:42:37 -05:00
server : ImmutablePropTypes . map ,
extendedDescription : ImmutablePropTypes . map ,
domainBlocks : ImmutablePropTypes . contains ( {
isLoading : PropTypes . bool ,
isAvailable : PropTypes . bool ,
items : ImmutablePropTypes . list ,
} ) ,
dispatch : PropTypes . func . isRequired ,
2022-10-04 13:13:23 -05:00
intl : PropTypes . object . isRequired ,
2022-10-20 07:35:29 -05:00
multiColumn : PropTypes . bool ,
2022-10-04 13:13:23 -05:00
} ;
2022-10-13 07:42:37 -05:00
componentDidMount ( ) {
const { dispatch } = this . props ;
dispatch ( fetchServer ( ) ) ;
dispatch ( fetchExtendedDescription ( ) ) ;
}
handleDomainBlocksOpen = ( ) => {
const { dispatch } = this . props ;
dispatch ( fetchDomainBlocks ( ) ) ;
2023-02-03 13:52:07 -06:00
} ;
2022-10-13 07:42:37 -05:00
2022-10-04 13:13:23 -05:00
render ( ) {
2022-10-20 07:35:29 -05:00
const { multiColumn , intl , server , extendedDescription , domainBlocks } = this . props ;
2022-10-13 07:42:37 -05:00
const isLoading = server . get ( 'isLoading' ) ;
2022-10-04 13:13:23 -05:00
return (
2022-10-20 07:35:29 -05:00
< Column bindToDocument = { ! multiColumn } label = { intl . formatMessage ( messages . title ) } >
2022-10-13 07:42:37 -05:00
< div className = 'scrollable about' >
< div className = 'about__header' >
2023-05-09 16:08:28 -05:00
< ServerHeroImage blurhash = { server . getIn ( [ 'thumbnail' , 'blurhash' ] ) } src = { server . getIn ( [ 'thumbnail' , 'url' ] ) } srcSet = { server . getIn ( [ 'thumbnail' , 'versions' ] ) ? . map ( ( value , key ) => ` ${ value } ${ key . replace ( '@' , '' ) } ` ) . join ( ', ' ) } className = 'about__header__hero' / >
2022-10-13 07:42:37 -05:00
< h1 > { isLoading ? < Skeleton width = '10ch' / > : server . get ( 'domain' ) } < / h1 >
< p > < FormattedMessage id = 'about.powered_by' defaultMessage = 'Decentralized social media powered by {mastodon}' values = { { mastodon : < a href = 'https://joinmastodon.org' className = 'about__mail' target = '_blank' > Mastodon < / a > } } / > < / p >
< / div >
< div className = 'about__meta' >
< div className = 'about__meta__column' >
< h4 > < FormattedMessage id = 'server_banner.administered_by' defaultMessage = 'Administered by:' / > < / h4 >
2022-10-31 07:06:17 -05:00
< Account id = { server . getIn ( [ 'contact' , 'account' , 'id' ] ) } size = { 36 } / >
2022-10-13 07:42:37 -05:00
< / div >
< hr className = 'about__meta__divider' / >
< div className = 'about__meta__column' >
< h4 > < FormattedMessage id = 'about.contact' defaultMessage = 'Contact:' / > < / h4 >
{ isLoading ? < Skeleton width = '10ch' / > : < a className = 'about__mail' href = { ` mailto: ${ server . getIn ( [ 'contact' , 'email' ] ) } ` } > { server . getIn ( [ 'contact' , 'email' ] ) } < / a > }
< / div >
< / div >
< Section open title = { intl . formatMessage ( messages . title ) } >
{ extendedDescription . get ( 'isLoading' ) ? (
< >
< Skeleton width = '100%' / >
< br / >
< Skeleton width = '100%' / >
< br / >
< Skeleton width = '100%' / >
< br / >
< Skeleton width = '70%' / >
< / >
) : ( extendedDescription . get ( 'content' ) ? . length > 0 ? (
< div
className = 'prose'
dangerouslySetInnerHTML = { { _ _html : extendedDescription . get ( 'content' ) } }
/ >
) : (
< p > < FormattedMessage id = 'about.not_available' defaultMessage = 'This information has not been made available on this server.' / > < / p >
) ) }
< / Section >
< Section title = { intl . formatMessage ( messages . rules ) } >
2023-07-02 04:12:16 -05:00
{ ! isLoading && ( server . get ( 'rules' , [ ] ) . isEmpty ( ) ? (
2022-10-13 07:42:37 -05:00
< p > < FormattedMessage id = 'about.not_available' defaultMessage = 'This information has not been made available on this server.' / > < / p >
) : (
< ol className = 'rules-list' >
{ server . get ( 'rules' ) . map ( rule => (
< li key = { rule . get ( 'id' ) } >
< span className = 'rules-list__text' > { rule . get ( 'text' ) } < / span >
< / li >
) ) }
< / ol >
) ) }
< / Section >
< Section title = { intl . formatMessage ( messages . blocks ) } onOpen = { this . handleDomainBlocksOpen } >
{ domainBlocks . get ( 'isLoading' ) ? (
< >
< Skeleton width = '100%' / >
< br / >
< Skeleton width = '70%' / >
< / >
) : ( domainBlocks . get ( 'isAvailable' ) ? (
< >
< p > < FormattedMessage id = 'about.domain_blocks.preamble' defaultMessage = 'Mastodon generally allows you to view content from and interact with users from any other server in the fediverse. These are the exceptions that have been made on this particular server.' / > < / p >
2022-11-11 01:26:58 -06:00
< div className = 'about__domain-blocks' >
{ domainBlocks . get ( 'items' ) . map ( block => (
< div className = 'about__domain-blocks__domain' key = { block . get ( 'domain' ) } >
< div className = 'about__domain-blocks__domain__header' >
< h6 > < span title = { ` SHA-256: ${ block . get ( 'digest' ) } ` } > { block . get ( 'domain' ) } < / span > < / h6 >
< span className = 'about__domain-blocks__domain__type' title = { intl . formatMessage ( severityMessages [ block . get ( 'severity' ) ] . explanation ) } > { intl . formatMessage ( severityMessages [ block . get ( 'severity' ) ] . title ) } < / span >
< / div >
2022-11-11 14:23:03 -06:00
< p > { ( block . get ( 'comment' ) || '' ) . length > 0 ? block . get ( 'comment' ) : < FormattedMessage id = 'about.domain_blocks.no_reason_available' defaultMessage = 'Reason not available' / > } < / p >
2022-11-11 01:26:58 -06:00
< / div >
) ) }
< / div >
2022-10-13 07:42:37 -05:00
< / >
) : (
< p > < FormattedMessage id = 'about.not_available' defaultMessage = 'This information has not been made available on this server.' / > < / p >
) ) }
< / Section >
< LinkFooter / >
2022-10-31 07:06:17 -05:00
< div className = 'about__footer' >
< p > < FormattedMessage id = 'about.fork_disclaimer' defaultMessage = 'Glitch-soc is free open source software forked from Mastodon.' / > < / p >
< p > < FormattedMessage id = 'about.disclaimer' defaultMessage = 'Mastodon is free, open-source software, and a trademark of Mastodon gGmbH.' / > < / p >
< / div >
2022-10-13 07:42:37 -05:00
< / div >
2022-10-04 13:13:23 -05:00
< Helmet >
2022-10-08 23:08:37 -05:00
< title > { intl . formatMessage ( messages . title ) } < / title >
2022-10-20 07:35:29 -05:00
< meta name = 'robots' content = 'all' / >
2022-10-04 13:13:23 -05:00
< / Helmet >
< / Column >
) ;
}
}
2023-03-24 17:15:25 -05:00
export default connect ( mapStateToProps ) ( injectIntl ( About ) ) ;