mirror of
https://github.com/danpros/htmly.git
synced 2026-04-23 05:56:22 +05:30
Cleaning up
Cleaning up the codes.
This commit is contained in:
parent
aea4e6d895
commit
daa3d40c3b
5 changed files with 55 additions and 44 deletions
|
|
@ -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 '<table>';
|
||||
echo '<table class="post-list">';
|
||||
echo '<tr><th>Title</th><th>Published</th><th>Tag</th><th>Operations</th></tr>';
|
||||
foreach($posts as $p) {
|
||||
echo '<tr>';
|
||||
echo '<td>' . $p->title . '</td>';
|
||||
echo '<td><a target="_blank" href="' . $p->url . '">' . $p->title . '</a></td>';
|
||||
echo '<td>' . date('d F Y', $p->date) . '</td>';
|
||||
echo '<td>' . $p->tag . '</td>';
|
||||
echo '<td><a href="' . $p->url . '/edit?destination=admin">Edit</a> <a href="' . $p->url . '/delete?destination=admin">Delete</a></td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
echo '</table>';
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -251,12 +247,11 @@ function get_recent_pages() {
|
|||
$posts = get_static_post(null);
|
||||
if(!empty($posts)) {
|
||||
krsort($posts);
|
||||
|
||||
echo '<table>';
|
||||
echo '<table class="post-list">';
|
||||
echo '<tr><th>Title</th><th>Operations</th></tr>';
|
||||
foreach($posts as $p) {
|
||||
echo '<tr>';
|
||||
echo '<td>' . $p->title . '</td>';
|
||||
echo '<td><a target="_blank" href="' . $p->url . '">' . $p->title . '</a></td>';
|
||||
echo '<td><a href="' . $p->url . '/edit?destination=admin">Edit</a> <a href="' . $p->url . '/delete?destination=admin">Delete</a></td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,10 +17,10 @@
|
|||
$i++;
|
||||
?>
|
||||
<tr>
|
||||
<td><?php echo $p->title ?></td>
|
||||
<td><a target="_blank" href="<?php echo $p->url ?>"><?php echo $p->title ?></a></td>
|
||||
<td><?php echo date('d F Y', $p->date) ?></td>
|
||||
<td><?php echo $p->tag ?></td>
|
||||
<td><a href="<?php echo $p->url ?>/edit?destination=admin/posts">Edit</a> <a href="<?php echo $p->url ?>/delete">Delete</a></td>
|
||||
<td><a href="<?php echo $p->url ?>/edit?destination=admin/posts">Edit</a> <a href="<?php echo $p->url ?>/delete?destination=admin/posts">Delete</a></td>
|
||||
</tr>
|
||||
<?php endforeach;?>
|
||||
</table>
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
$file = from($_REQUEST, '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' => '<a href="' . config('site.url') . '">' .config('breadcrumb.home'). '</a> » Posts tagged: ' . $tag,
|
||||
'pagination' => has_pagination($total, $perpage, $page)
|
||||
|
|
|
|||
|
|
@ -363,10 +363,10 @@ function get_static_post($static){
|
|||
|
||||
$posts = get_static_pages();
|
||||
|
||||
if(!empty($posts)) {
|
||||
|
||||
$tmp = array();
|
||||
|
||||
if(!empty($posts)) {
|
||||
|
||||
foreach($posts as $index => $v){
|
||||
if(strpos($v, $static.'.md') !== false){
|
||||
|
||||
|
|
@ -400,15 +400,17 @@ function get_static_post($static){
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Get related posts base on post tag.
|
||||
|
|
@ -993,6 +993,8 @@ function get_static_path(){
|
|||
|
||||
$tmp = array();
|
||||
|
||||
if(!empty($posts)) {
|
||||
|
||||
foreach($posts as $index => $v){
|
||||
|
||||
$post = new stdClass;
|
||||
|
|
@ -1008,7 +1010,10 @@ function get_static_path(){
|
|||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $tmp;
|
||||
|
||||
}
|
||||
|
||||
// Generate sitemap.xml.
|
||||
|
|
@ -1054,10 +1059,14 @@ function generate_sitemap($str){
|
|||
|
||||
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
|
||||
|
||||
if(!empty($posts)) {
|
||||
|
||||
foreach($posts as $p) {
|
||||
echo '<url><loc>' . $p->url . '</loc><changefreq>monthly</changefreq><priority>0.5</priority></url>';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
echo '</urlset>';
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
--------------------------*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue