Lurnby icon indicating copy to clipboard operation
Lurnby copied to clipboard

Import lurnby web to lurnby self hosted

Open brodokk opened this issue 2 years ago • 4 comments

In a case where a user want to self-host lurnby himself it would be interesting to add the ability to import the data exported from the current website https://www.lurnby.com.

My current use case is that im testing your application and would like to self-host it later.

brodokk avatar Feb 12 '22 10:02 brodokk

This is actually easier than other kinds of imports.

I'm assuming this is a total export of all data that needs to be imported back into a local Lurnby yeah?

Its hard to imagine this would work as a partial export of just some highlights.

On Feb 12, 2022, at 12:55, brodokk @.***> wrote:

 In a case where a user want to self-host lurnby himself it would be interesting to add the ability to import the data exported from the current website https://www.lurnby.com.

My current use case is that im testing your application and would like to self-host it later.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.

Roznoshchik avatar Feb 12 '22 12:02 Roznoshchik

Yeah its actually all data that need to be imported back to a local Lumby. I mean it make more sense that way.

brodokk avatar Feb 13 '22 10:02 brodokk

There is one difficult part of this which is that it's not guaranteed that the highlight will be able to keep the reference to it's counterpart in the actual article text.

When you highlight in an article, the actual html content gets updated with a span that shows the highlight. The span is given an id which matches the newly created highlight_id. That's how we know which highlight to open within the actual article.

That's also how we can navigate back to that part of the text when you're viewing a highlight elsewhere and click the go to highlight button. It opens up the article page and navigates to #HIGHLIGHT<highlight_id>

This causes issues when thinking through the import, because it's not guaranteed that you will be importing into a completely blank database. The lurnby database that you might be trying to import the files into, is likely another active installation which means that the highlight_id may not be unique.

If it's not unique, we will need to generate a new highlight_id to proceed with the import. In which case, the link between the highlight and the text will be broken.

Roznoshchik avatar Feb 24 '22 21:02 Roznoshchik

Perhaps the issue above isn't so complicated though.

We have

  1. Article text
  2. Original highlight_id
  3. New unique highlight_id

If when importing we determine that a highlight can't be created with the original_id, we create a new highlight id. Then we do a search and replace in the article.text for #Highlight<original_id> replacing it with #Highlight<new_id>

Then the reference stays and we have no issue.

Roznoshchik avatar Feb 24 '22 22:02 Roznoshchik