teesloane / firn

Org Mode Static Site Generator
Eclipse Public License 1.0
324 stars 24 forks source link

add: tree layout for sitemap #115

Open dinoallo opened 2 years ago

dinoallo commented 2 years ago

The "tree" layout for sitemap is to render the directories where the org files reside, which may be useful for some who want their sitemap more organized.

To use the layout, simply change sitemap.layout in config.yaml to "tree". Any values other than that will fall back to the default layout.

Currently this layout sorts the files by their real path on the machine rather than by their titles, so if the titles are not consistent with their filenames, the sitemap will probably be different in that case.

This pr also uses the percent representation in sitemap urls. It fixes the broken link issue if the filenames and dirnames have space, question mark, etc.

dinoallo commented 2 years ago

A picture is worth a thousand words: https://imgur.com/a/j7ysEcF

teesloane commented 2 years ago

Hi there!

Thanks for making a PR. This is a bit of a complex one for me, so I'm going to have to pull down the code and test it.

For some context, from a product side, In previous versions of Firn I tried enabling rendering of the sitemap as a tree-ish structure through the use of a FIRN_UNDER key in the frontmatter. This way files could be "under" another file, regardless of their file structure, and then be rendered as such. It was a pain, and I'd say doing it by file system makes a lot more sense.

I have not looked at this codebase for a few months, so I'll need to test this locally when I have a chance; It might not be until the end of this week or next week, unfortunately. Hopefully you don't mind waiting.

I have two requests:

1) Do you mind adding a test or two, if you can think of an appropriate place for them? I'm trying to be a bit more diligent with my testing. 2) Can you tell me how to recreate the bug you identified ("This pr also uses the percent representation in sitemap urls. It fixes the broken link issue if the filenames and dirnames have space, questionmark, etc.") so I can try to recreate it? Namely:

dinoallo commented 2 years ago

I have not looked at this codebase for a few months, so I'll need to test this locally when I have a chance; It might not be until the end of this week or next week, unfortunately. Hopefully you don't mind waiting.

Sure! I deploy my own version of firn so it's not huge problem for me if the patch has not been merged to origin/master. For anyone who wants to get a bit of taste, you can always check out my fork for firn.

I have two requests:

  1. Do you mind adding a test or two, if you can think of an appropriate place for them? I'm trying to be a bit more diligent with my testing.

I will try to come up some tests when I am free :)

  1. Can you tell me how to recreate the bug you identified ("This pr also uses the percent representation in sitemap urls. It fixes the broken link issue if the filenames and dirnames have space, questionmark, etc.") so I can try to recreate it? Namely:
  • where do the links break (in the old sitemap?)
  • an example file name to test (I'm guessing anything with an empty space?)

Let's say I have a file structure like this:

└── Space Folder
        └── leaf3.org

On current master branch, the link will be rendered like:

<a href="http://localhost:8080/Space" folder="" leaf3.html="">Leaf 3</a>

Another example is when the org file is called: questionmark?.org, the link will be just fine but it's not confined to the URL standard, which causes problems while serving(404).