summaryrefslogtreecommitdiffstats
path: root/controller
diff options
context:
space:
mode:
authorBernhard Posselt <dev@bernhard-posselt.com>2016-01-22 17:53:15 +0100
committerBernhard Posselt <dev@bernhard-posselt.com>2016-01-22 17:53:15 +0100
commit9435bfc2174ee35ea36c2ada14dc2a8275e56331 (patch)
treeb4d3058af71f5d1e10c60229f5c1fcecea6a7d02 /controller
parentdc9392d0f8881ab7736f0daf1f785e5c3d0871ef (diff)
change explore url
Diffstat (limited to 'controller')
-rw-r--r--controller/pagecontroller.php22
1 files changed, 16 insertions, 6 deletions
diff --git a/controller/pagecontroller.php b/controller/pagecontroller.php
index 5768549c6..23714f9ae 100644
--- a/controller/pagecontroller.php
+++ b/controller/pagecontroller.php
@@ -20,12 +20,14 @@ use OCP\IURLGenerator;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Http\JSONResponse;
+use OCP\AppFramework\Http;
use OCP\AppFramework\Http\ContentSecurityPolicy;
use OCA\News\Service\StatusService;
use OCA\News\Config\AppConfig;
use OCA\News\Config\Config;
use OCA\News\Explore\RecommendedSites;
+use OCA\News\Explore\RecommendedSiteNotFoundException;
use OCA\News\Db\FeedType;
class PageController extends Controller {
@@ -39,6 +41,8 @@ class PageController extends Controller {
private $recommendedSites;
private $statusService;
+ use JSONHttpError;
+
public function __construct($AppName,
IRequest $request,
IConfig $settings,
@@ -99,7 +103,11 @@ class PageController extends Controller {
$exploreUrl = $this->config->getExploreUrl();
if (trim($exploreUrl) === '') {
- $exploreUrl = $this->urlGenerator->linkToRoute('news.page.explore');
+ // default url should not feature the sites.en.json
+ $exploreUrl = $this->urlGenerator->linkToRoute(
+ 'news.page.explore', ['lang' => 'en']
+ );
+ $exploreUrl = preg_replace('/sites\.en\.json$/', '', $exploreUrl);
}
$result = [
@@ -191,16 +199,18 @@ class PageController extends Controller {
*
* @param string $lang
*/
- public function explore($lang='en') {
- $default = 'en';
-
+ public function explore($lang) {
$this->settings->setUserValue($this->userId, $this->appName,
'lastViewedFeedId', 0);
$this->settings->setUserValue($this->userId, $this->appName,
'lastViewedFeedType', FeedType::EXPLORE);
- return $this->recommendedSites->forLanguage($lang, $default);
+ try {
+ return $this->recommendedSites->forLanguage($lang);
+ } catch (RecommendedSiteNotFoundException $ex) {
+ return $this->error($ex, Http::STATUS_NOT_FOUND);
+ }
}
-} \ No newline at end of file
+}