-
-
Notifications
You must be signed in to change notification settings - Fork 308
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for readme rendering #860
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea in general but it should fit into the general current design of miniserve. We already supported an --index
file and perhaps this could be treated as an index file that still needs to be rendered? What do you think?
Btw quickest review ever. 😎 |
You can mark the PR as draft, then you don't need a |
@svenstaro Thanks I didn't know draft was public. As for index.html, html writing is complicated compared to markdown, hence I didn't check the index file. Do we have to write the index file with all the paths ourselves, or just the other parts and the file/directories will be the same? If we can only use the readme part and keep the other contents same as default we can add a bool flag to say the index file is a markdown. I think we can just add a separate add markdown render without less effort (relatively) and it'll be consistent design with how we share codes in other mediums I think it's worth looking into. Instead of generating a whole HTML. (Of course I'm talking here without knowing how index files work) And we can improve it further. I am just done implementing a flag so it won't be active by default. And I'll look into better renderer. |
I'm not saying we should actually write any additional HTML here. In fact, we most definitely shouldn't create any files and suprise users.
Sorry, I do not understand this at all. Why would we write any additional HTML files? I meant earlier that we should try to combine the
Perhaps it might make sense at this point if you toy around with the existing index functionality a little bit to check out whether this would fit with the markdown design somehow? |
If you think we need to integrate it with index flag then I'll look into how index is rendered and trace it. It'll take time, I'm not that good with html. I'll add some logics to make sure when I still have some changes that I need to push like actually implementing the EDIT: And really thank you for quick responses, you saved my time. :) |
I meant does the user need to write the entirety of the contents on the index file or will the directory listing part will be automatically generated? If it's the later then we can add readme with the same method, but if user has to write the whole index file, then I think it's better to separate that with the readme functionality where we only add the readme→html part to our template. I looked into the index file, and looks like it completely replaces the directory listing, and if we go with using So I think it's better to keep them separate after all. It also matches the file's themes, index file is a way to index directory, and readme is just extra information about that directory. And README can appear sparsely, some directories might have it some might not. And irrespective of its presence, the directory listing will always be there. Something like this:
So even if there is no if you provide index-file: it'll be used and directory listing will be disabled (whatever current default is) Current features of readme flag:
|
@svenstaro Any thoughts? My feeling as I said before is readme feature added into current render is ok as index file is supposed to be entry point and readme isn't. Those two seems like different things to me. |
Ok, I thought about this. Sorry, took some time. I want to make sure miniserve doesn't become a hodgepodge of features that don't really make sense. I like the feature the way you proposed it and I agree it should be a completely separate mechanism from how the index is rendered. A few points:
|
I think
Sorry. I wanted to say in case of nested paths we can render different README.md files automatically, in contrast to having to give the path of index file at start. Of course the one that'll be rendered at any moment is the one from current directory. Also about the test, there is problem from clippy due to too many arguments in the |
Does it cancel automatically once one of the tests failed? Would have been nice to know if there are some errors so we could fix in one go. Anyway, as I've said previously I'm waiting for your opinion on what to do about that too many argument problem. |
Do this for now:
I think we'll just ignore this as we know what we're doing here. |
Also please rebase your branch so that the merge into your branch goes away as otherwise the history looks kinda funky. |
* README.md will be rendered at currently visiting directory instead of just in the root. * Rendering is now done by comrak, which seems heavy but has a lot more features.
Looks like the formatting issue was because I hadn't set my editor to use spaces so there was tabs and it looked ok to me. I've made the other changes and force pushed. Sorry if there is some problem in intermediate commits as I'm not that familiar with rebasing. As for the file opening issue, We can make a struct with readme name and the content and pass that instead, and read contents in the listings instead of rendering so we have it under same variable instead of two. I read it from rendering originally to just use one variable. |
@svenstaro I tried with Readme struct but haben't merged to master: Atreyagaurav@04ec70e Is this good? Edit: I merged it, so that it'll be incorporated here. Looks ok to me, and |
My mind isn't adjusted to rust yet, sorry about that bool use in the struct. I've made the use of Readme struct better, I think. Making a blank struct when I could pass None was pretty stupid. Let me know what you think. This should at least move the heavy processing (IO) away from rendering for now. |
Sorry didn't notice the spelling, I somehow only saw the |
Merging as is. Thanks, this is great! |
Oh, I just noticed we don't actually have a test for this. Would you like to add one after the fact, @Atreyagaurav? |
I've never written rust tests, and currently have no idea how to test readme thing, let me read other tests and see what I can do. Might take a week or so. |
Not to worry! I think the tests are actually fairly easy to read and it might be a good learning exercise at any rate. |
Fixes #859
Suggestions are welcome, I'm only implemented the basic render for now.
Other things that might be needed:
markdown
crate).md
(.txt
and , maybe.org
)