Skip to content

Commit

Permalink
Redesign landing page
Browse files Browse the repository at this point in the history
  • Loading branch information
Gargron committed Mar 12, 2019
1 parent c8122e8 commit bc05d88
Show file tree
Hide file tree
Showing 77 changed files with 516 additions and 1,619 deletions.
25 changes: 5 additions & 20 deletions app/controllers/about_controller.rb
@@ -1,21 +1,17 @@
# frozen_string_literal: true

class AboutController < ApplicationController
before_action :set_body_classes
layout 'public'

before_action :set_instance_presenter, only: [:show, :more, :terms]

def show
serializable_resource = ActiveModelSerializers::SerializableResource.new(InitialStatePresenter.new(initial_state_params), serializer: InitialStateSerializer)
@initial_state_json = serializable_resource.to_json
@hide_navbar = true
end

def more
render layout: 'public'
end
def more; end

def terms
render layout: 'public'
end
def terms; end

private

Expand All @@ -28,15 +24,4 @@ def new_user
def set_instance_presenter
@instance_presenter = InstancePresenter.new
end

def set_body_classes
@body_classes = 'with-modals'
end

def initial_state_params
{
settings: { known_fediverse: Setting.show_known_fediverse_at_about_page },
token: current_session&.token,
}
end
end
34 changes: 34 additions & 0 deletions app/controllers/public_timelines_controller.rb
@@ -0,0 +1,34 @@
# frozen_string_literal: true

class PublicTimelinesController < ApplicationController
layout 'public'

before_action :check_enabled
before_action :set_body_classes
before_action :set_instance_presenter

def show
respond_to do |format|
format.html do
@initial_state_json = ActiveModelSerializers::SerializableResource.new(
InitialStatePresenter.new(settings: { known_fediverse: Setting.show_known_fediverse_at_about_page }, token: current_session&.token),
serializer: InitialStateSerializer
).to_json
end
end
end

private

def check_enabled
raise ActiveRecord::RecordNotFound unless Setting.timeline_preview
end

def set_body_classes
@body_classes = 'with-modals'
end

def set_instance_presenter
@instance_presenter = InstancePresenter.new
end
end
16 changes: 5 additions & 11 deletions app/controllers/tags_controller.rb
Expand Up @@ -13,8 +13,10 @@ def show

respond_to do |format|
format.html do
serializable_resource = ActiveModelSerializers::SerializableResource.new(InitialStatePresenter.new(initial_state_params), serializer: InitialStateSerializer)
@initial_state_json = serializable_resource.to_json
@initial_state_json = ActiveModelSerializers::SerializableResource.new(
InitialStatePresenter.new(settings: {}, token: current_session&.token),
serializer: InitialStateSerializer
).to_json
end

format.rss do
Expand All @@ -25,8 +27,7 @@ def show
end

format.json do
@statuses = HashtagQueryService.new.call(@tag, params.slice(:any, :all, :none), current_account, params[:local])
.paginate_by_max_id(PAGE_SIZE, params[:max_id])
@statuses = HashtagQueryService.new.call(@tag, params.slice(:any, :all, :none), current_account, params[:local]).paginate_by_max_id(PAGE_SIZE, params[:max_id])
@statuses = cache_collection(@statuses, Status)

render json: collection_presenter,
Expand Down Expand Up @@ -55,11 +56,4 @@ def collection_presenter
items: @statuses.map { |s| ActivityPub::TagManager.instance.uri_for(s) }
)
end

def initial_state_params
{
settings: {},
token: current_session&.token,
}
end
end
8 changes: 8 additions & 0 deletions app/helpers/home_helper.rb
Expand Up @@ -56,4 +56,12 @@ def custom_field_classes(field)
'emojify'
end
end

def optional_link_to(condition, path, options = {}, &block)
if condition
link_to(path, options, &block)
else
content_tag(:div, &block)
end
end
end
12 changes: 5 additions & 7 deletions app/javascript/mastodon/containers/timeline_container.js
Expand Up @@ -7,7 +7,6 @@ import { hydrateStore } from '../actions/store';
import { IntlProvider, addLocaleData } from 'react-intl';
import { getLocale } from '../locales';
import PublicTimeline from '../features/standalone/public_timeline';
import CommunityTimeline from '../features/standalone/community_timeline';
import HashtagTimeline from '../features/standalone/hashtag_timeline';
import ModalContainer from '../features/ui/containers/modal_container';
import initialState from '../initial_state';
Expand All @@ -26,31 +25,30 @@ export default class TimelineContainer extends React.PureComponent {
static propTypes = {
locale: PropTypes.string.isRequired,
hashtag: PropTypes.string,
showPublicTimeline: PropTypes.bool.isRequired,
local: PropTypes.bool,
};

static defaultProps = {
showPublicTimeline: initialState.settings.known_fediverse,
local: !initialState.settings.known_fediverse,
};

render () {
const { locale, hashtag, showPublicTimeline } = this.props;
const { locale, hashtag, local } = this.props;

let timeline;

if (hashtag) {
timeline = <HashtagTimeline hashtag={hashtag} />;
} else if (showPublicTimeline) {
timeline = <PublicTimeline />;
} else {
timeline = <CommunityTimeline />;
timeline = <PublicTimeline local={local} />;
}

return (
<IntlProvider locale={locale} messages={messages}>
<Provider store={store}>
<Fragment>
{timeline}

{ReactDOM.createPortal(
<ModalContainer />,
document.getElementById('modal-container'),
Expand Down

This file was deleted.

Expand Up @@ -2,13 +2,13 @@ import React from 'react';
import { connect } from 'react-redux';
import PropTypes from 'prop-types';
import ImmutablePropTypes from 'react-immutable-proptypes';
import { expandHashtagTimeline } from '../../../actions/timelines';
import { connectHashtagStream } from '../../../actions/streaming';
import { expandHashtagTimeline } from 'mastodon/actions/timelines';
import { connectHashtagStream } from 'mastodon/actions/streaming';
import Masonry from 'react-masonry-infinite';
import { List as ImmutableList } from 'immutable';
import DetailedStatusContainer from '../../status/containers/detailed_status_container';
import DetailedStatusContainer from 'mastodon/features/status/containers/detailed_status_container';
import { debounce } from 'lodash';
import LoadingIndicator from '../../../components/loading_indicator';
import LoadingIndicator from 'mastodon/components/loading_indicator';

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

0 comments on commit bc05d88

Please sign in to comment.