PeWu / topola-viewer

Topola Genealogy Viewer – interactive genealogy visualization
https://pewu.github.io/topola-viewer
Apache License 2.0
221 stars 56 forks source link

Is there a way to load the .ged directly from the server ? #151

Open hayoul opened 1 year ago

hayoul commented 1 year ago

I am trying to load the GEDECOM file directly from the backend and not sure what function loads the file and how to hardcode the function or any variable to load file itself without passing any parameters in the URL or using the load file options. Can you help? Bonus how would that load the file once the app is loaded and bypass the intro page?

PeWu commented 1 year ago

I'm not sure what you're trying to achieve. To load data directly from a URL, you can construct a URL like this: https://pewu.github.io/topola-viewer/#/view?url=https://raw.githubusercontent.com/PeWu/topola/master/demo/data/family.ged

Topola by default uses a CORS proxy to load files because most web servers have CORS turned on. To turn off this behavior and load files directly from the web server, add &handleCors=false to the URL. E.g. https://pewu.github.io/topola-viewer/#/view?url=https://raw.githubusercontent.com/PeWu/topola/master/demo/data/family.ged&handleCors=false

You can also have a look at https://github.com/develancer/topola-webpack for a way to create a self-contained package together with a GEDCOM file.

hayoul commented 1 year ago

The idea is to only display the tree under embedded mode at the first load (without giving the option for the user to load other tree). And privacy reasons not provide or display the loaded ged file publicly.

Hence the question to directly load it from the host itself:

The app would load a ged directly and display the tree. Skipping your intro page.

Note that I have tried the webpack repo and used your embedded sample repository but the first one didn't include a search & export option and the second is not the most efficient on modern browsers. In both case the ged is loaded from public urls...

Do you mind giving me some clues on the functions I should look at? I'd be happy to contribute once I get a final version.

(Great job by the way)

Czajkor commented 1 year ago

Hi. Anyone managed to use OneDrive/GDrive/Dropbox with handleCors=false parameter? I never succeded Greatly appreciated

adamgross42 commented 1 year ago

I was looking for something similar. I think the UI you are looking for is what is rendered at a URL like https://pewu.github.io/topola-viewer/#/view?url=https%3A%2F%2Fwebtreeprint.com%2Ftp_downloader.php%3Fpath%3Dfamous_gedcoms%2Fshakespeare.ged&embedded=true without putting the URL or hash of the GEDCOM file in the viewable URL (so that other viewers can't change it and point to a different GEDCOM file).

The goal would be to override the contents of the loaded file to point to a relative path on the web server, likely around here:

https://github.com/PeWu/topola-viewer/blob/ceee39d1d42cc1fe026423b330b21a351ccf270e/src/datasource/embedded.ts#L53-L63

Granted, this is still a static/client-side website, so people could find the file path/contents in the page source anyhow. But it would still be useful for distribution of a simpler landing URL.

My solution so far is a simple landing page to wrap the longer URL and prevent most people from "breaking" it:

<html>
    <iframe src="https://<mywebserver>/#/view?url=https%3A%2F%2F<mywebserver>%2Fged.ged&embedded=true&handleCors=false" style="height:100%;width:100%;border:none;"></iframe>
</html>
chrissb77 commented 1 month ago

Hello @hayoul , did you manage to do what you were looking for? I am able to have the default page on my web server. I am able to load a gedcom file manually. But I would like to have a specific file opened by default. I also do not want visitors to load other files.