From 5a7c07dd896175026171b103e0949e8295fbd93b Mon Sep 17 00:00:00 2001 From: Sommerregen Date: Fri, 7 Aug 2015 20:32:58 +0200 Subject: [PATCH 1/3] Fixes #30 --- admin.php | 2 +- pages/admin/logout.md | 14 ++++++++++++++ themes/grav/templates/logout.html.twig | 17 +++++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 pages/admin/logout.md create mode 100644 themes/grav/templates/logout.html.twig diff --git a/admin.php b/admin.php index 41fe95d22..64810d834 100644 --- a/admin.php +++ b/admin.php @@ -180,7 +180,7 @@ public function onPagesInitialized() // Replace page service with admin. $this->grav['page'] = function () use ($self) { $page = new Page; - $page->init(new \SplFileInfo(__DIR__ . "/pages/admin/{$self->template}.md")); + $page->init(new \SplFileInfo(str_ireplace('task:', '',__DIR__ . "/pages/admin/{$self->template}.md"))); $page->slug(basename($self->template)); return $page; }; diff --git a/pages/admin/logout.md b/pages/admin/logout.md new file mode 100644 index 000000000..371ebd8cc --- /dev/null +++ b/pages/admin/logout.md @@ -0,0 +1,14 @@ +--- +title: Dashboard Logout + +form: + fields: + - name: username + type: text + placeholder: Username + autofocus: true + + - name: password + type: password + placeholder: Password +--- diff --git a/themes/grav/templates/logout.html.twig b/themes/grav/templates/logout.html.twig new file mode 100644 index 000000000..38a935300 --- /dev/null +++ b/themes/grav/templates/logout.html.twig @@ -0,0 +1,17 @@ +{% extends 'partials/base.html.twig' %} + +{% block head %} + {{ parent() }} + +{% endblock %} + +{% block page %} +
+

+ {{ title }} +

+ +
{{ 'LOGGED_OUT'|t }}
+ {% include 'partials/messages.html.twig' %} +
+{% endblock %} From 0165f53d4436db687f2e69485a9e612514d0f3b4 Mon Sep 17 00:00:00 2001 From: Sommerregen Date: Sat, 8 Aug 2015 11:16:04 +0200 Subject: [PATCH 2/3] Fixes #30, added logout page --- admin.php | 2 +- classes/controller.php | 2 +- themes/grav/templates/dashboard.html.twig | 14 +++++----- themes/grav/templates/denied.html.twig | 2 +- .../forms/fields/uploads/uploads.html.twig | 8 +++--- themes/grav/templates/logout.html.twig | 28 +++++++++---------- themes/grav/templates/pages.html.twig | 10 +++---- themes/grav/templates/partials/nav.html.twig | 2 +- .../partials/plugins-details.html.twig | 4 +-- .../templates/partials/plugins-list.html.twig | 4 +-- .../partials/themes-details.html.twig | 4 +-- .../templates/partials/themes-list.html.twig | 6 ++-- .../grav/templates/partials/toolbar.html.twig | 2 +- 13 files changed, 44 insertions(+), 44 deletions(-) diff --git a/admin.php b/admin.php index 64810d834..41fe95d22 100644 --- a/admin.php +++ b/admin.php @@ -180,7 +180,7 @@ public function onPagesInitialized() // Replace page service with admin. $this->grav['page'] = function () use ($self) { $page = new Page; - $page->init(new \SplFileInfo(str_ireplace('task:', '',__DIR__ . "/pages/admin/{$self->template}.md"))); + $page->init(new \SplFileInfo(__DIR__ . "/pages/admin/{$self->template}.md")); $page->slug(basename($self->template)); return $page; }; diff --git a/classes/controller.php b/classes/controller.php index b9050328d..95e69b967 100644 --- a/classes/controller.php +++ b/classes/controller.php @@ -151,7 +151,7 @@ protected function taskLogout() $this->admin->session()->invalidate()->start(); $this->admin->setMessage($l->translate('LOGGED_OUT'), 'info'); - $this->setRedirect('/'); + $this->setRedirect('/logout'); return true; } diff --git a/themes/grav/templates/dashboard.html.twig b/themes/grav/templates/dashboard.html.twig index 0e1f2ebe4..c21b57d8c 100644 --- a/themes/grav/templates/dashboard.html.twig +++ b/themes/grav/templates/dashboard.html.twig @@ -3,15 +3,15 @@ {% block titlebar %}
@@ -62,8 +62,8 @@
- - + +
diff --git a/themes/grav/templates/denied.html.twig b/themes/grav/templates/denied.html.twig index 3a96e7b2b..11a67662e 100644 --- a/themes/grav/templates/denied.html.twig +++ b/themes/grav/templates/denied.html.twig @@ -8,7 +8,7 @@ {% include 'partials/messages.html.twig' %} -

{{ admin.user.fullname }}, your account does not have administrator permissions. Logout

+

{{ admin.user.fullname }}, your account does not have administrator permissions. Logout

{% endblock %} diff --git a/themes/grav/templates/forms/fields/uploads/uploads.html.twig b/themes/grav/templates/forms/fields/uploads/uploads.html.twig index d8ef5071b..947ff958e 100644 --- a/themes/grav/templates/forms/fields/uploads/uploads.html.twig +++ b/themes/grav/templates/forms/fields/uploads/uploads.html.twig @@ -60,7 +60,7 @@ previewTemplate: "
\n
\n
\n
\n \n
\n
\n
\n
\n
\nDelete\nInsert\n
", init: function() { thisDropzone = this; - $.get(URI + '/task:listmedia', function(data) { + $.get(URI + '/task{{ config.system.param_sep }}listmedia', function(data) { $.proxy(modalError, this, { data: data, @@ -106,7 +106,7 @@ this.on('removedfile', function(file) { if (!file.accepted || file.rejected) return; thisDropzone = this; - $.post(URI + '/task:delmedia', {filename: file.name}, function(data){ + $.post(URI + '/task{{ config.system.param_sep }}delmedia', {filename: file.name}, function(data){ $.proxy(modalError, thisDropzone, { file: file, data: data, @@ -118,7 +118,7 @@ } }; - var dropzone = new Dropzone("#gravDropzone", { url: URI + '/task:addmedia', createImageThumbnails: { thumbnailWidth: 150} }); + var dropzone = new Dropzone("#gravDropzone", { url: URI + '/task{{ config.system.param_sep }}addmedia', createImageThumbnails: { thumbnailWidth: 150} }); $("#gravDropzone").delegate('.dz-preview', 'dragstart', function(e){ var uri = $(this).find('.dz-filename').text(), shortcode = '![](' + encodeURI(uri) + ')'; @@ -146,4 +146,4 @@ -{% endif %} \ No newline at end of file +{% endif %} diff --git a/themes/grav/templates/logout.html.twig b/themes/grav/templates/logout.html.twig index 38a935300..cf454adb3 100644 --- a/themes/grav/templates/logout.html.twig +++ b/themes/grav/templates/logout.html.twig @@ -1,17 +1,17 @@ -{% extends 'partials/base.html.twig' %} - -{% block head %} +{% embed 'partials/login.html.twig' with {title:'Grav Logout'} %} + {% block head %} {{ parent() }} - -{% endblock %} + + {% endblock %} -{% block page %} -
-

- {{ title }} -

+ {% block page %} +
+

+ {{ title }} +

-
{{ 'LOGGED_OUT'|t }}
- {% include 'partials/messages.html.twig' %} -
-{% endblock %} +
{{ 'LOGGED_OUT'|t }}
+ {% include 'partials/messages.html.twig' %} +
+ {% endblock %} +{% endembed %} diff --git a/themes/grav/templates/pages.html.twig b/themes/grav/templates/pages.html.twig index 5dcd3b38f..b46e88d30 100644 --- a/themes/grav/templates/pages.html.twig +++ b/themes/grav/templates/pages.html.twig @@ -54,9 +54,9 @@ {{ p.home ? '' }} {% if warn %} - + {% else %} - + {% endif %}

