Tweak feed.json structuring
This commit is contained in:
@@ -1941,6 +1941,17 @@ mod tests {
|
|||||||
);
|
);
|
||||||
let content_html = item["content_html"].as_str().unwrap();
|
let content_html = item["content_html"].as_str().unwrap();
|
||||||
assert!(content_html.contains("<h2>"), "{content_html}");
|
assert!(content_html.contains("<h2>"), "{content_html}");
|
||||||
|
assert!(
|
||||||
|
content_html.contains("<p class=\"meta\">A. Writer · Example Feed · example.com</p>"),
|
||||||
|
"{content_html}"
|
||||||
|
);
|
||||||
|
assert!(
|
||||||
|
content_html.contains(
|
||||||
|
"<p class=\"links\"><a href=\"https://news.ycombinator.com/item?id=40100000\">Hacker News</a></p>"
|
||||||
|
),
|
||||||
|
"{content_html}"
|
||||||
|
);
|
||||||
|
assert!(!content_html.contains("</a> — "), "{content_html}");
|
||||||
assert!(
|
assert!(
|
||||||
!item["date_published"].as_str().unwrap().is_empty(),
|
!item["date_published"].as_str().unwrap().is_empty(),
|
||||||
"{item}"
|
"{item}"
|
||||||
|
|||||||
@@ -553,4 +553,35 @@ mod tests {
|
|||||||
assert!(!html.contains(private), "leaked {private:?} in {html}");
|
assert!(!html.contains(private), "leaked {private:?} in {html}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn feed_entry_wraps_byline_and_links_in_paragraphs() {
|
||||||
|
let mut source = crate::epub::fixtures::issue();
|
||||||
|
// A second comment link, so the separator between links is exercised.
|
||||||
|
source.lineup.picks[0].article.comments_url =
|
||||||
|
Some("https://example.com/discuss".to_string());
|
||||||
|
let issue = PublicIssue::from(&source);
|
||||||
|
let html = FeedEntryTemplate { issue: &issue }.render().unwrap();
|
||||||
|
|
||||||
|
assert!(html.contains("<h2>Top Stories</h2><ul>"), "{html}");
|
||||||
|
assert!(
|
||||||
|
html.contains(
|
||||||
|
"<li><a href=\"https://example.com/1001\">The Lead Story</a><p class=\"meta\">A. Writer · Example Feed · example.com</p>"
|
||||||
|
),
|
||||||
|
"{html}"
|
||||||
|
);
|
||||||
|
assert!(
|
||||||
|
html.contains("<p class=\"summary\">What it argues, and why it is worth the time.</p>"),
|
||||||
|
"{html}"
|
||||||
|
);
|
||||||
|
assert!(
|
||||||
|
html.contains(
|
||||||
|
"<p class=\"links\"><a href=\"https://news.ycombinator.com/item?id=40100000\">Hacker News</a> · <a href=\"https://example.com/discuss\">Comments</a></p></li>"
|
||||||
|
),
|
||||||
|
"{html}"
|
||||||
|
);
|
||||||
|
// The old run-together byline and adjacent links are gone.
|
||||||
|
assert!(!html.contains("</a> — "), "{html}");
|
||||||
|
assert!(!html.contains("Hacker News</a><a "), "{html}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{% for section in issue.sections %}<h2>{{ section.name }}</h2><ul>{% for entry in section.entries %}<li><a href="{{ entry.url }}">{{ entry.title }}</a> — {% match entry.author %}{% when Some with (author) %}{{ author }} · {% when None %}{% endmatch %}{{ entry.source }}{% match entry.publication %}{% when Some with (publication) %} · {{ publication }}{% when None %}{% endmatch %}{% match entry.summary %}{% when Some with (summary) %}<p class="summary">{{ summary }}</p>{% when None %}{% endmatch %}{% if !entry.comment_links.is_empty() %} · {% for link in entry.comment_links %}<a href="{{ link.url }}">{{ link.label }}</a>{% endfor %}{% endif %}</li>{% endfor %}</ul>{% endfor %}
|
{% for section in issue.sections %}<h2>{{ section.name }}</h2><ul>{% for entry in section.entries %}<li><a href="{{ entry.url }}">{{ entry.title }}</a><p class="meta">{% match entry.author %}{% when Some with (author) %}{{ author }} · {% when None %}{% endmatch %}{{ entry.source }}{% match entry.publication %}{% when Some with (publication) %} · {{ publication }}{% when None %}{% endmatch %}</p>{% match entry.summary %}{% when Some with (summary) %}<p class="summary">{{ summary }}</p>{% when None %}{% endmatch %}{% if !entry.comment_links.is_empty() %}<p class="links">{% for link in entry.comment_links %}<a href="{{ link.url }}">{{ link.label }}</a>{% if !loop.last %} · {% endif %}{% endfor %}</p>{% endif %}</li>{% endfor %}</ul>{% endfor %}
|
||||||
|
|||||||
Reference in New Issue
Block a user