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

Updates from Readability version 0.5.0 #46

Merged
merged 7 commits into from
May 30, 2024

Conversation

yalhyane
Copy link
Contributor

@yalhyane yalhyane commented Feb 21, 2024

  • Fix detection of elements hidden with style="visibility: hidden"
  • Expanded comma detection to non-Latin commas
  • Add published time metadata from JSONLD
  • Use dateparse library to support more date formats parsing
  • Parse JSONLD when context url includes a trailing slash

Closes #48
Closes #55

@fmartingr fmartingr requested a review from Monirzadeh May 18, 2024 06:44
Copy link
Member

@fmartingr fmartingr left a comment

Choose a reason for hiding this comment

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

This LGTM. Thank you for the improvements @yalhyane, really appreciated. This probably overrides #48 and #55 since it's more complete by using the library.

@Monirzadeh can you take a quick look yourself just to have another set of eyes on this? Thank you

parser.go Outdated

// DatePublished
if datePublished, isString := parsed["datePublished"].(string); isString {
fmt.Println(datePublished)
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
fmt.Println(datePublished)

Copy link
Contributor

@Monirzadeh Monirzadeh 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 contribution. It is looking good to me too.

parser-parse.go Outdated
Comment on lines 152 to 154
if err != nil {
fmt.Printf("Failed to parse date \"%s\"\n", dateStr)
return nil
Copy link
Contributor

Choose a reason for hiding this comment

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

better to use log

parser-parse.go Outdated
Comment on lines 153 to 155
if err != nil {
fmt.Printf("Failed to parse date \"%s\"\n", dateStr)
log.Printf("Failed to parse date \"%s\"\n", dateStr)
return nil
Copy link
Contributor

Choose a reason for hiding this comment

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

what do you think about something like this?

if err != nil {
    log.Printf("Failed to parse date \"%s\": %w\n", dateStr, err)
    return nil
}

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 was using it to detect unsupported date formats, but I'll delete it.

Copy link
Member

Choose a reason for hiding this comment

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

He means switching from fmt to log, not deleting it. Log line works fine to display errors in console 👍

Copy link
Contributor

Choose a reason for hiding this comment

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

Plus err give us more details.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My apologies, I misread the code . I also noticed that the Parser has a log method that considers Debug mode. It might be better to make getParsedDate a method of Parser struct so we can use the Parser's log method and print the error in Debug mode only. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

Good idea but I think about go-readability do that for all logs.
For example when we use that can define the log mode (in production or debug mode)
But I am not sure if it will be overkill or make things unnecessary complicated.

Copy link
Contributor

@Monirzadeh Monirzadeh left a comment

Choose a reason for hiding this comment

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

Good work. Thanks

@Monirzadeh Monirzadeh requested a review from fmartingr May 23, 2024 20:28
@fmartingr
Copy link
Member

Hey @yalhyane, thank you for the contribution! Just fix the CI error and we can merge this :)

@yalhyane
Copy link
Contributor Author

@fmartingr I've fixed it :)

@fmartingr
Copy link
Member

@fmartingr I've fixed it :)

Awesome, thanks a lot for this!

@fmartingr fmartingr merged commit e170598 into go-shiori:master May 30, 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.

None yet

3 participants