From d42ed78aa432e448346f2b9585ee983e08631ba0 Mon Sep 17 00:00:00 2001
From: Eugen Rochko <eugen@zeonfederated.com>
Date: Sun, 13 Nov 2016 14:01:21 +0100
Subject: Fix #110 - Make web UI use browser history, change links in e-mails
 to link to that

---
 .../javascripts/components/containers/mastodon.jsx | 71 ++++++++++++----------
 1 file changed, 38 insertions(+), 33 deletions(-)

(limited to 'app/assets/javascripts/components/containers/mastodon.jsx')

diff --git a/app/assets/javascripts/components/containers/mastodon.jsx b/app/assets/javascripts/components/containers/mastodon.jsx
index f29893ec0..20b57998a 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 (
       <Provider store={store}>
-        <Router history={hashHistory} render={applyRouterMiddleware(useScroll())}>
+        <Router history={browserHistory} render={applyRouterMiddleware(useScroll())}>
           <Route path='/' component={UI}>
             <IndexRoute component={GettingStarted} />
-            <Route path='/statuses/new' component={Compose} />
 
-            <Route path='/statuses/home' component={HomeTimeline} />
-            <Route path='/statuses/mentions' component={MentionsTimeline} />
-            <Route path='/statuses/all' component={PublicTimeline} />
-            <Route path='/statuses/tag/:id' component={HashtagTimeline} />
+            <Route path='timelines/home' component={HomeTimeline} />
+            <Route path='timelines/mentions' component={MentionsTimeline} />
+            <Route path='timelines/public' component={PublicTimeline} />
+            <Route path='timelines/tag/:id' component={HashtagTimeline} />
 
-            <Route path='/statuses/:statusId' component={Status} />
-            <Route path='/statuses/:statusId/reblogs' component={Reblogs} />
-            <Route path='/statuses/:statusId/favourites' component={Favourites} />
+            <Route path='statuses/new' component={Compose} />
+            <Route path='statuses/:statusId' component={Status} />
+            <Route path='statuses/:statusId/reblogs' component={Reblogs} />
+            <Route path='statuses/:statusId/favourites' component={Favourites} />
 
-            <Route path='/accounts/:accountId' component={Account}>
+            <Route path='accounts/:accountId' component={Account}>
               <IndexRoute component={AccountTimeline} />
-              <Route path='/accounts/:accountId/followers' component={Followers} />
-              <Route path='/accounts/:accountId/following' component={Following} />
+              <Route path='followers' component={Followers} />
+              <Route path='following' component={Following} />
             </Route>
           </Route>
         </Router>
-- 
cgit 

