Skip to content

Commit 1b4c876

Browse files
authored
Redesign landing page (mastodon#10232)
1 parent 7ca2dfe commit 1b4c876

77 files changed

Lines changed: 516 additions & 1619 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
11
# frozen_string_literal: true
22

33
class AboutController < ApplicationController
4-
before_action :set_body_classes
4+
layout 'public'
5+
56
before_action :set_instance_presenter, only: [:show, :more, :terms]
67

78
def show
8-
serializable_resource = ActiveModelSerializers::SerializableResource.new(InitialStatePresenter.new(initial_state_params), serializer: InitialStateSerializer)
9-
@initial_state_json = serializable_resource.to_json
9+
@hide_navbar = true
1010
end
1111

12-
def more
13-
render layout: 'public'
14-
end
12+
def more; end
1513

16-
def terms
17-
render layout: 'public'
18-
end
14+
def terms; end
1915

2016
private
2117

@@ -28,15 +24,4 @@ def new_user
2824
def set_instance_presenter
2925
@instance_presenter = InstancePresenter.new
3026
end
31-
32-
def set_body_classes
33-
@body_classes = 'with-modals'
34-
end
35-
36-
def initial_state_params
37-
{
38-
settings: { known_fediverse: Setting.show_known_fediverse_at_about_page },
39-
token: current_session&.token,
40-
}
41-
end
4227
end
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# frozen_string_literal: true
2+
3+
class PublicTimelinesController < ApplicationController
4+
layout 'public'
5+
6+
before_action :check_enabled
7+
before_action :set_body_classes
8+
before_action :set_instance_presenter
9+
10+
def show
11+
respond_to do |format|
12+
format.html do
13+
@initial_state_json = ActiveModelSerializers::SerializableResource.new(
14+
InitialStatePresenter.new(settings: { known_fediverse: Setting.show_known_fediverse_at_about_page }, token: current_session&.token),
15+
serializer: InitialStateSerializer
16+
).to_json
17+
end
18+
end
19+
end
20+
21+
private
22+
23+
def check_enabled
24+
raise ActiveRecord::RecordNotFound unless Setting.timeline_preview
25+
end
26+
27+
def set_body_classes
28+
@body_classes = 'with-modals'
29+
end
30+
31+
def set_instance_presenter
32+
@instance_presenter = InstancePresenter.new
33+
end
34+
end

app/controllers/tags_controller.rb

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ def show
1313

1414
respond_to do |format|
1515
format.html do
16-
serializable_resource = ActiveModelSerializers::SerializableResource.new(InitialStatePresenter.new(initial_state_params), serializer: InitialStateSerializer)
17-
@initial_state_json = serializable_resource.to_json
16+
@initial_state_json = ActiveModelSerializers::SerializableResource.new(
17+
InitialStatePresenter.new(settings: {}, token: current_session&.token),
18+
serializer: InitialStateSerializer
19+
).to_json
1820
end
1921

2022
format.rss do
@@ -25,8 +27,7 @@ def show
2527
end
2628

2729
format.json do
28-
@statuses = HashtagQueryService.new.call(@tag, params.slice(:any, :all, :none), current_account, params[:local])
29-
.paginate_by_max_id(PAGE_SIZE, params[:max_id])
30+
@statuses = HashtagQueryService.new.call(@tag, params.slice(:any, :all, :none), current_account, params[:local]).paginate_by_max_id(PAGE_SIZE, params[:max_id])
3031
@statuses = cache_collection(@statuses, Status)
3132

3233
render json: collection_presenter,
@@ -55,11 +56,4 @@ def collection_presenter
5556
items: @statuses.map { |s| ActivityPub::TagManager.instance.uri_for(s) }
5657
)
5758
end
58-
59-
def initial_state_params
60-
{
61-
settings: {},
62-
token: current_session&.token,
63-
}
64-
end
6559
end

app/helpers/home_helper.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,12 @@ def custom_field_classes(field)
5656
'emojify'
5757
end
5858
end
59+
60+
def optional_link_to(condition, path, options = {}, &block)
61+
if condition
62+
link_to(path, options, &block)
63+
else
64+
content_tag(:div, &block)
65+
end
66+
end
5967
end

app/javascript/mastodon/containers/timeline_container.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { hydrateStore } from '../actions/store';
77
import { IntlProvider, addLocaleData } from 'react-intl';
88
import { getLocale } from '../locales';
99
import PublicTimeline from '../features/standalone/public_timeline';
10-
import CommunityTimeline from '../features/standalone/community_timeline';
1110
import HashtagTimeline from '../features/standalone/hashtag_timeline';
1211
import ModalContainer from '../features/ui/containers/modal_container';
1312
import initialState from '../initial_state';
@@ -26,31 +25,30 @@ export default class TimelineContainer extends React.PureComponent {
2625
static propTypes = {
2726
locale: PropTypes.string.isRequired,
2827
hashtag: PropTypes.string,
29-
showPublicTimeline: PropTypes.bool.isRequired,
28+
local: PropTypes.bool,
3029
};
3130

3231
static defaultProps = {
33-
showPublicTimeline: initialState.settings.known_fediverse,
32+
local: !initialState.settings.known_fediverse,
3433
};
3534

3635
render () {
37-
const { locale, hashtag, showPublicTimeline } = this.props;
36+
const { locale, hashtag, local } = this.props;
3837

3938
let timeline;
4039

4140
if (hashtag) {
4241
timeline = <HashtagTimeline hashtag={hashtag} />;
43-
} else if (showPublicTimeline) {
44-
timeline = <PublicTimeline />;
4542
} else {
46-
timeline = <CommunityTimeline />;
43+
timeline = <PublicTimeline local={local} />;
4744
}
4845

4946
return (
5047
<IntlProvider locale={locale} messages={messages}>
5148
<Provider store={store}>
5249
<Fragment>
5350
{timeline}
51+
5452
{ReactDOM.createPortal(
5553
<ModalContainer />,
5654
document.getElementById('modal-container'),

app/javascript/mastodon/features/standalone/community_timeline/index.js

Lines changed: 0 additions & 71 deletions
This file was deleted.

app/javascript/mastodon/features/standalone/hashtag_timeline/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import React from 'react';
22
import { connect } from 'react-redux';
33
import PropTypes from 'prop-types';
44
import ImmutablePropTypes from 'react-immutable-proptypes';
5-
import { expandHashtagTimeline } from '../../../actions/timelines';
6-
import { connectHashtagStream } from '../../../actions/streaming';
5+
import { expandHashtagTimeline } from 'mastodon/actions/timelines';
6+
import { connectHashtagStream } from 'mastodon/actions/streaming';
77
import Masonry from 'react-masonry-infinite';
88
import { List as ImmutableList } from 'immutable';
9-
import DetailedStatusContainer from '../../status/containers/detailed_status_container';
9+
import DetailedStatusContainer from 'mastodon/features/status/containers/detailed_status_container';
1010
import { debounce } from 'lodash';
11-
import LoadingIndicator from '../../../components/loading_indicator';
11+
import LoadingIndicator from 'mastodon/components/loading_indicator';
1212

1313
const mapStateToProps = (state, { hashtag }) => ({
1414
statusIds: state.getIn(['timelines', `hashtag:${hashtag}`, 'items'], ImmutableList()),

0 commit comments

Comments
 (0)