gno icon indicating copy to clipboard operation
gno copied to clipboard

feat(example): refactor p/demo/blog

Open louonezime opened this issue 6 months ago • 4 comments

This PR is linked to the https://github.com/gnolang/gno/issues/4088 for scratching the old /p/demo/blog to make it better but still have it be compatible with the gnoblo-cli.

This is currently in /p/lou/blog as to start with a completely fresh package, the git diff is nicer to read this way.

These are the features:

  • [x] Blog rendering with use of mux
  • [x] Filtering of tags through query --> :tag/<tagname>
  • [x] Sorting alphabetically --> ?sort=alpha&order=asc
  • [x] Sorting from last updated --> ?sort=update&order=asc

Added/modified:

  • [x] Listing of all tags
    • [x] Add sorting options
    • [x] Number of posts
  • [x] Listing of all authors
    • [x] Add sorting options
    • [x] Number of posts
  • [x] Listing in time ranges (start – end) --> ?start=<time>&end=<time>
    • [x] time.RFC3339, // rfc3339 format
    • [x] "2006-01-02", // date only
    • [x] "2006-01", // year and month
    • [x] "2006", // year only
  • [x] Filtering of authors like it has already been done for tags (through query) --> :author/<authorname>
  • [x] Toggle grid and list mode for Rendering (using gno-columns) --> ?mode=grid or ?mode=list
  • [x] Adding pagination
  • [x] Updating comments based on comment ID
  • [x] Switching to seq.id as indexes
  • [x] Improve error handling and messages throughout the package.
  • [x] Pinning comments
  • [x] Resolve users via r/sys/users registry.

Further (not mentioned in issue):

  • [x] Filtering of commenters like it has already been done for tags (through query) --> :commenter/<commentername>
  • [x] Sorting from most/least recent (for posts and filters) --> ?sort=recent&order=asc
  • [x] Toggle time format -- Is it necessary?
  • [x] Add likes to comments
  • [x] Add replies to comments
  • [x] Add likes to posts -- Is it necessary?
  • [x] Mention method to simulate a link to a specific author/ commenter (will link to :author or :commenter)
  • [x] Make sorting/toggling options customizable (to disable/ or select)
  • [x] Add a customizable option for rendering previews (at home, to add actions)
  • [ ] Add tests
    • [x] Base of testings with uassert and urequire
    • [ ] For all scenarios
  • [ ] Add moderation
    • [x] Formatting, checking user validity and resolving
    • [ ] Permissions are handled
    • [ ] Assert users
    • [ ] Try using authorizable package
  • [x] Fix total replies for comments size + reply id are relative to comments
  • [ ] Add more documentation
    • [ ] More doc.gno
    • [ ] Add comments
    • [ ] Document customisation of rendering
    • [ ] Document custom of toggling/sort headers
  • [ ] Add realm example for the use of the package

louonezime avatar May 27 '25 13:05 louonezime

🛠 PR Checks Summary

All Automated Checks passed. ✅

Manual Checks (for Reviewers):
  • [x] IGNORE the bot requirements for this PR (force green CI check)
  • [x] The pull request description provides enough details
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) 🟢 Pending initial approval by a review team member, or review from tech-staff

☑️ Contributor Actions:
  1. Fix any issues flagged by automated checks.
  2. Follow the Contributor Checklist to ensure your PR is ready for review.
    • Add new tests, or document why they are unnecessary.
    • Provide clear examples/screenshots, if necessary.
    • Update documentation, if required.
    • Ensure no breaking changes, or include BREAKING CHANGE notes.
    • Link related issues/PRs, where applicable.
☑️ Reviewer Actions:
  1. Complete manual checks for the PR, including the guidelines and additional checks if applicable.
📚 Resources:
Debug
Automated Checks
Maintainers must be able to edit this pull request (more info)

If

🟢 Condition met
└── 🟢 And
    ├── 🟢 The base branch matches this pattern: ^master$
    └── 🟢 The pull request was created from a fork (head branch repo: louonezime/gno)

Then

🟢 Requirement satisfied
└── 🟢 Maintainer can modify this pull request

Pending initial approval by a review team member, or review from tech-staff

If

🟢 Condition met
└── 🟢 And
    ├── 🟢 The base branch matches this pattern: ^master$
    └── 🟢 Not (🔴 Pull request author is a member of the team: tech-staff)

Then

🟢 Requirement satisfied
└── 🟢 If
    ├── 🟢 Condition
    │   └── 🟢 Or
    │       ├── 🟢 User leohhhn already reviewed PR 4324 with state APPROVED
    │       ├── 🔴 At least 1 user(s) of the team tech-staff reviewed pull request
    │       └── 🔴 This pull request is a draft
    └── 🟢 Then
        └── 🟢 Not (🔴 This label is applied to pull request: review/triage-pending)

Manual Checks
**IGNORE** the bot requirements for this PR (force green CI check)

If

🟢 Condition met
└── 🟢 On every pull request

Can be checked by

  • Any user with comment edit permission
The pull request description provides enough details

If

🟢 Condition met
└── 🟢 And
    ├── 🟢 Not (🔴 Pull request author is a member of the team: core-contributors)
    └── 🟢 Not (🔴 Pull request author is user: dependabot[bot])

Can be checked by

  • team core-contributors

Gno2D2 avatar May 27 '25 13:05 Gno2D2

Codecov Report

:white_check_mark: All modified and coverable lines are covered by tests.

:loudspeaker: Thoughts on this report? Let us know!

codecov[bot] avatar May 27 '25 13:05 codecov[bot]

Looking forward to seeing a demo soon :)

leohhhn avatar Jun 10 '25 14:06 leohhhn

Gotta start writing some tests :)

I suggest you list out the scenarios first, then start writing the tests

Thanks! I also have another question regarding the PR — would it make more sense for users that can be resolved through /r/sys/user to also be identifiable via /u/<user> to allow write permissions? I assume this would need to be handled in gnoblogcli at the least, correct? If so, I would be glad to make this more streamlined in the future.

As of now, I feel it's most fitting to only check through the UserResolver.

So, since I'm polishing the moderation of the blog, what do you think would be best?

louonezime avatar Jun 18 '25 15:06 louonezime

@louonezime

How's this going along? When will it be ready for another review?

leohhhn avatar Jul 14 '25 11:07 leohhhn

oh btw, register your realm to r/leon/hor :)

leohhhn avatar Jul 15 '25 15:07 leohhhn

@louonezime

How's this going along? When will it be ready for another review?

Yes, it's going I'm just reviewing and testing every aspect to work my full realm now :) Will try and finish for this week, maybe Wednesday if I can finish the tests

EDIT : I am now doing tests, documentation and working on distinguishing owner and moderators. So I opened for review as I am sure there is room for improvement on the refactorisation. (not sure if my byId and bySlug functions are too much and should just be handled in the realm for example)

louonezime avatar Jul 15 '25 16:07 louonezime

The realm page has options to filter the blog posts. As we discussed in the dev call, the Render function has a CPU limit. In this video, I did a stress test to demonstrate this limit. I also discuss possible mitigations, including warning the user when getting close to the limit. https://www.loom.com/share/518211ca05664ac6b00a83704fcce34b

jefft0 avatar Jul 28 '25 13:07 jefft0

Hey @louonezime, can you please take a look at the CI and why it's failing?

leohhhn avatar Aug 07 '25 09:08 leohhhn

Looking at this now, glad to see you're still active 🙏

leohhhn avatar Nov 03 '25 14:11 leohhhn