From 7601ad705280804398bb6772b04b0b7c1f7fc313 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Mon, 11 Feb 2019 14:33:48 -0700 Subject: [PATCH] notifications js config --- admin.php | 1 + classes/admin.php | 4 ++-- .../partials/javascript-config.html.twig | 15 ++++++++++++++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/admin.php b/admin.php index 78850863..40054d42 100644 --- a/admin.php +++ b/admin.php @@ -563,6 +563,7 @@ class AdminPlugin extends Plugin $twig->twig_vars['location'] = $this->template; $twig->twig_vars['base_url_relative_frontend'] = $twig->twig_vars['base_url_relative'] ?: '/'; $twig->twig_vars['admin_route'] = trim($this->admin_route, '/'); + $twig->twig_vars['template_route'] = $this->template; $twig->twig_vars['current_route'] = '/' . $twig->twig_vars['admin_route'] . '/' . $this->template . '/' . $this->route; $twig->twig_vars['base_url_relative'] = $twig->twig_vars['base_url_simple'] . '/' . $twig->twig_vars['admin_route']; $twig->twig_vars['current_url'] = rtrim($twig->twig_vars['base_url_relative'] . '/' . $this->template . '/' . $this->route, '/'); diff --git a/classes/admin.php b/classes/admin.php index 54e1248d..6297a1b5 100644 --- a/classes/admin.php +++ b/classes/admin.php @@ -1346,8 +1346,8 @@ class Admin $timeout = $this->grav['config']->get('system.session.timeout', 1800); if ($force || !$last_checked || empty($notifications) || (time() - $last_checked > $timeout)) { - $body = Response::get('https://getgrav.org/notifications.json?' . time()); -// $body = Response::get('http://localhost/notifications.json?' . time()); +// $body = Response::get('https://getgrav.org/notifications.json?' . time()); + $body = Response::get('http://localhost/notifications.json?' . time()); $notifications = json_decode($body, true); // Sort by date diff --git a/themes/grav/templates/partials/javascript-config.html.twig b/themes/grav/templates/partials/javascript-config.html.twig index 9b22e6ab..09295d86 100644 --- a/themes/grav/templates/partials/javascript-config.html.twig +++ b/themes/grav/templates/partials/javascript-config.html.twig @@ -1,5 +1,15 @@ {% if authorize(['admin.login', 'admin.super']) %} {% set notifications = (config.plugins.admin.widgets['dashboard-notifications'] or config.plugins.admin.notifications.dashboard or config.plugins.admin.notifications.plugins or config.plugins.admin.notifications.themes) ? 1 : 0 %} +{% switch template_route %} + {% case 'dashboard' %} + {% set notifications_filters = 'feed,dashboard,top' %} + {% case 'plugins' %} + {% set notifications_filters = 'plugins,top' %} + {% case 'themes' %} + {% set notifications_filters = 'themes,top' %} + {% default %} + {% set notifications_filters = 'top' %} +{% endswitch %}