From 9fa8ef15010197c02e277812cf69fe32f40c10f5 Mon Sep 17 00:00:00 2001 From: Georg Gadinger Date: Sun, 19 Apr 2020 13:55:13 +0200 Subject: [PATCH] enable 'Discover' page for mods --- app/controllers/discover_controller.rb | 4 ++++ app/views/layouts/_header.html.haml | 2 +- config/routes.rb | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/controllers/discover_controller.rb b/app/controllers/discover_controller.rb index 5d1490a5..daeb7536 100644 --- a/app/controllers/discover_controller.rb +++ b/app/controllers/discover_controller.rb @@ -2,6 +2,10 @@ class DiscoverController < ApplicationController before_filter :authenticate_user! def index + unless APP_CONFIG.dig(:features, :discover, :enabled) || current_user.mod? + return redirect_to root_path + end + top_x = 10 # only display the top X items @popular_answers = Answer.where("created_at > ?", Time.now.ago(1.week)).order(:smile_count).reverse_order.limit(top_x) diff --git a/app/views/layouts/_header.html.haml b/app/views/layouts/_header.html.haml index 0c07ee32..fc88d814 100644 --- a/app/views/layouts/_header.html.haml +++ b/app/views/layouts/_header.html.haml @@ -22,7 +22,7 @@ %ul.nav.navbar-nav = nav_entry t('views.navigation.timeline'), root_path = nav_entry t('views.navigation.inbox'), "/inbox", badge: inbox_count - - if APP_CONFIG.dig(:features, :discover, :enabled) + - if APP_CONFIG.dig(:features, :discover, :enabled) || current_user.mod? = nav_entry t('views.navigation.discover'), discover_path %ul.nav.navbar-nav.navbar-right - unless @user.nil? diff --git a/config/routes.rb b/config/routes.rb index e266e01c..8176f058 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -104,7 +104,7 @@ Rails.application.routes.draw do match '/unsubscribe', to: 'subscription#unsubscribe', via: :post, as: :unsubscribe_answer end - match '/discover', to: 'discover#index', via: :get, as: :discover if APP_CONFIG.dig(:features, :discover, :enabled) + match '/discover', to: 'discover#index', via: :get, as: :discover match '/public', to: 'public#index', via: :get, as: :public_timeline if APP_CONFIG.dig(:features, :public, :enabled) match '/group/:group_name', to: 'group#index', via: :get, as: :group_timeline