Skip to content

Conversation

louonezime
Copy link
Contributor

@louonezime louonezime commented May 27, 2025

This PR is linked to the #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:

Base:

  • Blog rendering with use of mux
  • Filtering of tags through query --> :tag/<tagname>
  • Sorting alphabetically --> ?sort=alpha&order=asc
  • Sorting from last updated --> ?sort=update&order=asc
Added/modified:
  • Listing of all tags
    • Add sorting options
    • Number of posts
  • Listing of all authors
    • Add sorting options
    • Number of posts
  • Listing in time ranges (start – end) --> ?start=<time>&end=<time>
    • time.RFC3339, // rfc3339 format
    • "2006-01-02", // date only
    • "2006-01", // year and month
    • "2006", // year only
  • Filtering of authors like it has already been done for tags (through query) --> :author/<authorname>
  • Toggle grid and list mode for Rendering (using gno-columns) --> ?mode=grid or ?mode=list
  • Adding pagination
  • Updating comments based on comment ID
  • Switching to seq.id as indexes
  • Improve error handling and messages throughout the package.
  • Pinning comments
  • Resolve users via r/sys/users registry.
Further (not mentioned in issue):
  • Filtering of commenters like it has already been done for tags (through query) --> :commenter/<commentername>
  • Sorting from most/least recent (for posts and filters) --> ?sort=recent&order=asc
  • Toggle time format -- Is it necessary?
  • Add likes to comments
  • Add replies to comments
  • Add likes to posts -- Is it necessary?
  • Mention method to simulate a link to a specific author/ commenter (will link to :author or :commenter)
  • Make sorting/toggling options customizable (to disable/ or select)
  • Add a customizable option for rendering previews (at home, to add actions)
  • Add tests
    • Base of testings with uassert and urequire
    • For all scenarios
  • Add moderation
    • Formatting, checking user validity and resolving
    • Assert users
    • Try using authorizable package
  • 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

Package created to support:

@louonezime louonezime marked this pull request as draft May 27, 2025 13:12
@github-actions github-actions bot added the 🧾 package/realm Tag used for new Realms or Packages. label May 27, 2025
@Gno2D2 Gno2D2 requested a review from a team May 27, 2025 13:12
@Gno2D2
Copy link
Collaborator

Gno2D2 commented May 27, 2025

🛠 PR Checks Summary

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

Manual Checks (for Reviewers):
  • IGNORE the bot requirements for this PR (force green CI check)
  • 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 not satisfied
└── 🔴 If
    ├── 🔴 Condition
    │   └── 🔴 Or
    │       ├── 🔴 At least one of these user(s) reviewed the pull request: [jefft0 leohhhn n0izn0iz notJoon omarsy x1unix] (with state "APPROVED")
    │       ├── 🔴 At least 1 user(s) of the team tech-staff reviewed pull request
    │       └── 🔴 This pull request is a draft
    └── 🔴 Else
        └── 🔴 And
            ├── 🟢 This label is applied to pull request: review/triage-pending
            ├── 🔴 At least 1 user(s) of the team tech-staff reviewed pull request
            └── 🔴 On no pull request

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

Copy link

codecov bot commented May 27, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Prefix string
Posts *avl.Tree
PostId seqid.ID
DisplayMode string // Grid or List
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better to have this as an option in the render func, no? you then allow the user to render it however they want instead of having to toggle it :)

Also, imagine the blog instance is saved somewhere else except the specific realm its made in, maybe that other instance/realm wants to do something else to it, and with a toggle like this it's dependent on who has the power to change the display mode

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion, but just to clarify then (seeing as though this would change the Render function):

Are you thinking of moving away entirely from how p/demo/blog works (with Render(path string) and internal route handling via mux), and instead have rendering logic be completely controlled externally — like the caller deciding list/grid and rendering themselves per route?

Or do you still see the value in keeping built-in routing/rendering (like RenderPosts, RenderPost, etc.) with query params like ?mode=list)?

(if that makes sense)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or do you still see the value in keeping built-in routing/rendering (like RenderPosts, RenderPost, etc.) with query params like ?mode=list)?

This :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Gno2D2 Gno2D2 added the review/triage-pending PRs opened by external contributors that are waiting for the 1st review label Jul 16, 2025
@leohhhn leohhhn moved this from In Progress to In Review in 🧑‍🎓Student contributors Jul 16, 2025
@leohhhn leohhhn requested a review from aeddi July 16, 2025 09:12
@gfanton gfanton requested a review from leohhhn July 23, 2025 09:29
out := md.H4(b.Mention("commenter", user)) + "\n\n"
out += comment.Content() + "\n\n"
out += md.Italic(formatTime(comment.CreatedAt(), options.TimeFormat)) + "\n\n"
out += "in " + md.Link(p.Title(), b.Prefix()+":posts/"+p.Slug()) + "\n\n"
Copy link
Contributor

@jefft0 jefft0 Jul 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The slug is being used as part of a path. If the slug has a space like "my slug", then the markdown converter gets confused. Either escape non-path characters in the slug when creating a path, or forbid them in the slug.

image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see the commit to address this issue. It's better, but still not quite right. I add a post where the slug is "slug/1".
In the post, it shows the escaped "slug%2F1" . When you hover over the title, the URL is "http://127.0.0.1:8888/r/lou/blog:posts/slug/1" and when you click the title, it shows a 404 error. Maybe the URL should be "http://127.0.0.1:8888/r/lou/blog:posts/slug%252F1". Have the do the escaping at the right level.

image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, didn't see this:
2d465d4

is this what you meant?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, now the link to the post works. If you want, you can also make the slug in the rendered post appear as the user originally entered it. For example, I originally set the slug to "slug/1" not to "slug%252F1". It's up to you.
image

@jefft0
Copy link
Contributor

jefft0 commented Jul 28, 2025

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

@leohhhn
Copy link
Contributor

leohhhn commented Aug 7, 2025

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

stefann-01 pushed a commit to stefann-01/gno that referenced this pull request Aug 26, 2025
This PR introduces a new query package that provides reusable helpers
for working with URL query strings. It is designed to simplify parsing,
updating, and reconstructing query parameters in a clean and generic
way.

This logic was originally embedded in the `blog` package (in
gnolang#4324), but has now been extracted
into its own utility package to promote reusability and separation of
concerns.

- ParseQueryParams(key, rawURL) → get a single query parameter value
- ParseQueryMap(rawURL) → return all query parameters as a
map[string]string
- UpdateQuery(rawURL, key, value) → set or overwrite a single query
param
- UpdateQueryMulti(rawURL, map[string]string) → update multiple query
params at once
- DeleteQuery(rawURL, key) → remove a parameter from the query string

*UPDATE*

- `GetQueryValues` – Get all values for a given key.
- `GetQueryFirstValue` – Get the first value for a given key.
- `HasQueryKey` – Check if a key exists in the query.
- `GetQueryValueFromURL` – Retrieve a query value from a raw URL.
- `ParseQueryFirstValuesMap` – Parse a URL into a map of first values.
- `UpdateQueryValue` – Set a single value for a key.
- `UpdateQueryValues` – Set multiple values for a single key.
- `UpdateQueryFirstValues` – Set single values for multiple keys.
- `UpdateQueryAllValues` – Set multiple values for multiple keys.
- `SetQueries` – Replace or add keys with single values.
- `SetQueriesMulti` – Replace or add keys with multiple values.
- `DeleteQuery` – Remove a specific key from the query.
- `ResetQuery` – Remove all query parameters from the URL.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤝 contribs 🧾 package/realm Tag used for new Realms or Packages. review/triage-pending PRs opened by external contributors that are waiting for the 1st review
Projects
Status: No status
Status: In Review
Development

Successfully merging this pull request may close these issues.

examples: completely refactor p/demo/blog
4 participants