About Page support
This commit is contained in:
parent
6c698acef0
commit
6813f512e6
7 changed files with 61 additions and 1 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -5,5 +5,5 @@
|
||||||
/coverage/
|
/coverage/
|
||||||
/.eslintcache
|
/.eslintcache
|
||||||
/.env
|
/.env
|
||||||
/public/soapbox/soapbox.json
|
/public/soapbox
|
||||||
/deploy.sh
|
/deploy.sh
|
||||||
|
|
13
app/gabsocial/actions/about.js
Normal file
13
app/gabsocial/actions/about.js
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
import api from '../api';
|
||||||
|
|
||||||
|
export const FETCH_ABOUT_PAGE_REQUEST = 'FETCH_ABOUT_PAGE_REQUEST';
|
||||||
|
export const FETCH_ABOUT_PAGE_FAIL = 'FETCH_ABOUT_PAGE_FAIL';
|
||||||
|
|
||||||
|
export function fetchAboutPage(slug = 'index') {
|
||||||
|
return (dispatch, getState) => {
|
||||||
|
dispatch({ type: FETCH_ABOUT_PAGE_REQUEST, slug });
|
||||||
|
return api(getState).get(`/soapbox/about/${slug}.html`).catch(error => {
|
||||||
|
dispatch({ type: FETCH_ABOUT_PAGE_FAIL, slug });
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
|
@ -21,6 +21,7 @@ import { fetchInstance } from 'gabsocial/actions/instance';
|
||||||
import { fetchSoapboxConfig } from 'gabsocial/actions/soapbox';
|
import { fetchSoapboxConfig } from 'gabsocial/actions/soapbox';
|
||||||
import { fetchMe } from 'gabsocial/actions/me';
|
import { fetchMe } from 'gabsocial/actions/me';
|
||||||
import LandingPage from 'gabsocial/features/landing_page';
|
import LandingPage from 'gabsocial/features/landing_page';
|
||||||
|
import AboutPage from 'gabsocial/features/about';
|
||||||
|
|
||||||
const { localeData, messages } = getLocale();
|
const { localeData, messages } = getLocale();
|
||||||
addLocaleData(localeData);
|
addLocaleData(localeData);
|
||||||
|
@ -92,6 +93,7 @@ class GabSocialMount extends React.PureComponent {
|
||||||
<ScrollContext>
|
<ScrollContext>
|
||||||
<Switch>
|
<Switch>
|
||||||
{!me && <Route exact path='/' component={LandingPage} />}
|
{!me && <Route exact path='/' component={LandingPage} />}
|
||||||
|
<Route exact path='/about/:slug?' component={AboutPage} />
|
||||||
<Route path='/' component={UI} />
|
<Route path='/' component={UI} />
|
||||||
</Switch>
|
</Switch>
|
||||||
</ScrollContext>
|
</ScrollContext>
|
||||||
|
|
41
app/gabsocial/features/about/index.js
Normal file
41
app/gabsocial/features/about/index.js
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
import React from 'react';
|
||||||
|
import { connect } from 'react-redux';
|
||||||
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
||||||
|
import { fetchAboutPage } from 'gabsocial/actions/about';
|
||||||
|
|
||||||
|
class AboutPage extends ImmutablePureComponent {
|
||||||
|
|
||||||
|
state = {
|
||||||
|
pageHtml: '',
|
||||||
|
}
|
||||||
|
|
||||||
|
loadPageHtml = () => {
|
||||||
|
const { dispatch, match } = this.props;
|
||||||
|
const { slug } = match.params;
|
||||||
|
dispatch(fetchAboutPage(slug)).then(response => {
|
||||||
|
this.setState({ pageHtml: response.data });
|
||||||
|
}).catch(error => {
|
||||||
|
// TODO: Better error handling. 404 page?
|
||||||
|
this.setState({ pageHtml: '<h1>Page not found</h1>' });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
componentWillMount() {
|
||||||
|
this.loadPageHtml();
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidUpdate(prevProps, prevState) {
|
||||||
|
const { slug } = this.props.match.params;
|
||||||
|
const { slug: prevSlug } = prevProps.match.params;
|
||||||
|
if (slug !== prevSlug) this.loadPageHtml();
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<div dangerouslySetInnerHTML={{ __html: this.state.pageHtml }} />
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export default connect()(AboutPage);
|
|
@ -192,6 +192,7 @@
|
||||||
|
|
||||||
.public-layout {
|
.public-layout {
|
||||||
.container {
|
.container {
|
||||||
|
width: 100%;
|
||||||
max-width: 960px;
|
max-width: 960px;
|
||||||
|
|
||||||
@media screen and (max-width: $no-gap-breakpoint) {
|
@media screen and (max-width: $no-gap-breakpoint) {
|
||||||
|
|
3
public/soapbox/about/index.html
Normal file
3
public/soapbox/about/index.html
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
<h1>Hello world!</h1>
|
||||||
|
|
||||||
|
<p>You made it.</p>
|
0
public/soapbox/about/tos.html
Normal file
0
public/soapbox/about/tos.html
Normal file
Loading…
Reference in a new issue