diff options
Diffstat (limited to 'index.php')
-rw-r--r-- | index.php | 41 |
1 files changed, 3 insertions, 38 deletions
@@ -432,45 +432,8 @@ function renderPage($conf, $pluginManager, $bookmarkService, $history, $sessionM | |||
432 | // ATOM and RSS feed. | 432 | // ATOM and RSS feed. |
433 | if ($targetPage == Router::$PAGE_FEED_ATOM || $targetPage == Router::$PAGE_FEED_RSS) { | 433 | if ($targetPage == Router::$PAGE_FEED_ATOM || $targetPage == Router::$PAGE_FEED_RSS) { |
434 | $feedType = $targetPage == Router::$PAGE_FEED_RSS ? FeedBuilder::$FEED_RSS : FeedBuilder::$FEED_ATOM; | 434 | $feedType = $targetPage == Router::$PAGE_FEED_RSS ? FeedBuilder::$FEED_RSS : FeedBuilder::$FEED_ATOM; |
435 | header('Content-Type: application/'. $feedType .'+xml; charset=utf-8'); | ||
436 | |||
437 | // Cache system | ||
438 | $query = $_SERVER['QUERY_STRING']; | ||
439 | $cache = new CachedPage( | ||
440 | $conf->get('resource.page_cache'), | ||
441 | page_url($_SERVER), | ||
442 | startsWith($query, 'do='. $targetPage) && !$loginManager->isLoggedIn() | ||
443 | ); | ||
444 | $cached = $cache->cachedVersion(); | ||
445 | if (!empty($cached)) { | ||
446 | echo $cached; | ||
447 | exit; | ||
448 | } | ||
449 | 435 | ||
450 | $factory = new FormatterFactory($conf, $loginManager->isLoggedIn()); | 436 | header('Location: ./feed-'. $feedType .'?'. http_build_query($_GET)); |
451 | // Generate data. | ||
452 | $feedGenerator = new FeedBuilder( | ||
453 | $bookmarkService, | ||
454 | $factory->getFormatter(), | ||
455 | $_SERVER, | ||
456 | $loginManager->isLoggedIn() | ||
457 | ); | ||
458 | $feedGenerator->setLocale(strtolower(setlocale(LC_COLLATE, 0))); | ||
459 | $feedGenerator->setHideDates($conf->get('privacy.hide_timestamps') && !$loginManager->isLoggedIn()); | ||
460 | $feedGenerator->setUsePermalinks(isset($_GET['permalinks']) || !$conf->get('feed.rss_permalinks')); | ||
461 | $data = $feedGenerator->buildData($feedType, $_GET); | ||
462 | |||
463 | // Process plugin hook. | ||
464 | $pluginManager->executeHooks('render_feed', $data, array( | ||
465 | 'loggedin' => $loginManager->isLoggedIn(), | ||
466 | 'target' => $targetPage, | ||
467 | )); | ||
468 | |||
469 | // Render the template. | ||
470 | $PAGE->assignAll($data); | ||
471 | $PAGE->renderPage('feed.'. $feedType); | ||
472 | $cache->cache(ob_get_contents()); | ||
473 | ob_end_flush(); | ||
474 | exit; | 437 | exit; |
475 | } | 438 | } |
476 | 439 | ||
@@ -1610,6 +1573,8 @@ $app->group('', function () { | |||
1610 | $this->get('/tag-list', '\Shaarli\Front\Controller\TagCloudController:list')->setName('taglist'); | 1573 | $this->get('/tag-list', '\Shaarli\Front\Controller\TagCloudController:list')->setName('taglist'); |
1611 | $this->get('/daily', '\Shaarli\Front\Controller\DailyController:index')->setName('daily'); | 1574 | $this->get('/daily', '\Shaarli\Front\Controller\DailyController:index')->setName('daily'); |
1612 | $this->get('/daily-rss', '\Shaarli\Front\Controller\DailyController:rss')->setName('dailyrss'); | 1575 | $this->get('/daily-rss', '\Shaarli\Front\Controller\DailyController:rss')->setName('dailyrss'); |
1576 | $this->get('/feed-atom', '\Shaarli\Front\Controller\FeedController:atom')->setName('feedatom'); | ||
1577 | $this->get('/feed-rss', '\Shaarli\Front\Controller\FeedController:rss')->setName('feedrss'); | ||
1613 | 1578 | ||
1614 | $this->get('/add-tag/{newTag}', '\Shaarli\Front\Controller\TagController:addTag')->setName('add-tag'); | 1579 | $this->get('/add-tag/{newTag}', '\Shaarli\Front\Controller\TagController:addTag')->setName('add-tag'); |
1615 | })->add('\Shaarli\Front\ShaarliMiddleware'); | 1580 | })->add('\Shaarli\Front\ShaarliMiddleware'); |