Skip to content

Commit

Permalink
Optionally put the reddit comment thread in the title link, as before.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Feb 1, 2016
1 parent f866e5f commit 9a92fcc
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions feed/index.php
Expand Up @@ -212,27 +212,33 @@ function recache($subreddit, $fname, $url)
link => $oururl,
);

$linktothread = ((isset($_REQUEST['linktothread'])) && (intval($_REQUEST['linktothread']) != 0));

$items = array();
foreach ($json->data->children as $obj)
{
$item = $obj->data;

$nsfw = $item->over_18 ? "<font color='#FF0000'>[NSFW]</font>" : '';

$permalink = "https://www.reddit.com/{$item->permalink}";
$itemurl = $item->url;
$titleurl = $linktothread ? $permalink : $itemurl;

$desc = <<<EOF
<a href='{$item->url}'>{$item->title}</a> (<a href='https://www.reddit.com/domain/{$item->domain}/'>{$item->domain}</a>)<br/>
<a href='$titleurl'>{$item->title}</a> (<a href='https://www.reddit.com/domain/{$item->domain}/'>{$item->domain}</a>)<br/>
submitted by <a href='https://www.reddit.com/user/{$item->author}'>{$item->author}</a> to <a href='https://www.reddit.com/r/{$item->subreddit}'>/r/{$item->subreddit}</a><br/>
$nsfw <a href='https://www.reddit.com/{$item->permalink}'>{$item->num_comments} comments</a>
$nsfw <a href='$permalink'>{$item->num_comments} comments</a> <a href='$itemurl'>original</a>
EOF;

$pubdate = $item->created_utc;
$dt = new DateTime("@$pubdate");
$pubdatefmt = $dt->format(DateTime::RSS);

$items[] = array(
guid => "http://www.reddit.com/{$item->permalink}", // this matches the guid we used when scraping the RSS feeds.
guid => $permalink, // this matches the guid we used when scraping the RSS feeds.
title => $item->title,
link => $item->url,
link => $titleurl,
summary => $desc,
description => $desc,
pubdate => $pubdatefmt,
Expand Down

0 comments on commit 9a92fcc

Please sign in to comment.