-
Notifications
You must be signed in to change notification settings - Fork 421
feat(gnoweb): readme markdown viewer for p/ & r/ #4101
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
feat(gnoweb): readme markdown viewer for p/ & r/ #4101
Conversation
🛠 PR Checks SummaryAll Automated Checks passed. ✅ Manual Checks (for Reviewers):
Read More🤖 This bot helps streamline PR reviews by verifying automated checks and providing guidance for contributors and reviewers. ✅ Automated Checks (for Contributors):🟢 Maintainers must be able to edit this pull request (more info) ☑️ Contributor Actions:
☑️ Reviewer Actions:
📚 Resources:Debug
|
Codecov ReportAttention: Patch coverage is 📢 Thoughts on this report? Let us know! |
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.
First comment pass; I need to delve deeper for a full review, but I will wait for you to resolve the preliminary comments.
markdown: goldmark.New( | ||
goldmark.WithExtensions( | ||
markdown.GnoExtension, | ||
), | ||
), |
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.
the mock cannot depend on goldmark
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.
This test file doesn't make sense, you are not testing html client but the mock itself.
If no tests were existing before, it is because we need to have a mock for the RPC client itself to be able to test the HTML client.
// If writer is nil, just return metadata | ||
if w == nil { | ||
return &fileMeta, nil | ||
} | ||
|
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.
writer cannot and should not be nil; remove this. it will complexity the caller logic
} | ||
|
||
// RenderMd renders a markdown file and returns the rendered content | ||
func (s *HTMLWebClient) RenderMd(w io.Writer, u *weburl.GnoURL, fileName string) (*RealmMeta, error) { |
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.
func (s *HTMLWebClient) RenderMd(w io.Writer, u *weburl.GnoURL, fileName string) (*RealmMeta, error) { | |
func (s *HTMLWebClient) RenderMarkdownFile(w io.Writer, u *weburl.GnoURL, fileName string) (*RealmMeta, error) { |
type DisplayMode int | ||
|
||
const ( | ||
ModeCode DisplayMode = iota | ||
ModeMarkdown | ||
) |
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.
No, if you are using this within the template, it makes no sense to use int here. Just change this to string, or find a way to expose this as const within the template. But if it's not something simple, simply use string.
type DisplayMode int | |
const ( | |
ModeCode DisplayMode = iota | |
ModeMarkdown | |
) | |
type DisplayMode string | |
const ( | |
ModeCode DisplayMode = "code" | |
ModeMarkdown = "markdown" | |
) |
closing in favour of #4401 |
This PR implements `README.md` file support for both `pures` (p/) and `realms` (r/) in gno.land, addressing the requirements outlined in #4070. ## Features ### For p/ packages: - If a `README.md` exists, it is rendered at the top of the directory listing (in the `content` temaplte) - `README.md` is moved to the first position in the file list - The rendered content uses the existing Goldmark infrastructure with Gno extensions ### For r/ realms: - No Render() & no README.md: Display error page - Render() & no README.md: Works as before (existing behavior) - No Render() & README.md: Fallback to README.md rendering - Both present: Call `Render()` as primary, with `README.md` available in source view ## Next iteration This PR adds the first step to build the pkg.go template in gnoweb instead of the directory template and restructure the source template to be linked to it. This will improve and simplify the UX while giving more features/info to the users. **_Note**: This PR replaces the previous PR #4101 with a much cleaner and more maintainable implementation. The current code reuses existing infrastructure and avoids code duplication, while providing a consistent user experience for displaying `README.md` files._ <img width="1384" alt="Capture d’écran 2025-06-22 à 13 18 45" src="https://github.com/user-attachments/assets/61248889-11a5-48b5-b0c0-2bb4a6f56200" /> <img width="1380" alt="Capture d’écran 2025-06-22 à 13 55 48" src="https://github.com/user-attachments/assets/b976b373-c2ce-4f7b-bafe-3ec6c32abd5e" /> --------- Co-authored-by: Morgan Bazalgette <morgan@morganbaz.com>
This PR implements `README.md` file support for both `pures` (p/) and `realms` (r/) in gno.land, addressing the requirements outlined in gnolang#4070. ## Features ### For p/ packages: - If a `README.md` exists, it is rendered at the top of the directory listing (in the `content` temaplte) - `README.md` is moved to the first position in the file list - The rendered content uses the existing Goldmark infrastructure with Gno extensions ### For r/ realms: - No Render() & no README.md: Display error page - Render() & no README.md: Works as before (existing behavior) - No Render() & README.md: Fallback to README.md rendering - Both present: Call `Render()` as primary, with `README.md` available in source view ## Next iteration This PR adds the first step to build the pkg.go template in gnoweb instead of the directory template and restructure the source template to be linked to it. This will improve and simplify the UX while giving more features/info to the users. **_Note**: This PR replaces the previous PR gnolang#4101 with a much cleaner and more maintainable implementation. The current code reuses existing infrastructure and avoids code duplication, while providing a consistent user experience for displaying `README.md` files._ <img width="1384" alt="Capture d’écran 2025-06-22 à 13 18 45" src="https://github.com/user-attachments/assets/61248889-11a5-48b5-b0c0-2bb4a6f56200" /> <img width="1380" alt="Capture d’écran 2025-06-22 à 13 55 48" src="https://github.com/user-attachments/assets/b976b373-c2ce-4f7b-bafe-3ec6c32abd5e" /> --------- Co-authored-by: Morgan Bazalgette <morgan@morganbaz.com>
This PR implements a new feature to display README.md files in a formatted way for both
pures
(p/) andrealms
(r/) in gno.land. This would apply inDirectory
template and inSource
template.Changes
Added a new
RenderMd
method toHTMLWebClient
that:SourceFile
ParseMarkdown
functionModified the
GetDirectoryView
handler to:README.md
in the directoryREADME.md
to the first position in the file listReuse code to create a new
generateTOC
helper method toHTMLWebClient
that:RealmView
settings)In Source template, a markdown file is automatically rendered with Goldmark in HTML:
plain
WebQuery to force code view for markdown filesBenefits
Technical Details
This feature enhances the user experience by making documentation more accessible and readable directly in the web interface.
TODO
code
<->html
)In Directory template
In Source template