javascript-config.html.twig 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. {% if user.authorized and authorize(['admin.login', 'admin.super']) %}
  2. {% 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 %}
  3. {% switch template_route %}
  4. {% case 'dashboard' %}
  5. {% set notifications_filters = "['feed', 'dashboard', 'top']" %}
  6. {% case 'plugins' %}
  7. {% set notifications_filters = "['plugins', 'top']" %}
  8. {% case 'themes' %}
  9. {% set notifications_filters = "['themes', 'top']" %}
  10. {% default %}
  11. {% set notifications_filters = "['top']" %}
  12. {% endswitch %}
  13. <script type="text/javascript">
  14. window.GravAdmin = window.GravAdmin || {};
  15. window.GravAdmin.config = {
  16. current_url: '{{ uri.getCurrentRoute().withLanguage(grav.language.active).withExtension('').withoutParams().toString(true) }}',
  17. base_url_relative: '{{ base_url_relative }}',
  18. base_url_simple: '{{ base_url_simple }}',
  19. route: '{{ admin.route|trim('/') }}',
  20. param_sep: '{{ config.system.param_sep }}',
  21. {% if authorize(['admin.maintenance', 'admin.super']) %}
  22. enable_auto_updates_check: '{{ config.plugins.admin.enable_auto_updates_check }}',
  23. {% endif %}
  24. admin_timeout: '{{ config.plugins.admin.session.timeout ?: 1800 }}',
  25. admin_nonce: '{{ admin.getNonce }}',
  26. language: '{{ grav.user.language|default('en') }}',
  27. pro_enabled: '{{ config.plugins["admin-pro"].enabled }}',
  28. notifications: {
  29. enabled: {{ notifications }},
  30. filters: {{ notifications_filters|raw }}
  31. },
  32. local_notifications: '{{ config.system.local_notifications|default(false) }}',
  33. site: {
  34. delimiter: '{{ config.site.summary.delimiter|default('===') }}'
  35. }
  36. };
  37. window.GravAdmin.uri_params = {};
  38. {% for param, value in grav.uri.params(null, true) %}
  39. window.GravAdmin.uri_params[{{ param|json_encode|raw }}] = "{{value|replace({'\\': '/'})}}";
  40. {% endfor %}
  41. </script>
  42. {% endif %}