From d7e5f0ca75cb405ca02c9b8d32a9c256fed47992 Mon Sep 17 00:00:00 2001 From: Danang Probo Sayekti Date: Wed, 22 Jan 2014 17:39:42 +0700 Subject: [PATCH] Can edit tag and URL Can edit tag and URL (both blog post and static page). --- admin/action/create_page.php | 17 +++++++-------- admin/action/create_post.php | 4 ++-- admin/action/delete_page.php | 2 +- admin/action/delete_post.php | 2 +- admin/action/edit_page.php | 18 ++++++++++++++-- admin/action/edit_post.php | 26 +++++++++++++++++++++-- admin/action/login.php | 8 +++---- admin/includes/page_list.php | 4 ++-- admin/includes/post_list.php | 22 +++++++++++++------ admin/index.php | 4 ++-- admin/resources/style.css | 50 ++++++++++++++++++++++++++++++++++++++++++++ 11 files changed, 126 insertions(+), 31 deletions(-) diff --git a/admin/action/create_page.php b/admin/action/create_page.php index 1a0d17c..1377eb1 100644 --- a/admin/action/create_page.php +++ b/admin/action/create_page.php @@ -50,7 +50,7 @@
- Url:


+ Url:



@@ -58,15 +58,14 @@
+ var editor = new Markdown.Editor(converter); + + editor.run(); + })(); + diff --git a/admin/action/create_post.php b/admin/action/create_post.php index 8d3c67a..112be96 100644 --- a/admin/action/create_post.php +++ b/admin/action/create_post.php @@ -54,8 +54,8 @@
- Tag:


- Url:


+ Tag:


+ Url:



diff --git a/admin/action/delete_page.php b/admin/action/delete_page.php index c224a66..784c6e3 100644 --- a/admin/action/delete_page.php +++ b/admin/action/delete_page.php @@ -50,7 +50,7 @@ Are you sure want to delete ' . $url . '?

';?> -
+
diff --git a/admin/action/delete_post.php b/admin/action/delete_post.php index fcbac39..920deee 100644 --- a/admin/action/delete_post.php +++ b/admin/action/delete_post.php @@ -50,7 +50,7 @@ Are you sure want to delete ' . $url . '?

';?>
-
+
diff --git a/admin/action/edit_page.php b/admin/action/edit_page.php index becbd72..3aea9f9 100644 --- a/admin/action/edit_page.php +++ b/admin/action/edit_page.php @@ -12,11 +12,24 @@ header('location: ../index.php'); } + $dir = substr($url, 0, strrpos($url, '/')); + $oldurl = str_replace($dir . '/','',$url); + $oldmd = str_replace('.md','',$oldurl); + if(isset($_POST['submit'])) { + $post_url = preg_replace('/[^A-Za-z0-9,.-]/u', '', $_POST['url']); + $post_url = rtrim($post_url, ',\.\-'); $post_content = $_POST['content']; } if(!empty($post_content)) { - file_put_contents('../'. $url, print_r($post_content, true)); + $newurl = $dir . '/' . $post_url . '.md'; + if($url === $newurl) { + file_put_contents($url, print_r($post_content, true)); + } + else { + rename($url, $newurl); + file_put_contents($newurl, print_r($post_content, true)); + } header('location: ../index.php'); } @@ -49,8 +62,9 @@
+ Url:


-
+
diff --git a/admin/action/edit_post.php b/admin/action/edit_post.php index f165e9a..d1ffada 100644 --- a/admin/action/edit_post.php +++ b/admin/action/edit_post.php @@ -12,11 +12,30 @@ header('location: ../index.php'); } + $dir = substr($url, 0, strrpos($url, '/')); + + $oldurl = explode('_', $url); + + $oldtag = $oldurl[1]; + + $oldmd = str_replace('.md','',$oldurl[2]); + if(isset($_POST['submit'])) { + $post_tag = preg_replace('/[^A-Za-z0-9,.-]/u', '', $_POST['tag']); + $post_tag = rtrim($post_tag, ',\.\-'); + $post_url = preg_replace('/[^A-Za-z0-9,.-]/u', '', $_POST['url']); + $post_url = rtrim($post_url, ',\.\-'); $post_content = $_POST['content']; } if(!empty($post_content)) { - file_put_contents('../'. $url, print_r($post_content, true)); + $newurl = $oldurl[0] . '_' . $post_tag . '_' . $post_url . '.md'; + if($url === $newurl) { + file_put_contents($url, print_r($post_content, true)); + } + else { + rename($url, $newurl); + file_put_contents($newurl, print_r($post_content, true)); + } header('location: ../index.php'); } @@ -32,6 +51,7 @@ + @@ -48,8 +68,10 @@
+ Tag:


+ Url:


-
+
diff --git a/admin/action/login.php b/admin/action/login.php index abea591..ffdf589 100644 --- a/admin/action/login.php +++ b/admin/action/login.php @@ -29,9 +29,9 @@

Login Form

User:
-

+

Pass:
-

+

@@ -59,9 +59,9 @@ EOF;

Login Form

User:
-

+

Pass:
-

+

diff --git a/admin/includes/page_list.php b/admin/includes/page_list.php index 9a5b1b8..f0398ca 100644 --- a/admin/includes/page_list.php +++ b/admin/includes/page_list.php @@ -29,8 +29,8 @@ echo ''; echo '' . $v . ''; - echo '
'; - echo '
'; + echo '
'; + echo '
'; echo ''; } diff --git a/admin/includes/post_list.php b/admin/includes/post_list.php index a61d0d2..e2aa054 100644 --- a/admin/includes/post_list.php +++ b/admin/includes/post_list.php @@ -72,11 +72,21 @@ function get_posts($posts, $page = 1, $perpage = 0){ // The post URL $post->url = site_url().date('Y/m', $post->date).'/'.str_replace('.md','',$arr[2]); - // The post tag - $post->tag = str_replace($replaced,'',$arr[1]); + $tag = array(); + $url = array(); - // The post tag url - $post->tagurl = site_url(). 'tag/' . $arr[1]; + $t = explode(',', $arr[1]); + foreach($t as $tt) { + $tag[] = array($tt, site_url(). 'tag/' . $tt); + } + + foreach($tag as $a) { + $url[] = ''. $a[0] .''; + } + + $post->tag = implode(', ', $url); + + $post->tagb = implode(' ยป ', $url); $post->file = $filepath; @@ -126,8 +136,8 @@ function get_post_list() { foreach($posts as $p) { echo ''; echo '' . $p->file . ''; - echo '
'; - echo '
'; + echo '
'; + echo '
'; echo ''; } echo ''; diff --git a/admin/index.php b/admin/index.php index 09b3ffe..d6c7326 100644 --- a/admin/index.php +++ b/admin/index.php @@ -39,9 +39,9 @@

Login Form

User:
-

+

Pass:
-

+

diff --git a/admin/resources/style.css b/admin/resources/style.css index afc4145..f2a0eef 100644 --- a/admin/resources/style.css +++ b/admin/resources/style.css @@ -39,4 +39,54 @@ table td { width:100%; } +} + +/*---------------------------- + Video +-----------------------------*/ + +.video-wrapper { + margin:1em 0; +} + +@media all and (min-width: 420px) { + + .video-wrapper { + padding-top:315px!important; + position:relative; + width:100%; + max-width:420px!important; + max-height:315px!important; + } + + .video-wrapper iframe, .video-wrapper object, .video-wrapper embed { + height: 100%; + left: 0; + position: absolute; + top: 0; + max-width:420px!important; + width: 100%; + max-height:315px!important; + } + +} + +@media all and (max-width: 420px) { + + .video-wrapper { + position: relative; + padding-bottom: 56.25%; + padding-top: 30px; + height: 0; + overflow: hidden; + } + + .video-wrapper iframe, .video-wrapper object, .video-wrapper embed { + height: 100%; + left: 0; + position: absolute; + top: 0; + width: 100%; + } + } \ No newline at end of file