mirror of
https://github.com/danpros/htmly.git
synced 2026-04-17 19:26:08 +05:30
Improved autosaving feature
Autosaving now can be disabled in the config menu and only saves when the content field is not empty.
This commit is contained in:
parent
912418984b
commit
96d5145395
13 changed files with 162 additions and 31 deletions
|
|
@ -174,6 +174,7 @@ if (login()) {
|
|||
$draft = 'true';
|
||||
$posttype = $_POST['posttype'];
|
||||
|
||||
if (!empty($content)) {
|
||||
if ($posttype == 'is_page') {
|
||||
$response = auto_save_page($title, $url, $content, $draft, $description);
|
||||
} else {
|
||||
|
|
@ -202,7 +203,9 @@ if (login()) {
|
|||
}
|
||||
$response = auto_save_post($title, $tag, $url, $content, $user, $draft, $category, $type, $description, $media, $dateTime);
|
||||
}
|
||||
|
||||
} else {
|
||||
$response = "No content to save.";
|
||||
}
|
||||
echo $response;
|
||||
} else {
|
||||
$login = site_url() . 'login';
|
||||
|
|
|
|||
|
|
@ -183,7 +183,9 @@ rss_settings = "RSS settings"
|
|||
read_more_text = "Read more text"
|
||||
read_more_text_placeholder = "Read more"
|
||||
reading = "Reading"
|
||||
writing = "Writing"
|
||||
reading_settings = "Reading Settings"
|
||||
writing_settings = "Writing Settings"
|
||||
recaptcha = "reCAPTCHA"
|
||||
recent_posts = "Recent posts"
|
||||
recent_posts_widget_at_most = "Recent posts widget at most"
|
||||
|
|
@ -293,3 +295,5 @@ verify_password = "Verify current password"
|
|||
manualsetupkey = "You can also manually add the setup key"
|
||||
mfa_error = "MFA code is not correct"
|
||||
disablemfa = "Disable MFA"
|
||||
enable_auto_save = "Enable Auto Save to Drafts"
|
||||
explain_autosave = "When enabled, new posts or pages will automatically be saved as a draft every 60 seconds after you start writing."
|
||||
|
|
@ -313,4 +313,6 @@ $('.img-container').on("click", ".the-img", function(e) {
|
|||
$('#insertImageDialogURL').val($(e.target).attr('src'));
|
||||
});
|
||||
</script>
|
||||
<script src="<?php echo site_url() ?>system/resources/js/save_draft.js"></script>
|
||||
<?php if (config('autosave.enable') == 'true' ) {
|
||||
echo '<script src="'.site_url().'system/resources/js/save_draft.js"></script>';
|
||||
} ?>
|
||||
|
|
|
|||
|
|
@ -139,4 +139,6 @@ $('.img-container').on("click", ".the-img", function(e) {
|
|||
$('#insertImageDialogURL').val($(e.target).attr('src'));
|
||||
});
|
||||
</script>
|
||||
<script src="<?php echo site_url() ?>system/resources/js/save_draft.js"></script>
|
||||
<?php if (config('autosave.enable') == 'true' ) {
|
||||
echo '<script src="'.site_url().'system/resources/js/save_draft.js"></script>';
|
||||
} ?>
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
<div class="nav nav-tabs" id="nav-tab">
|
||||
<a class="nav-item nav-link" id="nav-general-tab" href="<?php echo site_url();?>admin/config"><?php echo i18n('General');?></a>
|
||||
<a class="nav-item nav-link" id="nav-profile-tab" href="<?php echo site_url();?>admin/config/reading"><?php echo i18n('Reading');?></a>
|
||||
<a class="nav-item nav-link" id="nav-writing-tab" href="<?php echo site_url();?>admin/config/writing"><?php echo i18n('Writing');?></a>
|
||||
<a class="nav-item nav-link" id="nav-widget-tab" href="<?php echo site_url();?>admin/config/widget"><?php echo i18n('Widget');?></a>
|
||||
<a class="nav-item nav-link" id="nav-metatags-tab" href="<?php echo site_url();?>admin/config/metatags"><?php echo i18n('Metatags');?></a>
|
||||
<a class="nav-item nav-link" id="nav-performance-tab" href="<?php echo site_url();?>admin/config/performance"><?php echo i18n('Performance');?></a>
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@ if (empty($defaultFormat)) {
|
|||
<div class="nav nav-tabs" id="nav-tab">
|
||||
<a class="nav-item nav-link" id="nav-general-tab" href="<?php echo site_url();?>admin/config"><?php echo i18n('General');?></a>
|
||||
<a class="nav-item nav-link" id="nav-profile-tab" href="<?php echo site_url();?>admin/config/reading"><?php echo i18n('Reading');?></a>
|
||||
<a class="nav-item nav-link" id="nav-writing-tab" href="<?php echo site_url();?>admin/config/writing"><?php echo i18n('Writing');?></a>
|
||||
<a class="nav-item nav-link" id="nav-widget-tab" href="<?php echo site_url();?>admin/config/widget"><?php echo i18n('Widget');?></a>
|
||||
<a class="nav-item nav-link active" id="nav-metatags-tab" href="<?php echo site_url();?>admin/config/metatags"><?php echo i18n('Metatags');?></a>
|
||||
<a class="nav-item nav-link" id="nav-performance-tab" href="<?php echo site_url();?>admin/config/performance"><?php echo i18n('Performance');?></a>
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
<div class="nav nav-tabs" id="nav-tab">
|
||||
<a class="nav-item nav-link" id="nav-general-tab" href="<?php echo site_url();?>admin/config"><?php echo i18n('General');?></a>
|
||||
<a class="nav-item nav-link" id="nav-profile-tab" href="<?php echo site_url();?>admin/config/reading"><?php echo i18n('Reading');?></a>
|
||||
<a class="nav-item nav-link" id="nav-writing-tab" href="<?php echo site_url();?>admin/config/writing"><?php echo i18n('Writing');?></a>
|
||||
<a class="nav-item nav-link" id="nav-widget-tab" href="<?php echo site_url();?>admin/config/widget"><?php echo i18n('Widget');?></a>
|
||||
<a class="nav-item nav-link" id="nav-metatags-tab" href="<?php echo site_url();?>admin/config/metatags"><?php echo i18n('Metatags');?></a>
|
||||
<a class="nav-item nav-link active" id="nav-performance-tab" href="<?php echo site_url();?>admin/config/performance"><?php echo i18n('Performance');?></a>
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
<div class="nav nav-tabs" id="nav-tab">
|
||||
<a class="nav-item nav-link" id="nav-general-tab" href="<?php echo site_url();?>admin/config"><?php echo i18n('General');?></a>
|
||||
<a class="nav-item nav-link active" id="nav-profile-tab" href="<?php echo site_url();?>admin/config/reading"><?php echo i18n('Reading');?></a>
|
||||
<a class="nav-item nav-link" id="nav-writing-tab" href="<?php echo site_url();?>admin/config/writing"><?php echo i18n('Writing');?></a>
|
||||
<a class="nav-item nav-link" id="nav-widget-tab" href="<?php echo site_url();?>admin/config/widget"><?php echo i18n('Widget');?></a>
|
||||
<a class="nav-item nav-link" id="nav-metatags-tab" href="<?php echo site_url();?>admin/config/metatags"><?php echo i18n('Metatags');?></a>
|
||||
<a class="nav-item nav-link" id="nav-performance-tab" href="<?php echo site_url();?>admin/config/performance"><?php echo i18n('Performance');?></a>
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
<div class="nav nav-tabs" id="nav-tab">
|
||||
<a class="nav-item nav-link" id="nav-general-tab" href="<?php echo site_url();?>admin/config"><?php echo i18n('General');?></a>
|
||||
<a class="nav-item nav-link" id="nav-profile-tab" href="<?php echo site_url();?>admin/config/reading"><?php echo i18n('Reading');?></a>
|
||||
<a class="nav-item nav-link" id="nav-writing-tab" href="<?php echo site_url();?>admin/config/writing"><?php echo i18n('Writing');?></a>
|
||||
<a class="nav-item nav-link active" id="nav-widget-tab" href="<?php echo site_url();?>admin/config/widget"><?php echo i18n('Widget');?></a>
|
||||
<a class="nav-item nav-link" id="nav-metatags-tab" href="<?php echo site_url();?>admin/config/metatags"><?php echo i18n('Metatags');?></a>
|
||||
<a class="nav-item nav-link" id="nav-performance-tab" href="<?php echo site_url();?>admin/config/performance"><?php echo i18n('Performance');?></a>
|
||||
|
|
|
|||
43
system/admin/views/config-writing.html.php
Normal file
43
system/admin/views/config-writing.html.php
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
<?php if (!defined('HTMLY')) die('HTMLy'); ?>
|
||||
<h2><?php echo i18n('Writing_Settings');?></h2>
|
||||
<br>
|
||||
<nav>
|
||||
<div class="nav nav-tabs" id="nav-tab">
|
||||
<a class="nav-item nav-link" id="nav-general-tab" href="<?php echo site_url();?>admin/config"><?php echo i18n('General');?></a>
|
||||
<a class="nav-item nav-link" id="nav-profile-tab" href="<?php echo site_url();?>admin/config/reading"><?php echo i18n('Reading');?></a>
|
||||
<a class="nav-item nav-link active" id="nav-writing-tab" href="<?php echo site_url();?>admin/config/writing"><?php echo i18n('Writing');?></a>
|
||||
<a class="nav-item nav-link" id="nav-widget-tab" href="<?php echo site_url();?>admin/config/widget"><?php echo i18n('Widget');?></a>
|
||||
<a class="nav-item nav-link" id="nav-metatags-tab" href="<?php echo site_url();?>admin/config/metatags"><?php echo i18n('Metatags');?></a>
|
||||
<a class="nav-item nav-link" id="nav-performance-tab" href="<?php echo site_url();?>admin/config/performance"><?php echo i18n('Performance');?></a>
|
||||
<a class="nav-item nav-link" id="nav-custom-tab" href="<?php echo site_url();?>admin/config/custom"><?php echo i18n('Custom');?></a>
|
||||
</div>
|
||||
</nav>
|
||||
<br><br>
|
||||
<form method="POST">
|
||||
<input type="hidden" name="csrf_token" value="<?php echo get_csrf(); ?>">
|
||||
<div class="form-group row">
|
||||
<label class="col-sm-2 col-form-label"><?php echo i18n('Enable_auto_save');?></label>
|
||||
<div class="col-sm-10">
|
||||
<div class="col-sm-10">
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="radio" name="-config-autosave.enable" id="autosave.enable1" value="true" <?php if (config('autosave.enable') === 'true'):?>checked<?php endif;?>>
|
||||
<label class="form-check-label" for="autosave.enable1">
|
||||
<?php echo i18n('Enable');?>
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="radio" name="-config-autosave.enable" id="autosave.enable2" value="false" <?php if (config('autosave.enable') === 'false'):?>checked<?php endif;?>>
|
||||
<label class="form-check-label" for="autosave.enable2">
|
||||
<?php echo i18n('Disable');?>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<small><em><?php echo i18n('explain_autosave');?></em></small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<div class="col-sm-10">
|
||||
<button type="submit" class="btn btn-primary"><?php echo i18n('Save_Config');?></button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
|
@ -11,6 +11,7 @@ Please install and enable the INTL extension to format the date format to your l
|
|||
<div class="nav nav-tabs" id="nav-tab">
|
||||
<a class="nav-item nav-link active" id="nav-general-tab" href="<?php echo site_url();?>admin/config"><?php echo i18n('General');?></a>
|
||||
<a class="nav-item nav-link" id="nav-profile-tab" href="<?php echo site_url();?>admin/config/reading"><?php echo i18n('Reading');?></a>
|
||||
<a class="nav-item nav-link" id="nav-writing-tab" href="<?php echo site_url();?>admin/config/writing"><?php echo i18n('Writing');?></a>
|
||||
<a class="nav-item nav-link" id="nav-widget-tab" href="<?php echo site_url();?>admin/config/widget"><?php echo i18n('Widget');?></a>
|
||||
<a class="nav-item nav-link" id="nav-metatags-tab" href="<?php echo site_url();?>admin/config/metatags"><?php echo i18n('Metatags');?></a>
|
||||
<a class="nav-item nav-link" id="nav-performance-tab" href="<?php echo site_url();?>admin/config/performance"><?php echo i18n('Performance');?></a>
|
||||
|
|
|
|||
|
|
@ -86,5 +86,6 @@
|
|||
"default.image",
|
||||
"favicon.image",
|
||||
"views.root",
|
||||
"views.layout"
|
||||
"views.layout",
|
||||
"autosave.enable"
|
||||
]
|
||||
|
|
@ -1774,6 +1774,76 @@ post('/admin/config/reading', function () {
|
|||
}
|
||||
});
|
||||
|
||||
// Show Config page
|
||||
get('/admin/config/writing', function () {
|
||||
|
||||
$user = $_SESSION[site_url()]['user'];
|
||||
$role = user('role', $user);
|
||||
|
||||
if (login()) {
|
||||
config('views.root', 'system/admin/views');
|
||||
if ($role === 'admin') {
|
||||
render('config-writing', array(
|
||||
'title' => generate_title('is_default', i18n('Config')),
|
||||
'description' => safe_html(strip_tags(blog_description())),
|
||||
'canonical' => site_url(),
|
||||
'metatags' => generate_meta(null, null),
|
||||
'type' => 'is_admin-config',
|
||||
'is_admin' => true,
|
||||
'bodyclass' => 'admin-config',
|
||||
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » ' . i18n('Config')
|
||||
));
|
||||
} else {
|
||||
render('denied', array(
|
||||
'title' => generate_title('is_default', i18n('Config')),
|
||||
'description' => safe_html(strip_tags(blog_description())),
|
||||
'canonical' => site_url(),
|
||||
'metatags' => generate_meta(null, null),
|
||||
'type' => 'is_admin-config',
|
||||
'is_admin' => true,
|
||||
'bodyclass' => 'denied',
|
||||
'breadcrumb' => '<a href="' . site_url() . '">' . config('breadcrumb.home') . '</a> » ' . i18n('Config')
|
||||
));
|
||||
}
|
||||
} else {
|
||||
$login = site_url() . 'login';
|
||||
header("location: $login");
|
||||
}
|
||||
});
|
||||
|
||||
// Submitted Config page data
|
||||
post('/admin/config/writing', function () {
|
||||
|
||||
$proper = is_csrf_proper(from($_REQUEST, 'csrf_token'));
|
||||
if (login() && $proper) {
|
||||
$new_config = array();
|
||||
$new_Keys = array();
|
||||
$user = $_SESSION[site_url()]['user'];
|
||||
$role = user('role', $user);
|
||||
if ($role === 'admin') {
|
||||
foreach ($_POST as $name => $value) {
|
||||
if (substr($name, 0, 8) == "-config-") {
|
||||
$name = str_replace("_", ".", substr($name, 8));
|
||||
if(!is_null(config($name))) {
|
||||
$new_config[$name] = $value;
|
||||
} else {
|
||||
$new_Keys[$name] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
save_config($new_config, $new_Keys);
|
||||
$redir = site_url() . 'admin/config/writing';
|
||||
header("location: $redir");
|
||||
} else {
|
||||
$redir = site_url();
|
||||
header("location: $redir");
|
||||
}
|
||||
} else {
|
||||
$login = site_url() . 'login';
|
||||
header("location: $login");
|
||||
}
|
||||
});
|
||||
|
||||
// Show Config page
|
||||
get('/admin/config/widget', function () {
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue