Change OPDS feed to show number of ebooks in each subject category, and a 'related' link back to the ebook's SE homepage

This commit is contained in:
Alex Cabal 2020-07-09 13:03:20 -05:00
parent 53f1e7ab29
commit 75e7cce726
2 changed files with 9 additions and 2 deletions

View file

@ -43,8 +43,14 @@ foreach($contentFiles as $path){
sort($subjects);
$subjectNavigationEntries = [];
foreach($subjects as $subject){
// We leave the updated timestamp blank, as it will be filled in when we generate the individaul feeds
$subjectNavigationEntries[] = new OpdsNavigationEntry('/opds/subjects/' . Formatter::MakeUrlSafe($subject), 'subsection', 'navigation', null, $subject, 'Browse Standard Ebooks tagged with “' . strtolower($subject) . ',” most-recently-released first.');
$summary = number_format(sizeof($ebooksBySubject[$subject])) . ' Standard Ebook';
if(sizeof($ebooksBySubject[$subject]) != 1){
$summary .= 's';
}
$summary .= ' tagged with “' . strtolower($subject) . ',” most-recently-released first.';
// We leave the updated timestamp blank, as it will be filled in when we generate the individual feeds
$subjectNavigationEntries[] = new OpdsNavigationEntry('/opds/subjects/' . Formatter::MakeUrlSafe($subject), 'subsection', 'navigation', null, $subject, $summary);
}
$subjectsFeed = new OpdsNavigationFeed('/opds/subjects', 'Standard Ebooks by Subject', '/opds', $subjectNavigationEntries);
$subjectsFeed->Save(WEB_ROOT . '/opds/subjects/index.xml');