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

Do not allow to save links with an empty title #73

Merged
merged 3 commits into from
Aug 19, 2024

Conversation

danilax86
Copy link
Contributor

@danilax86 danilax86 commented Aug 10, 2024

When it was possible to do so, a link looked super weird in a list view and you were not able to click on a link and visit one.

Here is a screenshot:
image

So, I decided to make a custom rule for garde. Now it looks like this:
image

A better feature may become to create a somewhat title fetcher, when title is empty. A client sends get request and parses response body by looking for <title> tag, if there is none, finds a <h1> and so on. If nothing else found a message returned and users are asked to provide a title themselves.

@raffomania
Copy link
Owner

Thanks! Automatically fetching the title is already being worked on in #63.

Could you run cargo fmt to format your changes?

@danilax86
Copy link
Contributor Author

danilax86 commented Aug 10, 2024

@raffomania done

upd: made cargo fmt, empty line was added, force pushed, but nothing changed in github when looking at a diff. Strange..

@raffomania
Copy link
Owner

I can see the change in the diff - do you have the "hide whitespace changes" setting on?

image

@raffomania
Copy link
Owner

raffomania commented Aug 12, 2024

The lints are still failing - please run just lint (or cargo clippy -- -D warnings) to see the errors and instructions on how to fix them.

Tip: You can run just ci-dev to catch almost all errors that would make the CI fail, locally, before pushing :)

@danilax86
Copy link
Contributor Author

@raffomania Thank you for tips!

I couldn't beat garde's impossibility to create a custom rule without context. I mean, I did with providing an empty context, but linter was suggesting do not pass context by reference, but by value, which breaks fn(&T, &<T as Validate>::Context) -> garde::Result as being said: https://github.com/jprochazk/garde?tab=readme-ov-file#custom-validation

I found a solution with garde's required rule. Changed type of title to Option<String> and dug around templates a bit. Have a look: danilax86@ae4d40b

Tell me, please, which solution do you like most

@raffomania
Copy link
Owner

Great initiative! Using an option is a creative solution. I think the custom validator is more straightforward and easier to understand. Bypassing the clippy lint is totally justified here. Thanks for your contribution!

@raffomania raffomania merged commit 3d39f79 into raffomania:main Aug 19, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants