From a128e603ca9cb33f246924aba1d0090ca582091c Mon Sep 17 00:00:00 2001 From: Emanuele Goldoni Date: Mon, 7 Mar 2022 23:12:58 +0100 Subject: [PATCH 1/2] enable content Preview - fixes #1383 --- bl-kernel/admin/views/editor.php | 10 ++++++++++ bl-plugins/api/plugin.php | 7 ++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/bl-kernel/admin/views/editor.php b/bl-kernel/admin/views/editor.php index a4b67003..674c6c8e 100644 --- a/bl-kernel/admin/views/editor.php +++ b/bl-kernel/admin/views/editor.php @@ -77,6 +77,10 @@ _pageKey = response.data.key; // Set friendly URL with the key //$('#friendlyURL').val(response.data.key); + $('#btnPreview').attr('data-key', response.data.key); + if (response.data.preview) { + $('#btnPreview').attr('data-preview', response.data.preview); + } } else { logs('An error occurred while trying to save the current page.'); showAlertError(response.message); @@ -211,6 +215,12 @@ openModal('type'); }); + $('#btnPreview').click(function() { + if ($(this).attr('data-key') && $(this).attr('data-preview')) { + window.open(''+$(this).attr('data-key')+'?preview='+$(this).attr('data-preview')); + } + }); + $('#category').on("change", function() { enableBtnSave(); }); diff --git a/bl-plugins/api/plugin.php b/bl-plugins/api/plugin.php index e9962ec3..e1e24f48 100644 --- a/bl-plugins/api/plugin.php +++ b/bl-plugins/api/plugin.php @@ -156,6 +156,8 @@ class pluginAPI extends Plugin { $key = $parmC.'/'.$parmD; } $data = $this->getFiles($key); + //$page = new Page($pageKey); + //$path = PATH_UPLOADS_PAGES.$page->uuid().DS; } // (POST) /api/pages/files/:key elseif ( ($method==='POST') && ($parmA==='pages') && ($parmB==='files') && !empty($parmC) && $writePermissions ) { @@ -539,11 +541,14 @@ class pluginAPI extends Plugin { 'message'=>'Error trying to edit the page.' ); } + + $page = new Page($newKey); + $preview = md5($page->uuid()); return array( 'status'=>'0', 'message'=>'Page edited.', - 'data'=>array('key'=>$newKey) + 'data'=>array('key'=>$newKey, 'preview'=>$preview) ); } From 2d4544acbb3a2087a9ec4059c9b19652554f2fd8 Mon Sep 17 00:00:00 2001 From: Emanuele Goldoni Date: Tue, 3 May 2022 20:10:01 +0200 Subject: [PATCH 2/2] remove commented code --- bl-plugins/api/plugin.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/bl-plugins/api/plugin.php b/bl-plugins/api/plugin.php index 950bf234..39b062e1 100644 --- a/bl-plugins/api/plugin.php +++ b/bl-plugins/api/plugin.php @@ -160,8 +160,6 @@ class pluginAPI extends Plugin { $key = $parmC.'/'.$parmD; } $data = $this->getFiles($key); - //$page = new Page($pageKey); - //$path = PATH_UPLOADS_PAGES.$page->uuid().DS; } // (POST) /api/pages/files/:key elseif ( ($method==='POST') && ($parmA==='pages') && ($parmB==='files') && !empty($parmC) && $writePermissions ) { @@ -1100,4 +1098,4 @@ class pluginAPI extends Plugin { 'message'=>'An error occurred while trying to configure the plugin.' ); } -} \ No newline at end of file +}