mirror of
https://github.com/danpros/htmly.git
synced 2026-04-22 05:26:22 +05:30
Revert "Simplify the first post and last post generation"
This reverts commit d5e6973e82.
This commit is contained in:
parent
4149ca4c2c
commit
37c54cfb9b
2 changed files with 27 additions and 46 deletions
|
|
@ -57,10 +57,10 @@ function get_posts($page = 1, $perpage = 0){
|
||||||
// Create a new instance of the markdown parser
|
// Create a new instance of the markdown parser
|
||||||
$md = new MarkdownParser();
|
$md = new MarkdownParser();
|
||||||
|
|
||||||
foreach($posts as $index => $v){
|
foreach($posts as $k=>$v){
|
||||||
|
|
||||||
$post = new stdClass;
|
$post = new stdClass;
|
||||||
|
|
||||||
// Extract the date
|
// Extract the date
|
||||||
$arr = explode('_', $v);
|
$arr = explode('_', $v);
|
||||||
|
|
||||||
|
|
@ -91,19 +91,9 @@ function get_posts($page = 1, $perpage = 0){
|
||||||
$post->title = str_replace('<h1>','',$arr[0]);
|
$post->title = str_replace('<h1>','',$arr[0]);
|
||||||
$post->body = $arr[1];
|
$post->body = $arr[1];
|
||||||
|
|
||||||
// Get first and last post
|
|
||||||
if ($index == 0) {
|
|
||||||
$post->cls = 'item first';
|
|
||||||
}
|
|
||||||
elseif ($index == count($posts) - 1) {
|
|
||||||
$post->cls = 'item last';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$post->cls = 'item';
|
|
||||||
}
|
|
||||||
|
|
||||||
$tmp[] = $post;
|
$tmp[] = $post;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $tmp;
|
return $tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -197,17 +187,6 @@ function get_tag($tag){
|
||||||
$arr = explode('</h1>', $content);
|
$arr = explode('</h1>', $content);
|
||||||
$post->title = str_replace('<h1>','',$arr[0]);
|
$post->title = str_replace('<h1>','',$arr[0]);
|
||||||
$post->body = $arr[1];
|
$post->body = $arr[1];
|
||||||
|
|
||||||
// Get first and last post
|
|
||||||
if ($index == 0) {
|
|
||||||
$post->cls = 'item first';
|
|
||||||
}
|
|
||||||
elseif ($index == count($posts) - 1) {
|
|
||||||
$post->cls = 'item last';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$post->cls = 'item';
|
|
||||||
}
|
|
||||||
|
|
||||||
$tmp[] = $post;
|
$tmp[] = $post;
|
||||||
}
|
}
|
||||||
|
|
@ -260,17 +239,6 @@ function get_archive($req){
|
||||||
$arr = explode('</h1>', $content);
|
$arr = explode('</h1>', $content);
|
||||||
$post->title = str_replace('<h1>','',$arr[0]);
|
$post->title = str_replace('<h1>','',$arr[0]);
|
||||||
$post->body = $arr[1];
|
$post->body = $arr[1];
|
||||||
|
|
||||||
// Get first and last post
|
|
||||||
if ($index == 0) {
|
|
||||||
$post->cls = 'item first';
|
|
||||||
}
|
|
||||||
elseif ($index == count($posts) - 1) {
|
|
||||||
$post->cls = 'item last';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$post->cls = 'item';
|
|
||||||
}
|
|
||||||
|
|
||||||
$tmp[] = $post;
|
$tmp[] = $post;
|
||||||
}
|
}
|
||||||
|
|
@ -648,16 +616,16 @@ function publisher(){
|
||||||
function analytics(){
|
function analytics(){
|
||||||
$analytics = config('google.analytics.id');
|
$analytics = config('google.analytics.id');
|
||||||
$script = <<<EOF
|
$script = <<<EOF
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var _gaq = _gaq || [];
|
var _gaq = _gaq || [];
|
||||||
_gaq.push(['_setAccount', '{$analytics}']);
|
_gaq.push(['_setAccount', '{$analytics}']);
|
||||||
_gaq.push(['_trackPageview']);
|
_gaq.push(['_trackPageview']);
|
||||||
(function() {
|
(function() {
|
||||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
EOF;
|
EOF;
|
||||||
if (!empty($analytics)) {
|
if (!empty($analytics)) {
|
||||||
return $script;
|
return $script;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,19 @@
|
||||||
<?php if (!empty($breadcrumb)):?><div class="breadcrumb"><?php echo $breadcrumb ?></div><?php endif;?>
|
<?php if (!empty($breadcrumb)):?><div class="breadcrumb"><?php echo $breadcrumb ?></div><?php endif;?>
|
||||||
|
<?php $i = 0; $len = count($posts);?>
|
||||||
<?php foreach($posts as $p):?>
|
<?php foreach($posts as $p):?>
|
||||||
<div class="post <?php echo $p->cls ?>" itemprop="blogPost" itemscope="itemscope" itemtype="http://schema.org/BlogPosting">
|
<?php
|
||||||
|
if ($i == 0) {
|
||||||
|
$class = 'first';
|
||||||
|
}
|
||||||
|
elseif ($i == $len - 1) {
|
||||||
|
$class = 'last';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$class = '';
|
||||||
|
}
|
||||||
|
$i++;
|
||||||
|
?>
|
||||||
|
<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 ucfirst($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">Komentar</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"><a href="<?php echo $p->tagurl ?>"><?php echo ucfirst($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">Komentar</a></span><?php endif;?></div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue