mirror of
https://github.com/PeWu/topola-viewer.git
synced 2025-12-23 18:50:04 +00:00
Add "single tree mode" when building
This commit is contained in:
parent
bd6f6a845b
commit
5836ea2133
15
README.md
15
README.md
@ -101,6 +101,21 @@ https://github.com/PeWu/topola-viewer/archive/refs/heads/gh-pages.zip
|
||||
|
||||
These are the exact files that are hosted on GitHub pages.
|
||||
|
||||
### Build for your own data only
|
||||
|
||||
You can run Topola Viewer in a "single tree mode" that displays only the GEDCOM you specify. Specify the URL to a GEDCOM file in the `REACT_APP_STATIC_URL` environment variable when building and running the application.
|
||||
|
||||
Run locally with the specified data URL:
|
||||
```
|
||||
REACT_APP_STATIC_URL=https://example.org/sample.ged npm start
|
||||
```
|
||||
|
||||
Build with the specified data URL:
|
||||
```
|
||||
REACT_APP_STATIC_URL=https://example.org/sample.ged npm run build
|
||||
```
|
||||
The `build/` folder will contain files that can be hosted on a Web server.
|
||||
|
||||
### Alternative build
|
||||
|
||||
The [topola-webpack](https://github.com/develancer/topola-webpack) tool can build a Topola Genealogy Viewer package bundled together with a GEDCOM file.
|
||||
|
||||
36
src/app.tsx
36
src/app.tsx
@ -48,6 +48,14 @@ import {
|
||||
WikiTreeSourceSpec,
|
||||
} from './datasource/wikitree';
|
||||
|
||||
/**
|
||||
* Load GEDCOM URL from REACT_APP_STATIC_URL environment variable.
|
||||
*
|
||||
* If this environment variable is provided, the viewer is switched to
|
||||
* single-tree mode without the option to load other data.
|
||||
*/
|
||||
const staticUrl = process.env.REACT_APP_STATIC_URL;
|
||||
|
||||
/** Shows an error message in the middle of the screen. */
|
||||
function ErrorMessage(props: {message?: string}) {
|
||||
return (
|
||||
@ -135,7 +143,13 @@ function getArguments(location: H.Location<any>): Arguments {
|
||||
const url = getParam('url');
|
||||
const embedded = getParam('embedded') === 'true'; // False by default.
|
||||
var sourceSpec: DataSourceSpec | undefined = undefined;
|
||||
if (getParam('source') === 'wikitree') {
|
||||
if (staticUrl) {
|
||||
sourceSpec = {
|
||||
source: DataSourceEnum.GEDCOM_URL,
|
||||
url: staticUrl,
|
||||
handleCors: false,
|
||||
};
|
||||
} else if (getParam('source') === 'wikitree') {
|
||||
sourceSpec = {
|
||||
source: DataSourceEnum.WIKITREE,
|
||||
authcode: getParam('authcode'),
|
||||
@ -170,7 +184,7 @@ function getArguments(location: H.Location<any>): Arguments {
|
||||
chartType: chartTypes.get(view) || ChartType.Hourglass,
|
||||
|
||||
showSidePanel: getParam('sidePanel') !== 'false', // True by default.
|
||||
standalone: getParam('standalone') !== 'false' && !embedded,
|
||||
standalone: getParam('standalone') !== 'false' && !embedded && !staticUrl,
|
||||
showWikiTreeMenus: getParam('showWikiTreeMenus') !== 'false', // True by default.
|
||||
freezeAnimation: getParam('freeze') === 'true', // False by default
|
||||
config: argsToConfig(search),
|
||||
@ -559,11 +573,19 @@ export function App() {
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
<Switch>
|
||||
<Route exact path="/" component={Intro} />
|
||||
<Route exact path="/view" render={renderMainArea} />
|
||||
<Redirect to={'/'} />
|
||||
</Switch>
|
||||
{staticUrl ? (
|
||||
<Switch>
|
||||
<Route exact path="/view" render={renderMainArea} />
|
||||
<Redirect to={'/view'} />
|
||||
</Switch>
|
||||
) : (
|
||||
<Switch>
|
||||
<Route exact path="/" component={Intro} />
|
||||
<Route exact path="/view" render={renderMainArea} />
|
||||
<Redirect to={'/'} />
|
||||
</Switch>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user