Skip to content

script/generate-test: add publishedTime, modifiedTime to expected metadata #97

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions scripts/generate-test.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,14 @@ func renderMetadataToFile(original *html.Node, article readability.Article, file
defer dstFile.Close()

metadata := struct {
Title string `json:"title,omitempty"`
Byline string `json:"byline,omitempty"`
Excerpt string `json:"excerpt,omitempty"`
Language string `json:"language,omitempty"`
SiteName string `json:"siteName,omitempty"`
Readerable bool `json:"readerable"`
Title string `json:"title,omitempty"`
Byline string `json:"byline,omitempty"`
Excerpt string `json:"excerpt,omitempty"`
Language string `json:"language,omitempty"`
SiteName string `json:"siteName,omitempty"`
Readerable bool `json:"readerable"`
PublishedTime string `json:"publishedTime,omitempty"`
ModifiedTime string `json:"modifiedTime,omitempty"`
}{
Title: article.Title,
Byline: article.Byline,
Expand All @@ -198,6 +200,13 @@ func renderMetadataToFile(original *html.Node, article readability.Article, file
Readerable: readability.CheckDocument(original),
}

if article.PublishedTime != nil {
metadata.PublishedTime = article.PublishedTime.Format(time.RFC3339Nano)
}
if article.ModifiedTime != nil {
metadata.ModifiedTime = article.ModifiedTime.Format(time.RFC3339Nano)
}

bt, err := json.MarshalIndent(&metadata, "", " ")
if err != nil {
return fmt.Errorf("failed to marshal json: %v", err)
Expand Down