2020-11-22 20:50:07 +00:00
|
|
|
/*
|
2021-02-01 21:55:49 +00:00
|
|
|
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
2020-11-22 20:50:07 +00:00
|
|
|
|
2020-05-14 13:41:38 +00:00
|
|
|
import React from 'react'
|
|
|
|
import ReactDOM from 'react-dom'
|
2020-05-27 13:43:28 +00:00
|
|
|
import { Provider } from 'react-redux'
|
2020-05-29 13:44:45 +00:00
|
|
|
import { BrowserRouter as Router, Redirect, Route, Switch } from 'react-router-dom'
|
|
|
|
import { ApplicationLoader } from './components/application-loader/application-loader'
|
2020-08-16 14:02:26 +00:00
|
|
|
import { NotFoundErrorScreen } from './components/common/routing/not-found-error-screen'
|
2020-09-07 18:18:03 +00:00
|
|
|
import { Redirector } from './components/common/routing/redirector'
|
|
|
|
import { ErrorBoundary } from './components/error-boundary/error-boundary'
|
2020-08-16 14:02:26 +00:00
|
|
|
import { HistoryPage } from './components/history-page/history-page'
|
|
|
|
import { IntroPage } from './components/intro-page/intro-page'
|
2020-09-07 18:18:03 +00:00
|
|
|
import { LandingLayout } from './components/landing-layout/landing-layout'
|
2020-08-16 14:02:26 +00:00
|
|
|
import { LoginPage } from './components/login-page/login-page'
|
|
|
|
import { ProfilePage } from './components/profile-page/profile-page'
|
|
|
|
import { RegisterPage } from './components/register-page/register-page'
|
|
|
|
import { store } from './redux'
|
2020-10-25 20:17:59 +00:00
|
|
|
import * as serviceWorkerRegistration from './service-worker-registration'
|
2020-09-13 16:04:02 +00:00
|
|
|
import './style/dark.scss'
|
2020-09-26 07:54:17 +00:00
|
|
|
import './style/index.scss'
|
2021-05-01 21:01:42 +00:00
|
|
|
import { isTestMode } from './utils/test-modes'
|
2020-09-26 07:54:17 +00:00
|
|
|
|
2021-02-17 21:58:21 +00:00
|
|
|
const EditorPage = React.lazy(() => import(/* webpackPrefetch: true *//* webpackChunkName: "editor" */ './components/editor-page/editor-page'))
|
|
|
|
const RenderPage = React.lazy(() => import (/* webpackPrefetch: true *//* webpackChunkName: "renderPage" */ './components/render-page/render-page'))
|
|
|
|
const DocumentReadOnlyPage = React.lazy(() => import (/* webpackPrefetch: true *//* webpackChunkName: "documentReadOnly" */ './components/document-read-only-page/document-read-only-page'))
|
2021-05-02 20:38:43 +00:00
|
|
|
const baseUrl = new URL(document.head.baseURI).pathname
|
2020-05-14 13:41:38 +00:00
|
|
|
|
2020-05-15 21:10:12 +00:00
|
|
|
ReactDOM.render(
|
2021-02-03 21:13:04 +00:00
|
|
|
<Provider store={ store }>
|
2021-05-02 20:38:43 +00:00
|
|
|
<Router basename={ baseUrl }>
|
2020-05-29 13:44:45 +00:00
|
|
|
<ApplicationLoader>
|
2020-09-07 18:18:03 +00:00
|
|
|
<ErrorBoundary>
|
|
|
|
<Switch>
|
|
|
|
<Route path="/history">
|
|
|
|
<LandingLayout>
|
|
|
|
<HistoryPage/>
|
|
|
|
</LandingLayout>
|
|
|
|
</Route>
|
|
|
|
<Route path="/intro">
|
|
|
|
<LandingLayout>
|
|
|
|
<IntroPage/>
|
|
|
|
</LandingLayout>
|
|
|
|
</Route>
|
|
|
|
<Route path="/login">
|
|
|
|
<LandingLayout>
|
|
|
|
<LoginPage/>
|
|
|
|
</LandingLayout>
|
|
|
|
</Route>
|
|
|
|
<Route path="/register">
|
|
|
|
<LandingLayout>
|
|
|
|
<RegisterPage/>
|
|
|
|
</LandingLayout>
|
|
|
|
</Route>
|
|
|
|
<Route path="/profile">
|
|
|
|
<LandingLayout>
|
|
|
|
<ProfilePage/>
|
|
|
|
</LandingLayout>
|
|
|
|
</Route>
|
2021-01-24 19:50:51 +00:00
|
|
|
<Route path="/render">
|
|
|
|
<RenderPage/>
|
|
|
|
</Route>
|
2020-09-07 18:18:03 +00:00
|
|
|
<Route path="/n/:id">
|
2021-02-01 23:03:47 +00:00
|
|
|
<EditorPage/>
|
2020-09-07 18:18:03 +00:00
|
|
|
</Route>
|
2020-10-12 19:58:00 +00:00
|
|
|
<Route path="/s/:id">
|
2021-02-01 23:03:47 +00:00
|
|
|
<DocumentReadOnlyPage/>
|
2020-10-12 19:58:00 +00:00
|
|
|
</Route>
|
2020-09-07 18:18:03 +00:00
|
|
|
<Route path="/:id">
|
|
|
|
<Redirector/>
|
|
|
|
</Route>
|
|
|
|
<Route path="/">
|
|
|
|
<Redirect to="/intro"/>
|
|
|
|
</Route>
|
|
|
|
<Route>
|
|
|
|
<NotFoundErrorScreen/>
|
|
|
|
</Route>
|
|
|
|
</Switch>
|
|
|
|
</ErrorBoundary>
|
2020-05-29 13:44:45 +00:00
|
|
|
</ApplicationLoader>
|
|
|
|
</Router>
|
2020-05-27 13:43:28 +00:00
|
|
|
</Provider>
|
|
|
|
, document.getElementById('root')
|
|
|
|
)
|
2020-05-14 13:41:38 +00:00
|
|
|
|
2020-12-29 16:13:07 +00:00
|
|
|
if (isTestMode()) {
|
2021-02-03 21:13:04 +00:00
|
|
|
console.log('This build runs in test mode. This means:\n - no sandboxed iframe')
|
2020-12-29 16:13:07 +00:00
|
|
|
}
|
|
|
|
|
2020-05-14 13:41:38 +00:00
|
|
|
// If you want your app to work offline and load faster, you can change
|
|
|
|
// unregister() to register() below. Note this comes with some pitfalls.
|
|
|
|
// Learn more about service workers: https://bit.ly/CRA-PWA
|
2020-10-25 20:17:59 +00:00
|
|
|
serviceWorkerRegistration.unregister()
|