generated feed: use tag: instead of the public.php URL as an entry ID; set enclosure length to 1 if unknown

This commit is contained in:
Andrew Dolgov 2015-03-28 16:11:44 +03:00
parent 7e1cf4e48e
commit 4b7391de7b
1 changed files with 9 additions and 4 deletions

View File

@ -101,8 +101,7 @@ class Handler_Public extends Handler {
$tpl->setVariable('ARTICLE_ID', $tpl->setVariable('ARTICLE_ID',
htmlspecialchars($orig_guid ? $line['link'] : htmlspecialchars($orig_guid ? $line['link'] :
get_self_url_prefix() . $this->url_to_tag_uri($line['id'], $line['date_entered'])), true);
"/public.php?url=" . urlencode($line['link'])), true);
$tpl->setVariable('ARTICLE_LINK', htmlspecialchars($line['link']), true); $tpl->setVariable('ARTICLE_LINK', htmlspecialchars($line['link']), true);
$tpl->setVariable('ARTICLE_TITLE', htmlspecialchars($line['title']), true); $tpl->setVariable('ARTICLE_TITLE', htmlspecialchars($line['title']), true);
$tpl->setVariable('ARTICLE_EXCERPT', $line["content_preview"], true); $tpl->setVariable('ARTICLE_EXCERPT', $line["content_preview"], true);
@ -125,7 +124,7 @@ class Handler_Public extends Handler {
$tpl->setVariable('ARTICLE_AUTHOR', htmlspecialchars($line['author']), true); $tpl->setVariable('ARTICLE_AUTHOR', htmlspecialchars($line['author']), true);
$tpl->setVariable('ARTICLE_SOURCE_LINK', htmlspecialchars($line['site_url']), true); $tpl->setVariable('ARTICLE_SOURCE_LINK', htmlspecialchars($line['site_url'] ? $line["site_url"] : get_self_url_prefix()), true);
$tpl->setVariable('ARTICLE_SOURCE_TITLE', htmlspecialchars($line['feed_title'] ? $line['feed_title'] : $feed_title), true); $tpl->setVariable('ARTICLE_SOURCE_TITLE', htmlspecialchars($line['feed_title'] ? $line['feed_title'] : $feed_title), true);
$tags = get_article_tags($line["id"], $owner_uid); $tags = get_article_tags($line["id"], $owner_uid);
@ -140,7 +139,7 @@ class Handler_Public extends Handler {
foreach ($enclosures as $e) { foreach ($enclosures as $e) {
$type = htmlspecialchars($e['content_type']); $type = htmlspecialchars($e['content_type']);
$url = htmlspecialchars($e['content_url']); $url = htmlspecialchars($e['content_url']);
$length = $e['duration']; $length = $e['duration'] ? $e['duration'] : 1;
$tpl->setVariable('ARTICLE_ENCLOSURE_URL', $url, true); $tpl->setVariable('ARTICLE_ENCLOSURE_URL', $url, true);
$tpl->setVariable('ARTICLE_ENCLOSURE_TYPE', $type, true); $tpl->setVariable('ARTICLE_ENCLOSURE_TYPE', $type, true);
@ -1033,5 +1032,11 @@ class Handler_Public extends Handler {
} }
} }
private function url_to_tag_uri($id, $timestamp) {
$timestamp = date("Y-m-d", strtotime($timestamp));
return "tag:" . parse_url(get_self_url_prefix(), PHP_URL_HOST) . ",$timestamp:/$id";
}
} }
?> ?>