From d42ed78aa432e448346f2b9585ee983e08631ba0 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sun, 13 Nov 2016 14:01:21 +0100 Subject: [PATCH] Fix #110 - Make web UI use browser history, change links in e-mails to link to that --- .../components/components/status_content.jsx | 2 +- .../components/containers/mastodon.jsx | 71 ++++++++++--------- .../features/compose/components/search.jsx | 2 +- .../features/getting_started/index.jsx | 2 +- .../features/ui/components/navigation_bar.jsx | 2 +- .../features/ui/components/tabs_bar.jsx | 6 +- .../notification_mailer/_status.text.erb | 2 +- app/views/notification_mailer/follow.text.erb | 2 +- config/routes.rb | 6 +- public/manifest.json | 2 +- 10 files changed, 51 insertions(+), 46 deletions(-) diff --git a/app/assets/javascripts/components/components/status_content.jsx b/app/assets/javascripts/components/components/status_content.jsx index e51be3c6..583f4cec 100644 --- a/app/assets/javascripts/components/components/status_content.jsx +++ b/app/assets/javascripts/components/components/status_content.jsx @@ -52,7 +52,7 @@ const StatusContent = React.createClass({ if (e.button === 0) { e.preventDefault(); - this.context.router.push(`/statuses/tag/${hashtag}`); + this.context.router.push(`/timelines/tag/${hashtag}`); } }, diff --git a/app/assets/javascripts/components/containers/mastodon.jsx b/app/assets/javascripts/components/containers/mastodon.jsx index f29893ec..20b57998 100644 --- a/app/assets/javascripts/components/containers/mastodon.jsx +++ b/app/assets/javascripts/components/containers/mastodon.jsx @@ -1,39 +1,44 @@ -import { Provider } from 'react-redux'; -import configureStore from '../store/configureStore'; +import { Provider } from 'react-redux'; +import configureStore from '../store/configureStore'; import { refreshTimelineSuccess, updateTimeline, deleteFromTimelines, refreshTimeline -} from '../actions/timelines'; +} from '../actions/timelines'; import { setAccessToken } from '../actions/meta'; import { setAccountSelf } from '../actions/accounts'; -import PureRenderMixin from 'react-addons-pure-render-mixin'; +import PureRenderMixin from 'react-addons-pure-render-mixin'; +import createBrowserHistory from 'history/lib/createBrowserHistory'; import { applyRouterMiddleware, + useRouterHistory, Router, Route, - hashHistory, IndexRoute -} from 'react-router'; -import { useScroll } from 'react-router-scroll'; -import UI from '../features/ui'; -import Account from '../features/account'; -import Status from '../features/status'; -import GettingStarted from '../features/getting_started'; -import PublicTimeline from '../features/public_timeline'; -import AccountTimeline from '../features/account_timeline'; -import HomeTimeline from '../features/home_timeline'; -import MentionsTimeline from '../features/mentions_timeline'; -import Compose from '../features/compose'; -import Followers from '../features/followers'; -import Following from '../features/following'; -import Reblogs from '../features/reblogs'; -import Favourites from '../features/favourites'; -import HashtagTimeline from '../features/hashtag_timeline'; +} from 'react-router'; +import { useScroll } from 'react-router-scroll'; +import UI from '../features/ui'; +import Account from '../features/account'; +import Status from '../features/status'; +import GettingStarted from '../features/getting_started'; +import PublicTimeline from '../features/public_timeline'; +import AccountTimeline from '../features/account_timeline'; +import HomeTimeline from '../features/home_timeline'; +import MentionsTimeline from '../features/mentions_timeline'; +import Compose from '../features/compose'; +import Followers from '../features/followers'; +import Following from '../features/following'; +import Reblogs from '../features/reblogs'; +import Favourites from '../features/favourites'; +import HashtagTimeline from '../features/hashtag_timeline'; const store = configureStore(); +const browserHistory = useRouterHistory(createBrowserHistory)({ + basename: '/web' +}); + const Mastodon = React.createClass({ propTypes: { @@ -78,24 +83,24 @@ const Mastodon = React.createClass({ render () { return ( - + - - - - - + + + + - - - + + + + - + - - + + diff --git a/app/assets/javascripts/components/features/compose/components/search.jsx b/app/assets/javascripts/components/features/compose/components/search.jsx index 93f7df77..37efbe5d 100644 --- a/app/assets/javascripts/components/features/compose/components/search.jsx +++ b/app/assets/javascripts/components/features/compose/components/search.jsx @@ -88,7 +88,7 @@ const Search = React.createClass({ if (suggestion.type === 'account') { this.context.router.push(`/accounts/${suggestion.id}`); } else { - this.context.router.push(`/statuses/tag/${suggestion.id}`); + this.context.router.push(`/timelines/tag/${suggestion.id}`); } }, diff --git a/app/assets/javascripts/components/features/getting_started/index.jsx b/app/assets/javascripts/components/features/getting_started/index.jsx index df912321..d5792dd9 100644 --- a/app/assets/javascripts/components/features/getting_started/index.jsx +++ b/app/assets/javascripts/components/features/getting_started/index.jsx @@ -9,7 +9,7 @@ const GettingStarted = () => {

You can follow people if you know their username and the domain they are on by entering an e-mail-esque address into the form in the bottom of the sidebar.

If the target user is on the same domain as you, just the username will work. The same rule applies to mentioning people in statuses.

The developer of this project can be followed as Gargron@mastodon.social

-

Also check out the public timeline for a start!

+

Also check out the public timeline for a start!

); diff --git a/app/assets/javascripts/components/features/ui/components/navigation_bar.jsx b/app/assets/javascripts/components/features/ui/components/navigation_bar.jsx index 68b660ee..d2dae141 100644 --- a/app/assets/javascripts/components/features/ui/components/navigation_bar.jsx +++ b/app/assets/javascripts/components/features/ui/components/navigation_bar.jsx @@ -19,7 +19,7 @@ const NavigationBar = React.createClass({
{this.props.account.get('acct')} - Settings · Public timeline · Logout + Settings · Public timeline · Logout
); diff --git a/app/assets/javascripts/components/features/ui/components/tabs_bar.jsx b/app/assets/javascripts/components/features/ui/components/tabs_bar.jsx index f5d98599..b39030ca 100644 --- a/app/assets/javascripts/components/features/ui/components/tabs_bar.jsx +++ b/app/assets/javascripts/components/features/ui/components/tabs_bar.jsx @@ -28,9 +28,9 @@ const TabsBar = () => { return (
Compose - Home - Mentions - Public + Home + Mentions + Public
); }; diff --git a/app/views/notification_mailer/_status.text.erb b/app/views/notification_mailer/_status.text.erb index 24c15436..b089a7b7 100644 --- a/app/views/notification_mailer/_status.text.erb +++ b/app/views/notification_mailer/_status.text.erb @@ -1,3 +1,3 @@ <%= strip_tags(@status.content) %> -<%= TagManager.instance.url_for(@status) %> +<%= web_url("statuses/#{@status.id}") %> diff --git a/app/views/notification_mailer/follow.text.erb b/app/views/notification_mailer/follow.text.erb index a13b6d7a..4098e484 100644 --- a/app/views/notification_mailer/follow.text.erb +++ b/app/views/notification_mailer/follow.text.erb @@ -2,4 +2,4 @@ <%= @account.acct %> is now following you! -<%= TagManager.instance.url_for(@account) %> +<%= web_url("accounts/#{@account.id}") %> diff --git a/config/routes.rb b/config/routes.rb index a19ccac5..176a4ccc 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,12 +1,10 @@ require 'sidekiq/web' Rails.application.routes.draw do - get 'tags/show' - mount ActionCable.server => '/cable' authenticate :user, lambda { |u| u.admin? } do - mount Sidekiq::Web => '/sidekiq' + mount Sidekiq::Web, at: 'sidekiq' mount PgHero::Engine, at: 'pghero' end @@ -99,6 +97,8 @@ Rails.application.routes.draw do end end + get '/web/*any', to: 'home#index', as: :web + get :about, to: 'about#index' get :terms, to: 'about#terms' diff --git a/public/manifest.json b/public/manifest.json index 063f7943..d12d128e 100644 --- a/public/manifest.json +++ b/public/manifest.json @@ -10,5 +10,5 @@ ], "theme_color": "#ffffff", "display": "standalone", - "start_url": "/#/statuses/home" + "start_url": "/web/timelines/home" }