mirror of
https://github.com/danpros/htmly.git
synced 2026-04-21 04:56:23 +05:30
Improve offline writing
This commit is contained in:
parent
f28ac22a42
commit
41d4617847
4 changed files with 30 additions and 14 deletions
|
|
@ -54,7 +54,7 @@ function session($user, $pass)
|
||||||
$user_enc = user('encryption', $user);
|
$user_enc = user('encryption', $user);
|
||||||
$user_pass = user('password', $user);
|
$user_pass = user('password', $user);
|
||||||
$user_role = user('role', $user);
|
$user_role = user('role', $user);
|
||||||
|
|
||||||
if(is_null($user_enc) || is_null($user_pass) || is_null($user_role)) {
|
if(is_null($user_enc) || is_null($user_pass) || is_null($user_role)) {
|
||||||
return $str = '<div class="error-message"><ul><li class="alert alert-danger">' . i18n('Invalid_Error') . '</li></ul></div>';
|
return $str = '<div class="error-message"><ul><li class="alert alert-danger">' . i18n('Invalid_Error') . '</li></ul></div>';
|
||||||
}
|
}
|
||||||
|
|
@ -576,7 +576,7 @@ function add_sub_page($title, $url, $content, $static, $draft, $description = nu
|
||||||
} else {
|
} else {
|
||||||
$post_url = $post_url;
|
$post_url = $post_url;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$post_content = '<!--t ' . $post_title . ' t-->' . $post_description . "\n\n" . $content;
|
$post_content = '<!--t ' . $post_title . ' t-->' . $post_description . "\n\n" . $content;
|
||||||
|
|
||||||
|
|
@ -755,11 +755,18 @@ function edit_category($title, $url, $content, $oldfile, $destination = null, $d
|
||||||
if (!empty($post_title) && !empty($post_url) && !empty($post_content)) {
|
if (!empty($post_title) && !empty($post_url) && !empty($post_content)) {
|
||||||
|
|
||||||
$newfile = $dir . '/' . $post_url . '.md';
|
$newfile = $dir . '/' . $post_url . '.md';
|
||||||
|
if (!is_dir($dir)) {
|
||||||
|
mkdir($dir, 0775, true);
|
||||||
|
}
|
||||||
if ($oldfile === $newfile) {
|
if ($oldfile === $newfile) {
|
||||||
file_put_contents($oldfile, print_r($post_content, true));
|
file_put_contents($oldfile, print_r($post_content, true));
|
||||||
} else {
|
} else {
|
||||||
rename($oldfile, $newfile);
|
if (file_exists($oldfile)) {
|
||||||
file_put_contents($newfile, print_r($post_content, true));
|
rename($oldfile, $newfile);
|
||||||
|
file_put_contents($newfile, print_r($post_content, true));
|
||||||
|
} else {
|
||||||
|
file_put_contents($newfile, print_r($post_content, true));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rename_category_folder($post_url, $oldfile);
|
rename_category_folder($post_url, $oldfile);
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,13 @@ if ($type == 'is_frontpage') {
|
||||||
$oldcontent = i18n('Author_Description');
|
$oldcontent = i18n('Author_Description');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} elseif ($type == 'is_category') {
|
||||||
|
$content = $p->body;
|
||||||
|
$oldtitle = $p->title;
|
||||||
|
$olddescription = $p->description;
|
||||||
|
$oldcontent = $p->body;
|
||||||
|
$oldmd = $p->md;
|
||||||
|
$url = 'content/data/category/'. $p->md;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (isset($p->file)) {
|
if (isset($p->file)) {
|
||||||
|
|
|
||||||
|
|
@ -1830,6 +1830,11 @@ get('/admin/categories/:category', function ($category) {
|
||||||
$desc = $desc[0];
|
$desc = $desc[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (empty($posts) || $page < 1) {
|
||||||
|
// a non-existing page
|
||||||
|
not_found();
|
||||||
|
}
|
||||||
|
|
||||||
$total = $desc->count;
|
$total = $desc->count;
|
||||||
|
|
||||||
render('category-list', array(
|
render('category-list', array(
|
||||||
|
|
@ -1890,13 +1895,13 @@ get('/category/:category', function ($category) {
|
||||||
$desc = $desc[0];
|
$desc = $desc[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
$total = $desc->count;
|
|
||||||
|
|
||||||
if (empty($posts) || $page < 1) {
|
if (empty($posts) || $page < 1) {
|
||||||
// a non-existing page
|
// a non-existing page
|
||||||
not_found();
|
not_found();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$total = $desc->count;
|
||||||
|
|
||||||
$vroot = rtrim(config('views.root'), '/');
|
$vroot = rtrim(config('views.root'), '/');
|
||||||
|
|
||||||
$lt = $vroot . '/layout--category--'. strtolower($category) .'.html.php';
|
$lt = $vroot . '/layout--category--'. strtolower($category) .'.html.php';
|
||||||
|
|
@ -1968,7 +1973,8 @@ get('/category/:category/edit', function ($category) {
|
||||||
config('views.root', 'system/admin/views');
|
config('views.root', 'system/admin/views');
|
||||||
$post = get_category_info($category);
|
$post = get_category_info($category);
|
||||||
|
|
||||||
if (!$post) {
|
|
||||||
|
if(empty($post)) {
|
||||||
not_found();
|
not_found();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2052,7 +2058,7 @@ get('/category/:category/delete', function ($category) {
|
||||||
config('views.root', 'system/admin/views');
|
config('views.root', 'system/admin/views');
|
||||||
$post = get_category_info($category);
|
$post = get_category_info($category);
|
||||||
|
|
||||||
if (!$post) {
|
if(empty($post)) {
|
||||||
not_found();
|
not_found();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -269,18 +269,14 @@ function rebuilt_cache($type = null)
|
||||||
foreach ($tmp as $file) {
|
foreach ($tmp as $file) {
|
||||||
if(strpos($file, '/draft/') === false && strpos($file, '/scheduled/') === false) {
|
if(strpos($file, '/draft/') === false && strpos($file, '/scheduled/') === false) {
|
||||||
$posts_cache[] = pathinfo($file);
|
$posts_cache[] = pathinfo($file);
|
||||||
|
$cd = explode('/', $file);
|
||||||
|
$ctmp[] = $cd[3];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
usort($posts_cache, "sortfile_d");
|
usort($posts_cache, "sortfile_d");
|
||||||
$string_posts = serialize($posts_cache);
|
$string_posts = serialize($posts_cache);
|
||||||
file_put_contents('cache/index/index-posts.txt', print_r($string_posts, true));
|
file_put_contents('cache/index/index-posts.txt', print_r($string_posts, true));
|
||||||
|
|
||||||
// Collect category slug
|
|
||||||
foreach ($posts_cache as $key => $c) {
|
|
||||||
$cd = explode('/', $c['dirname']);
|
|
||||||
$ctmp[] = $cd[3];
|
|
||||||
}
|
|
||||||
file_put_contents('cache/index/index-category.txt', print_r(serialize(array_unique($ctmp, SORT_REGULAR)), true));
|
file_put_contents('cache/index/index-category.txt', print_r(serialize(array_unique($ctmp, SORT_REGULAR)), true));
|
||||||
|
|
||||||
// Rebuilt static page index
|
// Rebuilt static page index
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue