Ejemplo n.º 1
0
function run()
{
    $client = \arc\cache::proxy(\arc\http::client(), function ($params) {
        return \arc\http\headers::parseCacheTime($params['target']->responseHeaders);
    });
    $feeds = handleFeeds(__DIR__ . '/../data/feeds.json', $client);
    $aggregator = aggregator($client);
    echo h::doctype() . h::html(h::head(h::title('RSS Aggregator'), h::link(['href' => '//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css', 'rel' => 'stylesheet']), h::link(['href' => 'cards.css', 'rel' => 'stylesheet']), h::script(['src' => '//code.jquery.com/jquery-1.12.0.min.js']), h::script(['src' => 'cards.js'])), h::body(h::raw($aggregator->render($feeds)), h::footer(h::form(['method' => 'POST'], h::input(['name' => 'newFeed']), h::button(['ype' => 'submit'], 'Add feed')))));
}
Ejemplo n.º 2
0
 function testCacheControl()
 {
     \arc\cache::purge();
     $testProxy = \arc\cache::proxy(new takesTooLong(true), function ($params) {
         return 30;
     });
     $result = $testProxy->waitForIt();
     $this->assertTrue($result);
 }
Ejemplo n.º 3
0
<?php

require __DIR__ . '/../vendor/autoload.php';
use arc\html as h;
use arc\xml as x;
$client = \arc\cache::proxy(\arc\http::client(), function ($params) {
    return \arc\http\headers::parseCacheTime($params['target']->responseHeaders);
});
$feed = $client->get('https://www.nasa.gov/rss/dyn/breaking_news.rss');
try {
    $rss = x::parse($feed);
} catch (\Exception $e) {
    $rss = h::parse($feed);
}
$items = $rss->find('item');
foreach ($items as $item) {
    echo h::article(h::h2(h::a(['href' => $item->link->nodeValue], $item->title->nodeValue)), h::div(['class' => 'body'], $item->description->nodeValue));
}