Skip to content
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: change gnoweb to add URL query string to render path #2876

Merged
merged 16 commits into from
Nov 6, 2024

Conversation

jeronimoalbi
Copy link
Member

@jeronimoalbi jeronimoalbi commented Oct 1, 2024

Description

This PR introduces a change for gnoweb to also pass the URL query string as part of the render path.

Passing the URL query string is required to support arguments when rendering realms, which is the case of the AVL pager implementation in #2584 that uses "page" and "size".

The PR changes the behavior of realm rendering calls by adding URL query arguments as suffix of the path argument, so URLs like https://gno.land/r/demo/foo:bar?baz=42 would call Render(path) with "bar?baz=42" as value of path.

It also changes how special gnoweb arguments like help of func are specified which now must be done by using the $ character, for example:

  • https://gno.land/r/demo/foo$help&func=Bar&name=Baz
  • https://gno.land/r/demo/foo:example$tz=Europe/Paris
  • https://gno.land/r/demo/foo:example?value=42$tz=Europe/Paris

Note that __func is now func, without the underscore prefix.

Possible Issues

The change could potentially affect realm or package implementations that rely on the render path in cases where the ? is not expected, for example when parsing or splitting it. Because of that there might be changes required to handle the case where a caller sends query string arguments. Realms and packages should be able to handle render paths which could look like render/path?arg=1&arg=N.

Links that still use ?, help and __func won't work as expected, they must be changed to use $ instead of ?, and func instead of __func.

Packages gno.land/p/moul/txlink and gno.land/p/moul/helplink has to be refactored to properly generate links.

@github-actions github-actions bot added the 📦 ⛰️ gno.land Issues or PRs gno.land package related label Oct 1, 2024
@jeronimoalbi jeronimoalbi added 🌍 gnoweb Issues & PRs related to gnoweb and render and removed 📦 ⛰️ gno.land Issues or PRs gno.land package related labels Oct 1, 2024
Copy link

codecov bot commented Oct 1, 2024

Codecov Report

Attention: Patch coverage is 54.54545% with 25 lines in your changes missing coverage. Please review.

Project coverage is 63.06%. Comparing base (367408a) to head (3612d58).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
gno.land/pkg/gnoweb/gnoweb.go 54.54% 18 Missing and 7 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2876      +/-   ##
==========================================
- Coverage   63.33%   63.06%   -0.28%     
==========================================
  Files         548      548              
  Lines       78601    81101    +2500     
==========================================
+ Hits        49780    51143    +1363     
- Misses      25466    26525    +1059     
- Partials     3355     3433      +78     
Flag Coverage Δ
contribs/gnodev 61.11% <ø> (ø)
contribs/gnofaucet 14.82% <ø> (ø)
gno.land 67.18% <54.54%> (-0.19%) ⬇️
gnovm 67.88% <ø> (ø)
misc/genstd 79.72% <ø> (ø)
tm2 62.41% <ø> (+0.10%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@moul
Copy link
Member

moul commented Oct 1, 2024

Hey, what is the expected direct or indirect impact of this change?

Edit: found the answer here: #2584 (review)

@jeronimoalbi
Copy link
Member Author

Hey, what is the expected direct or indirect impact of this change?

Edit: found the answer here: #2584 (review)

I will write a proper PR description soon and extend the unit tests for this case.
Also would like to check how it affects the mux package because I think it might break it.

@jeronimoalbi jeronimoalbi changed the title feat: change gnoweb to add URL query arguments to render path feat: change gnoweb to add URL query string to render path Oct 2, 2024
@moul
Copy link
Member

moul commented Oct 2, 2024

Related with #2602
Related with #2887

@github-actions github-actions bot added the 📦 ⛰️ gno.land Issues or PRs gno.land package related label Oct 4, 2024
thehowl pushed a commit that referenced this pull request Oct 25, 2024
This PR aimed to promote the use of a `p/` library for managing special
help links from contracts.

It also provided an opportunity for me to realize that our discussion
about changing the `$` symbol would require some parsing and detection
from the `gnoweb` perspective. If we want a simple library like this
one, the goal should be to ideally craft a link to the current package
without specifying the realm path. Relative URLs worked well with `?`,
but they won't function with `$`.

As an alternative, we can have this package look for
`std.PrevRealm().PkgAddr` if it is not specified.

cc @jeronimoalbi @thehowl @leohhhn 

Related with #2602
Related with #2876

---------

Signed-off-by: moul <[email protected]>
Co-authored-by: Leon Hudak <[email protected]>
@leohhhn leohhhn self-requested a review October 30, 2024 18:13
jeronimoalbi and others added 5 commits October 31, 2024 17:34
Public query arguments are the standard ones that come after the "?"
symbol, while the private arguments come after the "$" symbol.

Private gnoweb arguments are used for specific gnoweb features, some of
which are `help` or `func` and are filtered from the render path when
rendering realms.
@leohhhn leohhhn marked this pull request as ready for review November 4, 2024 13:21
@leohhhn
Copy link
Contributor

leohhhn commented Nov 5, 2024

I believe you missed the help button taking you to ?help instead of $help

In realm_render.html:

<a href="/r/{{ .Data.RealmName }}?help">[help]</a>

@leohhhn
Copy link
Contributor

leohhhn commented Nov 5, 2024

And, for txlink, just switch out this line & fix the tests:

url := r.prefix() + "?help&__func=" + fn

I think that CTRL+F on examples/ should help you find other broken links, like ?help & __func

Copy link
Contributor

@leohhhn leohhhn left a comment

Choose a reason for hiding this comment

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

Good after fixing links in examples, we'll fix other broken links as we find them

@github-actions github-actions bot added the 🧾 package/realm Tag used for new Realms or Packages. label Nov 5, 2024
Copy link
Member

@moul moul left a comment

Choose a reason for hiding this comment

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

pre-approving, well done!

@leohhhn leohhhn merged commit 538ebff into gnolang:master Nov 6, 2024
131 of 132 checks passed
@leohhhn leohhhn deleted the devx/add-render-query-arguments branch November 6, 2024 12:07
@leohhhn
Copy link
Contributor

leohhhn commented Nov 6, 2024

Merging with a codecov drop because we will be scraping the whole gnoweb codebase soon; to be replaced with a full package refactor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🌍 gnoweb Issues & PRs related to gnoweb and render 📦 ⛰️ gno.land Issues or PRs gno.land package related 🧾 package/realm Tag used for new Realms or Packages.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants