mirror of
https://github.com/danpros/htmly.git
synced 2026-04-18 03:26:20 +05:30
Various improvements
Various improvements
This commit is contained in:
parent
cd9341c155
commit
36f4c2d4df
19 changed files with 655 additions and 115 deletions
|
|
@ -1,2 +1,3 @@
|
|||
2014-02-01: HTMLy v1.0.
|
||||
2014-01-26: RC version.
|
||||
2014-01-01: Initial release.
|
||||
|
|
@ -9,11 +9,7 @@ function user($key, $user=null) {
|
|||
}
|
||||
}
|
||||
|
||||
function login_message($str = null) {
|
||||
echo $str;
|
||||
}
|
||||
|
||||
function session($user, $pass) {
|
||||
function session($user, $pass, $str = null) {
|
||||
$user_file = 'config/users/' . $user . '.ini';
|
||||
$user_pass = user('password', $user);
|
||||
|
||||
|
|
@ -23,13 +19,11 @@ function session($user, $pass) {
|
|||
header('location: admin');
|
||||
}
|
||||
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>';
|
||||
login_message($str);
|
||||
return $str = '<li>Your username and password mismatch.</li>';
|
||||
}
|
||||
}
|
||||
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>';
|
||||
login_message($str);
|
||||
return $str = '<li>Username not found in our record.</li>';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -39,9 +33,12 @@ function edit_post($title, $tag, $url, $content, $oldfile, $destination = null)
|
|||
|
||||
$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_tag = str_replace(' ', '-',$post_tag);
|
||||
$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, ',\.\-'), ',\.\-');
|
||||
$post_content = '<!--t ' . $post_title . ' t-->' . "\n\n" . $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], '/')) . '/';
|
||||
$dt = str_replace($replaced,'',$oldurl[0]);
|
||||
$time = new DateTime($dt);
|
||||
$t = str_replace('-','',$dt);
|
||||
$time = new DateTime($t);
|
||||
$timestamp= $time->format("Y-m-d");
|
||||
// The post date
|
||||
$postdate = strtotime($timestamp);
|
||||
|
|
@ -90,8 +88,10 @@ function edit_page($title, $url, $content, $oldfile, $destination = null) {
|
|||
$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_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;
|
||||
|
||||
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) {
|
||||
|
||||
$post_date = date('Y-m-d-H-i');
|
||||
$post_date = date('Y-m-d-H-i-s');
|
||||
$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_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, ' \,\.\-'), ' \,\.\-');
|
||||
$post_content = '<!--t ' . $post_title . ' t-->' . "\n\n" . $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) {
|
||||
|
||||
$post_title = $title;
|
||||
$post_url = preg_replace('/[^A-Za-z0-9,.-]/u', '', $url);
|
||||
$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;
|
||||
|
||||
if(!empty($post_title) && !empty($post_url) && !empty($post_content)) {
|
||||
|
|
@ -184,19 +188,31 @@ function delete_post($file, $destination) {
|
|||
$deleted_content = $file;
|
||||
if(!empty($deleted_content)) {
|
||||
unlink($deleted_content);
|
||||
if($destination == 'post') {
|
||||
$redirect = site_url();
|
||||
header("Location: $redirect");
|
||||
}
|
||||
else {
|
||||
$redirect = site_url() . $destination;
|
||||
header("Location: $redirect");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function delete_page($file, $destination) {
|
||||
$deleted_content = $file;
|
||||
if(!empty($deleted_content)) {
|
||||
unlink($deleted_content);
|
||||
if($destination == 'post') {
|
||||
$redirect = site_url();
|
||||
header("Location: $redirect");
|
||||
}
|
||||
else {
|
||||
$redirect = site_url() . $destination;
|
||||
header("Location: $redirect");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function edit_profile($title, $content, $user) {
|
||||
|
||||
|
|
@ -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() {
|
||||
if (isset($_SESSION['user'])) {
|
||||
$posts = get_profile($_SESSION['user'], 1, 5);
|
||||
|
|
|
|||
|
|
@ -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.Sanitizer.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">
|
||||
<form method="POST">
|
||||
Title: <br><input type="text" class="text" name="title"/><br><br>
|
||||
Url: <br><input type="text" class="text" name="url"/><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 (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>
|
||||
<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"/>
|
||||
</form>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -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.Sanitizer.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">
|
||||
<form method="POST">
|
||||
Title: <br><input type="text" class="text" name="title"/><br><br>
|
||||
Tag: <br><input type="text" class="text" name="tag"/><br><br>
|
||||
Url: <br><input type="text" class="text" name="url"/><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 <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 (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>
|
||||
<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"/>
|
||||
</form>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -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>';?>
|
||||
<form method="POST">
|
||||
<input type="hidden" name="file" value="<?php echo $p->file ?>"/><br>
|
||||
<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>
|
||||
|
|
@ -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>';?>
|
||||
<form method="POST">
|
||||
<input type="hidden" name="file" value="<?php echo $p->file ?>"/><br>
|
||||
<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>
|
||||
|
|
@ -1,6 +1,11 @@
|
|||
<?php
|
||||
|
||||
if(isset($p->file)) {
|
||||
$url = $p->file;
|
||||
}
|
||||
else {
|
||||
$url = $oldfile;
|
||||
}
|
||||
$content = file_get_contents($url);
|
||||
$arr = explode('t-->', $content);
|
||||
if(isset($arr[1])) {
|
||||
|
|
@ -12,23 +17,30 @@
|
|||
$oldcontent = ltrim($arr[0]);
|
||||
}
|
||||
|
||||
$destination = $_GET['destination'];
|
||||
$dir = substr($url, 0, strrpos($url, '/'));
|
||||
$oldurl = str_replace($dir . '/','',$url);
|
||||
$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" />
|
||||
<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.Editor.js"></script>
|
||||
<?php if (isset($error)) { ?>
|
||||
<div class="error-message"><?php echo $error ?></div>
|
||||
<?php } ?>
|
||||
<div class="wmd-panel">
|
||||
<form method="POST">
|
||||
Title: <br><input type="text" name="title" class="text" value="<?php echo $oldtitle?>"/><br><br>
|
||||
Url: <br><input type="text" name="url" class="text" value="<?php echo $oldmd ?>"/><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 (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>
|
||||
<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="submit" name="submit" class="submit" value="Submit"/>
|
||||
<input type="submit" name="submit" class="submit" value="Save"/> <a href="<?php echo $delete?>">Delete</a>
|
||||
</form>
|
||||
</div>
|
||||
<div id="wmd-preview" class="wmd-panel wmd-preview"></div>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,11 @@
|
|||
<?php
|
||||
if(isset($p->file)) {
|
||||
$url = $p->file;
|
||||
}
|
||||
else {
|
||||
$url = $oldfile;
|
||||
}
|
||||
|
||||
$content = file_get_contents($url);
|
||||
$arr = explode('t-->', $content);
|
||||
if(isset($arr[1])) {
|
||||
|
|
@ -19,20 +25,37 @@
|
|||
|
||||
$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" />
|
||||
<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.Editor.js"></script>
|
||||
<?php if (isset($error)) { ?>
|
||||
<div class="error-message"><?php echo $error ?></div>
|
||||
<?php } ?>
|
||||
<div class="wmd-panel">
|
||||
<form method="POST">
|
||||
Title: <br><input type="text" name="title" class="text" value="<?php echo $oldtitle?>"/><br><br>
|
||||
Tag: <br><input type="text" name="tag" class="text" value="<?php echo $oldtag?>"/><br><br>
|
||||
Url: <br><input type="text" name="url" class="text" value="<?php echo $oldmd ?>"/><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 <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 (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>
|
||||
<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="submit" name="submit" class="submit" value="Submit"/>
|
||||
<input type="submit" name="submit" class="submit" value="Save"/> <a href="<?php echo $delete?>">Delete</a>
|
||||
</form>
|
||||
</div>
|
||||
<div id="wmd-preview" class="wmd-panel wmd-preview"></div>
|
||||
|
|
|
|||
|
|
@ -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.Sanitizer.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">
|
||||
<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>
|
||||
<textarea id="wmd-input" class="wmd-input" name="content" cols="20" rows="10"><?php echo $oldcontent ?></textarea><br>
|
||||
<input type="submit" name="submit" class="submit" value="Submit"/>
|
||||
<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="Save"/>
|
||||
</form>
|
||||
</div>
|
||||
<div id="wmd-preview" class="wmd-panel wmd-preview"></div>
|
||||
|
|
|
|||
10
system/admin/views/import.html.php
Normal file
10
system/admin/views/import.html.php
Normal 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>
|
||||
|
|
@ -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/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() ?>admin/import">Import</a></li>
|
||||
<li><a href="<?php echo site_url() ?>logout">Logout</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
<?php if (isset($error)) { ?>
|
||||
<div class="error-message"><?php echo $error?></div>
|
||||
<?php } ?>
|
||||
<?php if(!login()) {?>
|
||||
<?php login_message(null);?>
|
||||
<h1>Login</h1>
|
||||
<form method="POST" action="login">
|
||||
User:<br>
|
||||
<input type="text" name="user"/><br><br>
|
||||
Pass:<br>
|
||||
<input type="password" name="password"/><br><br>
|
||||
User <span class="required">*</span> <br>
|
||||
<input type="text" class="<?php if (isset($username)) { if (empty($username)) { echo 'error';}} ?>" name="user"/><br><br>
|
||||
Password <span class="required">*</span> <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"/>
|
||||
</form>
|
||||
<?php } else {header('location: admin');} ?>
|
||||
264
system/htmly.php
264
system/htmly.php
|
|
@ -53,7 +53,47 @@ post('/login', function() {
|
|||
|
||||
$user = from($_REQUEST, 'user');
|
||||
$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> » 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> » Login'
|
||||
));
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
|
@ -143,8 +183,42 @@ post('/:year/:month/:name/edit', function() {
|
|||
$content = from($_REQUEST, 'content');
|
||||
$oldfile = from($_REQUEST, 'oldfile');
|
||||
$destination = from($_GET, 'destination');
|
||||
|
||||
if(!empty($title) && !empty($tag) && !empty($content)) {
|
||||
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> » Edit post'
|
||||
));
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
|
@ -262,7 +336,30 @@ post('/edit/profile', function() {
|
|||
$user = $_SESSION['user'];
|
||||
$title = from($_REQUEST, 'title');
|
||||
$content = from($_REQUEST, 'content');
|
||||
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> » Edit profile'
|
||||
));
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
|
@ -404,7 +501,7 @@ get('/:static', function($static){
|
|||
}
|
||||
die;
|
||||
}
|
||||
|
||||
else {
|
||||
$post = get_static_post($static);
|
||||
|
||||
if(!$post){
|
||||
|
|
@ -422,6 +519,7 @@ get('/:static', function($static){
|
|||
'p' => $post,
|
||||
'type' => 'staticpage',
|
||||
));
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
|
@ -463,8 +561,38 @@ post('/:static/edit', function() {
|
|||
$content = from($_REQUEST, 'content');
|
||||
$oldfile = from($_REQUEST, 'oldfile');
|
||||
$destination = from($_GET, 'destination');
|
||||
|
||||
if(!empty($title) && !empty($content)) {
|
||||
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> » Edit page'
|
||||
));
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
|
@ -536,7 +664,40 @@ post('/add/post', function(){
|
|||
$url = from($_REQUEST, 'url');
|
||||
$content = from($_REQUEST, 'content');
|
||||
$user = $_SESSION['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> » Add post'
|
||||
));
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
|
@ -567,7 +728,100 @@ post('/add/page', function(){
|
|||
$title = from($_REQUEST, 'title');
|
||||
$url = from($_REQUEST, 'url');
|
||||
$content = from($_REQUEST, '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> » 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> » 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> » 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> » Login'
|
||||
));
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
|
@ -578,7 +832,7 @@ get('/tag/:tag',function($tag){
|
|||
$page = $page ? (int)$page : 1;
|
||||
$perpage = config('tag.perpage');
|
||||
|
||||
$posts = get_tag($tag, $page, $perpage);
|
||||
$posts = get_tag($tag, $page, $perpage, false);
|
||||
|
||||
$total = get_count($tag, 'filename');
|
||||
|
||||
|
|
|
|||
|
|
@ -124,14 +124,15 @@ function get_posts($posts, $page = 1, $perpage = 0){
|
|||
$post->authorurl = site_url() . 'author/' . $author;
|
||||
|
||||
$dt = str_replace($replaced,'',$arr[0]);
|
||||
$time = new DateTime($dt);
|
||||
$timestamp= $time->format("Y-m-d");
|
||||
$t = str_replace('-', '', $dt);
|
||||
$time = new DateTime($t);
|
||||
$timestamp= $time->format("Y-m-d H:i:s");
|
||||
|
||||
// The post date
|
||||
$post->date = strtotime($timestamp);
|
||||
|
||||
// The archive per day
|
||||
$post->archive = site_url(). 'archive/' . $timestamp ;
|
||||
$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]);
|
||||
|
|
@ -162,7 +163,9 @@ function get_posts($posts, $page = 1, $perpage = 0){
|
|||
// Extract the title and body
|
||||
$arr = explode('t-->', $content);
|
||||
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];
|
||||
}
|
||||
else {
|
||||
|
|
@ -225,10 +228,14 @@ function find_post($year, $month, $name){
|
|||
}
|
||||
|
||||
// Return tag page.
|
||||
function get_tag($tag, $page, $perpage){
|
||||
function get_tag($tag, $page, $perpage, $random){
|
||||
|
||||
$posts = get_post_sorted();
|
||||
|
||||
if($random === true) {
|
||||
shuffle($posts);
|
||||
}
|
||||
|
||||
$tmp = array();
|
||||
|
||||
foreach ($posts as $index => $v) {
|
||||
|
|
@ -330,7 +337,9 @@ function get_bio($author){
|
|||
// Extract the title and body
|
||||
$arr = explode('t-->', $content);
|
||||
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];
|
||||
}
|
||||
else {
|
||||
|
|
@ -387,7 +396,9 @@ function get_static_post($static){
|
|||
// Extract the title and body
|
||||
$arr = explode('t-->', $content);
|
||||
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];
|
||||
}
|
||||
else {
|
||||
|
|
@ -441,8 +452,9 @@ function get_keyword($keyword){
|
|||
$post->authorurl = site_url() . 'author/' . $author;
|
||||
|
||||
$dt = str_replace($replaced,'',$arr[0]);
|
||||
$time = new DateTime($dt);
|
||||
$timestamp= $time->format("Y-m-d");
|
||||
$t = str_replace('-', '', $dt);
|
||||
$time = new DateTime($t);
|
||||
$timestamp= $time->format("Y-m-d H:i:s");
|
||||
|
||||
// The post date
|
||||
$post->date = strtotime($timestamp);
|
||||
|
|
@ -471,7 +483,9 @@ function get_keyword($keyword){
|
|||
// Extract the title and body
|
||||
$arr = explode('t-->', $content);
|
||||
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];
|
||||
}
|
||||
else {
|
||||
|
|
@ -497,7 +511,7 @@ function get_keyword($keyword){
|
|||
// Get related posts base on post tag.
|
||||
function get_related($tag) {
|
||||
$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();
|
||||
$req = $_SERVER['REQUEST_URI'];
|
||||
|
||||
|
|
@ -512,8 +526,6 @@ function get_related($tag) {
|
|||
|
||||
if($total >= 1) {
|
||||
|
||||
shuffle($tmp);
|
||||
|
||||
$i = 1;
|
||||
echo '<div class="related"><h4>Related posts</h4><ul>';
|
||||
foreach ($tmp as $post) {
|
||||
|
|
@ -575,11 +587,32 @@ function archive_list() {
|
|||
# Most recent year first
|
||||
krsort($by_year);
|
||||
# Iterate for display
|
||||
$script = <<<EOF
|
||||
if (this.parentNode.className.indexOf('expanded') > -1){this.parentNode.className = 'collapsed';this.innerHTML = '►';} else {this.parentNode.className = 'expanded';this.innerHTML = '▼';}
|
||||
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>';
|
||||
$i = 0;
|
||||
$len = count($by_year);
|
||||
foreach ($by_year as $year => $months){
|
||||
if ($i == 0) {
|
||||
$class = 'expanded';
|
||||
$arrow = '▼';
|
||||
}
|
||||
else {
|
||||
$class = 'collapsed';
|
||||
$arrow = '►';
|
||||
}
|
||||
$i++;
|
||||
|
||||
echo '<span class="year"><a href="' . site_url() . 'archive/' . $year . '">' . $year . '</a></span> ';
|
||||
echo '(' . count($months) . ')';
|
||||
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">';
|
||||
|
||||
$by_month = array_count_values($months);
|
||||
|
|
@ -592,6 +625,8 @@ function archive_list() {
|
|||
}
|
||||
|
||||
echo '</ul>';
|
||||
echo '</li>';
|
||||
echo '</ul>';
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -673,7 +708,7 @@ function get_description($text) {
|
|||
}
|
||||
else {
|
||||
$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')) {
|
||||
return $string;
|
||||
}
|
||||
|
|
@ -878,11 +913,22 @@ function get_menu() {
|
|||
|
||||
// Replaced string
|
||||
$replaced = substr($v, 0, strrpos($v, '/')) . '/';
|
||||
$base = str_replace($replaced,'',$v);
|
||||
$url = site_url() . str_replace('.md','',$base);
|
||||
|
||||
// The static page URL
|
||||
$title = str_replace($replaced,'',$v);
|
||||
$url = site_url() . str_replace('.md','',$title);
|
||||
echo '<li><a href="' . $url . '">' . ucfirst(str_replace('.md','',$title)) . '</a></li>';
|
||||
// Get the contents and convert it to HTML
|
||||
$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>';
|
||||
|
|
@ -924,12 +970,16 @@ function generate_rss($posts){
|
|||
|
||||
foreach($posts as $p){
|
||||
$item = new Item();
|
||||
$tags = explode(',', str_replace(' ', '', strip_tags($p->tag)));
|
||||
foreach($tags as $tag) {
|
||||
$item
|
||||
->category($tag, site_url() . 'tag/' . $tag );
|
||||
}
|
||||
$item
|
||||
->title($p->title)
|
||||
->pubDate($p->date)
|
||||
->description($p->body)
|
||||
->url($p->url)
|
||||
->category($p->tag, $p->tagurl)
|
||||
->appendTo($channel);
|
||||
}
|
||||
|
||||
|
|
@ -962,8 +1012,9 @@ function get_path(){
|
|||
$post->authorurl = site_url() . 'author/' . $author;
|
||||
|
||||
$dt = str_replace($replaced,'',$arr[0]);
|
||||
$time = new DateTime($dt);
|
||||
$timestamp= $time->format("Y-m-d");
|
||||
$t = str_replace('-', '', $dt);
|
||||
$time = new DateTime($t);
|
||||
$timestamp= $time->format("Y-m-d H:i:s");
|
||||
|
||||
// The post date
|
||||
$post->date = strtotime($timestamp);
|
||||
|
|
|
|||
|
|
@ -270,13 +270,19 @@ pre {
|
|||
margin: 1em 0;
|
||||
overflow: auto;
|
||||
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 {
|
||||
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;
|
||||
padding: 3px 8px;
|
||||
background: #F1F1FF;
|
||||
}
|
||||
|
||||
|
|
@ -285,7 +291,8 @@ pre code {
|
|||
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;
|
||||
padding:0;
|
||||
line-height:1.6;
|
||||
}
|
||||
|
||||
.comments {
|
||||
|
|
|
|||
|
|
@ -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/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() ?>admin/import">Import</a></li>
|
||||
<li><a href="<?php echo site_url() ?>logout">Logout</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -228,13 +228,19 @@ pre {
|
|||
margin: 1em 0;
|
||||
overflow: auto;
|
||||
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 {
|
||||
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;
|
||||
padding: 3px 8px;
|
||||
background: #F1F1FF;
|
||||
}
|
||||
|
||||
|
|
@ -243,7 +249,8 @@ pre code {
|
|||
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;
|
||||
padding:0;
|
||||
line-height:1.6;
|
||||
}
|
||||
|
||||
.thumbnail {
|
||||
|
|
@ -293,6 +300,10 @@ input.text {
|
|||
border: 1px solid #CFDAE5;
|
||||
}
|
||||
|
||||
input.error, textarea.error {
|
||||
border: 1px solid red;
|
||||
}
|
||||
|
||||
textarea {
|
||||
font-size: 15px;
|
||||
font-family: Georgia, sans-serif;
|
||||
|
|
@ -305,6 +316,22 @@ textarea:hover {
|
|||
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
|
||||
--------------------------*/
|
||||
|
|
|
|||
|
|
@ -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/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() ?>admin/import">Import</a></li>
|
||||
<li><a href="<?php echo site_url() ?>logout">Logout</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue