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(example): r/mouss #3472

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open

feat(example): r/mouss #3472

wants to merge 28 commits into from

Conversation

mous1985
Copy link
Contributor

@mous1985 mous1985 commented Jan 9, 2025

Hi Gnomes ,
This is my home page. it was difficult to be creative 😅 , so i did what i can do

Home :

I put some informations about me

Screenshot 2025-01-09 at 21 14 20

World kitchen :

I'm passionate about cooking, so I've set up a page for those who want to share their national culinary specialties or just their favorite recipes, since there are so many nationalities in gno community.

Screenshot 2025-01-09 at 21 22 54

feel free to add your recipes ;)

Screenshot 2025-01-09 at 21 35 17

@leohhhn

@github-actions github-actions bot added the 🧾 package/realm Tag used for new Realms or Packages. label Jan 9, 2025
@Gno2D2
Copy link
Collaborator

Gno2D2 commented Jan 9, 2025

🛠 PR Checks Summary

All Automated Checks passed. ✅

Manual Checks (for Reviewers):
  • IGNORE the bot requirements for this PR (force green CI check)
  • The pull request description provides enough details (checked by @thehowl)
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
└── 🟢 The pull request was created from a fork (head branch repo: mous1985/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
└── 🟢 Not (🔴 Pull request author is a member of the team: tech-staff)

Then

🟢 Requirement satisfied
└── 🟢 If
    ├── 🟢 Condition
    │   └── 🟢 Or
    │       ├── 🔴 At least 1 user(s) of the organization reviewed the pull request (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

@mous1985 mous1985 changed the title Home page feat: Home page Jan 9, 2025
}

func renderHomepage(res *mux.ResponseWriter, req *mux.Request) {
var b bytes.Buffer
Copy link
Member

Choose a reason for hiding this comment

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

why are you using a bytes.Buffer?

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 feedback, i've updated the code,i use strings.Builder instead of bytes.Buffer it's more efficient for string concatenation. bytes.Buffer was just general purpose.
8f5cb186

if !isUser(caller) {
return config.ErrorUnauthorized
}
if contains(profile.Followers, addr) {
Copy link
Member

Choose a reason for hiding this comment

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

looks like you should use the freshly merged addrset library (#3448)

Copy link
Contributor Author

@mous1985 mous1985 Jan 10, 2025

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Screenshot 2025-01-10 at 07 58 40

when i run gnodev

Copy link
Contributor

Choose a reason for hiding this comment

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

You need to run make install

Copy link
Contributor Author

@mous1985 mous1985 Jan 10, 2025

Choose a reason for hiding this comment

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

@leohhhn
I did it , i get the same error

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I realized I forgot to set the home_page branch to track master as its upstream so i haven't the p/moul/addrset in home_page branch . sorry 🙏🏽

}

func isUser(addr std.Address) bool {
return !isAuthorized(addr) && !contains(profile.Followers, addr)
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't the if condition be checking the exacte opposite?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I use isUser to check if follower is not admin address or if the follower exist already in the list of followers. i still working on ,I think it's could be a good feature to follow and be followed by other users.

}

func writeRecipe(b *bytes.Buffer, recipe *Recipe) {
b.WriteString("## " + recipe.Name + "\n")
Copy link
Member

Choose a reason for hiding this comment

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

i think that you should consider using a ui library.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

res.Write(b.String())
}

func writeRecipe(b *bytes.Buffer, recipe *Recipe) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
func writeRecipe(b *bytes.Buffer, recipe *Recipe) {
func (r Recipe) Render() string {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I also change writeProfile to (p Profile)Render
4959189b

@mous1985 mous1985 changed the title feat: Home page feat(example): r/mouss Jan 10, 2025
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.

Thanks for the PR; check my comments and resolve them, and we can move forward :)

On top of this, I suggest you remove the string builder for rendering and simply add a var out string

examples/gno.land/r/mouss/config/config.gno Outdated Show resolved Hide resolved
func Backup() std.Address {
return backup
}
func SetBack(buAddress std.Address) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not SetBackup(newAddr std.Addr) error?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -0,0 +1 @@
package config
Copy link
Contributor

Choose a reason for hiding this comment

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

Write some simple tests please :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

examples/gno.land/r/mouss/home/home.gno Outdated Show resolved Hide resolved
examples/gno.land/r/mouss/home/home.gno Outdated Show resolved Hide resolved
examples/gno.land/r/mouss/home/home.gno Outdated Show resolved Hide resolved
Comment on lines 186 to 198
}
func writeNavigation(b *strings.Builder) {
navItems := []string{
md.Link("Home", ""),
md.Link("World Kitchen", Rec),
md.Link("Hackerspace", "https://github.com/gnolang/hackerspace/issues/86#issuecomment-2535795751"),
}
b.WriteString(strings.Join(navItems, " | ") + "\n\n" + md.HorizontalRule() + "\n\n")
}
func Render(path string) string {
return router.Render(path)
}
func writeGnoArt(b *strings.Builder) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above, please make sure you have newlines.

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 27a0b5d1

Comment on lines 199 to 214
b.WriteString("```\n")
for _, line := range []string{
" -==++. ",
" *@@@@= @- -@",
" #@@@@@: -==-.-- :-::===: .-++-. @- .===:.- .-.-==- .===:=@",
" #@@@@@@@: -@@%**%@@ #@@#*#@@- *@@**@@* @- +%=::-*@ +@=-:-@* +%=::-*@",
" +@%#**#%@@ %@+ :@@ *@+ #@=+@% %@+ @= :@: -@ +% +%.@: -@",
" -: - *@%:..+@@ *@+ #@=-@@: :@@= @- .@= =@ +@ *%.@= =@",
" --:==+=-:=. =%@%#*@@ *@+ #@+ =%@%%@%= #* %#=.:%*===*@ +% +% -%*===*@",
" -++++=++++. =-:::*@# . . .::. .. :: .:: . . .:: .",
" .-=+++=: .*###%#= ",
" :: ",
} {
b.WriteString(line + "\n")
}
b.WriteString("```\n------")
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not write this as a single const string?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I add it in the first commit

Copy link
Contributor

Choose a reason for hiding this comment

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

Would be nice to have a bit of tests for this home package.

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 Jan 21, 2025
@leohhhn leohhhn removed the review/triage-pending PRs opened by external contributors that are waiting for the 1st review label Jan 21, 2025

// init initializes the router with the homepage and recipe routes.
func init() {

Copy link
Contributor

Choose a reason for hiding this comment

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

Newline!

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 about that, I'll be careful in the future to provide a clean code.
68b6a02a

}

func TestFollow(t *testing.T) {

Copy link
Contributor

Choose a reason for hiding this comment

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

Random newline

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I made a single commit for all random new lines in home_test.gno
e584e454

}

func TestIsUser(t *testing.T) {

Copy link
Contributor

Choose a reason for hiding this comment

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

Random newline

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 Jan 21, 2025
}

func TestIsAuthorized(t *testing.T) {

Copy link
Contributor

Choose a reason for hiding this comment

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

Random newline

Copy link
Contributor Author

Choose a reason for hiding this comment

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

)

func TestProfile(t *testing.T) {

Copy link
Contributor

Choose a reason for hiding this comment

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

Random newline

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines 125 to 126
// TODO:any user can follow and to be followed by any other user
// TODO: add a function to unfollow
Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest you fix these TODOs before we can merge

Copy link
Contributor Author

@mous1985 mous1985 Jan 22, 2025

Choose a reason for hiding this comment

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

  • I added func Unfollow d9f02e1e .

  • For // TODO: add a function to unfollow
    In my case, my profile is the only one on my home page, so no one else can create their profile there. What I’d like to propose for a future version, or for all home pages, is to have a template with commonly used features. for example: config, home, social, and within social, we include all the features related to user (home page) such like like, follow , unfollow , comment, subscribe ...etc.

@jefft0 jefft0 removed the review/triage-pending PRs opened by external contributors that are waiting for the 1st review label Jan 22, 2025
@jefft0
Copy link
Contributor

jefft0 commented Jan 22, 2025

Removed the review/triage-pending label because this PR was reviewed by core dev moul.

@Gno2D2 Gno2D2 added the review/triage-pending PRs opened by external contributors that are waiting for the 1st review label Jan 22, 2025
@jefft0 jefft0 removed the review/triage-pending PRs opened by external contributors that are waiting for the 1st review label Jan 24, 2025
@Gno2D2 Gno2D2 requested a review from a team January 24, 2025 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🧾 package/realm Tag used for new Realms or Packages.
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

5 participants