-
Notifications
You must be signed in to change notification settings - Fork 389
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
base: master
Are you sure you want to change the base?
feat(example): r/mouss
#3472
Conversation
🛠 PR Checks SummaryAll Automated Checks passed. ✅ Manual Checks (for Reviewers):
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) ☑️ Contributor Actions:
☑️ Reviewer Actions:
📚 Resources:Debug
|
} | ||
|
||
func renderHomepage(res *mux.ResponseWriter, req *mux.Request) { | ||
var b bytes.Buffer |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func writeRecipe(b *bytes.Buffer, recipe *Recipe) { | |
func (r Recipe) Render() string { |
There was a problem hiding this comment.
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
func writeProfile to method (p Profile)Render
There was a problem hiding this 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
func Backup() std.Address { | ||
return backup | ||
} | ||
func SetBack(buAddress std.Address) error { |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | ||
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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙏🏽 sorry 27a0b5d1
b.WriteString("```\n") | ||
for _, line := range []string{ | ||
" -==++. ", | ||
" *@@@@= @- -@", | ||
" #@@@@@: -==-.-- :-::===: .-++-. @- .===:.- .-.-==- .===:=@", | ||
" #@@@@@@@: -@@%**%@@ #@@#*#@@- *@@**@@* @- +%=::-*@ +@=-:-@* +%=::-*@", | ||
" +@%#**#%@@ %@+ :@@ *@+ #@=+@% %@+ @= :@: -@ +% +%.@: -@", | ||
" -: - *@%:..+@@ *@+ #@=-@@: :@@= @- .@= =@ +@ *%.@= =@", | ||
" --:==+=-:=. =%@%#*@@ *@+ #@+ =%@%%@%= #* %#=.:%*===*@ +% +% -%*===*@", | ||
" -++++=++++. =-:::*@# . . .::. .. :: .:: . . .:: .", | ||
" .-=+++=: .*###%#= ", | ||
" :: ", | ||
} { | ||
b.WriteString(line + "\n") | ||
} | ||
b.WriteString("```\n------") |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Co-authored-by: Leon Hudak <[email protected]>
Co-authored-by: Leon Hudak <[email protected]>
Co-authored-by: Leon Hudak <[email protected]>
Co-authored-by: Leon Hudak <[email protected]>
|
||
// init initializes the router with the homepage and recipe routes. | ||
func init() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Newline!
There was a problem hiding this comment.
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) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Random newline
There was a problem hiding this comment.
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) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Random newline
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | ||
|
||
func TestIsAuthorized(t *testing.T) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Random newline
There was a problem hiding this comment.
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) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Random newline
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// TODO:any user can follow and to be followed by any other user | ||
// TODO: add a function to unfollow |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 likelike
,follow
,unfollow
,comment
,subscribe
...etc.
Removed the |
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
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.feel free to add your recipes ;)
@leohhhn