root > potd > bin > potd-rss.php

potd-rss.php

application/x-php, 5239 bytes (load raw)
<?php
if (@$_SERVER['REQUEST_URI']) die("command line only");
require_once("potd-lib.php");

#$feedauthor = 'potd@tools.wikimedia.de';
$feedauthor = 'WikiPOTD';

$dir = $argv[1];
$sz = $argv[2];
$proj = basename($dir);

$info = load_info($dir);
extract($info); //$name, $url, $wiki

$tname = str_replace('_', ' ', $name);

$ttl = escape_xml("$tname @ $server ($sz)");
$timestamp = filemtime("$dir/potd.name");

//$description = file_get_contents("$dir/potd.html");
$description = NULL; //NOTE: people just want the purty image.

$thumbscale = get_thumbscale($info, '120x120');
$imgscale = get_thumbscale($info, $sz);

$credit = str_replace(' ', '_', $meta['user']) . ' at ' . $server;

$itemttl= "$tname [POTD for " . gmdate( 'F d', $timestamp ) . " from $wiki]";
$guid = "http://tools.wikimedia.de/~daniel/potd/#$proj/$sz@" . gmdate( 'YmdHis', $timestamp) . ":$uri@" . gmdate( 'YmdHis', $meta['epoch']);

$thumb = rendered_url($info, '120x120');

$html = '';
$html.= '<p style="text-align:center">' . "\n";
$html.= image_html($info, $sz);
$html.= '</p>';

if ($description) {
        $html.= '<hr/>' . "\n";
        $html.= '<p>' . "\n";
        $html.= $description;
        $html.= '</p>' . "\n";
}

function rssDate($timestamp) {
    return gmdate( 'D, d M Y H:i:s \G\M\T', $timestamp );
}

print '<?xml version="1.0" encoding="UTF-8"?>'."\n";
?>
<rss version="2.0"
        xmlns:media="http://search.yahoo.com/mrss/"
        xmlns:dc="http://purl.org/dc/elements/1.1/"
        xmlns:ocwlom="http://cwspace.mit.edu/docs/xsd/lomv1.0/ocwExtend/version10"
        xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
        xmlns:foaf='http://xmlns.com/foaf/0.1/'>

<channel>
<title>POTD - <?= escape_xml($wiki)?> (<?= $sz ?>)</title>
<link>http://tools.wikimedia.de/~daniel/potd/potd.php#<?=urlencode($proj)?></link>
<description>Picture of the Day from <?= escape_xml($wiki)?></description>
<language>en-us</language><? /* FIXME */ ?>
<copyright>Feed: GNU Free Documentation License; Images: see description page</copyright>
<pubDate><?= rssDate( $timestamp ) ?></pubDate>
<lastBuildDate><?= rssDate( $timestamp ) ?></lastBuildDate>

<generator>WikiPOTD 0.5.5</generator>
<docs>http://meta.wikimedia.org/wiki/User:Duesentrieb/POTD</docs>

<image>
        <!-- Icon from http://commons.wikimedia.org/wiki/Image:Featured_envelope.svg,
             created by pfctdayelise. Licensed under GFDL-1.2 and CC-BY-SA-2.5 -->
        <url>http://tools.wikimedia.de/~daniel/potd/potd.png</url>
        <title>POTD - <?= escape_xml($wiki)?> (<?= $sz ?>)</title>
        <link>http://tools.wikimedia.de/~daniel/potd/potd.php#<?=urlencode($proj)?></link>
</image>

<item>
       
        <!-- core RSS -->
        <title><?= escape_xml($itemttl) ?></title>
        <pubDate><?= rssDate( $timestamp ) ?></pubDate>
        <link><?= escape_xml($url)?></link>
        <guid isPermaLink="false"><?= escape_xml($guid)?></guid>
        <description>
                <?= escape_xml($html)?>
        </description>
        <? /* good in theory, but inreality only used for audio/video
        <enclosure url="<?= escape_xml(rendered_url($info, $sz)) ?>"
                length="<?= $meta['size'] ?>"
                type="<?= $mime ?>"/>
        */
?>

        <!-- DC -->
        <dc:title><?= escape_xml($itemttl) ?></dc:title>
        <dc:publisher><?= escape_xml($feedauthor) ?></dc:publisher>
        <dc:source><?= escape_xml($url)?></dc:source>
        <dc:identifier><?= escape_xml($guid)?></dc:identifier>
       
        <!-- RDF -->
        <rdf:Description rdf:about='<?= escape_xml($uri)?>'>
                <dc:identifier><?= escape_xml($uri)?></dc:identifier>
                <dc:title><?= escape_xml($tname) ?></dc:title>
                <dc:date><?= gmdate( 'c', $meta['epoch'] ) ?></dc:date>
                <dc:publisher><?= escape_xml($credit) ?></dc:publisher>
                <dc:type>Image</dc:type>
                <dc:format><?= $mime ?></dc:format>
                <dc:format><?= floor($imgscale * $width)  ?> x <?= floor($imgscale * $height) ?> pixels</dc:format>
        </rdf:Description>
       
        <!-- FOAF  -->
        <foaf:Image rdf:about='<?= escape_xml($uri)?>'>
                <foaf:page rdf:resource='<?= escape_xml($url)?>'/>
                <foaf:thumbnail rdf:resource='<?= escape_xml($thumb)?>'/>
                <dc:identifier><?= escape_xml($uri)?></dc:identifier>
                <dc:title><?= escape_xml($tname) ?></dc:title>
                <dc:date><?= gmdate( 'c', $meta['epoch'] ) ?></dc:date>
                <dc:publisher><?= escape_xml($credit) ?></dc:publisher>
                <dc:type>Image</dc:type>
                <dc:format><?= $mime ?></dc:format>
                <dc:format><?= floor($imgscale * $width)  ?> x <?= floor($imgscale * $height) ?> pixels</dc:format>
        </foaf:Image>
       
        <? foreach( $categories as $cat ) { ?>
                <foaf:topic rdf:resource='<?= "http://$server/wiki/Category:" . urlencode($cat) ?>'/>
        <? } ?>
       
        <!-- yahoo media -->
        <media:content url="<?= escape_xml(rendered_url($info, $sz)) ?>"
        type="<?= $mime ?>"
        height="<?= floor($imgscale * $height) ?>"
        width="<?= floor($imgscale * $width)  ?>"/>
        <media:title><?= escape_xml($tname) ?></media:title>
        <media:text type="html">
                <?= escape_xml($html)?>
        </media:text>
        <media:thumbnail url="<?= escape_xml($thumb) ?>" height="<?= floor($thumbscale * $height) ?>" width="<?= floor($thumbscale * $width) ?>" />
        <media:copyright url="<?= escape_xml($url) ?>">see description page</media:copyright>
        <media:credit scheme="ocwlom:roleValues" role="Content Provider"><?= escape_xml($credit) ?></media:credit>
        <media:category scheme="urn:mediawiki:categories"><?= implode(' ', $categories) ?></media:category>
</item>

</channel>
</rss>