-
Notifications
You must be signed in to change notification settings - Fork 373
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: add p/moul/txlink
+ p/moul/helplink
#2887
Conversation
Signed-off-by: moul <[email protected]>
Signed-off-by: moul <[email protected]>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #2887 +/- ##
==========================================
+ Coverage 63.38% 63.62% +0.24%
==========================================
Files 566 566
Lines 79490 79656 +166
==========================================
+ Hits 50388 50685 +297
+ Misses 25710 25577 -133
- Partials 3392 3394 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Signed-off-by: moul <[email protected]>
Signed-off-by: moul <[email protected]>
For me, it's ease of use with this kind of library. I found it simpler to just write out the constant up top, put in placeholders for specific arguments, and just populate it with a These two code paragraphs have the same output: // using helplink
out += "#### "
out += hl.Func(strconv.Itoa(i.upvote.Size())+like, "Upvote", "pkgpath", i.pkgpath)
out += " - "
out += hl.Func(strconv.Itoa(i.downvote.Size())+like, "Downvote", "pkgpath", i.pkgpath)
out += "\n\n"
// using sprintf
const likesBar = "#### [%d 👍](/r/demo/hof?help&__func=Upvote&pkgpath=%s) - [%d 👎](/r/demo/hof?help&__func=Downvote&pkgPath=%s)\n\n"
out += ufmt.Sprintf(
likesBar,
i.upvote.Size(),
i.pkgpath,
i.downvote.Size(),
i.pkgpath,
) The long package-level constant might be a little ugly, but I think I have to play around a bit more but for now I'm not fully convinced currently. |
i think it’s because you’re using a dynamic text with number; maybe in your case you should use the FuncURL and not the Func helper. |
TODO: rename Edit: kept the two packages, with distinct roles. |
p/moul/txlink
+ p/moul/helplink
Signed-off-by: moul <[email protected]>
Based on #2809, I decided to create these two new libraries in my personal realm, There is a question about whether we want to use personal namespaces starting today or if it still makes sense to find a better location. |
Signed-off-by: moul <[email protected]>
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 thegnoweb
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