diff --git a/system/admin/admin.php b/system/admin/admin.php index 953a28d..42ada8c 100644 --- a/system/admin/admin.php +++ b/system/admin/admin.php @@ -180,20 +180,20 @@ function add_page($title, $url, $content) { } -function delete_post($file) { +function delete_post($file, $destination) { $deleted_content = $file; if(!empty($deleted_content)) { unlink($deleted_content); - $redirect = site_url() . 'admin/posts'; + $redirect = site_url() . $destination; header("Location: $redirect"); } } -function delete_page($file) { +function delete_page($file, $destination) { $deleted_content = $file; if(!empty($deleted_content)) { unlink($deleted_content); - $redirect = site_url() . 'admin'; + $redirect = site_url() . $destination; header("Location: $redirect"); } } @@ -224,23 +224,19 @@ function edit_profile($title, $content, $user) { function get_recent_posts() { if (isset($_SESSION['user'])) { - $posts = get_profile($_SESSION['user'], 1, 5); - if(!empty($posts)) { - - echo ''; + echo '
'; echo ''; foreach($posts as $p) { echo ''; - echo ''; + echo ''; echo ''; echo ''; echo ''; echo ''; } echo '
TitlePublishedTagOperations
' . $p->title . '' . $p->title . '' . date('d F Y', $p->date) . '' . $p->tag . 'Edit Delete
'; - } } } @@ -251,16 +247,15 @@ function get_recent_pages() { $posts = get_static_post(null); if(!empty($posts)) { krsort($posts); - - echo ''; + echo '
'; echo ''; foreach($posts as $p) { echo ''; - echo ''; + echo ''; echo ''; echo ''; } echo '
TitleOperations
' . $p->title . '' . $p->title . 'Edit Delete
'; } } -} +} \ No newline at end of file diff --git a/system/admin/views/posts-list.html.php b/system/admin/views/posts-list.html.php index a94f5a5..13f4a73 100644 --- a/system/admin/views/posts-list.html.php +++ b/system/admin/views/posts-list.html.php @@ -17,10 +17,10 @@ $i++; ?> - title ?> + title ?> date) ?> tag ?> - Edit Delete + Edit Delete diff --git a/system/htmly.php b/system/htmly.php index 4746249..36261a4 100644 --- a/system/htmly.php +++ b/system/htmly.php @@ -179,9 +179,10 @@ get('/:year/:month/:name/delete', function($year, $month, $name){ // Get deleted data for blog post post('/:year/:month/:name/delete', function() { + $file = from($_REQUEST, 'file'); - - delete_post($file); + $destination = from($_GET, 'destination'); + delete_post($file, $destination); }); @@ -501,8 +502,8 @@ get('/:static/delete', function($static){ post('/:static/delete', function() { $file = from($_REQUEST, 'file'); - - delete_post($file); + $destination = from($_GET, 'destination'); + delete_page($file, $destination); }); @@ -591,7 +592,7 @@ get('/tag/:tag',function($tag){ 'page' => $page, 'posts' => $posts, 'canonical' => config('site.url') . '/tag/' . $tag, - 'description' => 'All posts tagged ' . $tag . ' on '. config('blog.title') . '.', + 'description' => 'All posts tagged: ' . $tag . ' on '. config('blog.title') . '.', 'bodyclass' => 'intag', 'breadcrumb' => '' .config('breadcrumb.home'). ' » Posts tagged: ' . $tag, 'pagination' => has_pagination($total, $perpage, $page) diff --git a/system/includes/functions.php b/system/includes/functions.php index 0d7d8b8..917a8c8 100644 --- a/system/includes/functions.php +++ b/system/includes/functions.php @@ -362,11 +362,11 @@ function default_profile($author) { function get_static_post($static){ $posts = get_static_pages(); + + $tmp = array(); if(!empty($posts)) { - $tmp = array(); - foreach($posts as $index => $v){ if(strpos($v, $static.'.md') !== false){ @@ -399,16 +399,18 @@ function get_static_post($static){ } } - - return $tmp; } + + return $tmp; + } // Return search page. function get_keyword($keyword){ $posts = get_post_unsorted(); + $tmp = array(); $words = explode(' ', $keyword); @@ -486,12 +488,10 @@ function get_keyword($keyword){ $tmp = array_unique($tmp, SORT_REGULAR); usort($tmp,'sortdate'); - - return $tmp; - } - else { - return $tmp; } + + return $tmp; + } // Get related posts base on post tag. @@ -992,23 +992,28 @@ function get_static_path(){ $posts = get_static_pages(); $tmp = array(); + + if(!empty($posts)) { - foreach($posts as $index => $v){ - - $post = new stdClass; - - // Replaced string - $replaced = substr($v, 0, strrpos($v, '/')) . '/'; - - // The static page URL - $url = str_replace($replaced,'',$v); - $post->url = site_url() . str_replace('.md','',$url); - - $tmp[] = $post; + foreach($posts as $index => $v){ + $post = new stdClass; + + // Replaced string + $replaced = substr($v, 0, strrpos($v, '/')) . '/'; + + // The static page URL + $url = str_replace($replaced,'',$v); + $post->url = site_url() . str_replace('.md','',$url); + + $tmp[] = $post; + + } + } return $tmp; + } // Generate sitemap.xml. @@ -1054,8 +1059,12 @@ function generate_sitemap($str){ echo ''; - foreach($posts as $p) { - echo '' . $p->url . 'monthly0.5'; + if(!empty($posts)) { + + foreach($posts as $p) { + echo '' . $p->url . 'monthly0.5'; + } + } echo ''; diff --git a/themes/default/css/style.css b/themes/default/css/style.css index b035fde..d146b4d 100644 --- a/themes/default/css/style.css +++ b/themes/default/css/style.css @@ -316,6 +316,8 @@ table { color:#333333; border: 1px solid #E3E3E3; margin: 1em 0; + white-space: pre-wrap; + word-wrap:break-word; } table h2.title { @@ -355,6 +357,10 @@ td { border-left:none; } +table.post-list td a { + margin:0 5px; +} + /*------------------------- Menu --------------------------*/