X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=index.php;h=c0e0c66dcc90441a68ffe2dfc3641779ce912ce6;hb=893f5159c64e5bcff505c8367e6dc22cc2a7b14d;hp=5d689ccb36508aa841611c55cc87fe2e06e61706;hpb=c56a540c6ef211cd9cb0189ba09911bb77696f28;p=github%2Fshaarli%2FShaarli.git diff --git a/index.php b/index.php index 5d689ccb..c0e0c66d 100644 --- a/index.php +++ b/index.php @@ -432,55 +432,14 @@ function renderPage($conf, $pluginManager, $bookmarkService, $history, $sessionM // ATOM and RSS feed. if ($targetPage == Router::$PAGE_FEED_ATOM || $targetPage == Router::$PAGE_FEED_RSS) { $feedType = $targetPage == Router::$PAGE_FEED_RSS ? FeedBuilder::$FEED_RSS : FeedBuilder::$FEED_ATOM; - header('Content-Type: application/'. $feedType .'+xml; charset=utf-8'); - - // Cache system - $query = $_SERVER['QUERY_STRING']; - $cache = new CachedPage( - $conf->get('resource.page_cache'), - page_url($_SERVER), - startsWith($query, 'do='. $targetPage) && !$loginManager->isLoggedIn() - ); - $cached = $cache->cachedVersion(); - if (!empty($cached)) { - echo $cached; - exit; - } - $factory = new FormatterFactory($conf, $loginManager->isLoggedIn()); - // Generate data. - $feedGenerator = new FeedBuilder( - $bookmarkService, - $factory->getFormatter(), - $feedType, - $_SERVER, - $_GET, - $loginManager->isLoggedIn() - ); - $feedGenerator->setLocale(strtolower(setlocale(LC_COLLATE, 0))); - $feedGenerator->setHideDates($conf->get('privacy.hide_timestamps') && !$loginManager->isLoggedIn()); - $feedGenerator->setUsePermalinks(isset($_GET['permalinks']) || !$conf->get('feed.rss_permalinks')); - $data = $feedGenerator->buildData(); - - // Process plugin hook. - $pluginManager->executeHooks('render_feed', $data, array( - 'loggedin' => $loginManager->isLoggedIn(), - 'target' => $targetPage, - )); - - // Render the template. - $PAGE->assignAll($data); - $PAGE->renderPage('feed.'. $feedType); - $cache->cache(ob_get_contents()); - ob_end_flush(); + header('Location: ./feed-'. $feedType .'?'. http_build_query($_GET)); exit; } // Display opensearch plugin (XML) if ($targetPage == Router::$PAGE_OPENSEARCH) { - header('Content-Type: application/xml; charset=utf-8'); - $PAGE->assign('serverurl', index_url($_SERVER)); - $PAGE->renderPage('opensearch'); + header('Location: ./open-search'); exit; } @@ -492,35 +451,7 @@ function renderPage($conf, $pluginManager, $bookmarkService, $history, $sessionM // -------- User clicks on a tag in result count: Remove the tag from the list of searched tags (searchtags=...) if (isset($_GET['removetag'])) { - // Get previous URL (http_referer) and remove the tag from the searchtags parameters in query. - if (empty($_SERVER['HTTP_REFERER'])) { - header('Location: ?'); - exit; - } - - // In case browser does not send HTTP_REFERER - parse_str(parse_url($_SERVER['HTTP_REFERER'], PHP_URL_QUERY), $params); - - // Prevent redirection loop - if (isset($params['removetag'])) { - unset($params['removetag']); - } - - if (isset($params['searchtags'])) { - $tags = explode(' ', $params['searchtags']); - // Remove value from array $tags. - $tags = array_diff($tags, array($_GET['removetag'])); - $params['searchtags'] = implode(' ', $tags); - - if (empty($params['searchtags'])) { - unset($params['searchtags']); - } - - // We also remove page (keeping the same page has no sense, since - // the results are different) - unset($params['page']); - } - header('Location: ?'.http_build_query($params)); + header('Location: ./remove-tag/'. $_GET['removetag']); exit; } @@ -1612,8 +1543,12 @@ $app->group('', function () { $this->get('/tag-list', '\Shaarli\Front\Controller\TagCloudController:list')->setName('taglist'); $this->get('/daily', '\Shaarli\Front\Controller\DailyController:index')->setName('daily'); $this->get('/daily-rss', '\Shaarli\Front\Controller\DailyController:rss')->setName('dailyrss'); + $this->get('/feed-atom', '\Shaarli\Front\Controller\FeedController:atom')->setName('feedatom'); + $this->get('/feed-rss', '\Shaarli\Front\Controller\FeedController:rss')->setName('feedrss'); + $this->get('/open-search', '\Shaarli\Front\Controller\OpenSearchController:index')->setName('opensearch'); $this->get('/add-tag/{newTag}', '\Shaarli\Front\Controller\TagController:addTag')->setName('add-tag'); + $this->get('/remove-tag/{tag}', '\Shaarli\Front\Controller\TagController:removeTag')->setName('remove-tag'); })->add('\Shaarli\Front\ShaarliMiddleware'); $response = $app->run(true);