Browse Source

Add multi tags

Add multi tags feature.
pull/31/merge
Danang Probo Sayekti 12 years ago
parent
commit
9925f2bc4a
11 changed files with 78 additions and 77 deletions
  1. +11
    -15
      admin/action/create_page.php
  2. +14
    -18
      admin/action/create_post.php
  3. +3
    -9
      admin/action/edit_bio.php
  4. +2
    -8
      admin/action/edit_page.php
  5. +2
    -9
      admin/action/edit_post.php
  6. +1
    -1
      system/htmly.php
  7. +41
    -13
      system/includes/functions.php
  8. +1
    -1
      themes/clean/main.html.php
  9. +1
    -1
      themes/clean/post.html.php
  10. +1
    -1
      themes/default/main.html.php
  11. +1
    -1
      themes/default/post.html.php

+ 11
- 15
admin/action/create_page.php View File

@ -6,7 +6,8 @@
include '../includes/session.php'; include '../includes/session.php';
if(isset($_POST['submit'])) { if(isset($_POST['submit'])) {
$post_url = $_POST['url'];
$post_url = preg_replace('/[^A-Za-z0-9,.-]/u', '', $_POST['url']);
$post_url = rtrim($post_url, ',\.\-');
$post_content = $_POST['content']; $post_content = $_POST['content'];
} }
if(!empty($post_url) && !empty($post_content)) { if(!empty($post_url) && !empty($post_content)) {
@ -57,20 +58,15 @@
</div> </div>
<div id="wmd-preview" class="wmd-panel wmd-preview"></div> <div id="wmd-preview" class="wmd-panel wmd-preview"></div>
<script type="text/javascript"> <script type="text/javascript">
(function () {
var converter = Markdown.getSanitizingConverter();
converter.hooks.chain("preBlockGamut", function (text, rbg) {
return text.replace(/^ {0,3}""" *\n((?:.*?\n)+?) {0,3}""" *$/gm, function (whole, inner) {
return "<blockquote>" + rbg(inner) + "</blockquote>\n";
});
});
var editor = new Markdown.Editor(converter);
editor.run();
})();
</script>
<script type="text/javascript">
(function () {
var converter = new Markdown.Converter();
var editor = new Markdown.Editor(converter);
editor.run();
})();
</script>
</div> </div>
</div> </div>
</body> </body>


+ 14
- 18
admin/action/create_post.php View File

@ -6,9 +6,11 @@
include '../includes/session.php'; include '../includes/session.php';
if(isset($_POST['submit'])) { if(isset($_POST['submit'])) {
$post_date = date('Y-m-d-H');
$post_tag = $_POST['tag'];
$post_url = $_POST['url'];
$post_date = date('Y-m-d-H-i');
$post_tag = preg_replace('/[^A-Za-z0-9,.-]/u', '', $_POST['tag']);
$post_tag = rtrim($post_tag, ',\.\-');
$post_url = preg_replace('/[^A-Za-z0-9,.-]/u', '', $_POST['url']);
$post_url = rtrim($post_url, ',\.\-');
$post_content = $_POST['content']; $post_content = $_POST['content'];
} }
if(!empty($post_tag) && !empty($post_url) && !empty($post_content)) { if(!empty($post_tag) && !empty($post_url) && !empty($post_content)) {
@ -60,21 +62,15 @@
</form> </form>
</div> </div>
<div id="wmd-preview" class="wmd-panel wmd-preview"></div> <div id="wmd-preview" class="wmd-panel wmd-preview"></div>
<script type="text/javascript">
(function () {
var converter = Markdown.getSanitizingConverter();
converter.hooks.chain("preBlockGamut", function (text, rbg) {
return text.replace(/^ {0,3}""" *\n((?:.*?\n)+?) {0,3}""" *$/gm, function (whole, inner) {
return "<blockquote>" + rbg(inner) + "</blockquote>\n";
});
});
var editor = new Markdown.Editor(converter);
editor.run();
})();
</script>
<script type="text/javascript">
(function () {
var converter = new Markdown.Converter();
var editor = new Markdown.Editor(converter);
editor.run();
})();
</script>
</div> </div>
</div> </div>
</body> </body>


+ 3
- 9
admin/action/edit_bio.php View File

@ -37,7 +37,7 @@
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" user-scalable="no" /> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" user-scalable="no" />
<title>Edit post</title>
<title>Edit bio</title>
<link rel="stylesheet" type="text/css" href="../resources/style.css" /> <link rel="stylesheet" type="text/css" href="../resources/style.css" />
<link rel="stylesheet" type="text/css" href="../editor/css/editor.css" /> <link rel="stylesheet" type="text/css" href="../editor/css/editor.css" />
<script type="text/javascript" src="../editor/js/Markdown.Converter.js"></script> <script type="text/javascript" src="../editor/js/Markdown.Converter.js"></script>
@ -65,14 +65,8 @@
<div id="wmd-preview" class="wmd-panel wmd-preview"></div> <div id="wmd-preview" class="wmd-panel wmd-preview"></div>
<script type="text/javascript"> <script type="text/javascript">
(function () { (function () {
var converter = Markdown.getSanitizingConverter();
converter.hooks.chain("preBlockGamut", function (text, rbg) {
return text.replace(/^ {0,3}""" *\n((?:.*?\n)+?) {0,3}""" *$/gm, function (whole, inner) {
return "<blockquote>" + rbg(inner) + "</blockquote>\n";
});
});
var converter = new Markdown.Converter();
var editor = new Markdown.Editor(converter); var editor = new Markdown.Editor(converter);
editor.run(); editor.run();


+ 2
- 8
admin/action/edit_page.php View File

@ -57,14 +57,8 @@
<div id="wmd-preview" class="wmd-panel wmd-preview"></div> <div id="wmd-preview" class="wmd-panel wmd-preview"></div>
<script type="text/javascript"> <script type="text/javascript">
(function () { (function () {
var converter = Markdown.getSanitizingConverter();
converter.hooks.chain("preBlockGamut", function (text, rbg) {
return text.replace(/^ {0,3}""" *\n((?:.*?\n)+?) {0,3}""" *$/gm, function (whole, inner) {
return "<blockquote>" + rbg(inner) + "</blockquote>\n";
});
});
var converter = new Markdown.Converter();
var editor = new Markdown.Editor(converter); var editor = new Markdown.Editor(converter);
editor.run(); editor.run();


+ 2
- 9
admin/action/edit_post.php View File

@ -32,7 +32,6 @@
<link rel="stylesheet" type="text/css" href="../resources/style.css" /> <link rel="stylesheet" type="text/css" href="../resources/style.css" />
<link rel="stylesheet" type="text/css" href="../editor/css/editor.css" /> <link rel="stylesheet" type="text/css" href="../editor/css/editor.css" />
<script type="text/javascript" src="../editor/js/Markdown.Converter.js"></script> <script type="text/javascript" src="../editor/js/Markdown.Converter.js"></script>
<script type="text/javascript" src="../editor/js/Markdown.Sanitizer.js"></script>
<script type="text/javascript" src="../editor/js/Markdown.Editor.js"></script> <script type="text/javascript" src="../editor/js/Markdown.Editor.js"></script>
</head> </head>
<body> <body>
@ -57,14 +56,8 @@
<div id="wmd-preview" class="wmd-panel wmd-preview"></div> <div id="wmd-preview" class="wmd-panel wmd-preview"></div>
<script type="text/javascript"> <script type="text/javascript">
(function () { (function () {
var converter = Markdown.getSanitizingConverter();
converter.hooks.chain("preBlockGamut", function (text, rbg) {
return text.replace(/^ {0,3}""" *\n((?:.*?\n)+?) {0,3}""" *$/gm, function (whole, inner) {
return "<blockquote>" + rbg(inner) + "</blockquote>\n";
});
});
var converter = new Markdown.Converter();
var editor = new Markdown.Editor(converter); var editor = new Markdown.Editor(converter);
editor.run(); editor.run();


+ 1
- 1
system/htmly.php View File

@ -161,7 +161,7 @@ get('/:year/:month/:name', function($year, $month, $name){
'canonical' => $current->url, 'canonical' => $current->url,
'description' => $description = get_description($current->body), 'description' => $description = get_description($current->body),
'bodyclass' => 'inpost', 'bodyclass' => 'inpost',
'breadcrumb' => '<span typeof="v:Breadcrumb"><a property="v:title" rel="v:url" href="' . config('site.url') . '">' .config('breadcrumb.home'). '</a></span> &#187; <span typeof="v:Breadcrumb"><a property="v:title" rel="v:url" href="' . $current->tagurl .'">' . $current->tag . '</a></span> &#187; ' . $current->title,
'breadcrumb' => '<span typeof="v:Breadcrumb"><a property="v:title" rel="v:url" href="' . config('site.url') . '">' .config('breadcrumb.home'). '</a></span> &#187; '. $current->tagb . ' &#187; ' . $current->title,
'prev' => has_prev($prev), 'prev' => has_prev($prev),
'next' => has_next($next), 'next' => has_next($next),
'type' => 'blogpost', 'type' => 'blogpost',


+ 41
- 13
system/includes/functions.php View File

@ -130,11 +130,21 @@ function get_posts($posts, $page = 1, $perpage = 0){
// 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]);
// The post tag
$post->tag = str_replace($replaced,'',$arr[1]);
$tag = array();
$url = array();
// The post tag url
$post->tagurl = site_url(). 'tag/' . $arr[1];
$t = explode(',', $arr[1]);
foreach($t as $tt) {
$tag[] = array($tt, site_url(). 'tag/' . $tt);
}
foreach($tag as $a) {
$url[] = '<span typeof="v:Breadcrumb"><a property="v:title" rel="v:url" href="' . $a[1] . '">'. $a[0] .'</a></span>';
}
$post->tag = implode(', ', $url);
$post->tagb = implode(' » ', $url);
// Get the contents and convert it to HTML // Get the contents and convert it to HTML
$content = MarkdownExtra::defaultTransform(file_get_contents($filepath)); $content = MarkdownExtra::defaultTransform(file_get_contents($filepath));
@ -208,8 +218,14 @@ function get_tag($tag, $page, $perpage){
foreach ($posts as $index => $v) { foreach ($posts as $index => $v) {
$url = $v['filename']; $url = $v['filename'];
$str = explode('_', $url); $str = explode('_', $url);
if($tag === $str[1]){
$tmp[] = $v;
$mtag = explode(',', $str[1]);
$etag = explode(',', $tag);
foreach ($mtag as $t) {
foreach ($etag as $e) {
if($t === $e){
$tmp[] = $v;
}
}
} }
} }
@ -389,11 +405,21 @@ function get_keyword($keyword){
// 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]);
// The post tag
$post->tag = str_replace($replaced,'',$arr[1]);
$tag = array();
$url = array();
// The post tag URL
$post->tagurl = site_url(). 'tag/' . $arr[1];
$t = explode(',', $arr[1]);
foreach($t as $tt) {
$tag[] = array($tt, site_url(). 'tag/' . $tt);
}
foreach($tag as $a) {
$url[] = '<span typeof="v:Breadcrumb"><a property="v:title" rel="v:url" href="' . $a[1] . '">'. $a[0] .'</a></span>';
}
$post->tag = implode(', ', $url);
$post->tagb = implode(' » ', $url);
// Extract the title and body // Extract the title and body
$arr = explode('</h1>', $content); $arr = explode('</h1>', $content);
@ -414,9 +440,8 @@ 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($tag, 1, $perpage+1);
$posts = get_tag(strip_tags($tag), 1, $perpage+1);
$tmp = array(); $tmp = array();
$req = $_SERVER['REQUEST_URI']; $req = $_SERVER['REQUEST_URI'];
@ -527,7 +552,10 @@ function tag_cloud() {
$arr = explode('_', $v); $arr = explode('_', $v);
$data = $arr[1]; $data = $arr[1];
$tags[] = $data;
$mtag = explode(',', $data);
foreach($mtag as $etag) {
$tags[] = $etag;
}
} }


+ 1
- 1
themes/clean/main.html.php View File

@ -16,7 +16,7 @@
<div class="post <?php echo $class ?>" itemprop="blogPost" itemscope="itemscope" itemtype="http://schema.org/BlogPosting"> <div class="post <?php echo $class ?>" itemprop="blogPost" itemscope="itemscope" itemtype="http://schema.org/BlogPosting">
<div class="main"> <div class="main">
<h2 class="title-index" itemprop="name"><a href="<?php echo $p->url?>"><?php echo $p->title ?></a></h2> <h2 class="title-index" itemprop="name"><a href="<?php echo $p->url?>"><?php echo $p->title ?></a></h2>
<div class="date"><span itemprop="datePublished"><?php echo date('d F Y', $p->date)?></span> - Posted in <span itemprop="articleSection"><a href="<?php echo $p->tagurl ?>"><?php echo $p->tag ?></a></span> by <span itemprop="author"><a href="<?php echo $p->authorurl ?>"><?php echo $p->author ?></a></span><?php if (disqus_count() == true):?> - <span><a href="<?php echo $p->url?>#disqus_thread">Comments</a></span><?php endif;?></div>
<div class="date"><span itemprop="datePublished"><?php echo date('d F Y', $p->date)?></span> - Posted in <span itemprop="articleSection"><?php echo $p->tag ?></span> by <span itemprop="author"><a href="<?php echo $p->authorurl ?>"><?php echo $p->author ?></a></span><?php if (disqus_count() == true):?> - <span><a href="<?php echo $p->url?>#disqus_thread">Comments</a></span><?php endif;?></div>
<div class="teaser-body" itemprop="articleBody"> <div class="teaser-body" itemprop="articleBody">
<?php if (config('img.thumbnail') == 'true'):?> <?php if (config('img.thumbnail') == 'true'):?>
<?php echo get_thumbnail($p->body)?> <?php echo get_thumbnail($p->body)?>


+ 1
- 1
themes/clean/post.html.php View File

@ -6,7 +6,7 @@
<?php endif;?> <?php endif;?>
<h1 class="title-post" itemprop="name"><?php echo $p->title ?></h1> <h1 class="title-post" itemprop="name"><?php echo $p->title ?></h1>
<?php if ($type == 'blogpost'):?> <?php if ($type == 'blogpost'):?>
<div class="date"><span itemprop="datePublished"><a href="<?php echo $p->archive ?>" title="Show all posts made on this day"><?php echo date('d F Y', $p->date)?></a></span> - Posted in <span itemprop="articleSection"><a href="<?php echo $p->tagurl ?>"><?php echo $p->tag ?></a></span> by <span itemprop="author"><a href="<?php echo $p->authorurl ?>"><?php echo $p->author ?></a></span> - <span><a href="<?php echo $p->url ?>" rel="permalink">Permalink</a></span></div>
<div class="date"><span itemprop="datePublished"><a href="<?php echo $p->archive ?>" title="Show all posts made on this day"><?php echo date('d F Y', $p->date)?></a></span> - Posted in <span itemprop="articleSection"><?php echo $p->tag ?></span> by <span itemprop="author"><a href="<?php echo $p->authorurl ?>"><?php echo $p->author ?></a></span> - <span><a href="<?php echo $p->url ?>" rel="permalink">Permalink</a></span></div>
<?php endif;?> <?php endif;?>
<div class="post-body" itemprop="articleBody"> <div class="post-body" itemprop="articleBody">
<?php echo $p->body; ?> <?php echo $p->body; ?>


+ 1
- 1
themes/default/main.html.php View File

@ -16,7 +16,7 @@
<div class="post <?php echo $class ?>" itemprop="blogPost" itemscope="itemscope" itemtype="http://schema.org/BlogPosting"> <div class="post <?php echo $class ?>" itemprop="blogPost" itemscope="itemscope" itemtype="http://schema.org/BlogPosting">
<div class="main"> <div class="main">
<h2 class="title-index" itemprop="name"><a href="<?php echo $p->url?>"><?php echo $p->title ?></a></h2> <h2 class="title-index" itemprop="name"><a href="<?php echo $p->url?>"><?php echo $p->title ?></a></h2>
<div class="date"><span itemprop="datePublished"><?php echo date('d F Y', $p->date)?></span> - Posted in <span itemprop="articleSection"><a href="<?php echo $p->tagurl ?>"><?php echo $p->tag ?></a></span> by <span itemprop="author"><a href="<?php echo $p->authorurl ?>"><?php echo $p->author ?></a></span><?php if (disqus_count() == true):?> - <span><a href="<?php echo $p->url?>#disqus_thread">Comments</a></span><?php endif;?></div>
<div class="date"><span itemprop="datePublished"><?php echo date('d F Y', $p->date)?></span> - Posted in <span itemprop="articleSection"><?php echo $p->tag ?></span> by <span itemprop="author"><a href="<?php echo $p->authorurl ?>"><?php echo $p->author ?></a></span><?php if (disqus_count() == true):?> - <span><a href="<?php echo $p->url?>#disqus_thread">Comments</a></span><?php endif;?></div>
<div class="teaser-body" itemprop="articleBody"> <div class="teaser-body" itemprop="articleBody">
<?php if (config('img.thumbnail') == 'true'):?> <?php if (config('img.thumbnail') == 'true'):?>
<?php echo get_thumbnail($p->body)?> <?php echo get_thumbnail($p->body)?>


+ 1
- 1
themes/default/post.html.php View File

@ -6,7 +6,7 @@
<?php endif;?> <?php endif;?>
<h1 class="title-post" itemprop="name"><?php echo $p->title ?></h1> <h1 class="title-post" itemprop="name"><?php echo $p->title ?></h1>
<?php if ($type == 'blogpost'):?> <?php if ($type == 'blogpost'):?>
<div class="date"><span itemprop="datePublished"><a href="<?php echo $p->archive ?>" title="Show all posts made on this day"><?php echo date('d F Y', $p->date)?></a></span> - Posted in <span itemprop="articleSection"><a href="<?php echo $p->tagurl ?>"><?php echo $p->tag ?></a></span> by <span itemprop="author"><a href="<?php echo $p->authorurl ?>"><?php echo $p->author ?></a></span> - <span><a href="<?php echo $p->url ?>" rel="permalink">Permalink</a></span></div>
<div class="date"><span itemprop="datePublished"><a href="<?php echo $p->archive ?>" title="Show all posts made on this day"><?php echo date('d F Y', $p->date)?></a></span> - Posted in <span itemprop="articleSection"><?php echo $p->tag ?></span> by <span itemprop="author"><a href="<?php echo $p->authorurl ?>"><?php echo $p->author ?></a></span> - <span><a href="<?php echo $p->url ?>" rel="permalink">Permalink</a></span></div>
<?php endif;?> <?php endif;?>
<div class="post-body" itemprop="articleBody"> <div class="post-body" itemprop="articleBody">
<?php echo $p->body; ?> <?php echo $p->body; ?>


Loading…
Cancel
Save