From cdf2a4dd2b47e0c9c10983c8dac37669511a6267 Mon Sep 17 00:00:00 2001 From: Danang Probo Sayekti Date: Wed, 29 Jan 2014 10:30:45 +0700 Subject: [PATCH] Change admin panel Change admin panel. --- admin/action/create_page.php | 78 -- admin/action/create_post.php | 83 --- admin/action/delete_page.php | 60 -- admin/action/delete_post.php | 60 -- admin/action/edit_bio.php | 101 --- admin/action/edit_page.php | 101 --- admin/action/edit_post.php | 108 --- admin/action/login.php | 77 -- admin/action/logout.php | 9 - admin/includes/.htaccess | 1 - admin/includes/page_list.php | 42 -- admin/includes/post_list.php | 148 ---- admin/includes/user.php | 10 - admin/index.php | 52 -- admin/resources/style.css | 159 ---- system/admin/admin.php | 228 ++++++ {admin => system/admin}/editor/LICENSE.txt | 0 {admin => system/admin}/editor/README.txt | 0 {admin => system/admin}/editor/css/editor.css | 2 +- {admin => system/admin}/editor/img/wmd-buttons.png | Bin .../admin}/editor/js/Markdown.Converter.js | 0 .../admin}/editor/js/Markdown.Editor.js | 0 .../admin}/editor/js/Markdown.Sanitizer.js | 0 .../admin}/editor/js/local/Markdown.local.fr.js | 0 {admin => system/admin}/editor/js/node-pagedown.js | 0 {admin => system/admin}/editor/package.json | 0 system/admin/views/add-page.html.php | 23 + system/admin/views/add-post.html.php | 24 + system/admin/views/css/style.css | 820 +++++++++++++++++++++ system/admin/views/delete-page.html.php | 6 + system/admin/views/delete-post.html.php | 6 + system/admin/views/edit-page.html.php | 43 ++ system/admin/views/edit-post.html.php | 47 ++ system/admin/views/edit-profile.html.php | 50 ++ system/admin/views/layout.html.php | 76 ++ system/admin/views/login.html.php | 11 + system/admin/views/logout.html.php | 7 + system/admin/views/main.html.php | 5 + system/admin/views/pages-list.html.php | 0 system/admin/views/posts-list.html.php | 37 + system/htmly.php | 595 ++++++++++++--- system/includes/functions.php | 6 +- {admin => system}/includes/session.php | 0 themes/clean/css/style.css | 38 + themes/clean/layout.html.php | 14 + themes/clean/profile.html.php | 4 +- themes/default/css/style.css | 38 + themes/default/layout.html.php | 14 + themes/default/profile.html.php | 4 +- 49 files changed, 1988 insertions(+), 1199 deletions(-) delete mode 100644 admin/action/create_page.php delete mode 100644 admin/action/create_post.php delete mode 100644 admin/action/delete_page.php delete mode 100644 admin/action/delete_post.php delete mode 100644 admin/action/edit_bio.php delete mode 100644 admin/action/edit_page.php delete mode 100644 admin/action/edit_post.php delete mode 100644 admin/action/login.php delete mode 100644 admin/action/logout.php delete mode 100644 admin/includes/.htaccess delete mode 100644 admin/includes/page_list.php delete mode 100644 admin/includes/post_list.php delete mode 100644 admin/includes/user.php delete mode 100644 admin/index.php delete mode 100644 admin/resources/style.css create mode 100644 system/admin/admin.php rename {admin => system/admin}/editor/LICENSE.txt (100%) rename {admin => system/admin}/editor/README.txt (100%) rename {admin => system/admin}/editor/css/editor.css (99%) rename {admin => system/admin}/editor/img/wmd-buttons.png (100%) rename {admin => system/admin}/editor/js/Markdown.Converter.js (100%) rename {admin => system/admin}/editor/js/Markdown.Editor.js (100%) rename {admin => system/admin}/editor/js/Markdown.Sanitizer.js (100%) rename {admin => system/admin}/editor/js/local/Markdown.local.fr.js (100%) rename {admin => system/admin}/editor/js/node-pagedown.js (100%) rename {admin => system/admin}/editor/package.json (100%) create mode 100644 system/admin/views/add-page.html.php create mode 100644 system/admin/views/add-post.html.php create mode 100644 system/admin/views/css/style.css create mode 100644 system/admin/views/delete-page.html.php create mode 100644 system/admin/views/delete-post.html.php create mode 100644 system/admin/views/edit-page.html.php create mode 100644 system/admin/views/edit-post.html.php create mode 100644 system/admin/views/edit-profile.html.php create mode 100644 system/admin/views/layout.html.php create mode 100644 system/admin/views/login.html.php create mode 100644 system/admin/views/logout.html.php create mode 100644 system/admin/views/main.html.php create mode 100644 system/admin/views/pages-list.html.php create mode 100644 system/admin/views/posts-list.html.php rename {admin => system}/includes/session.php (100%) diff --git a/admin/action/create_page.php b/admin/action/create_page.php deleted file mode 100644 index 376b558..0000000 --- a/admin/action/create_page.php +++ /dev/null @@ -1,78 +0,0 @@ -' . "\n\n" . $_POST['content']; - } - if(!empty($post_title) && !empty($post_url) && !empty($post_content)) { - if(get_magic_quotes_gpc()) { - $post_content = stripslashes($post_content); - } - $filename = $post_url . '.md'; - $dir = '../../content/static/'; - if(is_dir($dir)) { - file_put_contents($dir . $filename, print_r($post_content, true)); - } - else { - mkdir($dir, 0777, true); - file_put_contents($dir . $filename, print_r($post_content, true)); - } - header('location: ../index.php'); - } - if (login()) { -?> - - - - - - - Create page - - - - - - - -
-
- -
-
- Title:


- Url:


-
-
- -
-
-
- -
-
- - - \ No newline at end of file diff --git a/admin/action/create_post.php b/admin/action/create_post.php deleted file mode 100644 index 7e51993..0000000 --- a/admin/action/create_post.php +++ /dev/null @@ -1,83 +0,0 @@ -' . "\n\n" . $_POST['content']; - } - if(!empty($post_title) && !empty($post_tag) && !empty($post_url) && !empty($post_content)) { - if(get_magic_quotes_gpc()) { - $post_content = stripslashes($post_content); - } - $user = $_SESSION['user']; - $filename = $post_date . '_' . $post_tag . '_' . $post_url . '.md'; - $dir = '../../content/' . $user. '/blog/'; - if(is_dir($dir)) { - file_put_contents($dir . $filename, print_r($post_content, true)); - } - else { - mkdir($dir, 0777, true); - file_put_contents($dir . $filename, print_r($post_content, true)); - } - header('location: ../index.php'); - } - if (login()) { -?> - - - - - - - Create post - - - - - - - -
-
- -
-
- Title:


- Tag:


- Url:


-
-
- -
-
-
- -
-
- - - \ No newline at end of file diff --git a/admin/action/delete_page.php b/admin/action/delete_page.php deleted file mode 100644 index 8e04561..0000000 --- a/admin/action/delete_page.php +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - Delete page - - - - - - - -
-
- - - Are you sure want to delete ' . $url . '?

';?> -
-
- -
-
-
- - - \ No newline at end of file diff --git a/admin/action/delete_post.php b/admin/action/delete_post.php deleted file mode 100644 index 1c631a2..0000000 --- a/admin/action/delete_post.php +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - Delete post - - - - - - - -
-
- - - Are you sure want to delete ' . $url . '?

';?> -
-
- -
-
-
- - - \ No newline at end of file diff --git a/admin/action/edit_bio.php b/admin/action/edit_bio.php deleted file mode 100644 index 83c22e0..0000000 --- a/admin/action/edit_bio.php +++ /dev/null @@ -1,101 +0,0 @@ -', $content); - if(isset($arr[1])) { - $oldtitle = ltrim(rtrim(str_replace('' . "\n\n" . $_POST['content']; - } - if(!empty($bio_title) && !empty($bio_content)) { - if(get_magic_quotes_gpc()) { - $bio_content = stripslashes($bio_content); - } - $dir = '../../content/' . $user. '/'; - if(is_dir($dir)) { - file_put_contents($dir . $filename, print_r($bio_content, true)); - } - else { - mkdir($dir, 0777, true); - file_put_contents($dir . $filename, print_r($bio_content, true)); - } - header('location: ../index.php'); - } - - if (login()) { -?> - - - - - - - Edit bio - - - - - - - -
-
- -
-
- Title:


-
-
- -
-
-
- -
-
- - - \ No newline at end of file diff --git a/admin/action/edit_page.php b/admin/action/edit_page.php deleted file mode 100644 index b924c71..0000000 --- a/admin/action/edit_page.php +++ /dev/null @@ -1,101 +0,0 @@ -', $content); - if(isset($arr[1])) { - $oldtitle = ltrim(rtrim(str_replace('' . "\n\n" . $_POST['content']; - } - if(!empty($post_title) && !empty($post_url) && !empty($post_content)) { - if(get_magic_quotes_gpc()) { - $post_content = stripslashes($post_content); - } - $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'); - } - - if (login()) { -?> - - - - - - - Edit page - - - - - - - -
-
- -
-
- Title:


- Url:


-
-
- -
-
-
- -
-
- - - \ No newline at end of file diff --git a/admin/action/edit_post.php b/admin/action/edit_post.php deleted file mode 100644 index 57b9da6..0000000 --- a/admin/action/edit_post.php +++ /dev/null @@ -1,108 +0,0 @@ -', $content); - if(isset($arr[1])) { - $oldtitle = ltrim(rtrim(str_replace('' . "\n\n" . $_POST['content']; - } - if(!empty($post_title) && !empty($post_tag) && !empty($post_url) && !empty($post_content)) { - if(get_magic_quotes_gpc()) { - $post_content = stripslashes($post_content); - } - $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'); - } - - if (login()) { -?> - - - - - - - Edit post - - - - - - - -
-
- -
-
- Title:


- Tag:


- Url:


-
-
- -
-
-
- -
-
- - - \ No newline at end of file diff --git a/admin/action/login.php b/admin/action/login.php deleted file mode 100644 index 95c940f..0000000 --- a/admin/action/login.php +++ /dev/null @@ -1,77 +0,0 @@ - - - - Admin Panel - - - -
-
-

Password and username not match!

-

Login Form

-
- User:
-

- Pass:
-

- -
-
-
- - -EOF; - } - } - else { - echo << - - - - - - Admin Panel - - - -
-
-

Please create username.txt inside "admin/users" folder and put your password inside it.

-

Login Form

-
- User:
-

- Pass:
-

- -
-
-
- - -EOF; - } - } - else { - header('location: ../index.php'); - } -?> \ No newline at end of file diff --git a/admin/action/logout.php b/admin/action/logout.php deleted file mode 100644 index a91ebe5..0000000 --- a/admin/action/logout.php +++ /dev/null @@ -1,9 +0,0 @@ - \ No newline at end of file diff --git a/admin/includes/.htaccess b/admin/includes/.htaccess deleted file mode 100644 index 3418e55..0000000 --- a/admin/includes/.htaccess +++ /dev/null @@ -1 +0,0 @@ -deny from all \ No newline at end of file diff --git a/admin/includes/page_list.php b/admin/includes/page_list.php deleted file mode 100644 index 57160e6..0000000 --- a/admin/includes/page_list.php +++ /dev/null @@ -1,42 +0,0 @@ -'; - foreach($posts as $index => $v){ - - echo ''; - echo '' . $v . ''; - echo '
'; - echo '
'; - echo ''; - - } - echo ''; - - } - - -?> \ No newline at end of file diff --git a/admin/includes/post_list.php b/admin/includes/post_list.php deleted file mode 100644 index 42fe7c3..0000000 --- a/admin/includes/post_list.php +++ /dev/null @@ -1,148 +0,0 @@ - $v){ - - $post = new stdClass; - - $filepath = $v['dirname'] . '/' . $v['basename']; - - // Extract the date - $arr = explode('_', $filepath); - - // Replaced string - $replaced = substr($arr[0], 0,strrpos($arr[0], '/')) . '/'; - - // Author string - $str = explode('/', $replaced); - $author = $str[count($str)-3]; - - // The post author + author url - $post->author = $author; - $post->authorurl = site_url() . 'author/' . $author; - - // The post date - $post->date = strtotime(str_replace($replaced,'',$arr[0])); - - // The archive per day - $post->archive = site_url(). 'archive/' . date('Y-m-d', $post->date) ; - - // The post URL - $post->url = site_url().date('Y/m', $post->date).'/'.str_replace('.md','',$arr[2]); - - $tag = array(); - $url = array(); - - $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; - - // Get the contents and convert it to HTML - // $content = file_get_contents($filepath); - // $post->content = $content; - - $tmp[] = $post; - } - - return $tmp; -} - -// Return posts list on profile. -function get_profile($profile, $page, $perpage){ - - $posts = admin_get_post(); - - $tmp = array(); - - foreach ($posts as $index => $v) { - $url = $v['dirname']; - $str = explode('/', $url); - $author = $str[count($str)-2]; - if($profile === $author){ - $tmp[] = $v; - } - } - - if(empty($tmp)) { - echo '
No posts found!
'; - return; - } - - return $tmp = get_posts($tmp, $page, $perpage); - -} - -function get_post_list() { - if (isset($_SESSION['user'])) { - - $posts = get_profile($_SESSION['user'], null, null); - - if(!empty($posts)) { - - echo ''; - foreach($posts as $p) { - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - } - echo '
' . $p->file . '
'; - - } - } -} -?> \ No newline at end of file diff --git a/admin/includes/user.php b/admin/includes/user.php deleted file mode 100644 index bd8d8b7..0000000 --- a/admin/includes/user.php +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - Admin Panel - - - -
-
- - - -

Your blog posts:

- -

Static page:

- - - - -

Login Form

-
- User:
-

- Pass:
-

- -
- - -
-
- - \ No newline at end of file diff --git a/admin/resources/style.css b/admin/resources/style.css deleted file mode 100644 index db518af..0000000 --- a/admin/resources/style.css +++ /dev/null @@ -1,159 +0,0 @@ -body { - font-size: 16px; - font-family: Arial, Verdana; - margin:0 auto; - padding:0; - background: none repeat scroll 0 0 #F9F9F9; - width:100%; -} - -.wrapper-outer { - float:left; - position:relative; - width:100%; - padding-bottom: 30px; -} - -.wrapper-inner { - margin:0 auto; - width:980px; -} - -.nav { - width: 96%; - padding:2% 0; - border-bottom: 4px solid #cccccc; - margin-bottom: 30px; -} - -input.text, input.password { - width: 75%; -} - -img { - border: 0 none; - height: auto; - max-width: 100%; - outline: 0 none; -} - -/*------------------------- - Link ---------------------------*/ - -a, a:visited { - outline:none; - text-decoration:none; -} - -a:hover{ - text-decoration:underline; -} - -/*------------------------- - Table ---------------------------*/ - -table { - font-size:14px; - border: none; - color:#333333; - border: 1px solid #E3E3E3; - margin: 1em 0; -} - -table h2.title { - margin:5px 0; -} - -th, td { - padding: 5px 10px; - border: none; -} - -th.title { - margin:5px 0; - font-family: Arial,sans-serif; - font-size:18px; - font-weight:normal; -} - -td.title { - font-weight:normal; - background-color: #eeeeee; - font-family: Arial,sans-serif; -} - -th { - background-color: #eeeeee; - border-bottom: 1px solid #E3E3E3; - border-right: 1px solid #E3E3E3; - font-family: Arial,sans-serif; - font-size:18px; -} - -td { - background-color: #eeeeee; - border: 1px solid #E3E3E3; - border-top: none; - border-left:none; -} - -@media all and (max-width: 980px) { - - .wrapper-inner { - margin:0 auto; - 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 diff --git a/system/admin/admin.php b/system/admin/admin.php new file mode 100644 index 0000000..5da0577 --- /dev/null +++ b/system/admin/admin.php @@ -0,0 +1,228 @@ +

Your username and password are wrong.

Back

'; + login_message($str); + } + } + else { + $str = '

Username not found in our record.

Back

'; + login_message($str); + } +} + +function edit_post($title, $tag, $url, $content, $oldfile) { + + $oldurl = explode('_', $oldfile); + + $post_title = $title; + $post_tag = preg_replace('/[^A-Za-z0-9,.-]/u', '', $tag); + $post_tag = rtrim($post_tag, ',\.\-'); + $post_url = preg_replace('/[^A-Za-z0-9,.-]/u', '', $url); + $post_url = rtrim($post_url, ',\.\-'); + $post_content = '' . "\n\n" . $content; + + if(!empty($post_title) && !empty($post_tag) && !empty($post_url) && !empty($post_content)) { + if(get_magic_quotes_gpc()) { + $post_content = stripslashes($post_content); + } + $newfile = $oldurl[0] . '_' . $post_tag . '_' . $post_url . '.md'; + if($oldfile === $newfile) { + file_put_contents($oldfile, print_r($post_content, true)); + } + else { + rename($oldfile, $newfile); + file_put_contents($newfile, print_r($post_content, true)); + } + $redirect = site_url() . 'admin/posts'; + header("Location: $redirect"); + } + +} + +function edit_page($title, $url, $content, $oldfile) { + + $dir = substr($oldfile, 0, strrpos($oldfile, '/')); + + $post_title = $title; + $post_url = preg_replace('/[^A-Za-z0-9,.-]/u', '', $url); + $post_url = rtrim($post_url, ',\.\-'); + $post_content = '' . "\n\n" . $content; + + if(!empty($post_title) && !empty($post_url) && !empty($post_content)) { + if(get_magic_quotes_gpc()) { + $post_content = stripslashes($post_content); + } + $newfile = $dir . '/' . $post_url . '.md'; + if($oldfile === $newfile) { + file_put_contents($oldfile, print_r($post_content, true)); + } + else { + rename($oldfile, $newfile); + file_put_contents($newfile, print_r($post_content, true)); + } + $redirect = site_url() . 'admin'; + header("Location: $redirect"); + } + +} + +function add_post($title, $tag, $url, $content, $user) { + + $post_date = date('Y-m-d-H-i'); + $post_title = $title; + $post_tag = preg_replace('/[^A-Za-z0-9,.-]/u', '', $tag); + $post_tag = rtrim($post_tag, ',\.\-'); + $post_url = preg_replace('/[^A-Za-z0-9,.-]/u', '', $url); + $post_url = rtrim($post_url, ',\.\-'); + $post_content = '' . "\n\n" . $content; + + if(!empty($post_title) && !empty($post_tag) && !empty($post_url) && !empty($post_content)) { + if(get_magic_quotes_gpc()) { + $post_content = stripslashes($post_content); + } + $filename = $post_date . '_' . $post_tag . '_' . $post_url . '.md'; + $dir = 'content/' . $user. '/blog/'; + if(is_dir($dir)) { + file_put_contents($dir . $filename, print_r($post_content, true)); + } + else { + mkdir($dir, 0777, true); + file_put_contents($dir . $filename, print_r($post_content, true)); + } + $redirect = site_url() . 'admin/posts'; + header("Location: $redirect"); + } + +} + +function add_page($title, $url, $content) { + + $post_title = $title; + $post_url = preg_replace('/[^A-Za-z0-9,.-]/u', '', $url); + $post_url = rtrim($post_url, ',\.\-'); + $post_content = '' . "\n\n" . $content; + + if(!empty($post_title) && !empty($post_url) && !empty($post_content)) { + if(get_magic_quotes_gpc()) { + $post_content = stripslashes($post_content); + } + $filename = $post_url . '.md'; + $dir = 'content/static/'; + if(is_dir($dir)) { + file_put_contents($dir . $filename, print_r($post_content, true)); + } + else { + mkdir($dir, 0777, true); + file_put_contents($dir . $filename, print_r($post_content, true)); + } + $redirect = site_url() . 'admin'; + header("Location: $redirect"); + } + +} + +function delete_post($file) { + $deleted_content = $file; + if(!empty($deleted_content)) { + unlink($deleted_content); + $redirect = site_url() . 'admin/posts'; + header("Location: $redirect"); + } +} + +function delete_page($file) { + $deleted_content = $file; + if(!empty($deleted_content)) { + unlink($deleted_content); + $redirect = site_url() . 'admin'; + header("Location: $redirect"); + } +} + +function edit_profile($title, $content, $user) { + + $user_title = $title; + $user_content = '' . "\n\n" . $content; + + if(!empty($user_title) && !empty($user_content)) { + if(get_magic_quotes_gpc()) { + $user_content = stripslashes($user_content); + } + $dir = 'content/' . $user. '/'; + $filename = 'content/' . $user . '/author.md'; + if(is_dir($dir)) { + file_put_contents($filename, print_r($user_content, true)); + } + else { + mkdir($dir, 0777, true); + file_put_contents($filename, print_r($user_content, true)); + } + $redirect = site_url() . 'admin'; + header("Location: $redirect"); + } + +} + +function get_recent_posts() { + if (isset($_SESSION['user'])) { + + $posts = get_profile($_SESSION['user'], 1, 5); + + if(!empty($posts)) { + + echo ''; + echo ''; + foreach($posts as $p) { + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + echo '
TitlePublishedTagOperations
' . $p->title . '' . date('d F Y', $p->date) . '' . $p->tag . 'Edit Delete
'; + + } + } +} + +// Auto generate menu from static page +function get_recent_pages() { + if (isset($_SESSION['user'])) { + $posts = get_static_post(null); + krsort($posts); + + echo ''; + echo ''; + foreach($posts as $p) { + echo ''; + echo ''; + echo ''; + echo ''; + } + echo '
TitleOperations
' . $p->title . 'Edit Delete
'; + } +} diff --git a/admin/editor/LICENSE.txt b/system/admin/editor/LICENSE.txt similarity index 100% rename from admin/editor/LICENSE.txt rename to system/admin/editor/LICENSE.txt diff --git a/admin/editor/README.txt b/system/admin/editor/README.txt similarity index 100% rename from admin/editor/README.txt rename to system/admin/editor/README.txt diff --git a/admin/editor/css/editor.css b/system/admin/editor/css/editor.css similarity index 99% rename from admin/editor/css/editor.css rename to system/admin/editor/css/editor.css index bd3f11d..873cc78 100644 --- a/admin/editor/css/editor.css +++ b/system/admin/editor/css/editor.css @@ -22,7 +22,7 @@ blockquote { } .wmd-input { - height: 300px; + min-height: 300px; width: 96%; background-color: #FFFFFF; border:none; diff --git a/admin/editor/img/wmd-buttons.png b/system/admin/editor/img/wmd-buttons.png similarity index 100% rename from admin/editor/img/wmd-buttons.png rename to system/admin/editor/img/wmd-buttons.png diff --git a/admin/editor/js/Markdown.Converter.js b/system/admin/editor/js/Markdown.Converter.js similarity index 100% rename from admin/editor/js/Markdown.Converter.js rename to system/admin/editor/js/Markdown.Converter.js diff --git a/admin/editor/js/Markdown.Editor.js b/system/admin/editor/js/Markdown.Editor.js similarity index 100% rename from admin/editor/js/Markdown.Editor.js rename to system/admin/editor/js/Markdown.Editor.js diff --git a/admin/editor/js/Markdown.Sanitizer.js b/system/admin/editor/js/Markdown.Sanitizer.js similarity index 100% rename from admin/editor/js/Markdown.Sanitizer.js rename to system/admin/editor/js/Markdown.Sanitizer.js diff --git a/admin/editor/js/local/Markdown.local.fr.js b/system/admin/editor/js/local/Markdown.local.fr.js similarity index 100% rename from admin/editor/js/local/Markdown.local.fr.js rename to system/admin/editor/js/local/Markdown.local.fr.js diff --git a/admin/editor/js/node-pagedown.js b/system/admin/editor/js/node-pagedown.js similarity index 100% rename from admin/editor/js/node-pagedown.js rename to system/admin/editor/js/node-pagedown.js diff --git a/admin/editor/package.json b/system/admin/editor/package.json similarity index 100% rename from admin/editor/package.json rename to system/admin/editor/package.json diff --git a/system/admin/views/add-page.html.php b/system/admin/views/add-page.html.php new file mode 100644 index 0000000..7d68ee8 --- /dev/null +++ b/system/admin/views/add-page.html.php @@ -0,0 +1,23 @@ + + + + +
+
+ Title:


+ Url:


+
+
+ +
+
+
+ \ No newline at end of file diff --git a/system/admin/views/add-post.html.php b/system/admin/views/add-post.html.php new file mode 100644 index 0000000..3dc53b1 --- /dev/null +++ b/system/admin/views/add-post.html.php @@ -0,0 +1,24 @@ + + + + +
+
+ Title:


+ Tag:


+ Url:


+
+
+ +
+
+
+ \ No newline at end of file diff --git a/system/admin/views/css/style.css b/system/admin/views/css/style.css new file mode 100644 index 0000000..032fe79 --- /dev/null +++ b/system/admin/views/css/style.css @@ -0,0 +1,820 @@ +/*------------------------- + Simple reset +--------------------------*/ + +*{ + margin:0; + padding:0; +} + + +body { + font-family: Georgia, sans-serif, Arial; + font-size: 17px; + line-height: 1.6; + color: #343A3F; + padding: 0; + margin: 0; +} + +section, footer, header, aside, nav{ + display: block; +} + +img { + border: 0 none; + height: auto; + max-width: 100%; + outline: 0 none; +} + +/*------------------------- + Heading +--------------------------*/ + +h1, h2, h3, h4, h5, h6 { + font-family: 'Open Sans',sans-serif; + line-height: 1.3; + margin: 0.5em 0; +} + +h1 { + font-size: 28px; +} + +h2 { + font-size: 24px; +} + +h3 { + font-size: 18px; +} + +h4 { + font-size: 16px; +} + +h5 { + font-size: 14px; +} + +h6 { + font-size: 12px; +} + +/*------------------------- + Toolbar +--------------------------*/ + +#toolbar { + background: none repeat scroll 0 0 #666666; + box-shadow: 0 3px 20px #000000; + color: #CCCCCC; + font-family: 'Open Sans',sans-serif; + left: 0; + margin: 0 -20px; + padding: 0 25px; + position: fixed; + right: 0; + top: 0; + z-index: 600; + border: 0 none; + font-size: 15px; + text-align: left; + vertical-align: baseline; +} + +#toolbar ul { + margin:0; +} + +#toolbar ul li, #toolbar ul li a { + float: left; + list-style: none outside none; +} +#toolbar a { + color: #FFFFFF; + font-size: 0.846em; + text-decoration: none; + border-radius: 10px; + padding: 0 10px; +} + +/*------------------------- + Layout +--------------------------*/ + +#outer-wrapper { + margin:0; + padding:0; + float:left; + width: 100%; +} + +#inner-wrapper { + padding: 0 10px; +} + +.container { + padding: 0 20px; +} + +#header-wrapper { + background: #546673; + position:relative; + padding: 1em 0; + float:left; + width: 100%; + color: #ffffff; + font-family: Georgia, sans-serif; + font-style:italic; +} + +#content-wrapper { + float:left; + width: 100%; + padding: 3em 0; + background-color: #FAFAFA; +} + +#menu, #header, #content, #footer { + width: 980px; + margin: 0 auto; +} + +#header { + text-align:center; +} + +.hide { + display:none; +} + +.wmd-panel { + display:table-row; +} + +/*------------------------- + Link +--------------------------*/ + +a, a:visited { + outline:none; + color:#2E9FFF; + text-decoration:none; +} + +a:hover{ + text-decoration:underline; +} + +/*------------------------- + Text element +--------------------------*/ + +blockquote:before { + color: #BBBBBB; + content: "“"; + font-size: 3em; + line-height: 0.1em; + margin-right: 0.2em; + vertical-align: -0.4em; +} + +blockquote:after { + color: #BBBBBB; + content: "”"; + font-size: 3em; + line-height: 0.1em; + vertical-align: -0.45em; +} + +blockquote { + font-style: italic; + margin: 1em 0 1em 1em; +} + +blockquote p { + display:inline; +} + +pre { + margin: 1em 0; + overflow: auto; + background: #F1F1FF; +} + +code { + color: #333333; + font-family: Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif; + font-size: 15px; + padding: 5px 10px; + background: #F1F1FF; +} + +pre code { + color: #333333; + display: block; + font-family: Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif; + font-size: 14px; + padding: 5px 10px; +} + +.thumbnail { + float: left; + height: 80px; + width: 80px; + margin: 5px 15px 0 0; + overflow: hidden; + display: block; + background-repeat: no-repeat; + background-position: center; + background-size: cover; +} + +ul, ol { + padding-left: 30px; + margin: 1em 0; +} + +ul li, ol li{ + margin: 0.25em 0; +} + +input.text, input.password { + width: 75%; +} + +/*------------------------- + Table +--------------------------*/ + +table { + font-size:12px; + border: none; + width:100%; + color:#333333; + border: 1px solid #E3E3E3; + margin: 1em 0; +} + +table h2.title { + margin:5px 0; +} + +th, td { + padding: 5px 10px; + border: none; +} + +th.title { + margin:5px 0; + font-family: 'Open Sans',sans-serif; + font-size:16px; + font-weight:normal; +} + +td.title { + font-weight:normal; + background-color: #f6f6f6; + font-family: 'Open Sans',sans-serif; +} + +th { + background-color: #f6f6f6; + border-bottom: 1px solid #E3E3E3; + border-right: 1px solid #E3E3E3; + font-family: 'Open Sans',sans-serif; + font-size:16px; +} + +td { + background-color: #fafafa; + border: 1px solid #E3E3E3; + border-top: none; + border-left:none; +} + +/*------------------------- + Menu +--------------------------*/ + +#menu-wrapper { + font-family: 'Open Sans',sans-serif; + color: #7E909D; + padding: 10px 0; + float:left; + width:100%; +} + +#menu { + font-weight:bold; + font-family: 'Open Sans',sans-serif; + color: #7E909D; + font-size: 14px; +} + +#menu ul { + margin:0; + padding:0; +} + +#menu a { + color: #7E909D; +} + +#menu ul li { + float:left; + margin:0 20px 0 0; + list-style:none; + padding-top:3px; +} + +#menu ul li:last-child { + margin:0; +} + +/*---------------------------- + Search form +-----------------------------*/ + +#search-form { + position:relative; + float:right; +} + +.search-input{ + margin: 0; + padding: 4px 15px; + font-size:14px; + border:1px solid #0076a3; + border-top-left-radius: 5px 5px; + border-bottom-left-radius: 5px 5px; + width: 120px; + color: #888888; +} +.search-button { + margin: 0; + padding: 4px; + font-size:14px; + outline: none; + cursor: pointer; + text-align: center; + text-decoration: none; + color: #ffffff; + border: solid 1px #546673; + border-right:0px; + background: #0095cd; + background: -webkit-gradient(linear, left top, left bottom, from(#2E9FFF), to(#2E9CCC)); + background: -moz-linear-gradient(top, #2E9FFF, #2E9CCC); + border-top-right-radius: 5px 5px; + border-bottom-right-radius: 5px 5px; + width: 60px; +} +.search-button:hover { + text-decoration: none; + background: #007ead; + background: -webkit-gradient(linear, left top, left bottom, from(#0095cc), to(#00678e)); + background: -moz-linear-gradient(top, #0095cc, #00678e); +} +/* Fixes submit button height problem in Firefox */ +.search-button::-moz-focus-inner { + border: 0; +} + +/*------------------------- + Post +--------------------------*/ + +.post { + border-bottom: 1px solid #EBF2F6; + padding: 1em 0; + float: left; + width: 100%; +} + +.inpost .post { + padding-bottom: 0; +} + +p, ul { + margin :1em 0; +} + +.breadcrumb { + font-family: 'Open Sans',sans-serif; + font-size: 14px; + font-weight:normal; +} + +.date { + font-family: 'Open Sans',sans-serif; + font-size: 14px; + color: #A7A7A7; + font-weight:normal; + margin:1em 0; +} + +h1.blog-title { + font-style:normal; +} + +h1.title-post a, h2.title-index a{ + color:#4f4f4f; + text-decoration: none; +} + +h1.title-post a:hover, h2.title-index a:hover { + color: #2E9FFF; +} + +.inpost .post { + padding-top:0; + border: none; +} + +.inpage .border { + padding:0; + margin:0; + border:0; +} + +.inpage .post { + padding-top:0; +} + +.infront .first, .inpost .post, .intag .first, .inarchive .first, .insearch .first { + padding-top:0; +} + +.infront .first h2.title-index { + margin-top:0; +} + +.inprofile .bio { + font-size: 14px; + font-style:italic; + border-bottom: 1px solid #EBF2F6; + padding-bottom: 1em; + margin-bottom: 2em; +} + +.post-list { + font-size: 14px; +} + +/*------------------------- + Comments +--------------------------*/ + +.comments { + position:relative; + display:block; + font-size:16px; + float:left; + width:100%; +} + +.border { + border-top: 1px solid #DFDFDF; + margin-bottom: 15px; + margin-top: 10px; + padding-bottom: 15px; + width: 100%; + float:left; +} + +.border #disqus_thread { + padding-top: 1.2em; +} + +#disqus_thread { + font-family: Georgia, Times, Cambria, serif; + float:left; + width:100%; +} + +/*------------------------- + Raleted posts +--------------------------*/ + +.related { + font-size: 14px; + font-family: 'Open Sans',sans-serif; + width:100%; + float:left; + margin-bottom: 1em; +} + +.related ul { + margin:0; +} + +/*------------------------- + Pagination + Postnav +--------------------------*/ + +.postnav{ + width:100%; + float:left; + padding-bottom:1em; + font-family: 'Open Sans',sans-serif; + font-size: 12px; + font-weight:bold; +} + +.postnav a { + background: none repeat scroll 0 0 #E4E7EE; + border-radius: 3px; + color: #555555; + line-height: 1; + text-align: center; +} + +.postnav a:hover { + text-decoration:none; + color:#333333; +} + +.postnav .newer { + float:left; + margin-right:1em; + margin-bottom:0.1em; + padding: 10px 15px 10px 25px; +} + +.postnav .older { + float:right; + padding: 10px 25px 10px 15px; +} + +.postnav .pagination-arrow{ + display: inline-block; + border-radius: 3px; + color: #555 !important; + text-decoration: none !important; + text-transform: none; + position: relative; +} + +.postnav .pagination-arrow.newer:before, +.postnav .pagination-arrow.older:before{ + content: ''; + border: 5px solid #555; + border-color: transparent #555 transparent transparent; + width: 0; + height: 0; + position: absolute; + left: 5px; + top: 12px; +} + +.postnav .pagination-arrow.older:before{ + left:auto; + right:5px; + border-color: transparent transparent transparent #555; +} + +.pager { + width:100%; + float:left; + padding: 30px 0 1em 0; + font-family: 'Open Sans',sans-serif; + font-size: 12px; + font-weight:bold; +} + +.pager a { + background: none repeat scroll 0 0 #E4E7EE; + border-radius: 3px; + color: #555555; + line-height: 1; + padding: 10px 20px; + text-align: center; +} + +.pager .newer { + float:left; +} + +.pager .older { + float:right; +} + +.pager a:hover { + text-decoration:none; + color:#333333; +} + +/*------------------------- + Footer +--------------------------*/ + +#footer-wrapper { + background: #546673; + position:relative; + padding: 20px 0; + float:left; + width: 100%; + color: #ABB6C5; + font-family: 'Open Sans', sans-serif; +} + +#footer { + font-size: 14px; +} + +#footer a { + color: #CBD2DC; + font-weight:bold; +} + +#footer ul { + margin:0.5em 0; +} + +.footer-column { + padding-bottom: 1.5em; + float:left; + width:100%; +} + +.column { + float: left; + width: 33%; +} + +.social { + float:right; +} + +.social .inner { + padding-left:30px; +} + +.tagcloud ul { + padding:0; + margin:0; +} + +.tagcloud ul li { + float:left; + list-style:none; + margin-right: 10px; +} + +.copyright { + font-size: 12px; + float:left; + width: 100%; + border-top: 1px solid #ABB6C5; + padding-top:1em; +} + +.copyright p { + margin: 0.5em 0; + line-height: 1.2; +} + +/*---------------------------- + The 404 page +-----------------------------*/ + +.message{ + padding:50px 20px 20px 20px; +} + +.message h1{ + font-size:36px; + margin-bottom: 18px; +} + +.message p{ + font-size:13px; +} + +.center{ + text-align:center; +} + +.search-404 { + position:relative; + float:left; + width:100%; + margin-bottom: 1.2em; +} + +.search-404 #search-form { + float:none; +} + +/*---------------------------- + Media queries +-----------------------------*/ + +@media all and (max-width: 700px) { + + #menu, #header, #content, #footer { + margin: 0 auto; + width: 100%; + } + + #menu-wrapper { + text-align:center; + } + + #menu ul li { + float:none; + display:inline-block; + } + + #search-form { + float:none; + padding: 10px 0; + } + + .author-info { + width: 100%; + float:left; + } + + .share { + width:100%; + margin-right: 0; + padding-bottom: 1em; + } + + .column { + float:left; + width:100%; + } + + .postnav .newer { + float:left; + margin-bottom:1em; + } + + .postnav .older { + float:left; + } + + .social .inner { + padding-left:0px; + } + + pre { + white-space: pre-wrap; + word-wrap:break-word; + } + +} + +/*---------------------------- + 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 diff --git a/system/admin/views/delete-page.html.php b/system/admin/views/delete-page.html.php new file mode 100644 index 0000000..1dfabac --- /dev/null +++ b/system/admin/views/delete-page.html.php @@ -0,0 +1,6 @@ +Are you sure want to delete ' . $p->title . '?

';?> +
+
+ + Cancel +
\ No newline at end of file diff --git a/system/admin/views/delete-post.html.php b/system/admin/views/delete-post.html.php new file mode 100644 index 0000000..4f79066 --- /dev/null +++ b/system/admin/views/delete-post.html.php @@ -0,0 +1,6 @@ +Are you sure want to delete ' . $p->title . '?

';?> +
+
+ + Cancel +
\ No newline at end of file diff --git a/system/admin/views/edit-page.html.php b/system/admin/views/edit-page.html.php new file mode 100644 index 0000000..4799f23 --- /dev/null +++ b/system/admin/views/edit-page.html.php @@ -0,0 +1,43 @@ +file; + $content = file_get_contents($url); + $arr = explode('t-->', $content); + if(isset($arr[1])) { + $oldtitle = ltrim(rtrim(str_replace('', $content); + if(isset($arr[1])) { + $oldtitle = ltrim(rtrim(str_replace('', $content); + if(isset($arr[1])) { + $oldtitle = ltrim(rtrim(str_replace(' + + +
+ + +
+ + + + +
+ +
+
+ +
+
+
+
+
+ +
+
+
+ +
+ + + \ No newline at end of file diff --git a/system/admin/views/login.html.php b/system/admin/views/login.html.php new file mode 100644 index 0000000..db37225 --- /dev/null +++ b/system/admin/views/login.html.php @@ -0,0 +1,11 @@ + + +

Login

+
+ User:
+

+ Pass:
+

+ +
+ \ No newline at end of file diff --git a/system/admin/views/logout.html.php b/system/admin/views/logout.html.php new file mode 100644 index 0000000..a8b9c93 --- /dev/null +++ b/system/admin/views/logout.html.php @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/system/admin/views/main.html.php b/system/admin/views/main.html.php new file mode 100644 index 0000000..90403f0 --- /dev/null +++ b/system/admin/views/main.html.php @@ -0,0 +1,5 @@ +Your recent posts'; +get_recent_posts(); +echo '

Static pages

'; +get_recent_pages(); ?> \ No newline at end of file diff --git a/system/admin/views/pages-list.html.php b/system/admin/views/pages-list.html.php new file mode 100644 index 0000000..e69de29 diff --git a/system/admin/views/posts-list.html.php b/system/admin/views/posts-list.html.php new file mode 100644 index 0000000..e52cc37 --- /dev/null +++ b/system/admin/views/posts-list.html.php @@ -0,0 +1,37 @@ +

Your posts

+ + + + + + + + + + + + + +
TitlePublishedTagOperations
title ?>date) ?>tag ?>Edit Delete
+ +
+ + + + + + +
+ + \ No newline at end of file diff --git a/system/htmly.php b/system/htmly.php index 684e235..7faed7e 100644 --- a/system/htmly.php +++ b/system/htmly.php @@ -7,7 +7,9 @@ date_default_timezone_set('Asia/Jakarta'); // and our functions.php file require 'system/includes/dispatch.php'; require 'system/includes/functions.php'; -require 'system/includes/opml.php'; +require 'system/admin/admin.php'; +require 'system/includes/session.php'; +include 'system/includes/opml.php'; // Load the configuration file config('source', 'config/config.ini'); @@ -46,78 +48,13 @@ get('/index', function () { )); }); -// The tag page -get('/tag/:tag',function($tag){ +// Get submitted login data +post('/login', function() { - $page = from($_GET, 'page'); - $page = $page ? (int)$page : 1; - $perpage = config('tag.perpage'); + $user = from($_REQUEST, 'user'); + $pass = from($_REQUEST, 'password'); + session($user, $pass); - $posts = get_tag($tag, $page, $perpage); - - $total = get_count($tag, 'filename'); - - if(empty($posts) || $page < 1){ - // a non-existing page - not_found(); - } - - render('main',array( - 'title' => 'Posts tagged: ' . $tag .' - ' . config('blog.title'), - 'page' => $page, - 'posts' => $posts, - 'canonical' => config('site.url') . '/tag/' . $tag, - 'description' => 'All posts tagged ' . $tag . ' on '. config('blog.title') . '.', - 'bodyclass' => 'intag', - 'breadcrumb' => '' .config('breadcrumb.home'). ' » Posts tagged: ' . $tag, - 'pagination' => has_pagination($total, $perpage, $page) - )); -}); - -// The archive page -get('/archive/:req',function($req){ - - $page = from($_GET, 'page'); - $page = $page ? (int)$page : 1; - $perpage = config('archive.perpage'); - - $posts = get_archive($req, $page, $perpage); - - $total = get_count($req, 'filename'); - - if(empty($posts) || $page < 1){ - // a non-existing page - not_found(); - } - - $time = explode('-', $req); - $date = strtotime($req); - - if (isset($time[0]) && isset($time[1]) && isset($time[2])) { - $timestamp = date('d F Y', $date); - } - else if (isset($time[0]) && isset($time[1])) { - $timestamp = date('F Y', $date); - } - else { - $timestamp = $req; - } - - if(!$date){ - // a non-existing page - not_found(); - } - - render('main',array( - 'title' => 'Archive for: ' . $timestamp .' - ' . config('blog.title'), - 'page' => $page, - 'posts' => $posts, - 'canonical' => config('site.url') . '/archive/' . $req, - 'description' => 'Archive page for: ' . $timestamp . ' on ' . config('blog.title') . '.', - 'bodyclass' => 'inarchive', - 'breadcrumb' => '' .config('breadcrumb.home'). ' » Archive for: ' . $timestamp, - 'pagination' => has_pagination($total, $perpage, $page) - )); }); // The blog post page @@ -168,37 +105,224 @@ get('/:year/:month/:name', function($year, $month, $name){ )); }); -// The search page -get('/search/:keyword', function($keyword){ +// Edit blog post +get('/:year/:month/:name/edit', function($year, $month, $name){ + + if(login()) { + + config('views.root', 'system/admin/views'); + $post = find_post($year, $month, $name); + + if(!$post){ + not_found(); + } + + $current = $post['current']; + + render('edit-post',array( + 'title' => $current->title .' - ' . config('blog.title'), + 'p' => $current, + 'canonical' => $current->url, + 'description' => $description = get_description($current->body), + 'bodyclass' => 'inedit', + 'breadcrumb' => '' .config('breadcrumb.home'). ' » '. $current->tagb . ' » ' . $current->title + )); + } + else { + $login = site_url() . 'login'; + header("location: $login"); + } +}); + +// Get edited data for blog post +post('/:year/:month/:name/edit', function() { + + $title = from($_REQUEST, 'title'); + $tag = from($_REQUEST, 'tag'); + $url = from($_REQUEST, 'url'); + $content = from($_REQUEST, 'content'); + $oldfile = from($_REQUEST, 'oldfile'); + + edit_post($title, $tag, $url, $content, $oldfile); + +}); + +// Delete blog post +get('/:year/:month/:name/delete', function($year, $month, $name){ + + if(login()) { + + config('views.root', 'system/admin/views'); + $post = find_post($year, $month, $name); + + if(!$post){ + not_found(); + } + + $current = $post['current']; + + render('delete-post',array( + 'title' => $current->title .' - ' . config('blog.title'), + 'p' => $current, + 'canonical' => $current->url, + 'description' => $description = get_description($current->body), + 'bodyclass' => 'inedit', + 'breadcrumb' => '' .config('breadcrumb.home'). ' » '. $current->tagb . ' » ' . $current->title + )); + } + else { + $login = site_url() . 'login'; + header("location: $login"); + } +}); + +// Get deleted data for blog post +post('/:year/:month/:name/delete', function() { + $file = from($_REQUEST, 'file'); + + delete_post($file); + +}); + +// The author page +get('/author/:profile', function($profile){ $page = from($_GET, 'page'); $page = $page ? (int)$page : 1; - $perpage = config('search.perpage'); + $perpage = config('profile.perpage'); - $posts = get_keyword($keyword); + $posts = get_profile($profile, $page, $perpage); - $total = count($posts); + $total = get_count($profile, 'dirname'); + + $bio = get_bio($profile); + + if(isset($bio[0])) { + $bio = $bio[0]; + } + else { + $bio = default_profile($profile); + } - // Extract a specific page with results - $posts = array_slice($posts, ($page-1) * $perpage, $perpage); - if(empty($posts) || $page < 1){ - // a non-existing page - render('404-search', null, false); + render('profile',array( + 'title' => 'Profile for: '. $bio->title .' - ' . config('blog.title'), + 'page' => $page, + 'posts' => null, + 'bio' => $bio->body, + 'name' => $bio->title, + 'canonical' => config('site.url') . '/author/' . $profile, + 'description' => 'Profile page and all posts by ' . $bio->title . ' on ' . config('blog.title') . '.', + 'bodyclass' => 'inprofile', + 'breadcrumb' => '' .config('breadcrumb.home'). ' » Profile for: ' . $bio->title, + 'pagination' => has_pagination($total, $perpage, $page) + )); die; } - render('main',array( - 'title' => 'Search results for: ' . $keyword . ' - ' . config('blog.title'), + render('profile',array( + 'title' => 'Profile for: '. $bio->title .' - ' . config('blog.title'), 'page' => $page, 'posts' => $posts, - 'canonical' => config('site.url') . '/search/' . $keyword, - 'description' => 'Search results for: ' . $keyword . ' on '. config('blog.title') . '.', - 'bodyclass' => 'insearch', - 'breadcrumb' => '' .config('breadcrumb.home'). ' » Search results for: ' . $keyword, + 'bio' => $bio->body, + 'name' => $bio->title, + 'canonical' => config('site.url') . '/author/' . $profile, + 'description' => 'Profile page and all posts by ' . $bio->title . ' on ' . config('blog.title') . '.', + 'bodyclass' => 'inprofile', + 'breadcrumb' => '' .config('breadcrumb.home'). ' » Profile for: ' . $bio->title, 'pagination' => has_pagination($total, $perpage, $page) )); +}); + +// Edit the profile +get('/edit/profile', function(){ + + if(login()) { + + config('views.root', 'system/admin/views'); + render('edit-profile',array( + 'title' => 'Edit profile - ' . config('blog.title'), + 'canonical' => config('site.url') . '/profile', + 'description' => 'Edit profile.', + 'bodyclass' => 'inpage', + 'breadcrumb' => '' .config('breadcrumb.home'). ' » Edit profile', + )); + } + else { + $login = site_url() . 'login'; + header("location: $login"); + } +}); + +// Get edited data for static page +post('/edit/profile', function() { + $user = $_SESSION['user']; + $title = from($_REQUEST, 'title'); + $content = from($_REQUEST, 'content'); + edit_profile($title, $content, $user); + +}); + +// The author page +get('/admin/posts', function(){ + + if(login()) { + + config('views.root', 'system/admin/views'); + + $profile = $_SESSION['user']; + + $page = from($_GET, 'page'); + $page = $page ? (int)$page : 1; + $perpage = config('profile.perpage'); + + $posts = get_profile($profile, $page, $perpage); + + $total = get_count($profile, 'dirname'); + + $bio = get_bio($profile); + + if(isset($bio[0])) { + $bio = $bio[0]; + } + else { + $bio = default_profile($profile); + } + + if(empty($posts) || $page < 1){ + render('posts-list',array( + 'title' => 'Profile for: '. $bio->title .' - ' . config('blog.title'), + 'page' => $page, + 'posts' => null, + 'bio' => $bio->body, + 'name' => $bio->title, + 'canonical' => config('site.url') . '/author/' . $profile, + 'description' => 'Profile page and all posts by ' . $bio->title . ' on ' . config('blog.title') . '.', + 'bodyclass' => 'inprofile', + 'breadcrumb' => '' .config('breadcrumb.home'). ' » Profile for: ' . $bio->title, + 'pagination' => has_pagination($total, $perpage, $page) + )); + die; + } + + render('posts-list',array( + 'title' => 'Profile for: '. $bio->title .' - ' . config('blog.title'), + 'page' => $page, + 'posts' => $posts, + 'bio' => $bio->body, + 'name' => $bio->title, + 'canonical' => config('site.url') . '/author/' . $profile, + 'description' => 'Profile page and all posts by ' . $bio->title . ' on ' . config('blog.title') . '.', + 'bodyclass' => 'inprofile', + 'breadcrumb' => '' .config('breadcrumb.home'). ' » Profile for: ' . $bio->title, + 'pagination' => has_pagination($total, $perpage, $page) + )); + } + else { + $login = site_url() . 'login'; + header("location: $login"); + } }); // The static page @@ -233,7 +357,52 @@ get('/:static', function($static){ die; } - + elseif($static === 'admin') { + if(login()) { + config('views.root', 'system/admin/views'); + render('main', array( + 'title' => 'Admin - ' . config('blog.title'), + 'canonical' => config('site.url') . '/admin', + 'description' => 'Admin page from ' . config('blog.title') . '.', + 'bodyclass' => 'inadmin', + 'breadcrumb' => '' .config('breadcrumb.home'). ' » Admin' + )); + die; + } + else { + $login = site_url() . 'login'; + header("location: $login"); + } + } + elseif($static === 'login') { + config('views.root', 'system/admin/views'); + render('login', array( + 'title' => 'Login - ' . config('blog.title'), + 'canonical' => config('site.url') . '/login', + 'description' => 'Login page from ' . config('blog.title') . '.', + 'bodyclass' => 'inlogin', + 'breadcrumb' => '' .config('breadcrumb.home'). ' » Login' + )); + die; + } + elseif($static === 'logout') { + if(login()) { + config('views.root', 'system/admin/views'); + render('logout', array( + 'title' => 'Logout - ' . config('blog.title'), + 'canonical' => config('site.url') . '/logout', + 'description' => 'Logout page from ' . config('blog.title') . '.', + 'bodyclass' => 'inlogout', + 'breadcrumb' => '' .config('breadcrumb.home'). ' » Logout' + )); + die; + } + else { + $login = site_url() . 'login'; + header("location: $login"); + } + } + $post = get_static_post($static); if(!$post){ @@ -251,45 +420,259 @@ get('/:static', function($static){ 'p' => $post, 'type' => 'staticpage', )); + }); -// The author page -get('/author/:profile', function($profile){ +// Edit the static page +get('/:static/edit', function($static){ + + if(login()) { + + config('views.root', 'system/admin/views'); + $post = get_static_post($static); + + if(!$post){ + not_found(); + } + + $post = $post[0]; + + render('edit-page',array( + 'title' => $post->title .' - ' . config('blog.title'), + 'canonical' => $post->url, + 'description' => $description = get_description($post->body), + 'bodyclass' => 'inpage', + 'breadcrumb' => '' .config('breadcrumb.home'). ' » ' . $post->title, + 'p' => $post, + 'type' => 'staticpage', + )); + } + else { + $login = site_url() . 'login'; + header("location: $login"); + } +}); + +// Get edited data for static page +post('/:static/edit', function() { + + $title = from($_REQUEST, 'title'); + $url = from($_REQUEST, 'url'); + $content = from($_REQUEST, 'content'); + $oldfile = from($_REQUEST, 'oldfile'); + + edit_page($title, $url, $content, $oldfile); + +}); + +// Deleted the static page +get('/:static/delete', function($static){ + + if(login()) { + + config('views.root', 'system/admin/views'); + $post = get_static_post($static); + + if(!$post){ + not_found(); + } + + $post = $post[0]; + + render('delete-page',array( + 'title' => $post->title .' - ' . config('blog.title'), + 'canonical' => $post->url, + 'description' => $description = get_description($post->body), + 'bodyclass' => 'inpage', + 'breadcrumb' => '' .config('breadcrumb.home'). ' » ' . $post->title, + 'p' => $post, + 'type' => 'staticpage', + )); + } + else { + $login = site_url() . 'login'; + header("location: $login"); + } +}); + +// Get deleted data for static page +post('/:static/delete', function() { + + $file = from($_REQUEST, 'file'); + + delete_post($file); + +}); + +// Add blog post +get('/add/post', function(){ + + if(login()) { + + config('views.root', 'system/admin/views'); + + render('add-post',array( + 'title' => 'Add post - ' . config('blog.title'), + 'canonical' => config('site.url') . '/add/post', + 'description' => 'Add post on ' .config('blog.title'), + 'bodyclass' => 'addpost', + 'breadcrumb' => '' .config('breadcrumb.home'). ' » Add post' + )); + } + else { + $login = site_url() . 'login'; + header("location: $login"); + } +}); + +// Get submitted blog post data +post('/add/post', function(){ + + $title = from($_REQUEST, 'title'); + $tag = from($_REQUEST, 'tag'); + $url = from($_REQUEST, 'url'); + $content = from($_REQUEST, 'content'); + $user = $_SESSION['user']; + add_post($title, $tag, $url, $content, $user); + +}); + +// Add the static page +get('/add/page', function(){ + + if(login()) { + + config('views.root', 'system/admin/views'); + + render('add-page',array( + 'title' => 'Add static page - ' . config('blog.title'), + 'canonical' => config('site.url') . '/add/page', + 'description' => 'Add static page on ' .config('blog.title'), + 'bodyclass' => 'addpage', + 'breadcrumb' => '' .config('breadcrumb.home'). ' » Add page' + )); + } + else { + $login = site_url() . 'login'; + header("location: $login"); + } +}); + +// Get submitted static page data +post('/add/page', function(){ + + $title = from($_REQUEST, 'title'); + $url = from($_REQUEST, 'url'); + $content = from($_REQUEST, 'content'); + add_page($title, $url, $content); + +}); + +// The tag page +get('/tag/:tag',function($tag){ $page = from($_GET, 'page'); $page = $page ? (int)$page : 1; - $perpage = config('profile.perpage'); + $perpage = config('tag.perpage'); - $posts = get_profile($profile, $page, $perpage); + $posts = get_tag($tag, $page, $perpage); - $total = get_count($profile, 'dirname'); + $total = get_count($tag, 'filename'); + + if(empty($posts) || $page < 1){ + // a non-existing page + not_found(); + } - $bio = get_bio($profile); + render('main',array( + 'title' => 'Posts tagged: ' . $tag .' - ' . config('blog.title'), + 'page' => $page, + 'posts' => $posts, + 'canonical' => config('site.url') . '/tag/' . $tag, + 'description' => 'All posts tagged ' . $tag . ' on '. config('blog.title') . '.', + 'bodyclass' => 'intag', + 'breadcrumb' => '' .config('breadcrumb.home'). ' » Posts tagged: ' . $tag, + 'pagination' => has_pagination($total, $perpage, $page) + )); +}); + +// The archive page +get('/archive/:req',function($req){ + + $page = from($_GET, 'page'); + $page = $page ? (int)$page : 1; + $perpage = config('archive.perpage'); + + $posts = get_archive($req, $page, $perpage); - if(isset($bio[0])) { - $bio = $bio[0]; + $total = get_count($req, 'filename'); + + if(empty($posts) || $page < 1){ + // a non-existing page + not_found(); } + + $time = explode('-', $req); + $date = strtotime($req); + + if (isset($time[0]) && isset($time[1]) && isset($time[2])) { + $timestamp = date('d F Y', $date); + } + else if (isset($time[0]) && isset($time[1])) { + $timestamp = date('F Y', $date); + } else { - $bio = default_profile($profile); + $timestamp = $req; + } + + if(!$date){ + // a non-existing page + not_found(); } + render('main',array( + 'title' => 'Archive for: ' . $timestamp .' - ' . config('blog.title'), + 'page' => $page, + 'posts' => $posts, + 'canonical' => config('site.url') . '/archive/' . $req, + 'description' => 'Archive page for: ' . $timestamp . ' on ' . config('blog.title') . '.', + 'bodyclass' => 'inarchive', + 'breadcrumb' => '' .config('breadcrumb.home'). ' » Archive for: ' . $timestamp, + 'pagination' => has_pagination($total, $perpage, $page) + )); +}); + +// The search page +get('/search/:keyword', function($keyword){ + + $page = from($_GET, 'page'); + $page = $page ? (int)$page : 1; + $perpage = config('search.perpage'); + + $posts = get_keyword($keyword); + + $total = count($posts); + + // Extract a specific page with results + $posts = array_slice($posts, ($page-1) * $perpage, $perpage); + if(empty($posts) || $page < 1){ // a non-existing page - not_found(); + render('404-search', null, false); + die; } - render('profile',array( - 'title' => 'Profile for: '. $bio->title .' - ' . config('blog.title'), + render('main',array( + 'title' => 'Search results for: ' . $keyword . ' - ' . config('blog.title'), 'page' => $page, 'posts' => $posts, - 'bio' => $bio->body, - 'name' => $bio->title, - 'canonical' => config('site.url') . '/author/' . $profile, - 'description' => 'Profile page and all posts by ' . $bio->title . ' on ' . config('blog.title') . '.', - 'bodyclass' => 'inprofile', - 'breadcrumb' => '' .config('breadcrumb.home'). ' » Profile for: ' . $bio->title, + 'canonical' => config('site.url') . '/search/' . $keyword, + 'description' => 'Search results for: ' . $keyword . ' on '. config('blog.title') . '.', + 'bodyclass' => 'insearch', + 'breadcrumb' => '' .config('breadcrumb.home'). ' » Search results for: ' . $keyword, 'pagination' => has_pagination($total, $perpage, $page) )); + }); // The JSON API diff --git a/system/includes/functions.php b/system/includes/functions.php index 829569e..86aea33 100644 --- a/system/includes/functions.php +++ b/system/includes/functions.php @@ -151,6 +151,8 @@ function get_posts($posts, $page = 1, $perpage = 0){ $post->tag = implode(', ', $url); $post->tagb = implode(' » ', $bc); + + $post->file = $filepath; // Get the contents and convert it to HTML $content = MarkdownExtra::defaultTransform(file_get_contents($filepath)); @@ -289,7 +291,7 @@ function get_profile($profile, $page, $perpage){ } if(empty($tmp)) { - not_found(); + return; } return $tmp = get_posts($tmp, $page, $perpage); @@ -370,6 +372,8 @@ function get_static_post($static){ $url = str_replace($replaced,'',$v); $post->url = site_url() . str_replace('.md','',$url); + $post->file = $v; + // Get the contents and convert it to HTML $content = MarkdownExtra::defaultTransform(file_get_contents($v)); diff --git a/admin/includes/session.php b/system/includes/session.php similarity index 100% rename from admin/includes/session.php rename to system/includes/session.php diff --git a/themes/clean/css/style.css b/themes/clean/css/style.css index 16de570..990d5b6 100644 --- a/themes/clean/css/style.css +++ b/themes/clean/css/style.css @@ -125,6 +125,44 @@ h6{ margin: 0.5em 0; } +/*------------------------- + Toolbar +--------------------------*/ + +#toolbar { + background: none repeat scroll 0 0 #666666; + box-shadow: 0 3px 20px #000000; + color: #CCCCCC; + font-family: 'Open Sans',sans-serif; + left: 0; + margin: 0 -20px; + padding: 0 25px; + position: fixed; + right: 0; + top: 0; + z-index: 600; + border: 0 none; + font-size: 15px; + text-align: left; + vertical-align: baseline; +} + +#toolbar ul { + margin:0; +} + +#toolbar ul li, #toolbar ul li a { + float: left; + list-style: none outside none; +} +#toolbar a { + color: #FFFFFF; + font-size: 0.846em; + text-decoration: none; + border-radius: 10px; + padding: 0 10px; +} + /*---------------------------- Content & Posts -----------------------------*/ diff --git a/themes/clean/layout.html.php b/themes/clean/layout.html.php index 75c9e42..51ba191 100644 --- a/themes/clean/layout.html.php +++ b/themes/clean/layout.html.php @@ -23,6 +23,20 @@ + + + +