Skip to content

Conversation

@camstevenson
Copy link
Contributor

This adds support for importing cards from an OPML file into the current folder. Export will be next, but I thought import may be useful immediately.

A few things:

  • I chose a fairly arbitrary icon for the action
  • There are strings to translate
  • The actual operations on the outline require some scrutiny (I'm not entirely sure I've done everything correctly)

Tested with a largeish OPML manuscript import

@olivierkes
Copy link
Owner

Hi Cam,

Good works, this looks great. I'm not on my computer so I've only browsed the code from my phone, but I'll look more closely later on.

Questions :

  • what about a File > Import menu entry, rather than a button where you put it? I think I'll rather do that (so we can also more easily extend with other import format).

  • For the export, have you tried pandoc opml export? Maybe we don't need to do our own thing.

  • Are you sure the {lf} trick is necessary with lxml?

  • why put the title as text if not text? We can have empty items. In the same vein, why have the summary be the beginning of the body? And same question about trimming long titles.

    In my mind, if we export to opml and then import the file right after, we should have exactly the same result. What do you think?

Once more, thanks for contributing to manuskript!

@camstevenson
Copy link
Contributor Author

camstevenson commented Nov 5, 2017

what about a File > Import menu entry, rather than a button where you put it? I think I'll rather do that (so we can also more easily extend with other import format).

That's what I did first, before I started importing cards into sub folders (rather than at the root), then it seemed best to have the import action closer to the folder actions

For the export, have you tried pandoc opml export? Maybe we don't need to do our own thing.

Not yet :-)

Are you sure the {lf} trick is necessary with lxml?

Yes :-(

why put the title as text if not text? We can have empty items. In the same vein, why have the summary be the beginning of the body? And same question about trimming long titles.

In my mind, if we export to opml and then import the file right after, we should have exactly the same result. What do you think?

Yeah...so oops, the title trimming was an experiment that I neglected to remove. The issue is that long titles end up with a tab (in the editor) that's the full length of the window. They're also hard to edit, which is why I duplicated them on import into the body. I have a few of them.

Without creating a summary, the cards, well, don't have a summary ;-) It's common practice to take a snippet from somewhere for a summary if there isn't one. Perhaps making the title into the summary is a better idea.

I am, of course, open to better ideas than what I've done ;-)

Oh, and here's some different illustrative screenshots

Without a summary:
without-summary

With a summary:
with-summary

With {lf} and title trimming:
lf-and-title-trim

Without {lf} and title trimming:
no-lf-or-title-trim

@olivierkes
Copy link
Owner

Thanks for the clarifications :)

That's what I did first, before I started importing cards into sub folders (rather than at the root), then it seemed best to have the import action closer to the folder actions

I was thinking of a dialog that allow you to chose the parent item, as in the compile dialog:

image

The issue is that long titles end up with a tab (in the editor) that's the full length of the window.

That's a bug ! I reported it here #194

Without creating a summary, the cards, well, don't have a summary ;-) It's common practice to take a snippet from somewhere for a summary if there isn't one.

I think this all could be options on import. But we could also decide that when an index card has text but no summary, it displays a snippet of the text as summary. That way there wouldn't be no duplicate in the project file, and no problem if exporting/importing. Openned an issue here: #195.

Are you sure the {lf} trick is necessary with lxml?
Yes :-(

This is strange. I use lxml to save and restore manuskript's projects, and new lines are kept. 😕

Also, do you have an OPML files that you could post here for testing purposes?

@olivierkes olivierkes changed the title Import export Adds: Import OPML Nov 5, 2017
@camstevenson
Copy link
Contributor Author

I can work on an import dialog if you like. Just give the command ;-)

I believe the "significant whitespace removal" in lxml and others is due to the fact that the text is contained in an attribute rather than a child element. That's what I've seen elsewhere.

Attached is a snapshot of my current in-progress manuscript. Feel free to use it for testing purposes. You'll note that I've extended OPML (the same way it was extended with _note) for a better interchange experience with my own apps. It includes ignorable attributes like _summary, _type and _done.

Perhaps we should propose such a more robust OPML format to the world ;-)

End Plan 2.opml.tar.gz

@olivierkes olivierkes changed the base branch from develop to feature/importers November 6, 2017 07:20
@olivierkes olivierkes merged commit 1f04bf6 into olivierkes:feature/importers Nov 6, 2017
@olivierkes
Copy link
Owner

Thank you very much, also for providing End Plan 2 :)

So I merged your PR to a feature/importers branch. I started a conversation about it there: #200.

Thanks again, great job !

@camstevenson
Copy link
Contributor Author

My pleasure

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants