mirror of
https://github.com/danpros/htmly.git
synced 2026-04-19 12:06:22 +05:30
Add multi tags
Add multi tags feature.
This commit is contained in:
parent
13a0696eda
commit
9925f2bc4a
11 changed files with 78 additions and 77 deletions
|
|
@ -6,7 +6,8 @@
|
|||
include '../includes/session.php';
|
||||
|
||||
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'];
|
||||
}
|
||||
if(!empty($post_url) && !empty($post_content)) {
|
||||
|
|
@ -57,20 +58,15 @@
|
|||
</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>
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -6,9 +6,11 @@
|
|||
include '../includes/session.php';
|
||||
|
||||
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'];
|
||||
}
|
||||
if(!empty($post_tag) && !empty($post_url) && !empty($post_content)) {
|
||||
|
|
@ -60,21 +62,15 @@
|
|||
</form>
|
||||
</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>
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@
|
|||
<meta charset="utf-8" />
|
||||
<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" />
|
||||
<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="../editor/css/editor.css" />
|
||||
<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>
|
||||
<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 converter = new Markdown.Converter();
|
||||
|
||||
var editor = new Markdown.Editor(converter);
|
||||
|
||||
editor.run();
|
||||
|
|
|
|||
|
|
@ -57,14 +57,8 @@
|
|||
<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 converter = new Markdown.Converter();
|
||||
|
||||
var editor = new Markdown.Editor(converter);
|
||||
|
||||
editor.run();
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@
|
|||
<link rel="stylesheet" type="text/css" href="../resources/style.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.Sanitizer.js"></script>
|
||||
<script type="text/javascript" src="../editor/js/Markdown.Editor.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
|
@ -57,14 +56,8 @@
|
|||
<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 converter = new Markdown.Converter();
|
||||
|
||||
var editor = new Markdown.Editor(converter);
|
||||
|
||||
editor.run();
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ get('/:year/:month/:name', function($year, $month, $name){
|
|||
'canonical' => $current->url,
|
||||
'description' => $description = get_description($current->body),
|
||||
'bodyclass' => 'inpost',
|
||||
'breadcrumb' => '<span typeof="v:Breadcrumb"><a property="v:title" rel="v:url" href="' . config('site.url') . '">' .config('breadcrumb.home'). '</a></span> » <span typeof="v:Breadcrumb"><a property="v:title" rel="v:url" href="' . $current->tagurl .'">' . $current->tag . '</a></span> » ' . $current->title,
|
||||
'breadcrumb' => '<span typeof="v:Breadcrumb"><a property="v:title" rel="v:url" href="' . config('site.url') . '">' .config('breadcrumb.home'). '</a></span> » '. $current->tagb . ' » ' . $current->title,
|
||||
'prev' => has_prev($prev),
|
||||
'next' => has_next($next),
|
||||
'type' => 'blogpost',
|
||||
|
|
|
|||
|
|
@ -130,11 +130,21 @@ function get_posts($posts, $page = 1, $perpage = 0){
|
|||
// The post URL
|
||||
$post->url = site_url().date('Y/m', $post->date).'/'.str_replace('.md','',$arr[2]);
|
||||
|
||||
// The post tag
|
||||
$post->tag = str_replace($replaced,'',$arr[1]);
|
||||
$tag = array();
|
||||
$url = array();
|
||||
|
||||
// The post tag url
|
||||
$post->tagurl = site_url(). 'tag/' . $arr[1];
|
||||
$t = explode(',', $arr[1]);
|
||||
foreach($t as $tt) {
|
||||
$tag[] = array($tt, site_url(). 'tag/' . $tt);
|
||||
}
|
||||
|
||||
foreach($tag as $a) {
|
||||
$url[] = '<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
|
||||
$content = MarkdownExtra::defaultTransform(file_get_contents($filepath));
|
||||
|
|
@ -208,8 +218,14 @@ function get_tag($tag, $page, $perpage){
|
|||
foreach ($posts as $index => $v) {
|
||||
$url = $v['filename'];
|
||||
$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
|
||||
$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
|
||||
$arr = explode('</h1>', $content);
|
||||
|
|
@ -414,9 +440,8 @@ function get_keyword($keyword){
|
|||
|
||||
// Get related posts base on post tag.
|
||||
function get_related($tag) {
|
||||
|
||||
$perpage = config('related.count');
|
||||
$posts = get_tag($tag, 1, $perpage+1);
|
||||
$posts = get_tag(strip_tags($tag), 1, $perpage+1);
|
||||
$tmp = array();
|
||||
$req = $_SERVER['REQUEST_URI'];
|
||||
|
||||
|
|
@ -527,7 +552,10 @@ function tag_cloud() {
|
|||
$arr = explode('_', $v);
|
||||
|
||||
$data = $arr[1];
|
||||
$tags[] = $data;
|
||||
$mtag = explode(',', $data);
|
||||
foreach($mtag as $etag) {
|
||||
$tags[] = $etag;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
<div class="post <?php echo $class ?>" itemprop="blogPost" itemscope="itemscope" itemtype="http://schema.org/BlogPosting">
|
||||
<div class="main">
|
||||
<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">
|
||||
<?php if (config('img.thumbnail') == 'true'):?>
|
||||
<?php echo get_thumbnail($p->body)?>
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
<?php endif;?>
|
||||
<h1 class="title-post" itemprop="name"><?php echo $p->title ?></h1>
|
||||
<?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;?>
|
||||
<div class="post-body" itemprop="articleBody">
|
||||
<?php echo $p->body; ?>
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
<div class="post <?php echo $class ?>" itemprop="blogPost" itemscope="itemscope" itemtype="http://schema.org/BlogPosting">
|
||||
<div class="main">
|
||||
<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">
|
||||
<?php if (config('img.thumbnail') == 'true'):?>
|
||||
<?php echo get_thumbnail($p->body)?>
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
<?php endif;?>
|
||||
<h1 class="title-post" itemprop="name"><?php echo $p->title ?></h1>
|
||||
<?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;?>
|
||||
<div class="post-body" itemprop="articleBody">
|
||||
<?php echo $p->body; ?>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue