Various improvements

Various improvements
This commit is contained in:
Danang Probo Sayekti 2014-02-07 07:14:05 +07:00
commit 36f4c2d4df
19 changed files with 655 additions and 115 deletions

View file

@ -1,2 +1,3 @@
2014-02-01: HTMLy v1.0.
2014-01-26: RC version. 2014-01-26: RC version.
2014-01-01: Initial release. 2014-01-01: Initial release.

View file

@ -9,11 +9,7 @@ function user($key, $user=null) {
} }
} }
function login_message($str = null) { function session($user, $pass, $str = null) {
echo $str;
}
function session($user, $pass) {
$user_file = 'config/users/' . $user . '.ini'; $user_file = 'config/users/' . $user . '.ini';
$user_pass = user('password', $user); $user_pass = user('password', $user);
@ -23,13 +19,11 @@ function session($user, $pass) {
header('location: admin'); header('location: admin');
} }
else { else {
$str = '<div style="text-align:center;padding-top:50px;"><h1>Your username and password are wrong.</h1><p><a href="' . site_url() . 'login">Back</a></p></div>'; return $str = '<li>Your username and password mismatch.</li>';
login_message($str);
} }
} }
else { else {
$str = '<div style="text-align:center;padding-top:50px;"><h1>Username not found in our record.</h1><p><a href="' . site_url() . 'login">Back</a></p></div>'; return $str = '<li>Username not found in our record.</li>';
login_message($str);
} }
} }
@ -39,9 +33,12 @@ function edit_post($title, $tag, $url, $content, $oldfile, $destination = null)
$post_title = $title; $post_title = $title;
$post_tag = preg_replace('/[^A-Za-z0-9,.-]/u', '', $tag); $post_tag = preg_replace('/[^A-Za-z0-9,.-]/u', '', $tag);
$post_tag = rtrim($post_tag, ',\.\-'); $post_tag = str_replace(' ', '-',$post_tag);
$post_url = preg_replace('/[^A-Za-z0-9,.-]/u', '', $url); $post_tag = rtrim(ltrim($post_tag, ',\.\-'), ',\.\-');
$post_url = rtrim($post_url, ',\.\-'); $post_url = preg_replace('/[^A-Za-z0-9 ,.-]/u', '', strtolower($url));
$post_url = str_replace(' ', '-',$post_url);
$post_url = str_replace('--', '-',$post_url);
$post_url = rtrim(ltrim($post_url, ',\.\-'), ',\.\-');
$post_content = '<!--t ' . $post_title . ' t-->' . "\n\n" . $content; $post_content = '<!--t ' . $post_title . ' t-->' . "\n\n" . $content;
if(!empty($post_title) && !empty($post_tag) && !empty($post_url) && !empty($post_content)) { if(!empty($post_title) && !empty($post_tag) && !empty($post_url) && !empty($post_content)) {
@ -59,7 +56,8 @@ function edit_post($title, $tag, $url, $content, $oldfile, $destination = null)
$replaced = substr($oldurl[0], 0,strrpos($oldurl[0], '/')) . '/'; $replaced = substr($oldurl[0], 0,strrpos($oldurl[0], '/')) . '/';
$dt = str_replace($replaced,'',$oldurl[0]); $dt = str_replace($replaced,'',$oldurl[0]);
$time = new DateTime($dt); $t = str_replace('-','',$dt);
$time = new DateTime($t);
$timestamp= $time->format("Y-m-d"); $timestamp= $time->format("Y-m-d");
// The post date // The post date
$postdate = strtotime($timestamp); $postdate = strtotime($timestamp);
@ -90,8 +88,10 @@ function edit_page($title, $url, $content, $oldfile, $destination = null) {
$dir = substr($oldfile, 0, strrpos($oldfile, '/')); $dir = substr($oldfile, 0, strrpos($oldfile, '/'));
$post_title = $title; $post_title = $title;
$post_url = preg_replace('/[^A-Za-z0-9,.-]/u', '', $url); $post_url = preg_replace('/[^A-Za-z0-9 ,.-]/u', '', strtolower($url));
$post_url = rtrim($post_url, ',\.\-'); $post_url = str_replace(' ', '-',$post_url);
$post_url = str_replace('--', '-',$post_url);
$post_url = rtrim(ltrim($post_url, ',\.\-'), ',\.\-');
$post_content = '<!--t ' . $post_title . ' t-->' . "\n\n" . $content; $post_content = '<!--t ' . $post_title . ' t-->' . "\n\n" . $content;
if(!empty($post_title) && !empty($post_url) && !empty($post_content)) { if(!empty($post_title) && !empty($post_url) && !empty($post_content)) {
@ -127,12 +127,14 @@ function edit_page($title, $url, $content, $oldfile, $destination = null) {
function add_post($title, $tag, $url, $content, $user) { function add_post($title, $tag, $url, $content, $user) {
$post_date = date('Y-m-d-H-i'); $post_date = date('Y-m-d-H-i-s');
$post_title = $title; $post_title = $title;
$post_tag = preg_replace('/[^A-Za-z0-9,.-]/u', '', $tag); $post_tag = preg_replace('/[^A-Za-z0-9,.-]/u', '', $tag);
$post_tag = rtrim($post_tag, ',\.\-'); $post_tag = rtrim(ltrim($post_tag, ',\.\-'), ',\.\-');
$post_url = preg_replace('/[^A-Za-z0-9,.-]/u', '', $url); $post_url = preg_replace('/[^A-Za-z0-9 ,.-]/u', '', strtolower($url));
$post_url = rtrim($post_url, ',\.\-'); $post_url = str_replace(' ', '-',$post_url);
$post_url = str_replace('--', '-',$post_url);
$post_url = rtrim(ltrim($post_url, ' \,\.\-'), ' \,\.\-');
$post_content = '<!--t ' . $post_title . ' t-->' . "\n\n" . $content; $post_content = '<!--t ' . $post_title . ' t-->' . "\n\n" . $content;
if(!empty($post_title) && !empty($post_tag) && !empty($post_url) && !empty($post_content)) { if(!empty($post_title) && !empty($post_tag) && !empty($post_url) && !empty($post_content)) {
@ -157,8 +159,10 @@ function add_post($title, $tag, $url, $content, $user) {
function add_page($title, $url, $content) { function add_page($title, $url, $content) {
$post_title = $title; $post_title = $title;
$post_url = preg_replace('/[^A-Za-z0-9,.-]/u', '', $url); $post_url = preg_replace('/[^A-Za-z0-9 ,.-]/u', '', strtolower($url));
$post_url = rtrim($post_url, ',\.\-'); $post_url = str_replace(' ', '-',$post_url);
$post_url = str_replace('--', '-',$post_url);
$post_url = rtrim(ltrim($post_url, ',\.\-'), ',\.\-');
$post_content = '<!--t ' . $post_title . ' t-->' . "\n\n" . $content; $post_content = '<!--t ' . $post_title . ' t-->' . "\n\n" . $content;
if(!empty($post_title) && !empty($post_url) && !empty($post_content)) { if(!empty($post_title) && !empty($post_url) && !empty($post_content)) {
@ -184,8 +188,14 @@ function delete_post($file, $destination) {
$deleted_content = $file; $deleted_content = $file;
if(!empty($deleted_content)) { if(!empty($deleted_content)) {
unlink($deleted_content); unlink($deleted_content);
$redirect = site_url() . $destination; if($destination == 'post') {
header("Location: $redirect"); $redirect = site_url();
header("Location: $redirect");
}
else {
$redirect = site_url() . $destination;
header("Location: $redirect");
}
} }
} }
@ -193,8 +203,14 @@ function delete_page($file, $destination) {
$deleted_content = $file; $deleted_content = $file;
if(!empty($deleted_content)) { if(!empty($deleted_content)) {
unlink($deleted_content); unlink($deleted_content);
$redirect = site_url() . $destination; if($destination == 'post') {
header("Location: $redirect"); $redirect = site_url();
header("Location: $redirect");
}
else {
$redirect = site_url() . $destination;
header("Location: $redirect");
}
} }
} }
@ -222,6 +238,84 @@ function edit_profile($title, $content, $user) {
} }
function migrate($title, $time, $tags, $content, $url, $user, $source) {
$post_date = date('Y-m-d-H-i-s', $time);
$post_title = $title;
$post_tag = preg_replace('/[^A-Za-z0-9,.-]/u', '', $tags);
$post_tag = rtrim(ltrim($post_tag, ',\.\-'), ',\.\-');
$post_url = preg_replace('/[^A-Za-z0-9 ,.-]/u', '', strtolower($url));
$post_url = str_replace(' ', '-',$post_url);
$post_url = str_replace('--', '-',$post_url);
$post_url = rtrim(ltrim($post_url, ',\.\-'), ',\.\-');
if(!empty($source)) {
$post_content = '<!--t ' . $post_title . ' t-->' . "\n\n" . $content . "\n\n" . 'Source: <a target="_blank" href="' . $source . '">' . $title . '</a>';
}
else {
$post_content = '<!--t ' . $post_title . ' t-->' . "\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 get_feed($feed_url, $credit, $message=null) {
$source = file_get_contents($feed_url);
$feed = new SimpleXmlElement($source);
if(!empty($feed->channel->item)) {
foreach($feed->channel->item as $entry) {
$descriptionA = $entry->children('content', true);
$descriptionB = $entry->description;
if(!empty($descriptionA)) {
$content = $descriptionA;
}
else if (!empty($descriptionB)) {
$content = preg_replace('#<br\s*/?>#i', "\n", $descriptionB);
}
else {
return $str = '<li>Can not read the feed content.</li>';
}
$time = new DateTime($entry->pubDate);
$timestamp= $time->format("Y-m-d H:i:s");
$time = strtotime($timestamp);
$tags = strip_tags(preg_replace('/[^A-Za-z0-9,.-]/u', '', $entry->category));
$title = rtrim($entry->title, ' \,\.\-');
$title = ltrim($title, ' \,\.\-');
$user = $_SESSION['user'];
$url = preg_replace('/[^A-Za-z0-9 .-]/u', '', strtolower($title));
$url = str_replace(' ', '-',$url);
$url = str_replace('--', '-',$url);
$url = rtrim($url, ',\.\-');
$url = ltrim($url, ',\.\-');
if ($credit == 'yes') {
$source = $entry->link;
}
else {
$source= null;
}
migrate($title, $time, $tags, $content, $url, $user, $source);
}
}
else {
return $str= '<li>Unsupported feed.</li>';
}
}
function get_recent_posts() { function get_recent_posts() {
if (isset($_SESSION['user'])) { if (isset($_SESSION['user'])) {
$posts = get_profile($_SESSION['user'], 1, 5); $posts = get_profile($_SESSION['user'], 1, 5);

View file

@ -2,12 +2,17 @@
<script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/Markdown.Converter.js"></script> <script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/Markdown.Converter.js"></script>
<script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/Markdown.Sanitizer.js"></script> <script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/Markdown.Sanitizer.js"></script>
<script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/Markdown.Editor.js"></script> <script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/Markdown.Editor.js"></script>
<?php if (isset($error)) { ?>
<div class="error-message"><?php echo $error ?></div>
<?php } ?>
<div class="wmd-panel"> <div class="wmd-panel">
<form method="POST"> <form method="POST">
Title: <br><input type="text" class="text" name="title"/><br><br> Title <span class="required">*</span><br><input type="text" class="text <?php if (isset($postTitle)) { if (empty($postTitle)) { echo 'error';}} ?>" name="title" value="<?php if (isset($postTitle)) { echo $postTitle;} ?>"/><br><br>
Url: <br><input type="text" class="text" name="url"/><br><br> Url (optional)<br><input type="text" class="text" name="url" value="<?php if (isset($postUrl)) { echo $postUrl;} ?>"/><br>
<span class="help">If the url leave empty we will use the page title.</span>
<br><br>
<div id="wmd-button-bar" class="wmd-button-bar"></div> <div id="wmd-button-bar" class="wmd-button-bar"></div>
<textarea id="wmd-input" class="wmd-input" name="content" cols="20" rows="10"></textarea><br/> <textarea id="wmd-input" class="wmd-input <?php if (isset($postContent)) { if (empty($postContent)) { echo 'error';}} ?>" name="content" cols="20" rows="10"><?php if (isset($postContent)) { echo $postContent;} ?></textarea><br/>
<input type="submit" name="submit" class="submit" value="Publish"/> <input type="submit" name="submit" class="submit" value="Publish"/>
</form> </form>
</div> </div>

View file

@ -2,13 +2,18 @@
<script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/Markdown.Converter.js"></script> <script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/Markdown.Converter.js"></script>
<script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/Markdown.Sanitizer.js"></script> <script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/Markdown.Sanitizer.js"></script>
<script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/Markdown.Editor.js"></script> <script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/Markdown.Editor.js"></script>
<?php if (isset($error)) { ?>
<div class="error-message"><?php echo $error ?></div>
<?php } ?>
<div class="wmd-panel"> <div class="wmd-panel">
<form method="POST"> <form method="POST">
Title: <br><input type="text" class="text" name="title"/><br><br> Title <span class="required">*</span> <br><input type="text" class="text <?php if (isset($postTitle)) { if (empty($postTitle)) { echo 'error';}} ?>" name="title" value="<?php if (isset($postTitle)) { echo $postTitle;} ?>"/><br><br>
Tag: <br><input type="text" class="text" name="tag"/><br><br> Tag <span class="required">*</span> <br><input type="text" class="text <?php if (isset($postTag)) { if (empty($postTag)) { echo 'error';}} ?>" name="tag" value="<?php if (isset($postTag)) { echo $postTag;} ?>"/><br><br>
Url: <br><input type="text" class="text" name="url"/><br><br> Url (optional)<br><input type="text" class="text" name="url" value="<?php if (isset($postUrl)) { echo $postUrl;} ?>"/><br>
<span class="help">If the url leave empty we will use the post title.</span>
<br><br>
<div id="wmd-button-bar" class="wmd-button-bar"></div> <div id="wmd-button-bar" class="wmd-button-bar"></div>
<textarea id="wmd-input" class="wmd-input" name="content" cols="20" rows="10"></textarea><br/> <textarea id="wmd-input" class="wmd-input <?php if (isset($postContent)) { if (empty($postContent)) { echo 'error';}} ?>" name="content" cols="20" rows="10"><?php if (isset($postContent)) { echo $postContent;} ?></textarea><br/>
<input type="submit" name="submit" class="submit" value="Publish"/> <input type="submit" name="submit" class="submit" value="Publish"/>
</form> </form>
</div> </div>

View file

@ -1,6 +1,24 @@
<?php
$destination = $_GET['destination'];
$url = $p->file;
$dir = substr($url, 0, strrpos($url, '/'));
$oldurl = str_replace($dir . '/','',$url);
$oldmd = str_replace('.md','',$oldurl);
$post = site_url() . $oldmd;
if($destination == 'post') {
$back = $post;
}
else {
$back = site_url() . $destination;
}
?>
<?php echo '<p>Are you sure want to delete <strong>' . $p->title . '</strong>?</p>';?> <?php echo '<p>Are you sure want to delete <strong>' . $p->title . '</strong>?</p>';?>
<form method="POST"> <form method="POST">
<input type="hidden" name="file" value="<?php echo $p->file ?>"/><br> <input type="hidden" name="file" value="<?php echo $p->file ?>"/><br>
<input type="submit" name="submit" value="Delete"/> <input type="submit" name="submit" value="Delete"/>
<span><a href="<?php echo site_url() . 'admin' ?>">Cancel</a></span> <span><a href="<?php echo $back ?>">Cancel</a></span>
</form> </form>

View file

@ -1,6 +1,31 @@
<?php
$destination = $_GET['destination'];
$url = $p->file;
$oldurl = explode('_', $url);
$oldtag = $oldurl[1];
$oldmd = str_replace('.md','',$oldurl[2]);
$replaced = substr($oldurl[0], 0,strrpos($oldurl[0], '/')) . '/';
$dt = str_replace($replaced,'',$oldurl[0]);
$t = str_replace('-','',$dt);
$time = new DateTime($t);
$timestamp= $time->format("Y-m-d");
// The post date
$postdate = strtotime($timestamp);
// The post URL
$post = site_url().date('Y/m', $postdate).'/'.$oldmd;
if($destination == 'post') {
$back = $post;
}
else {
$back = site_url() . $destination;
}
?>
<?php echo '<p>Are you sure want to delete <strong>' . $p->title . '</strong>?</p>';?> <?php echo '<p>Are you sure want to delete <strong>' . $p->title . '</strong>?</p>';?>
<form method="POST"> <form method="POST">
<input type="hidden" name="file" value="<?php echo $p->file ?>"/><br> <input type="hidden" name="file" value="<?php echo $p->file ?>"/><br>
<input type="submit" name="submit" value="Delete"/> <input type="submit" name="submit" value="Delete"/>
<span><a href="<?php echo site_url() . 'admin/posts' ?>">Cancel</a></span> <span><a href="<?php echo $back ?>">Cancel</a></span>
</form> </form>

View file

@ -1,6 +1,11 @@
<?php <?php
$url = $p->file; if(isset($p->file)) {
$url = $p->file;
}
else {
$url = $oldfile;
}
$content = file_get_contents($url); $content = file_get_contents($url);
$arr = explode('t-->', $content); $arr = explode('t-->', $content);
if(isset($arr[1])) { if(isset($arr[1])) {
@ -12,23 +17,30 @@
$oldcontent = ltrim($arr[0]); $oldcontent = ltrim($arr[0]);
} }
$destination = $_GET['destination'];
$dir = substr($url, 0, strrpos($url, '/')); $dir = substr($url, 0, strrpos($url, '/'));
$oldurl = str_replace($dir . '/','',$url); $oldurl = str_replace($dir . '/','',$url);
$oldmd = str_replace('.md','',$oldurl); $oldmd = str_replace('.md','',$oldurl);
$delete = site_url() . $oldmd . '/delete?destination=' . $destination;
?> ?>
<link rel="stylesheet" type="text/css" href="<?php echo site_url() ?>system/admin/editor/css/editor.css" /> <link rel="stylesheet" type="text/css" href="<?php echo site_url() ?>system/admin/editor/css/editor.css" />
<script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/Markdown.Converter.js"></script> <script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/Markdown.Converter.js"></script>
<script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/Markdown.Sanitizer.js"></script> <script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/Markdown.Sanitizer.js"></script>
<script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/Markdown.Editor.js"></script> <script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/Markdown.Editor.js"></script>
<?php if (isset($error)) { ?>
<div class="error-message"><?php echo $error ?></div>
<?php } ?>
<div class="wmd-panel"> <div class="wmd-panel">
<form method="POST"> <form method="POST">
Title: <br><input type="text" name="title" class="text" value="<?php echo $oldtitle?>"/><br><br> Title <span class="required">*</span><br><input type="text" name="title" class="text <?php if (isset($postTitle)) { if (empty($postTitle)) { echo 'error';}} ?>" value="<?php echo $oldtitle?>"/><br><br>
Url: <br><input type="text" name="url" class="text" value="<?php echo $oldmd ?>"/><br><br> Url (optional)<br><input type="text" name="url" class="text" value="<?php echo $oldmd ?>"/><br>
<span class="help">If the url leave empty we will use the page title.</span><br><br>
<div id="wmd-button-bar" class="wmd-button-bar"></div> <div id="wmd-button-bar" class="wmd-button-bar"></div>
<textarea id="wmd-input" class="wmd-input" name="content" cols="20" rows="10"><?php echo $oldcontent ?></textarea><br> <textarea id="wmd-input" class="wmd-input <?php if (isset($postContent)) { if (empty($postContent)) { echo 'error';}} ?>" name="content" cols="20" rows="10"><?php echo $oldcontent ?></textarea><br>
<input type="hidden" name="oldfile" class="text" value="<?php echo $url ?>"/> <input type="hidden" name="oldfile" class="text" value="<?php echo $url ?>"/>
<input type="submit" name="submit" class="submit" value="Submit"/> <input type="submit" name="submit" class="submit" value="Save"/> <a href="<?php echo $delete?>">Delete</a>
</form> </form>
</div> </div>
<div id="wmd-preview" class="wmd-panel wmd-preview"></div> <div id="wmd-preview" class="wmd-panel wmd-preview"></div>

View file

@ -1,5 +1,11 @@
<?php <?php
$url = $p->file; if(isset($p->file)) {
$url = $p->file;
}
else {
$url = $oldfile;
}
$content = file_get_contents($url); $content = file_get_contents($url);
$arr = explode('t-->', $content); $arr = explode('t-->', $content);
if(isset($arr[1])) { if(isset($arr[1])) {
@ -19,20 +25,37 @@
$oldmd = str_replace('.md','',$oldurl[2]); $oldmd = str_replace('.md','',$oldurl[2]);
$destination = $_GET['destination'];
$replaced = substr($oldurl[0], 0,strrpos($oldurl[0], '/')) . '/';
$dt = str_replace($replaced,'',$oldurl[0]);
$t = str_replace('-','',$dt);
$time = new DateTime($t);
$timestamp= $time->format("Y-m-d");
// The post date
$postdate = strtotime($timestamp);
// The post URL
$delete= site_url().date('Y/m', $postdate).'/'.$oldmd . '/delete?destination=' . $destination;
?> ?>
<link rel="stylesheet" type="text/css" href="<?php echo site_url() ?>system/admin/editor/css/editor.css" /> <link rel="stylesheet" type="text/css" href="<?php echo site_url() ?>system/admin/editor/css/editor.css" />
<script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/Markdown.Converter.js"></script> <script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/Markdown.Converter.js"></script>
<script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/Markdown.Sanitizer.js"></script> <script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/Markdown.Sanitizer.js"></script>
<script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/Markdown.Editor.js"></script> <script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/Markdown.Editor.js"></script>
<?php if (isset($error)) { ?>
<div class="error-message"><?php echo $error ?></div>
<?php } ?>
<div class="wmd-panel"> <div class="wmd-panel">
<form method="POST"> <form method="POST">
Title: <br><input type="text" name="title" class="text" value="<?php echo $oldtitle?>"/><br><br> Title <span class="required">*</span> <br><input type="text" name="title" class="text <?php if (isset($postTitle)) { if (empty($postTitle)) { echo 'error';}} ?>" value="<?php echo $oldtitle?>"/><br><br>
Tag: <br><input type="text" name="tag" class="text" value="<?php echo $oldtag?>"/><br><br> Tag <span class="required">*</span> <br><input type="text" name="tag" class="text <?php if (isset($postTag)) { if (empty($postTag)) { echo 'error';}} ?>" value="<?php echo $oldtag?>"/><br><br>
Url: <br><input type="text" name="url" class="text" value="<?php echo $oldmd ?>"/><br><br> Url (optional)<br><input type="text" name="url" class="text" value="<?php echo $oldmd ?>"/><br>
<span class="help">If the url leave empty we will use the post title.</span>
<br><br>
<div id="wmd-button-bar" class="wmd-button-bar"></div> <div id="wmd-button-bar" class="wmd-button-bar"></div>
<textarea id="wmd-input" class="wmd-input" name="content" cols="20" rows="10"><?php echo $oldcontent ?></textarea><br> <textarea id="wmd-input" class="wmd-input <?php if (isset($postContent)) { if (empty($postContent)) { echo 'error';}} ?>" name="content" cols="20" rows="10"><?php echo $oldcontent ?></textarea><br>
<input type="hidden" name="oldfile" class="text" value="<?php echo $url ?>"/> <input type="hidden" name="oldfile" class="text" value="<?php echo $url ?>"/>
<input type="submit" name="submit" class="submit" value="Submit"/> <input type="submit" name="submit" class="submit" value="Save"/> <a href="<?php echo $delete?>">Delete</a>
</form> </form>
</div> </div>
<div id="wmd-preview" class="wmd-panel wmd-preview"></div> <div id="wmd-preview" class="wmd-panel wmd-preview"></div>

View file

@ -29,12 +29,15 @@
<script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/Markdown.Converter.js"></script> <script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/Markdown.Converter.js"></script>
<script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/Markdown.Sanitizer.js"></script> <script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/Markdown.Sanitizer.js"></script>
<script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/Markdown.Editor.js"></script> <script type="text/javascript" src="<?php echo site_url() ?>system/admin/editor/js/Markdown.Editor.js"></script>
<?php if (isset($error)) { ?>
<div class="error-message"><?php echo $error ?></div>
<?php } ?>
<div class="wmd-panel"> <div class="wmd-panel">
<form method="POST"> <form method="POST">
Title: <br><input type="text" name="title" class="text" value="<?php echo $oldtitle?>"/><br><br> Title <span class="required">*</span> <br><input type="text" name="title" class="text <?php if (isset($postTitle)) { if (empty($postTitle)) { echo 'error';}} ?>" value="<?php echo $oldtitle?>"/><br><br>
<div id="wmd-button-bar" class="wmd-button-bar"></div> <div id="wmd-button-bar" class="wmd-button-bar"></div>
<textarea id="wmd-input" class="wmd-input" name="content" cols="20" rows="10"><?php echo $oldcontent ?></textarea><br> <textarea id="wmd-input" class="wmd-input <?php if (isset($postContent)) { if (empty($postContent)) { echo 'error';}} ?>" name="content" cols="20" rows="10"><?php echo $oldcontent ?></textarea><br>
<input type="submit" name="submit" class="submit" value="Submit"/> <input type="submit" name="submit" class="submit" value="Save"/>
</form> </form>
</div> </div>
<div id="wmd-preview" class="wmd-panel wmd-preview"></div> <div id="wmd-preview" class="wmd-panel wmd-preview"></div>

View file

@ -0,0 +1,10 @@
<?php if (isset($error)) { ?>
<div class="error-message"><?php echo $error?></div>
<?php } ?>
<h1>Import RSS Feed 2.0</h1>
<p>By using this importer you are agree if the feed is yours.</p>
<form method="POST">
Feed Url <span class="required">*</span> <br><input type="url" class="text <?php if (isset($url)) { if (empty($url)) { echo 'error';}} ?>" name="url"/><br><br>
Add source link (optional) <input type="checkbox" class="checkbox" name="credit" value="yes"/><br><br>
<input type="submit" name="submit" class="submit" value="Import"/>
</form>

View file

@ -33,6 +33,7 @@
<li><a href="<?php echo site_url() ?>add/post">Add post</a></li> <li><a href="<?php echo site_url() ?>add/post">Add post</a></li>
<li><a href="<?php echo site_url() ?>add/page">Add page</a></li> <li><a href="<?php echo site_url() ?>add/page">Add page</a></li>
<li><a href="<?php echo site_url() ?>edit/profile">Edit profile</a></li> <li><a href="<?php echo site_url() ?>edit/profile">Edit profile</a></li>
<li><a href="<?php echo site_url() ?>admin/import">Import</a></li>
<li><a href="<?php echo site_url() ?>logout">Logout</a></li> <li><a href="<?php echo site_url() ?>logout">Logout</a></li>
</ul> </ul>
</div> </div>

View file

@ -1,11 +1,13 @@
<?php if (isset($error)) { ?>
<div class="error-message"><?php echo $error?></div>
<?php } ?>
<?php if(!login()) {?> <?php if(!login()) {?>
<?php login_message(null);?>
<h1>Login</h1> <h1>Login</h1>
<form method="POST" action="login"> <form method="POST" action="login">
User:<br> User <span class="required">*</span> <br>
<input type="text" name="user"/><br><br> <input type="text" class="<?php if (isset($username)) { if (empty($username)) { echo 'error';}} ?>" name="user"/><br><br>
Pass:<br> Password <span class="required">*</span> <br>
<input type="password" name="password"/><br><br> <input type="password" class="<?php if (isset($password)) { if (empty($password)) { echo 'error';}} ?>" name="password"/><br><br>
<input type="submit" name="submit" value="Login"/> <input type="submit" name="submit" value="Login"/>
</form> </form>
<?php } else {header('location: admin');} ?> <?php } else {header('location: admin');} ?>

View file

@ -50,10 +50,50 @@ get('/index', function () {
// Get submitted login data // Get submitted login data
post('/login', function() { post('/login', function() {
$user = from($_REQUEST, 'user'); $user = from($_REQUEST, 'user');
$pass = from($_REQUEST, 'password'); $pass = from($_REQUEST, 'password');
session($user, $pass); if(!empty($user) && !empty($pass)) {
session($user, $pass, null);
$log = session($user, $pass, null);
if(!empty($log)) {
config('views.root', 'system/admin/views');
render('login',array(
'error' => '<ul>' . $log . '</ul>',
'title' => 'Login - ' . config('blog.title'),
'canonical' => config('site.url'),
'description' => 'Login page on ' .config('blog.title'),
'bodyclass' => 'editprofile',
'breadcrumb' => '<a href="' . config('site.url') . '">' .config('breadcrumb.home'). '</a> &#187; Login'
));
}
}
else {
$message['error'] = '';
if(empty($user)) {
$message['error'] .= '<li>User field is required.</li>';
}
if (empty($pass)) {
$message['error'] .= '<li>Password field is required.</li>';
}
config('views.root', 'system/admin/views');
render('login',array(
'error' => '<ul>' . $message['error'] . '</ul>',
'title' => 'Login - ' . config('blog.title'),
'username' => $user,
'password' => $pass,
'canonical' => config('site.url'),
'description' => 'Login page on ' .config('blog.title'),
'bodyclass' => 'editprofile',
'breadcrumb' => '<a href="' . config('site.url') . '">' .config('breadcrumb.home'). '</a> &#187; Login'
));
}
}); });
@ -136,15 +176,49 @@ get('/:year/:month/:name/edit', function($year, $month, $name){
// Get edited data for blog post // Get edited data for blog post
post('/:year/:month/:name/edit', function() { post('/:year/:month/:name/edit', function() {
$title = from($_REQUEST, 'title'); $title = from($_REQUEST, 'title');
$tag = from($_REQUEST, 'tag'); $tag = from($_REQUEST, 'tag');
$url = from($_REQUEST, 'url'); $url = from($_REQUEST, 'url');
$content = from($_REQUEST, 'content'); $content = from($_REQUEST, 'content');
$oldfile = from($_REQUEST, 'oldfile'); $oldfile = from($_REQUEST, 'oldfile');
$destination = from($_GET, 'destination'); $destination = from($_GET, 'destination');
if(!empty($title) && !empty($tag) && !empty($content)) {
edit_post($title, $tag, $url, $content, $oldfile, $destination); if(!empty($url)) {
edit_post($title, $tag, $url, $content, $oldfile, $destination);
}
else {
$url = $title;
edit_post($title, $tag, $url, $content, $oldfile, $destination);
}
}
else {
$message['error'] = '';
if(empty($title)) {
$message['error'] .= '<li>Title field is required.</li>';
}
if (empty($tag)) {
$message['error'] .= '<li>Tag field is required.</li>';
}
if (empty($content)) {
$message['error'] .= '<li>Content field is required.</li>';
}
config('views.root', 'system/admin/views');
render('edit-post',array(
'error' => '<ul>' . $message['error'] . '</ul>',
'title' => 'Edit post - ' . config('blog.title'),
'oldfile' => $oldfile,
'postTitle' => $title,
'postTag' => $tag,
'postUrl' => $url,
'postContent' => $content,
'canonical' => config('site.url'),
'description' => 'Adit post on ' .config('blog.title'),
'bodyclass' => 'editpost',
'breadcrumb' => '<a href="' . config('site.url') . '">' .config('breadcrumb.home'). '</a> &#187; Edit post'
));
}
}); });
@ -262,7 +336,30 @@ post('/edit/profile', function() {
$user = $_SESSION['user']; $user = $_SESSION['user'];
$title = from($_REQUEST, 'title'); $title = from($_REQUEST, 'title');
$content = from($_REQUEST, 'content'); $content = from($_REQUEST, 'content');
edit_profile($title, $content, $user); if(!empty($title) && !empty($content)) {
edit_profile($title, $content, $user);
}
else {
$message['error'] = '';
if(empty($title)) {
$message['error'] .= '<li>Title field is required.</li>';
}
if (empty($content)) {
$message['error'] .= '<li>Content field is required.</li>';
}
config('views.root', 'system/admin/views');
render('edit-profile',array(
'error' => '<ul>' . $message['error'] . '</ul>',
'title' => 'Edit profile - ' . config('blog.title'),
'postTitle' => $title,
'postContent' => $content,
'canonical' => config('site.url'),
'description' => 'Edit profile on ' .config('blog.title'),
'bodyclass' => 'editprofile',
'breadcrumb' => '<a href="' . config('site.url') . '">' .config('breadcrumb.home'). '</a> &#187; Edit profile'
));
}
}); });
@ -404,24 +501,25 @@ get('/:static', function($static){
} }
die; die;
} }
else {
$post = get_static_post($static); $post = get_static_post($static);
if(!$post){ if(!$post){
not_found(); not_found();
} }
$post = $post[0]; $post = $post[0];
render('post',array( render('post',array(
'title' => $post->title .' - ' . config('blog.title'), 'title' => $post->title .' - ' . config('blog.title'),
'canonical' => $post->url, 'canonical' => $post->url,
'description' => $description = get_description($post->body), 'description' => $description = get_description($post->body),
'bodyclass' => 'inpage', 'bodyclass' => 'inpage',
'breadcrumb' => '<a href="' . config('site.url') . '">' .config('breadcrumb.home'). '</a> &#187; ' . $post->title, 'breadcrumb' => '<a href="' . config('site.url') . '">' .config('breadcrumb.home'). '</a> &#187; ' . $post->title,
'p' => $post, 'p' => $post,
'type' => 'staticpage', 'type' => 'staticpage',
)); ));
}
}); });
@ -463,8 +561,38 @@ post('/:static/edit', function() {
$content = from($_REQUEST, 'content'); $content = from($_REQUEST, 'content');
$oldfile = from($_REQUEST, 'oldfile'); $oldfile = from($_REQUEST, 'oldfile');
$destination = from($_GET, 'destination'); $destination = from($_GET, 'destination');
if(!empty($title) && !empty($content)) {
edit_page($title, $url, $content, $oldfile, $destination); if(!empty($url)) {
edit_page($title, $url, $content, $oldfile, $destination);
}
else {
$url = $title;
edit_page($title, $url, $content, $oldfile, $destination);
}
}
else {
$message['error'] = '';
if(empty($title)) {
$message['error'] .= '<li>Title field is required.</li>';
}
if (empty($content)) {
$message['error'] .= '<li>Content field is required.</li>';
}
config('views.root', 'system/admin/views');
render('edit-page',array(
'error' => '<ul>' . $message['error'] . '</ul>',
'title' => 'Edit page - ' . config('blog.title'),
'oldfile' => $oldfile,
'postTitle' => $title,
'postUrl' => $url,
'postContent' => $content,
'canonical' => config('site.url'),
'description' => 'Edit page on ' .config('blog.title'),
'bodyclass' => 'editpage',
'breadcrumb' => '<a href="' . config('site.url') . '">' .config('breadcrumb.home'). '</a> &#187; Edit page'
));
}
}); });
@ -536,7 +664,40 @@ post('/add/post', function(){
$url = from($_REQUEST, 'url'); $url = from($_REQUEST, 'url');
$content = from($_REQUEST, 'content'); $content = from($_REQUEST, 'content');
$user = $_SESSION['user']; $user = $_SESSION['user'];
add_post($title, $tag, $url, $content, $user); if(!empty($title) && !empty($tag) && !empty($content)) {
if(!empty($url)) {
add_post($title, $tag, $url, $content, $user);
}
else {
$url = $title;
add_post($title, $tag, $url, $content, $user);
}
}
else {
$message['error'] = '';
if(empty($title)) {
$message['error'] .= '<li>Title field is required.</li>';
}
if (empty($tag)) {
$message['error'] .= '<li>Tag field is required.</li>';
}
if (empty($content)) {
$message['error'] .= '<li>Content field is required.</li>';
}
config('views.root', 'system/admin/views');
render('add-post',array(
'error' => '<ul>' . $message['error'] . '</ul>',
'title' => 'Add post - ' . config('blog.title'),
'postTitle' => $title,
'postTag' => $tag,
'postUrl' => $url,
'postContent' => $content,
'canonical' => config('site.url') . '/add/post',
'description' => 'Add post on ' .config('blog.title'),
'bodyclass' => 'addpost',
'breadcrumb' => '<a href="' . config('site.url') . '">' .config('breadcrumb.home'). '</a> &#187; Add post'
));
}
}); });
@ -567,7 +728,100 @@ post('/add/page', function(){
$title = from($_REQUEST, 'title'); $title = from($_REQUEST, 'title');
$url = from($_REQUEST, 'url'); $url = from($_REQUEST, 'url');
$content = from($_REQUEST, 'content'); $content = from($_REQUEST, 'content');
add_page($title, $url, $content); if(!empty($title) && !empty($content)) {
if(!empty($url)) {
add_page($title, $url, $content);
}
else {
$url = $title;
add_page($title, $url, $content);
}
}
else {
$message['error'] = '';
if(empty($title)) {
$message['error'] .= '<li>Title field is required.</li>';
}
if (empty($content)) {
$message['error'] .= '<li>Content field is required.</li>';
}
config('views.root', 'system/admin/views');
render('add-page',array(
'error' => '<ul>' . $message['error'] . '</ul>',
'title' => 'Add page - ' . config('blog.title'),
'postTitle' => $title,
'postUrl' => $url,
'postContent' => $content,
'canonical' => config('site.url') . '/add/page',
'description' => 'Add page on ' .config('blog.title'),
'bodyclass' => 'addpage',
'breadcrumb' => '<a href="' . config('site.url') . '">' .config('breadcrumb.home'). '</a> &#187; Add page'
));
}
});
// Import page
get('/admin/import',function(){
if(login()) {
config('views.root', 'system/admin/views');
render('import', array(
'title' => 'Import feed - ' . config('blog.title'),
'canonical' => config('site.url') . '/import',
'description' => 'Import feed to ' . config('blog.title') . '.',
'bodyclass' => 'importfeed',
'breadcrumb' => '<a href="' . config('site.url') . '">' .config('breadcrumb.home'). '</a> &#187; Import feed'
));
}
else {
$login = site_url() . 'login';
header("location: $login");
}
die;
});
// Get import post
post('/admin/import', function() {
$url = from($_REQUEST, 'url');
$credit = from($_REQUEST, 'credit');
if(!empty($url)) {
get_feed($url, $credit, null);
$log = get_feed($url, $credit, null);
if(!empty($log)) {
config('views.root', 'system/admin/views');
render('import',array(
'error' => '<ul>' . $log . '</ul>',
'title' => 'Import feed - ' . config('blog.title'),
'canonical' => config('site.url'),
'description' => 'Import feed on ' .config('blog.title'),
'bodyclass' => 'editprofile',
'breadcrumb' => '<a href="' . config('site.url') . '">' .config('breadcrumb.home'). '</a> &#187; Import feed'
));
}
}
else {
$message['error'] = '';
if(empty($url)) {
$message['error'] .= '<li>You need to specify the feed url.</li>';
}
config('views.root', 'system/admin/views');
render('import',array(
'error' => '<ul>' . $message['error'] . '</ul>',
'title' => 'Login - ' . config('blog.title'),
'url' => $url,
'canonical' => config('site.url'),
'description' => 'Login page on ' .config('blog.title'),
'bodyclass' => 'editprofile',
'breadcrumb' => '<a href="' . config('site.url') . '">' .config('breadcrumb.home'). '</a> &#187; Login'
));
}
}); });
@ -578,7 +832,7 @@ get('/tag/:tag',function($tag){
$page = $page ? (int)$page : 1; $page = $page ? (int)$page : 1;
$perpage = config('tag.perpage'); $perpage = config('tag.perpage');
$posts = get_tag($tag, $page, $perpage); $posts = get_tag($tag, $page, $perpage, false);
$total = get_count($tag, 'filename'); $total = get_count($tag, 'filename');

View file

@ -124,14 +124,15 @@ function get_posts($posts, $page = 1, $perpage = 0){
$post->authorurl = site_url() . 'author/' . $author; $post->authorurl = site_url() . 'author/' . $author;
$dt = str_replace($replaced,'',$arr[0]); $dt = str_replace($replaced,'',$arr[0]);
$time = new DateTime($dt); $t = str_replace('-', '', $dt);
$timestamp= $time->format("Y-m-d"); $time = new DateTime($t);
$timestamp= $time->format("Y-m-d H:i:s");
// The post date // The post date
$post->date = strtotime($timestamp); $post->date = strtotime($timestamp);
// The archive per day // The archive per day
$post->archive = site_url(). 'archive/' . $timestamp ; $post->archive = site_url(). 'archive/' . date('Y-m-d', $post->date) ;
// The post URL // The post URL
$post->url = site_url().date('Y/m', $post->date).'/'.str_replace('.md','',$arr[2]); $post->url = site_url().date('Y/m', $post->date).'/'.str_replace('.md','',$arr[2]);
@ -162,11 +163,13 @@ function get_posts($posts, $page = 1, $perpage = 0){
// Extract the title and body // Extract the title and body
$arr = explode('t-->', $content); $arr = explode('t-->', $content);
if(isset($arr[1])) { if(isset($arr[1])) {
$post->title = str_replace('<!--t','',$arr[0]); $title = str_replace('<!--t','',$arr[0]);
$title = rtrim(ltrim($title, ' '), ' ');
$post->title = $title;
$post->body = $arr[1]; $post->body = $arr[1];
} }
else { else {
$post->title = ' Untitled: ' . date('l jS \of F Y', $post->date); $post->title = 'Untitled: ' . date('l jS \of F Y', $post->date);
$post->body = $arr[0]; $post->body = $arr[0];
} }
@ -225,10 +228,14 @@ function find_post($year, $month, $name){
} }
// Return tag page. // Return tag page.
function get_tag($tag, $page, $perpage){ function get_tag($tag, $page, $perpage, $random){
$posts = get_post_sorted(); $posts = get_post_sorted();
if($random === true) {
shuffle($posts);
}
$tmp = array(); $tmp = array();
foreach ($posts as $index => $v) { foreach ($posts as $index => $v) {
@ -329,8 +336,10 @@ function get_bio($author){
// Extract the title and body // Extract the title and body
$arr = explode('t-->', $content); $arr = explode('t-->', $content);
if(isset($arr[1])) { if(isset($arr[1])) {
$post->title = str_replace('<!--t','',$arr[0]); $title = str_replace('<!--t','',$arr[0]);
$title = rtrim(ltrim($title, ' '), ' ');
$post->title = $title;
$post->body = $arr[1]; $post->body = $arr[1];
} }
else { else {
@ -387,7 +396,9 @@ function get_static_post($static){
// Extract the title and body // Extract the title and body
$arr = explode('t-->', $content); $arr = explode('t-->', $content);
if(isset($arr[1])) { if(isset($arr[1])) {
$post->title = str_replace('<!--t','',$arr[0]); $title = str_replace('<!--t','',$arr[0]);
$title = rtrim(ltrim($title, ' '), ' ');
$post->title = $title;
$post->body = $arr[1]; $post->body = $arr[1];
} }
else { else {
@ -441,8 +452,9 @@ function get_keyword($keyword){
$post->authorurl = site_url() . 'author/' . $author; $post->authorurl = site_url() . 'author/' . $author;
$dt = str_replace($replaced,'',$arr[0]); $dt = str_replace($replaced,'',$arr[0]);
$time = new DateTime($dt); $t = str_replace('-', '', $dt);
$timestamp= $time->format("Y-m-d"); $time = new DateTime($t);
$timestamp= $time->format("Y-m-d H:i:s");
// The post date // The post date
$post->date = strtotime($timestamp); $post->date = strtotime($timestamp);
@ -471,11 +483,13 @@ function get_keyword($keyword){
// Extract the title and body // Extract the title and body
$arr = explode('t-->', $content); $arr = explode('t-->', $content);
if(isset($arr[1])) { if(isset($arr[1])) {
$post->title = str_replace('<!--t','',$arr[0]); $title = str_replace('<!--t','',$arr[0]);
$title = rtrim(ltrim($title, ' '), ' ');
$post->title = $title;
$post->body = $arr[1]; $post->body = $arr[1];
} }
else { else {
$post->title = ' Untitled: ' . date('l jS \of F Y', $post->date); $post->title = 'Untitled: ' . date('l jS \of F Y', $post->date);
$post->body = $arr[0]; $post->body = $arr[0];
} }
@ -497,7 +511,7 @@ function get_keyword($keyword){
// Get related posts base on post tag. // Get related posts base on post tag.
function get_related($tag) { function get_related($tag) {
$perpage = config('related.count'); $perpage = config('related.count');
$posts = get_tag(strip_tags($tag), 1, $perpage+1); $posts = get_tag(strip_tags($tag), 1, $perpage+1, true);
$tmp = array(); $tmp = array();
$req = $_SERVER['REQUEST_URI']; $req = $_SERVER['REQUEST_URI'];
@ -511,8 +525,6 @@ function get_related($tag) {
$total = count($tmp); $total = count($tmp);
if($total >= 1) { if($total >= 1) {
shuffle($tmp);
$i = 1; $i = 1;
echo '<div class="related"><h4>Related posts</h4><ul>'; echo '<div class="related"><h4>Related posts</h4><ul>';
@ -575,11 +587,32 @@ function archive_list() {
# Most recent year first # Most recent year first
krsort($by_year); krsort($by_year);
# Iterate for display # Iterate for display
$script = <<<EOF
if (this.parentNode.className.indexOf('expanded') > -1){this.parentNode.className = 'collapsed';this.innerHTML = '&#9658;';} else {this.parentNode.className = 'expanded';this.innerHTML = '&#9660;';}
EOF;
echo <<<EOF
<style>.toggle{font-size:16px;font-family:Georgia, Arial, sans-serif}ul.archivegroup{padding:0;margin:0;}.archivegroup .expanded ul{display:block;}.archivegroup .collapsed ul{display:none;}.archivegroup li.expanded,.archivegroup li.collapsed{list-style:none;}
</style>
EOF;
echo '<h3>Archive</h3>'; echo '<h3>Archive</h3>';
$i = 0;
$len = count($by_year);
foreach ($by_year as $year => $months){ foreach ($by_year as $year => $months){
if ($i == 0) {
echo '<span class="year"><a href="' . site_url() . 'archive/' . $year . '">' . $year . '</a></span> '; $class = 'expanded';
echo '(' . count($months) . ')'; $arrow = '&#9660;';
}
else {
$class = 'collapsed';
$arrow = '&#9658;';
}
$i++;
echo '<ul class="archivegroup">';
echo '<li class="' . $class . '">';
echo '<a href="javascript:void(0)" class="toggle" onclick="' . $script . '">' . $arrow . '</a> ';
echo '<a href="' . site_url() . 'archive/' . $year . '">' . $year . '</a> ';
echo '<span class="count">(' . count($months) . ')</span>';
echo '<ul class="month">'; echo '<ul class="month">';
$by_month = array_count_values($months); $by_month = array_count_values($months);
@ -592,9 +625,11 @@ function archive_list() {
} }
echo '</ul>'; echo '</ul>';
echo '</li>';
echo '</ul>';
} }
} }
// Return tag cloud. // Return tag cloud.
@ -673,7 +708,7 @@ function get_description($text) {
} }
else { else {
$string = preg_replace('/[^A-Za-z0-9 !@#$%^&*(),.-]/u', ' ', strip_tags($text)); $string = preg_replace('/[^A-Za-z0-9 !@#$%^&*(),.-]/u', ' ', strip_tags($text));
$string = ltrim($string); $string = rtrim(ltrim($string), $string);
if (strlen($string) < config('description.char')) { if (strlen($string) < config('description.char')) {
return $string; return $string;
} }
@ -878,11 +913,22 @@ function get_menu() {
// Replaced string // Replaced string
$replaced = substr($v, 0, strrpos($v, '/')) . '/'; $replaced = substr($v, 0, strrpos($v, '/')) . '/';
$base = str_replace($replaced,'',$v);
// The static page URL $url = site_url() . str_replace('.md','',$base);
$title = str_replace($replaced,'',$v);
$url = site_url() . str_replace('.md','',$title); // Get the contents and convert it to HTML
echo '<li><a href="' . $url . '">' . ucfirst(str_replace('.md','',$title)) . '</a></li>'; $content = MarkdownExtra::defaultTransform(file_get_contents($v));
// Extract the title and body
$arr = explode('t-->', $content);
if(isset($arr[1])) {
$title = str_replace('<!--t','',$arr[0]);
$title = rtrim(ltrim($title, ' '), ' ');
}
else {
$title = str_replace('-',' ', str_replace('.md','',$base));
}
echo '<li><a href="' . $url . '">' . ucwords($title) . '</a></li>';
} }
echo '</ul>'; echo '</ul>';
@ -924,12 +970,16 @@ function generate_rss($posts){
foreach($posts as $p){ foreach($posts as $p){
$item = new Item(); $item = new Item();
$tags = explode(',', str_replace(' ', '', strip_tags($p->tag)));
foreach($tags as $tag) {
$item
->category($tag, site_url() . 'tag/' . $tag );
}
$item $item
->title($p->title) ->title($p->title)
->pubDate($p->date) ->pubDate($p->date)
->description($p->body) ->description($p->body)
->url($p->url) ->url($p->url)
->category($p->tag, $p->tagurl)
->appendTo($channel); ->appendTo($channel);
} }
@ -962,8 +1012,9 @@ function get_path(){
$post->authorurl = site_url() . 'author/' . $author; $post->authorurl = site_url() . 'author/' . $author;
$dt = str_replace($replaced,'',$arr[0]); $dt = str_replace($replaced,'',$arr[0]);
$time = new DateTime($dt); $t = str_replace('-', '', $dt);
$timestamp= $time->format("Y-m-d"); $time = new DateTime($t);
$timestamp= $time->format("Y-m-d H:i:s");
// The post date // The post date
$post->date = strtotime($timestamp); $post->date = strtotime($timestamp);

View file

@ -270,13 +270,19 @@ pre {
margin: 1em 0; margin: 1em 0;
overflow: auto; overflow: auto;
background: #F1F1FF; background: #F1F1FF;
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: 10px;
line-height:1.3;
} }
code { code {
color: #333333; color: #333333;
font-family: Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif; font-family: Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif;
font-size: 15px; font-size: 15px;
padding: 5px 10px; padding: 3px 8px;
background: #F1F1FF; background: #F1F1FF;
} }
@ -285,7 +291,8 @@ pre code {
display: block; display: block;
font-family: Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif; font-family: Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif;
font-size: 14px; font-size: 14px;
padding: 5px 10px; padding:0;
line-height:1.6;
} }
.comments { .comments {

View file

@ -33,6 +33,7 @@
<li><a href="<?php echo site_url() ?>add/post">Add post</a></li> <li><a href="<?php echo site_url() ?>add/post">Add post</a></li>
<li><a href="<?php echo site_url() ?>add/page">Add page</a></li> <li><a href="<?php echo site_url() ?>add/page">Add page</a></li>
<li><a href="<?php echo site_url() ?>edit/profile">Edit profile</a></li> <li><a href="<?php echo site_url() ?>edit/profile">Edit profile</a></li>
<li><a href="<?php echo site_url() ?>admin/import">Import</a></li>
<li><a href="<?php echo site_url() ?>logout">Logout</a></li> <li><a href="<?php echo site_url() ?>logout">Logout</a></li>
</ul> </ul>
</div> </div>

View file

@ -228,13 +228,19 @@ pre {
margin: 1em 0; margin: 1em 0;
overflow: auto; overflow: auto;
background: #F1F1FF; background: #F1F1FF;
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: 10px;
line-height:1.3;
} }
code { code {
color: #333333; color: #333333;
font-family: Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif; font-family: Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif;
font-size: 15px; font-size: 15px;
padding: 5px 10px; padding: 3px 8px;
background: #F1F1FF; background: #F1F1FF;
} }
@ -243,7 +249,8 @@ pre code {
display: block; display: block;
font-family: Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif; font-family: Consolas,Menlo,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace,serif;
font-size: 14px; font-size: 14px;
padding: 5px 10px; padding:0;
line-height:1.6;
} }
.thumbnail { .thumbnail {
@ -293,6 +300,10 @@ input.text {
border: 1px solid #CFDAE5; border: 1px solid #CFDAE5;
} }
input.error, textarea.error {
border: 1px solid red;
}
textarea { textarea {
font-size: 15px; font-size: 15px;
font-family: Georgia, sans-serif; font-family: Georgia, sans-serif;
@ -305,6 +316,22 @@ textarea:hover {
border: 1px solid #CCCCCC; border: 1px solid #CCCCCC;
} }
.error-message {
color: red;
background: #f4f4f4;
padding: 10px 0;
margin-bottom:2em;
}
span.required {
color: red;
}
span.help {
font-size: 12px;
font-style:italic;
}
/*------------------------- /*-------------------------
Table Table
--------------------------*/ --------------------------*/

View file

@ -33,6 +33,7 @@
<li><a href="<?php echo site_url() ?>add/post">Add post</a></li> <li><a href="<?php echo site_url() ?>add/post">Add post</a></li>
<li><a href="<?php echo site_url() ?>add/page">Add page</a></li> <li><a href="<?php echo site_url() ?>add/page">Add page</a></li>
<li><a href="<?php echo site_url() ?>edit/profile">Edit profile</a></li> <li><a href="<?php echo site_url() ?>edit/profile">Edit profile</a></li>
<li><a href="<?php echo site_url() ?>admin/import">Import</a></li>
<li><a href="<?php echo site_url() ?>logout">Logout</a></li> <li><a href="<?php echo site_url() ?>logout">Logout</a></li>
</ul> </ul>
</div> </div>