{{ p.route }}

@@ -81,12 +81,12 @@ {% elseif mode == 'edit' %} Back {% if exists %} - Copy + Copy Move {% if warn %} - Delete + Delete {% else %} - + {% endif %} {% endif %} diff --git a/themes/grav/templates/partials/nav.html.twig b/themes/grav/templates/partials/nav.html.twig index 08b29b6e7..6a89b0e3e 100644 --- a/themes/grav/templates/partials/nav.html.twig +++ b/themes/grav/templates/partials/nav.html.twig @@ -62,7 +62,7 @@ -->
  • - Logout + Logout
  • diff --git a/themes/grav/templates/partials/plugins-details.html.twig b/themes/grav/templates/partials/plugins-details.html.twig index 2ed264489..8e7bdf014 100644 --- a/themes/grav/templates/partials/plugins-details.html.twig +++ b/themes/grav/templates/partials/plugins-details.html.twig @@ -35,10 +35,10 @@ {% else %} {% endif %} diff --git a/themes/grav/templates/partials/plugins-list.html.twig b/themes/grav/templates/partials/plugins-list.html.twig index b0a80ddcb..e30f6c9ca 100644 --- a/themes/grav/templates/partials/plugins-list.html.twig +++ b/themes/grav/templates/partials/plugins-list.html.twig @@ -25,11 +25,11 @@ {% if (not installing and plugin.form.fields.enabled and (plugin.form.fields.enabled.type != 'hidden')) %} - + {% elseif (installing) %} - Install + Install {% endif %} diff --git a/themes/grav/templates/partials/themes-details.html.twig b/themes/grav/templates/partials/themes-details.html.twig index b168b0b55..18a7bfb19 100644 --- a/themes/grav/templates/partials/themes-details.html.twig +++ b/themes/grav/templates/partials/themes-details.html.twig @@ -102,12 +102,12 @@ {% if (config.get('system.pages.theme') != admin.route) %} {% endif %} {% else %} {% endif %} diff --git a/themes/grav/templates/partials/themes-list.html.twig b/themes/grav/templates/partials/themes-list.html.twig index 87d384508..c2f0d78df 100644 --- a/themes/grav/templates/partials/themes-list.html.twig +++ b/themes/grav/templates/partials/themes-list.html.twig @@ -31,15 +31,15 @@ {% if (state == 'installing') %} {% elseif state == 'active' %}
    Active Theme
    {% else %} - - {# #} + + {# #} Activate {% endif %} diff --git a/themes/grav/templates/partials/toolbar.html.twig b/themes/grav/templates/partials/toolbar.html.twig index 59b961de8..34c6b4ff8 100644 --- a/themes/grav/templates/partials/toolbar.html.twig +++ b/themes/grav/templates/partials/toolbar.html.twig @@ -10,6 +10,6 @@ {% if admin.authorise %} -6Hi, {{ admin.user.fullname }} Logout +6Hi, {{ admin.user.fullname }} Logout {% endif %} From fa8db3dd90c06f184804895b2ead34bf5a51cd1d Mon Sep 17 00:00:00 2001 From: Sommerregen Date: Sat, 8 Aug 2015 17:41:53 +0200 Subject: [PATCH 3/3] Add `config.param_sep` option to JS files --- themes/grav/js/admin-all.js | 13 ++++++++----- themes/grav/js/mdeditor.js | 5 +++-- themes/grav/js/pages-all.js | 3 ++- .../templates/partials/javascript-config.html.twig | 5 +++-- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/themes/grav/js/admin-all.js b/themes/grav/js/admin-all.js index 78628fe14..8c9a0722d 100644 --- a/themes/grav/js/admin-all.js +++ b/themes/grav/js/admin-all.js @@ -123,13 +123,14 @@ $(function () { $(this).attr('disabled','disabled').find('> .fa').removeClass('fa-cloud-download').addClass('fa-refresh fa-spin'); var url = $(this).data('maintenanceUpdate'); + var task = 'task' + GravAdmin.config.param_sep; GravAjax({ dataType: "json", url: url, toastErrors: true, success: function(result, status) { - if (url.indexOf('task:updategrav') !== -1) { + if (url.indexOf(task + 'updategrav') !== -1) { if (result.status == 'success') { $('[data-gpm-grav]').remove(); toastr.success(result.message + window.grav_available_version); @@ -181,6 +182,7 @@ $(function () { url: url, toastErrors: true, success: function(result, status) { + var task = 'task' + GravAdmin.config.param_sep; var toastrBackup = {}; if (result.toastr) { @@ -198,7 +200,7 @@ $(function () { } } - if (url.indexOf('task:backup') !== -1) { + if (url.indexOf(task + 'backup') !== -1) { //Reset backup days count $('.backups-chart .numeric').html("0 days"); @@ -255,13 +257,14 @@ $(function () { success: function (response) { var grav = response.payload.grav, installed = response.payload.installed, - resources = response.payload.resources; + resources = response.payload.resources, + task = 'task' + GravAdmin.config.param_sep; // grav updatable if (grav.isUpdatable) { var icon = ' '; content = 'Grav v{available} is now available! (Current: v{version}) ', - button = ''; + button = ''; if (grav.isSymlink) { button = ''; @@ -293,7 +296,7 @@ $(function () { var length, icon = '', content = '{updates} of your {type} have an update available', - button = 'Update {Type}', + button = 'Update {Type}', plugins = $('.grav-update.plugins'), themes = $('.grav-update.themes'), sidebar = {plugins: $('#admin-menu a[href$="/plugins"]'), themes: $('#admin-menu a[href$="/themes"]')}; diff --git a/themes/grav/js/mdeditor.js b/themes/grav/js/mdeditor.js index 7b9e48299..efe4c0dcb 100644 --- a/themes/grav/js/mdeditor.js +++ b/themes/grav/js/mdeditor.js @@ -36,7 +36,8 @@ ].join(''); var MDEditor = function(editor, options){ - var tpl = template, $this = this; + var tpl = template, $this = this, + task = 'task' + GravAdmin.config.param_sep; this.defaults = { markdown : false, @@ -93,7 +94,7 @@ if ($(this).hasClass('grav-mdeditor-button-preview')) { GravAjax({ dataType: 'JSON', - url: $this.element.data('grav-urlpreview') + '/task:processmarkdown', + url: $this.element.data('grav-urlpreview') + '/' + task + 'processmarkdown', method: 'post', data: $this.element.parents('form').serialize(), toastErrors: true, diff --git a/themes/grav/js/pages-all.js b/themes/grav/js/pages-all.js index 98f54ea87..e85fb198c 100644 --- a/themes/grav/js/pages-all.js +++ b/themes/grav/js/pages-all.js @@ -76,6 +76,7 @@ $(function(){ restoreStates(); var startFilterPages = function () { + var task = 'task' + GravAdmin.config.param_sep; $('input[name="page-search"]').focus(); var flags = $('input[name="page-filter"]').val(), @@ -89,7 +90,7 @@ $(function(){ GravAjax({ dataType: 'json', method: 'POST', - url: GravAdmin.config.base_url_relative + '/pages-filter.json/task:filterPages', + url: GravAdmin.config.base_url_relative + '/pages-filter.json/' + task + 'filterPages', data: { flags: flags, query: query diff --git a/themes/grav/templates/partials/javascript-config.html.twig b/themes/grav/templates/partials/javascript-config.html.twig index c5014e97d..e1c1854fe 100644 --- a/themes/grav/templates/partials/javascript-config.html.twig +++ b/themes/grav/templates/partials/javascript-config.html.twig @@ -1,6 +1,7 @@ \ No newline at end of file +