Feature page preview and switch button for publish and draft
This commit is contained in:
parent
3fa5a420c2
commit
3066c091d2
|
@ -45,9 +45,6 @@ if (IMAGE_RESTRICT) {
|
|||
define('PAGE_THUMBNAILS_DIRECTORY', PATH_UPLOADS_PAGES.PAGE_IMAGES_KEY.DS.'thumbnails'.DS);
|
||||
define('PAGE_THUMBNAILS_HTML', HTML_PATH_UPLOADS_PAGES.PAGE_IMAGES_KEY.'/thumbnails/');
|
||||
define('PAGE_THUMBNAILS_URL', DOMAIN_UPLOADS_PAGES.PAGE_IMAGES_KEY.'/thumbnails/');
|
||||
|
||||
// Create the directory to store the images
|
||||
Filesystem::mkdir(PAGE_THUMBNAILS_DIRECTORY, true);
|
||||
} else {
|
||||
define('PAGE_IMAGES_DIRECTORY', (IMAGE_RELATIVE_TO_ABSOLUTE? '' : HTML_PATH_UPLOADS));
|
||||
define('PAGE_IMAGES_URL', (IMAGE_RELATIVE_TO_ABSOLUTE? '' : DOMAIN_UPLOADS));
|
||||
|
|
|
@ -61,7 +61,7 @@ echo Bootstrap::formOpen(array(
|
|||
|
||||
<div id="jseditorToolbarLeft">
|
||||
<button type="button" class="btn btn-sm btn-primary" id="jsbuttonSave"><?php echo $L->g('Save') ?></button>
|
||||
<button type="button" class="btn btn-sm btn-secondary" id="jsbuttonSave"><?php $L->p('Discard') ?></button>
|
||||
<button id="jsbuttonPreview" type="button" class="btn btn-sm btn-secondary"><?php $L->p('Preview') ?></button>
|
||||
<span id="jsswitchButton" data-switch="<?php echo ($page->draft()?'draft':'publish') ?>" class="ml-2 text-secondary switch-button"><i class="fa fa-square switch-icon-<?php echo ($page->draft()?'draft':'publish') ?>"></i> <?php echo ($page->draft()?$L->g('Draft'):$L->g('Publish')) ?></span>
|
||||
</div>
|
||||
|
||||
|
@ -394,6 +394,16 @@ $(document).ready(function() {
|
|||
}
|
||||
});
|
||||
|
||||
// Button preview
|
||||
$("#jsbuttonPreview").on("click", function() {
|
||||
var uuid = $("#jsuuid").val();
|
||||
var title = $("#jstitle").val();
|
||||
var content = editorGetContent();
|
||||
var ajax = new bluditAjax();
|
||||
ajax.autosave(uuid, title, content, false);
|
||||
window.open("<?php echo DOMAIN_PAGES.'autosave-'.$page->uuid().'?preview='.md5('autosave-'.$page->uuid()) ?>", "_blank");
|
||||
});
|
||||
|
||||
// Button Save
|
||||
$("#jsbuttonSave").on("click", function() {
|
||||
// If the switch is setted to "published", get the value from the selector
|
||||
|
|
|
@ -54,9 +54,9 @@ echo Bootstrap::formOpen(array(
|
|||
</div>
|
||||
|
||||
<div id="jseditorToolbarLeft">
|
||||
<button type="button" class="btn btn-sm btn-primary" id="jsbuttonSave"><?php $L->p('Save') ?></button>
|
||||
<button type="button" class="btn btn-sm btn-secondary" id="jsbuttonSave"><?php $L->p('Discard') ?></button>
|
||||
<span id="jsswitchButton" data-switch="publish" class="ml-2 text-secondary switch-button"><i class="fa fa-square switch-icon-publish"></i> <?php $L->p('Publish') ?></span>
|
||||
<button id="jsbuttonSave" type="button" class="btn btn-sm btn-primary" ><?php $L->p('Save') ?></button>
|
||||
<button id="jsbuttonPreview" type="button" class="btn btn-sm btn-secondary"><?php $L->p('Preview') ?></button>
|
||||
<span id="jsbuttonSwitch" data-switch="publish" class="ml-2 text-secondary switch-button"><i class="fa fa-square switch-icon-publish"></i> <?php $L->p('Publish') ?></span>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
|
@ -334,7 +334,7 @@ $(document).ready(function() {
|
|||
}
|
||||
|
||||
// Button switch
|
||||
$("#jsswitchButton").on("click", function() {
|
||||
$("#jsbuttonSwitch").on("click", function() {
|
||||
if ($(this).data("switch")=="publish") {
|
||||
$(this).html('<i class="fa fa-square switch-icon-draft"></i> <?php $L->p('Draft') ?>');
|
||||
$(this).data("switch", "draft");
|
||||
|
@ -344,10 +344,20 @@ $(document).ready(function() {
|
|||
}
|
||||
});
|
||||
|
||||
// Button preview
|
||||
$("#jsbuttonPreview").on("click", function() {
|
||||
var uuid = $("#jsuuid").val();
|
||||
var title = $("#jstitle").val();
|
||||
var content = editorGetContent();
|
||||
var ajax = new bluditAjax();
|
||||
ajax.autosave(uuid, title, content, false);
|
||||
window.open("<?php echo DOMAIN_PAGES.'autosave-'.$uuid.'?preview='.md5('autosave-'.$uuid) ?>", "_blank");
|
||||
});
|
||||
|
||||
// Button Save
|
||||
$("#jsbuttonSave").on("click", function() {
|
||||
// If the switch is setted to "published", get the value from the selector
|
||||
if ($("#jsswitchButton").data("switch")=="publish") {
|
||||
if ($("#jsbuttonSwitch").data("switch")=="publish") {
|
||||
var value = $("#jstypeSelector option:selected").val();
|
||||
$("#jstype").val(value);
|
||||
} else {
|
||||
|
|
|
@ -16,11 +16,6 @@ if (empty($uuid)) {
|
|||
ajaxResponse(1, 'Autosave fail. UUID not defined.');
|
||||
}
|
||||
|
||||
// Check content length to create the autosave page
|
||||
if (Text::length($content)<100) {
|
||||
ajaxResponse(1, 'Autosave not completed. The content length is less than 100 characters.');
|
||||
}
|
||||
|
||||
$autosaveUUID = 'autosave-'.$uuid;
|
||||
$page = array(
|
||||
'uuid'=>$autosaveUUID,
|
||||
|
|
|
@ -18,6 +18,9 @@ $uuid = empty($_POST['uuid']) ? false : $_POST['uuid'];
|
|||
if ($uuid && IMAGE_RESTRICT) {
|
||||
$imageDirectory = PATH_UPLOADS_PAGES.$uuid.DS;
|
||||
$thumbnailDirectory = $imageDirectory.'thumbnails'.DS;
|
||||
if (!Filesystem::directoryExists($thumbnailDirectory)) {
|
||||
Filesystem::mkdir($thumbnailDirectory, true);
|
||||
}
|
||||
} else {
|
||||
$imageDirectory = PATH_UPLOADS;
|
||||
$thumbnailDirectory = PATH_UPLOADS_THUMBNAILS;
|
||||
|
|
|
@ -50,7 +50,7 @@ if ($pages->scheduler()) {
|
|||
));
|
||||
}
|
||||
|
||||
// Set home page if the user defined them
|
||||
// Set home page if the user defined one
|
||||
if ($site->homepage() && $url->whereAmI()==='home') {
|
||||
$pageKey = $site->homepage();
|
||||
if ($pages->exists($pageKey)) {
|
||||
|
|
Loading…
Reference in New Issue