Skip to content

Commit

Permalink
Merge branch 'danpros:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
sb0001 authored Mar 3, 2024
2 parents fa0b0e9 + a749ef2 commit e35cc2c
Show file tree
Hide file tree
Showing 14 changed files with 65 additions and 47 deletions.
12 changes: 8 additions & 4 deletions system/admin/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -1010,7 +1010,9 @@ function find_draft_page($static = null)

$tmp = array();

if (config('views.counter') == 'true') {
$counter = config('views.counter');

if ($counter == 'true') {
$viewsFile = "content/data/views.json";
if (file_exists($viewsFile)) {
$views = json_decode(file_get_contents($viewsFile), true);
Expand Down Expand Up @@ -1052,7 +1054,7 @@ function find_draft_page($static = null)
// Get the contents and convert it to HTML
$post->body = MarkdownExtra::defaultTransform(remove_html_comments($content));

if (config('views.counter') == 'true') {
if ($counter == 'true') {
$post->views = get_views('page_' . $post->slug, $post->file, $views);
} else {
$post->views = null;
Expand All @@ -1078,7 +1080,9 @@ function find_draft_subpage($static = null, $sub_static = null)

$tmp = array();

if (config('views.counter') == 'true') {
$counter = config('views.counter');

if ($counter == 'true') {
$viewsFile = "content/data/views.json";
if (file_exists($viewsFile)) {
$views = json_decode(file_get_contents($viewsFile), true);
Expand Down Expand Up @@ -1129,7 +1133,7 @@ function find_draft_subpage($static = null, $sub_static = null)
// Get the contents and convert it to HTML
$post->body = MarkdownExtra::defaultTransform(remove_html_comments($content));

if (config('views.counter') == 'true') {
if ($counter == 'true') {
$post->views = get_views('subpage_' . $post->parentSlug .'.'. $post->slug, $post->file, $views);
} else {
$post->views = null;
Expand Down
51 changes: 30 additions & 21 deletions system/includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,13 @@ function get_posts($posts, $page = 1, $perpage = 0)
$posts = array_slice($posts, ($page - 1) * $perpage, $perpage);

$cList = category_list(true);

if (config('views.counter') == 'true') {

$auto = config('toc.automatic');
$counter = config('views.counter');
$caption = config('fig.captions');
$permalink = config('permalink.type');

if ($counter == 'true') {
$viewsFile = "content/data/views.json";
if (file_exists($viewsFile)) {
$views = json_decode(file_get_contents($viewsFile), true);
Expand Down Expand Up @@ -459,7 +464,7 @@ function get_posts($posts, $page = 1, $perpage = 0)
// The archive per day
$post->archive = site_url() . 'archive/' . date('Y-m', $post->date);

if (config('permalink.type') == 'post') {
if ($permalink == 'post') {
$post->url = site_url() . 'post/' . str_replace('.md', '', $arr[2]);
} else {
$post->url = site_url() . date('Y/m', $post->date) . '/' . str_replace('.md', '', $arr[2]);
Expand Down Expand Up @@ -535,18 +540,17 @@ function get_posts($posts, $page = 1, $perpage = 0)
if (isset($toc['1'])) {
$post->body = insert_toc('post-' . $post->date, $toc['0'], $toc['1']);
} else {
$auto = config('toc.automatic');
if ($auto === 'true') {
$post->body = automatic_toc($post->body, 'post-' . $post->date);
}
}

// Convert image tags to figures
if (config('fig.captions') == 'true') {
if ($caption == 'true') {
$post->body = preg_replace( '/<p>(<img .*?alt="(.*?)"\s*\/>)<\/p>/', '<figure>$1<figcaption>$2</figcaption></figure>', $post->body );
}

if (config('views.counter') == 'true') {
if ($counter == 'true') {
$post->views = get_views('post_' . $post->slug, $post->file, $views);
} else {
$post->views = null;
Expand All @@ -565,8 +569,11 @@ function get_pages($pages, $page = 1, $perpage = 0)
}

$tmp = array();

$auto = config('toc.automatic');
$counter = config('views.counter');

if (config('views.counter') == 'true') {
if ($counter == 'true') {
$viewsFile = "content/data/views.json";
if (file_exists($viewsFile)) {
$views = json_decode(file_get_contents($viewsFile), true);
Expand Down Expand Up @@ -616,13 +623,12 @@ function get_pages($pages, $page = 1, $perpage = 0)
if (isset($toc['1'])) {
$post->body = insert_toc('page-' . $post->slug, $toc['0'], $toc['1']);
} else {
$auto = config('toc.automatic');
if ($auto === 'true') {
$post->body = automatic_toc($post->body, 'page-' . $post->slug);
}
}

if (config('views.counter') == 'true') {
if ($counter == 'true') {
$post->views = get_views('page_' . $post->slug, $post->file, $views);
} else {
$post->views = null;
Expand All @@ -642,8 +648,11 @@ function get_subpages($sub_pages, $page = 1, $perpage = 0)
}

$tmp = array();

$auto = config('toc.automatic');
$counter = config('views.counter');

if (config('views.counter') == 'true') {
if ($counter == 'true') {
$viewsFile = "content/data/views.json";
if (file_exists($viewsFile)) {
$views = json_decode(file_get_contents($viewsFile), true);
Expand Down Expand Up @@ -703,13 +712,12 @@ function get_subpages($sub_pages, $page = 1, $perpage = 0)
if (isset($toc['1'])) {
$post->body = insert_toc('subpage-' . $post->slug, $toc['0'], $toc['1']);
} else {
$auto = config('toc.automatic');
if ($auto === 'true') {
$post->body = automatic_toc($post->body, 'subpage-' . $post->slug);
}
}

if (config('views.counter') == 'true') {
if ($counter == 'true') {
$post->views = get_views('subpage_' . $post->parentSlug .'.'. $post->slug, $post->file, $views);
} else {
$post->views = null;
Expand Down Expand Up @@ -2210,6 +2218,7 @@ function get_teaser($string, $url = null, $char = null)
{
$teaserType = config('teaser.type');
$more = config('read.more');
$behave = config('teaser.behave');

if(empty($more)) {
$more = 'Read more';
Expand All @@ -2231,7 +2240,7 @@ function get_teaser($string, $url = null, $char = null)
return $string;
}
} else {
if (config('teaser.behave') === 'check') {
if ($behave === 'check') {
$readMore = explode('<!--more-->', $string);
if (isset($readMore['1'])) {
$string = shorten($readMore[0]);
Expand Down Expand Up @@ -2387,35 +2396,35 @@ function social($class = null)
$social .= '<div class="social-logo ' . $class . '">';
$social .= '<link rel="stylesheet" id="social-logo-style" href="'. site_url() .'system/resources/css/social-logos.css" type="text/css" media="all">';
if (!empty($twitter)) {
$social .= '<a class="social-logo-twitter-alt" href="' . $twitter . '" target="_blank"><span class="screen-reader-text">Twitter</span></a>';
$social .= '<a class="social-logo-twitter-alt" href="' . $twitter . '" target="_blank" rel="nofollow"><span class="screen-reader-text">Twitter</span></a>';
}

if (!empty($facebook)) {
$social .= '<a class="social-logo-facebook" href="' . $facebook . '" target="_blank"><span class="screen-reader-text">Facebook</span></a>';
$social .= '<a class="social-logo-facebook" href="' . $facebook . '" target="_blank" rel="nofollow"><span class="screen-reader-text">Facebook</span></a>';
}

if (!empty($instagram)) {
$social .= '<a class="social-logo-instagram" href="' . $instagram . '" target="_blank"><span class="screen-reader-text">Instagram</span></a>';
$social .= '<a class="social-logo-instagram" href="' . $instagram . '" target="_blank" rel="nofollow"><span class="screen-reader-text">Instagram</span></a>';
}

if (!empty($linkedin)) {
$social .= '<a class="social-logo-linkedin" href="' . $linkedin . '" target="_blank"><span class="screen-reader-text">Linkedin</span></a>';
$social .= '<a class="social-logo-linkedin" href="' . $linkedin . '" target="_blank" rel="nofollow"><span class="screen-reader-text">Linkedin</span></a>';
}

if (!empty($github)) {
$social .= '<a class="social-logo-github" href="' . $github . '" target="_blank"><span class="screen-reader-text">Github</span></a>';
$social .= '<a class="social-logo-github" href="' . $github . '" target="_blank" rel="nofollow"><span class="screen-reader-text">Github</span></a>';
}

if (!empty($youtube)) {
$social .= '<a class="social-logo-youtube" href="' . $youtube . '" target="_blank"><span class="screen-reader-text">Youtube</span></a>';
$social .= '<a class="social-logo-youtube" href="' . $youtube . '" target="_blank" rel="nofollow"><span class="screen-reader-text">Youtube</span></a>';
}

if (!empty($mastodon)) {
$social .= '<a class="social-logo-mastodon" href="' . $mastodon . '" target="_blank"><span class="screen-reader-text">Mastodon</span></a>';
$social .= '<a class="social-logo-mastodon" href="' . $mastodon . '" target="_blank" rel="nofollow"><span class="screen-reader-text">Mastodon</span></a>';
}

if (!empty($tiktok)) {
$social .= '<a class="social-logo-tiktok" href="' . $tiktok . '" target="_blank"><span class="screen-reader-text">TikTok</span></a>';
$social .= '<a class="social-logo-tiktok" href="' . $tiktok . '" target="_blank" rel="nofollow"><span class="screen-reader-text">TikTok</span></a>';
}

$social .= '<a class="social-logo-feed" href="' . $rss . '" target="_blank"><span class="screen-reader-text">RSS</span></a>';
Expand Down
8 changes: 5 additions & 3 deletions themes/blog/main.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
</div>
</div>
<?php endif; ?>
<?php $teaserType = config('teaser.type'); $readMore = config('read.more');?>
<?php foreach ($posts as $p): ?>
<section class="post section" itemprop="blogPost" itemscope="itemscope" itemtype="http://schema.org/BlogPosting">
<div class="section-inner">
Expand Down Expand Up @@ -61,11 +62,12 @@
</p>
</div>
<div class="desc text-left post-<?php echo $p->date;?>" itemprop="articleBody">
<?php echo get_teaser($p->body, $p->url) ?>
<?php echo get_teaser($p->body, $p->url);?>
<?php if ($teaserType === 'trimmed'):?>[...]<?php endif;?>
</div><!--//desc-->
<div style="position:relative;">
<?php if (config('teaser.type') === 'trimmed'):?>
<span class="more"><a class="btn btn-cta-secondary" href="<?php echo $p->url;?>"><?php echo config('read.more'); ?></a></span>
<?php if ($teaserType === 'trimmed'):?>
<span class="more"><a class="btn btn-cta-secondary" href="<?php echo $p->url;?>"><?php echo $readMore; ?></a></span>
<?php endif;?>
<span class="share pull-right">
<a target="_blank" class="first" href="https://www.facebook.com/sharer.php?u=<?php echo $p->url ?>&t=<?php echo $p->title ?>"><i class="fa fa-facebook"></i></a>
Expand Down
3 changes: 2 additions & 1 deletion themes/clean/main.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
</div>
</div>
<?php endif; ?>
<?php $teaserType = config('teaser.type'); $readMore = config('read.more');?>
<?php foreach ($posts as $p): ?>
<div class="post" itemprop="blogPost" itemscope="itemscope" itemtype="http://schema.org/BlogPosting">
<div class="main">
Expand Down Expand Up @@ -52,7 +53,7 @@
<div class="teaser-body post-<?php echo $p->date;?>" itemprop="articleBody">
<?php echo get_thumbnail($p->body) ?>
<?php echo get_teaser($p->body, $p->url) ?>
<?php if (config('teaser.type') === 'trimmed'):?><a href="<?php echo $p->url;?>"><?php echo config('read.more'); ?></a><?php endif;?>
<?php if ($teaserType === 'trimmed'):?>[...] <a href="<?php echo $p->url;?>"><?php echo $readMore; ?></a><?php endif;?>
</div>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions themes/clean/post.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@
</div>
<div class="postnav">
<?php if (!empty($next)): ?>
<span><a href="<?php echo($next['url']); ?>" class="pagination-arrow newer" rel="next"><?php echo($next['title']); ?></a></span>
<span><a href="<?php echo($next['url']); ?>" class="pagination-arrow newer" rel="next" style="margin-bottom:5px;"><?php echo($next['title']); ?></a></span>
<?php endif; ?>
<?php if (!empty($prev)): ?>
<span><a href="<?php echo($prev['url']); ?>" class="pagination-arrow older" rel="prev"><?php echo($prev['title']); ?></a></span>
<span><a href="<?php echo($prev['url']); ?>" class="pagination-arrow older" rel="prev" style="margin-bottom:5px;"><?php echo($prev['title']); ?></a></span>
<?php endif; ?>
</div>
<?php if (disqus()): ?>
Expand Down
4 changes: 2 additions & 2 deletions themes/clean/profile.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
<?php if (!empty($pagination['prev']) || !empty($pagination['next'])): ?>
<div class="pager">
<?php if (!empty($pagination['prev'])): ?>
<span><a href="?page=<?php echo $page - 1 ?>" class="pagination-arrow newer" rel="prev">Newer</a></span>
<span><a href="?page=<?php echo $page - 1 ?>" class="pagination-arrow newer" rel="prev"><?php echo i18n('Newer'); ?></a></span>
<?php endif; ?>
<span class="page-number"><?php echo $pagination['pagenum']; ?></span>
<?php if (!empty($pagination['next'])): ?>
<span><a href="?page=<?php echo $page + 1 ?>" class="pagination-arrow older" rel="next">Older</a></span>
<span><a href="?page=<?php echo $page + 1 ?>" class="pagination-arrow older" rel="next"><?php echo i18n('Older'); ?></a></span>
<?php endif; ?>
</div>
<?php endif; ?>
Expand Down
4 changes: 2 additions & 2 deletions themes/clean/static.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
<div class="border"></div>
<div class="postnav">
<?php if (!empty($next)): ?>
<span><a href="<?php echo($next['url']); ?>" class="pagination-arrow newer" rel="next"><?php echo($next['title']); ?></a></span>
<span><a href="<?php echo($next['url']); ?>" class="pagination-arrow newer" rel="next" style="margin-bottom:5px;"><?php echo($next['title']); ?></a></span>
<?php endif; ?>
<?php if (!empty($prev)): ?>
<span><a href="<?php echo($prev['url']); ?>" class="pagination-arrow older" rel="prev"><?php echo($prev['title']); ?></a></span>
<span><a href="<?php echo($prev['url']); ?>" class="pagination-arrow older" rel="prev" style="margin-bottom:5px;"><?php echo($prev['title']); ?></a></span>
<?php endif; ?>
</div>
</div>
2 changes: 1 addition & 1 deletion themes/doks/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -2797,7 +2797,7 @@ pre code::-webkit-scrollbar-thumb:hover {
padding:0.4375rem 0
}
#mode {
margin-right:1.25rem
margin-right:0.5rem
}
.btn-link:focus {
outline:0;
Expand Down
4 changes: 2 additions & 2 deletions themes/doks/main.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
</div>
</div>
<?php endif;?>

<?php $teaserType = config('teaser.type'); $readMore = config('read.more');?>
<?php foreach ($posts as $post):?>
<?php $img = get_image($post->body);?>
<article>
Expand Down Expand Up @@ -101,7 +101,7 @@

<div class="content-body">
<?php echo get_teaser($post->body, $post->url); ?>
<?php if (config('teaser.type') === 'trimmed'):?><a class="more-link" href="<?php echo $post->url; ?>"><?php echo config('read.more'); ?></a><?php endif;?>
<?php if ($teaserType === 'trimmed'):?>[...] <a class="more-link" href="<?php echo $post->url; ?>"><?php echo $readMore; ?></a><?php endif;?>
</div>

<p>
Expand Down
6 changes: 3 additions & 3 deletions themes/doks/profile.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<div class="lead"><?php echo $author->about;?></div>
</div>
</div>

<?php $teaserType = config('teaser.type'); $readMore = config('read.more');?>
<?php if (!empty($posts)):?>
<?php foreach ($posts as $post):?>
<?php $img = get_image($post->body);?>
Expand All @@ -17,7 +17,7 @@

<?php if (!empty($post->image)) {?>
<a href="<?php echo $post->url;?>"><img alt="<?php echo $post->title;?>" src="<?php echo $post->image;?>" width="100%"></a>
<?php } elseif (!empty($img) && config('teaser.type') === 'trimmed') {?>
<?php } elseif (!empty($img) && $teaserType === 'trimmed') {?>
<a href="<?php echo $post->url;?>"><img alt="<?php echo $post->title;?>" src="<?php echo $img;?>" width="100%"></a>
<?php } ?>

Expand Down Expand Up @@ -48,7 +48,7 @@

<div class="content-body">
<?php echo get_teaser($post->body, $post->url); ?>
<?php if (config('teaser.type') === 'trimmed'):?><a class="more-link" href="<?php echo $post->url; ?>"><?php echo config('read.more'); ?></a><?php endif;?>
<?php if ($teaserType === 'trimmed'):?>[...] <a class="more-link" href="<?php echo $post->url; ?>"><?php echo $readMore; ?></a><?php endif;?>
</div>

<p>
Expand Down
4 changes: 2 additions & 2 deletions themes/logs/main.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
</div>
</div>
<?php endif; ?>
<?php $teaserType = config('teaser.type'); $readMore = config('read.more');?>
<?php foreach ($posts as $p): ?>
<div class="post" itemprop="blogPost" itemscope="itemscope" itemtype="http://schema.org/BlogPosting">
<div class="main">
Expand Down Expand Up @@ -50,9 +51,8 @@
</div>
<?php } ?>
<div class="teaser-body post-<?php echo $p->date;?>" itemprop="articleBody">
<?php echo get_thumbnail($p->body) ?>
<?php echo get_teaser($p->body, $p->url) ?>
<?php if (config('teaser.type') === 'trimmed'):?><a href="<?php echo $p->url;?>"><?php echo config('read.more'); ?></a><?php endif;?>
<?php if ($teaserType === 'trimmed'):?>[...] <a href="<?php echo $p->url;?>"><?php echo $readMore; ?></a><?php endif;?>
</div>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions themes/readable/main.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
</div>
</div>
<?php endif; ?>
<?php $teaserType = config('teaser.type'); $readMore = config('read.more');?>
<?php foreach ($posts as $p): ?>
<div class="post" itemprop="blogPost" itemscope="itemscope" itemtype="http://schema.org/BlogPosting">
<div class="main">
Expand Down Expand Up @@ -50,9 +51,8 @@
</div>
<?php } ?>
<div class="teaser-body post-<?php echo $p->date;?>" itemprop="articleBody">
<?php echo get_thumbnail($p->body) ?>
<?php echo get_teaser($p->body, $p->url) ?>
<?php if (config('teaser.type') === 'trimmed'):?><a href="<?php echo $p->url;?>"><?php echo config('read.more'); ?></a><?php endif;?>
<?php if ($teaserType === 'trimmed'):?>[...] <a href="<?php echo $p->url;?>"><?php echo $readMore; ?></a><?php endif;?>
</div>
</div>
</div>
Expand Down
3 changes: 2 additions & 1 deletion themes/twentyfifteen/main.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<h1 class="page-title">Type: <?php echo ucfirst($type->title);?></h1>
</header>
<?php endif;?>
<?php $teaserType = config('teaser.type'); $readMore = config('read.more');?>
<?php foreach ($posts as $p): ?>
<article class="post type-post hentry <?php if (!empty($p->image) || !empty ($p->audio) || !empty ($p->video)):?>has-post-thumbnail<?php endif;?>">
<?php if (!empty($p->image)):?>
Expand Down Expand Up @@ -63,7 +64,7 @@
<?php } ?>
<div class="entry-content post-<?php echo $p->date;?>">
<?php echo get_teaser($p->body, $p->url); ?>
<?php if (config('teaser.type') === 'trimmed'):?><a class="more-link" href="<?php echo $p->url; ?>"><?php echo config('read.more'); ?></a><?php endif;?>
<?php if ($teaserType === 'trimmed'):?>[...] <a class="more-link" href="<?php echo $p->url; ?>"><?php echo $readMore; ?></a><?php endif;?>
</div>
<footer class="entry-footer">
<span class="posted-on">
Expand Down
Loading

0 comments on commit e35cc2c

Please sign in to comment.