javascript-config.html.twig 1.5 KB

123456789101112131415161718192021222324252627282930
  1. {% if 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. <script type="text/javascript">
  4. window.GravAdmin = window.GravAdmin || {};
  5. window.GravAdmin.config = {
  6. current_url: '{{ uri.route(true) }}',
  7. base_url_relative: '{{ base_url_relative }}',
  8. base_url_simple: '{{ base_url_simple }}',
  9. route: '{{ admin.route|trim('/') }}',
  10. param_sep: '{{ config.system.param_sep }}',
  11. {% if authorize(['admin.maintenance', 'admin.super']) %}
  12. enable_auto_updates_check: '{{ config.plugins.admin.enable_auto_updates_check }}',
  13. {% endif %}
  14. admin_timeout: '{{ config.plugins.admin.session.timeout ?: 1800 }}',
  15. admin_nonce: '{{ admin.getNonce }}',
  16. language: '{{ grav.user.language|default('en') }}',
  17. pro_enabled: '{{ config.plugins["admin-pro"].enabled }}',
  18. notifications: {{ notifications }},
  19. local_notifications: '{{ config.system.local_notifications|default(false) }}',
  20. site: {
  21. delimiter: '{{ config.site.summary.delimiter|default('===') }}'
  22. }
  23. };
  24. window.GravAdmin.uri_params = {};
  25. {% for param, value in grav.uri.params(null, true) %}
  26. window.GravAdmin.uri_params.{{param}} = "{{value|replace({'\\': '/'})}}";
  27. {% endfor %}
  28. </script>
  29. {% endif %}