0.7.1
This commit is contained in:
parent
75773ee369
commit
78cdfb6fe9
|
@ -0,0 +1,100 @@
|
|||
<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
|
||||
<?php $this->need('module/header.php'); ?>
|
||||
<?php
|
||||
// 获取特殊高亮的分类ID
|
||||
$highlightCategoryId = Helper::options()->highlight_category;
|
||||
?>
|
||||
<header class="archive--header">
|
||||
<h2 class="post--single__title">
|
||||
<?php $this->archiveTitle(array(
|
||||
'category' => _t(' <span> %s </span> '),
|
||||
'search' => _t('包含关键字<span> %s </span>的文章'),
|
||||
'date' => _t('在 <span> %s </span>发布的文章'),
|
||||
'tag' => _t('标签 <span> %s </span>下的文章'),
|
||||
'author' => _t('作者 <span>%s </span>发布的文章')
|
||||
), '', ''); ?>
|
||||
</h2>
|
||||
<?php if ($this->is('category') && $this->categoryDescription()): ?>
|
||||
<div class="taxonomy--description">
|
||||
<?php $this->categorydescription(); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</header>
|
||||
<div class="site--main">
|
||||
<div class="post--cards">
|
||||
<?php if ($this->have()): ?>
|
||||
<?php while($this->next()): ?>
|
||||
<?php
|
||||
// 获取文章的所有分类
|
||||
$currentCategories = $this->categories;
|
||||
// 检查是否为高亮分类
|
||||
$isHighlightCategory = false;
|
||||
foreach ($currentCategories as $category) {
|
||||
if ($category['mid'] == $highlightCategoryId) {
|
||||
$isHighlightCategory = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// 获取文章图片
|
||||
$default_thumbnail = Helper::options()->themeUrl . '/assets/images/nopic.svg';
|
||||
$firstImage = img_postthumb($this->cid);
|
||||
if (empty($firstImage)) {
|
||||
$firstImage = $default_thumbnail;
|
||||
}
|
||||
$cover = $this->fields->cover;
|
||||
$imageToDisplay = $cover;
|
||||
if (empty($imageToDisplay)) {
|
||||
$imageToDisplay = $firstImage;
|
||||
}
|
||||
?>
|
||||
<article class="post--card">
|
||||
<img src="<?php echo $imageToDisplay; ?>" alt="<?php $this->title() ?>" class="cover" itemprop="image"/>
|
||||
<div class="content">
|
||||
<h2 class="post--title">
|
||||
<a href="<?php $this->permalink() ?>">
|
||||
<?php $this->title() ?>
|
||||
</a>
|
||||
</h2>
|
||||
<div class="description">
|
||||
<?php $this->excerpt(20, '...'); ?>
|
||||
</div>
|
||||
<div class="meta">
|
||||
<svg class="icon" viewBox="0 0 1024 1024" width="16" height="16">
|
||||
<path d="M512 97.52381c228.912762 0 414.47619 185.563429 414.47619 414.47619s-185.563429 414.47619-414.47619 414.47619S97.52381 740.912762 97.52381 512 283.087238 97.52381 512 97.52381z m0 73.142857C323.486476 170.666667 170.666667 323.486476 170.666667 512s152.81981 341.333333 341.333333 341.333333 341.333333-152.81981 341.333333-341.333333S700.513524 170.666667 512 170.666667z m36.571429 89.697523v229.86362h160.865523v73.142857H512a36.571429 36.571429 0 0 1-36.571429-36.571429V260.388571h73.142858z"></path>
|
||||
</svg>
|
||||
<time datetime='<?php $this->date('Y-m-d'); ?>' class="humane--time">
|
||||
<?php $this->date('Y-m-d'); ?>
|
||||
</time>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
<?php endwhile; ?>
|
||||
</div>
|
||||
<?php $this->pageNav(
|
||||
' ',
|
||||
' ',
|
||||
1,
|
||||
'...',
|
||||
array(
|
||||
'wrapTag' => 'nav',
|
||||
'wrapClass' => 'nav-links nav-links__comment',
|
||||
'itemTag' => '',
|
||||
'textTag' => 'span',
|
||||
'itemClass' => 'page-numbers',
|
||||
'currentClass' => 'page-numbers current',
|
||||
'prevClass' => 'hidden',
|
||||
'nextClass' => 'hidden'
|
||||
)
|
||||
); ?>
|
||||
<?php else: ?>
|
||||
<main class="site--main">
|
||||
<header class="archive-header archive-header__search">
|
||||
<div class="pagination">
|
||||
<h2>Sorry</h2>
|
||||
<p>很遗憾,未找到您期待的内容</p>
|
||||
</div>
|
||||
</header>
|
||||
</main>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php $this->need('module/footer.php'); ?>
|
196
archive.php
196
archive.php
|
@ -1,77 +1,141 @@
|
|||
<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
|
||||
<?php $this->need('module/header.php'); ?>
|
||||
<main class="site--main">
|
||||
<header class="archive--header"><?php if ($this->have()): ?>
|
||||
<h2 class="post--single__title"><?php $this->archiveTitle(array(
|
||||
<?php
|
||||
// 获取高亮分类ID
|
||||
$travelId = Helper::options()->travel;
|
||||
|
||||
// 处理可能的情况
|
||||
$travelId = is_array($travelId)
|
||||
? intval(reset($travelId))
|
||||
: intval($travelId);
|
||||
?>
|
||||
|
||||
<header class="archive--header">
|
||||
<h2 class="post--single__title">
|
||||
<?php $this->archiveTitle(array(
|
||||
'category' => _t(' <span> %s </span> '),
|
||||
'search' => _t('包含关键字<span> %s </span>的文章'),
|
||||
'date' => _t('在 <span> %s </span>发布的文章'),
|
||||
'tag' => _t('标签 <span> %s </span>下的文章'),
|
||||
'author' => _t('作者 <span>%s </span>发布的文章')
|
||||
), '', ''); ?></h2>
|
||||
<h3 class="post--single__subtitle"><?php $this->categorydescription(); ?></h3>
|
||||
), '', ''); ?>
|
||||
</h2>
|
||||
<?php if ($this->is('category') && $this->categoryDescription()): ?>
|
||||
<div class="taxonomy--description">
|
||||
<?php $this->categorydescription(); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</header>
|
||||
<div class="site--main">
|
||||
<div class="<?php echo ($this->category == $travelId) ? 'post--cards' : 'post--item'; ?>">
|
||||
<?php if ($this->have()): ?>
|
||||
<?php while($this->next()): ?>
|
||||
</header>
|
||||
<article class="post--item">
|
||||
<div class="content">
|
||||
<h2 class="post--title">
|
||||
<a href="<?php $this->permalink() ?>"><?php $this->title() ?></a>
|
||||
</h2>
|
||||
<div class="description">
|
||||
<?php
|
||||
// 判断是否存在自定义字段summary并输出,否则输出自动生成的摘要
|
||||
if($this->fields->summary){echo $this->fields->summary;} else {$this->excerpt(180); }
|
||||
?>
|
||||
</div>
|
||||
<div class="meta">
|
||||
<svg class="icon" viewBox="0 0 1024 1024" width="16" height="16">
|
||||
<path
|
||||
d="M512 97.52381c228.912762 0 414.47619 185.563429 414.47619 414.47619s-185.563429 414.47619-414.47619 414.47619S97.52381 740.912762 97.52381 512 283.087238 97.52381 512 97.52381z m0 73.142857C323.486476 170.666667 170.666667 323.486476 170.666667 512s152.81981 341.333333 341.333333 341.333333 341.333333-152.81981 341.333333-341.333333S700.513524 170.666667 512 170.666667z m36.571429 89.697523v229.86362h160.865523v73.142857H512a36.571429 36.571429 0 0 1-36.571429-36.571429V260.388571h73.142858z">
|
||||
</path>
|
||||
</svg><time><?php $this->date('Y-m-d'); ?></time>
|
||||
<svg class="icon" viewBox="0 0 1024 1024" width="16" height="16">
|
||||
<path
|
||||
d="M408.551619 97.52381a73.142857 73.142857 0 0 1 51.736381 21.430857L539.306667 197.973333A73.142857 73.142857 0 0 0 591.067429 219.428571H804.571429a73.142857 73.142857 0 0 1 73.142857 73.142858v560.761904a73.142857 73.142857 0 0 1-73.142857 73.142857H219.428571a73.142857 73.142857 0 0 1-73.142857-73.142857V170.666667a73.142857 73.142857 0 0 1 73.142857-73.142857h189.123048z m0 73.142857H219.428571v682.666666h585.142858V292.571429h-213.504a146.285714 146.285714 0 0 1-98.499048-38.13181L487.619048 249.734095 408.551619 170.666667zM365.714286 633.904762v73.142857h-73.142857v-73.142857h73.142857z m365.714285 0v73.142857H414.47619v-73.142857h316.952381z m-365.714285-195.047619v73.142857h-73.142857v-73.142857h73.142857z m365.714285 0v73.142857H414.47619v-73.142857h316.952381z">
|
||||
</path>
|
||||
</svg><?php $this->category(','); ?>
|
||||
<svg viewBox="0 0 24 24" class="icon" aria-hidden="true" width="16" height="16">
|
||||
<g>
|
||||
<path
|
||||
d="M1.751 10c0-4.42 3.584-8 8.005-8h4.366c4.49 0 8.129 3.64 8.129 8.13 0 2.96-1.607 5.68-4.196 7.11l-8.054 4.46v-3.69h-.067c-4.49.1-8.183-3.51-8.183-8.01zm8.005-6c-3.317 0-6.005 2.69-6.005 6 0 3.37 2.77 6.08 6.138 6.01l.351-.01h1.761v2.3l5.087-2.81c1.951-1.08 3.163-3.13 3.163-5.36 0-3.39-2.744-6.13-6.129-6.13H9.756z">
|
||||
</path>
|
||||
</g>
|
||||
</svg><a href="<?php $this->permalink() ?>#comments"><?php $this->commentsNum('0 ', '1 ', '%d '); ?></a>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
<?php endwhile; ?>
|
||||
</main>
|
||||
<?php $this->pageNav(
|
||||
' ',
|
||||
' ',
|
||||
1,
|
||||
'...',
|
||||
array(
|
||||
'wrapTag' => 'nav',
|
||||
'wrapClass' => 'nav-links nav-links__comment',
|
||||
'itemTag' => '',
|
||||
'textTag' => 'span',
|
||||
'itemClass' => 'page-numbers',
|
||||
'currentClass' => 'page-numbers current',
|
||||
'prevClass' => 'hidden',
|
||||
'nextClass' => 'hidden'
|
||||
)
|
||||
);
|
||||
?>
|
||||
<!-- 搜索结果 -->
|
||||
<?php else: ?>
|
||||
<main class="site--main">
|
||||
<header class="archive-header archive-header__search">
|
||||
<div class="pagination">
|
||||
<h2>Sorry</h2>
|
||||
<p>很遗憾,未找到您期待的内容</p>
|
||||
<?php
|
||||
// 使用数组函数优化分类检查
|
||||
$istravel = array_reduce($this->categories, function($carry, $category) use ($travelId) {
|
||||
return $carry || (intval($category['mid']) === $travelId);
|
||||
}, false);
|
||||
|
||||
// 获取文章图片
|
||||
$default_thumbnail = Helper::options()->themeUrl . '/assets/images/nopic.svg';
|
||||
$firstImage = img_postthumb($this->cid);
|
||||
if (empty($firstImage)) {
|
||||
$firstImage = $default_thumbnail;
|
||||
}
|
||||
$cover = $this->fields->cover;
|
||||
$imageToDisplay = $cover;
|
||||
if (empty($imageToDisplay)) {
|
||||
$imageToDisplay = $firstImage;
|
||||
}
|
||||
?>
|
||||
|
||||
<?php if ($istravel): ?>
|
||||
<!-- 高亮分类下的样式 -->
|
||||
|
||||
<article class="post--card">
|
||||
<img src="<?php echo $imageToDisplay; ?>" alt="<?php $this->title() ?>" class="cover" itemprop="image"/>
|
||||
<div class="content">
|
||||
<h2 class="post--title">
|
||||
<a href="<?php $this->permalink() ?>">
|
||||
<?php $this->title() ?>
|
||||
</a>
|
||||
</h2>
|
||||
<div class="description">
|
||||
<?php $this->excerpt(20, '...'); ?>
|
||||
</div>
|
||||
<div class="meta">
|
||||
<svg class="icon" viewBox="0 0 1024 1024" width="16" height="16">
|
||||
<path d="M512 97.52381c228.912762 0 414.47619 185.563429 414.47619 414.47619s-185.563429 414.47619-414.47619 414.47619S97.52381 740.912762 97.52381 512 283.087238 97.52381 512 97.52381z m0 73.142857C323.486476 170.666667 170.666667 323.486476 170.666667 512s152.81981 341.333333 341.333333 341.333333 341.333333-152.81981 341.333333-341.333333S700.513524 170.666667 512 170.666667z m36.571429 89.697523v229.86362h160.865523v73.142857H512a36.571429 36.571429 0 0 1-36.571429-36.571429V260.388571h73.142858z"></path>
|
||||
</svg>
|
||||
<time datetime='<?php $this->date('Y-m-d'); ?>' class="humane--time">
|
||||
<?php $this->date('Y-m-d'); ?>
|
||||
</time>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
|
||||
<?php else: ?>
|
||||
<!-- 正常分类下的样式 -->
|
||||
<article class="post--item">
|
||||
<div class="content">
|
||||
<h2 class="post--title">
|
||||
<a href="<?php $this->permalink() ?>"><?php $this->title() ?></a>
|
||||
</h2>
|
||||
<div class="description">
|
||||
<?php
|
||||
// 使用三元运算符简化摘要处理
|
||||
echo $this->fields->summary
|
||||
? $this->fields->summary
|
||||
: $this->excerpt(180);
|
||||
?>
|
||||
</div>
|
||||
<div class="meta">
|
||||
<svg class="icon" viewBox="0 0 1024 1024" width="16" height="16">
|
||||
<path d="M512 97.52381c228.912762 0 414.47619 185.563429 414.47619 414.47619s-185.563429 414.47619-414.47619 414.47619S97.52381 740.912762 97.52381 512 283.087238 97.52381 512 97.52381z m0 73.142857C323.486476 170.666667 170.666667 323.486476 170.666667 512s152.81981 341.333333 341.333333 341.333333 341.333333-152.81981 341.333333-341.333333S700.513524 170.666667 512 170.666667z m36.571429 89.697523v229.86362h160.865523v73.142857H512a36.571429 36.571429 0 0 1-36.571429-36.571429V260.388571h73.142858z"></path>
|
||||
</svg>
|
||||
<time><?php $this->date('Y-m-d'); ?></time>
|
||||
<svg class="icon" viewBox="0 0 1024 1024" width="16" height="16">
|
||||
<path d="M408.551619 97.52381a73.142857 73.142857 0 0 1 51.736381 21.430857L539.306667 197.973333A73.142857 73.142857 0 0 0 591.067429 219.428571H804.571429a73.142857 73.142857 0 0 1 73.142857 73.142858v560.761904a73.142857 73.142857 0 0 1-73.142857 73.142857H219.428571a73.142857 73.142857 0 0 1-73.142857-73.142857V170.666667a73.142857 73.142857 0 0 1 73.142857-73.142857h189.123048z m0 73.142857H219.428571v682.666666h585.142858V292.571429h-213.504a146.285714 146.285714 0 0 1-98.499048-38.13181L487.619048 249.734095 408.551619 170.666667zM365.714286 633.904762v73.142857h-73.142857v-73.142857h73.142857z m365.714285 0v73.142857H414.47619v-73.142857h316.952381z m-365.714285-195.047619v73.142857h-73.142857v-73.142857h73.142857z m365.714285 0v73.142857H414.47619v-73.142857h316.952381z"></path>
|
||||
</svg>
|
||||
<?php $this->category(','); ?>
|
||||
<svg viewBox="0 0 24 24" class="icon" aria-hidden="true" width="16" height="16">
|
||||
<g>
|
||||
<path d="M1.751 10c0-4.42 3.584-8 8.005-8h4.366c4.49 0 8.129 3.64 8.129 8.13 0 2.96-1.607 5.68-4.196 7.11l-8.054 4.46v-3.69h-.067c-4.49.1-8.183-3.51-8.183-8.01zm8.005-6c-3.317 0-6.005 2.69-6.005 6 0 3.37 2.77 6.08 6.138 6.01l.351-.01h1.761v2.3l5.087-2.81c1.951-1.08 3.163-3.13 3.163-5.36 0-3.39-2.744-6.13-6.129-6.13H9.756z"></path>
|
||||
</g>
|
||||
</svg>
|
||||
<a href="<?php $this->permalink() ?>#comments"><?php $this->commentsNum('0 ', '1 ', '%d '); ?></a>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php endwhile; ?>
|
||||
</div>
|
||||
</header>
|
||||
<?php $this->pageNav(
|
||||
' ',
|
||||
' ',
|
||||
1,
|
||||
'...',
|
||||
array(
|
||||
'wrapTag' => 'nav',
|
||||
'wrapClass' => 'nav-links nav-links__comment',
|
||||
'itemTag' => '',
|
||||
'textTag' => 'span',
|
||||
'itemClass' => 'page-numbers',
|
||||
'currentClass' => 'page-numbers current',
|
||||
'prevClass' => 'hidden',
|
||||
'nextClass' => 'hidden'
|
||||
)
|
||||
); ?>
|
||||
<?php else: ?>
|
||||
<main class="site--main">
|
||||
<header class="archive-header archive-header__search">
|
||||
<div class="pagination">
|
||||
<h2>Sorry</h2>
|
||||
<p>很遗憾,未找到您期待的内容</p>
|
||||
</div>
|
||||
</header>
|
||||
</main>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php $this->need('module/footer.php'); ?>
|
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="800" height="400" viewBox="0 0 800 400"><rect width="100%" height="100%" fill="#f5f5f5"/><path fill="#969696" d="M220.935 149.4h13.28v80.98h-7.73q-1.79 0-3-.59-1.2-.59-2.32-1.99l-42.28-53.98q.33 3.7.33 6.83v49.73h-13.27V149.4h7.9q.95 0 1.65.09.7.08 1.23.33.53.26 1.04.73.5.48 1.12 1.26l42.45 54.21q-.17-1.96-.28-3.86-.12-1.91-.12-3.53zm54.55 22.63q6.38 0 11.62 2.07 5.23 2.07 8.96 5.88 3.72 3.81 5.74 9.3 2.01 5.48 2.01 12.26 0 6.83-2.01 12.32-2.02 5.49-5.74 9.35-3.73 3.87-8.96 5.94-5.24 2.07-11.62 2.07-6.44 0-11.71-2.07-5.26-2.07-8.98-5.94-3.73-3.86-5.77-9.35-2.05-5.49-2.05-12.32 0-6.78 2.05-12.26 2.04-5.49 5.77-9.3 3.72-3.81 8.98-5.88 5.27-2.07 11.71-2.07m0 48.55q7.17 0 10.61-4.82 3.44-4.81 3.44-14.11 0-9.29-3.44-14.17-3.44-4.87-10.61-4.87-7.28 0-10.78 4.9t-3.5 14.14 3.5 14.09q3.5 4.84 10.78 4.84m83.44-71.18v80.98h-15.12V149.4zm29.73 80.98h-13.83v-57.46h8.46q2.69 0 3.53 2.52l.89 4.26q1.51-1.68 3.17-3.08 1.65-1.4 3.52-2.41 1.88-1.01 4.04-1.59 2.15-.59 4.73-.59 5.43 0 8.93 2.94t5.24 7.81q1.34-2.86 3.36-4.9 2.01-2.04 4.42-3.33t5.12-1.91q2.72-.61 5.46-.61 4.76 0 8.46 1.45 3.7 1.46 6.22 4.26t3.83 6.83q1.32 4.03 1.32 9.24v36.57h-13.83v-36.57q0-5.49-2.41-8.26t-7.06-2.77q-2.13 0-3.95.73t-3.19 2.1-2.15 3.44q-.79 2.07-.79 4.76v36.57h-13.89v-36.57q0-5.77-2.32-8.4t-6.8-2.63q-3.03 0-5.63 1.48-2.61 1.49-4.85 4.06zm110.32-14.84v-9.69q-5.99.28-10.08 1.04-4.08.75-6.55 1.93-2.46 1.18-3.53 2.74-1.06 1.57-1.06 3.42 0 3.64 2.16 5.21 2.15 1.57 5.62 1.57 4.26 0 7.37-1.54t6.07-4.68m-29.23-30.18-2.46-4.43q9.91-9.07 23.85-9.07 5.04 0 9.02 1.65t6.72 4.59 4.17 7.03 1.43 8.96v36.29h-6.27q-1.96 0-3.03-.59-1.06-.59-1.68-2.38l-1.23-4.14q-2.18 1.96-4.25 3.44-2.08 1.49-4.32 2.49-2.24 1.01-4.78 1.54-2.55.54-5.63.54-3.64 0-6.72-.98t-5.32-2.94-3.47-4.88q-1.24-2.91-1.24-6.77 0-2.19.73-4.34.73-2.16 2.38-4.12t4.29-3.69q2.63-1.74 6.46-3.03 3.84-1.29 8.94-2.1 5.09-.81 11.64-.98v-3.36q0-5.77-2.46-8.54t-7.11-2.77q-3.36 0-5.57.78-2.22.79-3.9 1.77t-3.05 1.76q-1.37.79-3.05.79-1.46 0-2.46-.76-1.01-.76-1.63-1.76m76.72 14.89q2.58 0 4.48-.7 1.91-.7 3.17-1.93t1.9-2.97q.64-1.73.64-3.81 0-4.25-2.54-6.74-2.55-2.5-7.65-2.5-5.09 0-7.64 2.5-2.55 2.49-2.55 6.74 0 2.02.64 3.76.65 1.73 1.91 2.99t3.19 1.96 4.45.7m15.63 32.71q0-1.68-1.01-2.75-1.01-1.06-2.75-1.65-1.73-.59-4.06-.87-2.32-.28-4.92-.42-2.61-.14-5.38-.25t-5.4-.45q-2.3 1.29-3.73 3.03-1.43 1.73-1.43 4.03 0 1.51.76 2.83.76 1.31 2.41 2.26 1.65.96 4.28 1.49t6.44.53q3.87 0 6.67-.59t4.62-1.62q1.82-1.04 2.66-2.47.84-1.42.84-3.1m-2.75-58.08h16.52v5.16q0 2.46-2.97 3.02l-5.15.95q1.18 2.97 1.18 6.5 0 4.25-1.71 7.7-1.71 3.44-4.73 5.85-3.03 2.41-7.14 3.72-4.12 1.32-8.88 1.32-1.68 0-3.25-.17-1.56-.17-3.08-.45-2.68 1.63-2.68 3.64 0 1.74 1.59 2.55 1.6.81 4.23 1.15t5.99.42 6.89.36 6.89.98 5.99 2.22q2.63 1.51 4.23 4.11 1.59 2.61 1.59 6.69 0 3.81-1.87 7.4-1.88 3.58-5.43 6.38-3.56 2.8-8.74 4.51t-11.79 1.71q-6.49 0-11.31-1.26t-8.01-3.36-4.76-4.85q-1.57-2.74-1.57-5.71 0-4.03 2.44-6.75 2.44-2.71 6.69-4.34-2.29-1.17-3.64-3.13-1.34-1.96-1.34-5.16 0-1.28.47-2.66.48-1.37 1.4-2.71.93-1.35 2.33-2.55t3.3-2.16q-4.37-2.35-6.86-6.27t-2.49-9.18q0-4.26 1.71-7.7 1.71-3.45 4.76-5.88 3.05-2.44 7.22-3.73 4.17-1.28 9.1-1.28 3.7 0 6.95.75 3.24.76 5.93 2.21m36.18 20.16h26.09q0-2.68-.75-5.06-.76-2.38-2.27-4.18-1.51-1.79-3.84-2.82-2.32-1.04-5.4-1.04-5.99 0-9.44 3.42-3.44 3.41-4.39 9.68m35.28 8.35h-35.56q.33 4.42 1.57 7.64 1.23 3.22 3.24 5.32 2.02 2.1 4.79 3.14 2.77 1.03 6.13 1.03t5.8-.78 4.26-1.74q1.82-.95 3.19-1.73 1.37-.79 2.66-.79 1.73 0 2.57 1.29l3.98 5.04q-2.3 2.69-5.15 4.51-2.86 1.82-5.97 2.91-3.1 1.09-6.32 1.54t-6.25.45q-5.99 0-11.14-1.99t-8.96-5.88-5.99-9.63q-2.19-5.74-2.19-13.3 0-5.88 1.91-11.06 1.9-5.18 5.46-9.02 3.55-3.83 8.68-6.07 5.12-2.24 11.56-2.24 5.43 0 10.02 1.73 4.6 1.74 7.9 5.07t5.18 8.18q1.88 4.84 1.88 11.06 0 3.13-.68 4.23-.67 1.09-2.57 1.09"/></svg>
|
After Width: | Height: | Size: 3.8 KiB |
|
@ -7,6 +7,8 @@ function themeConfig($form) {
|
|||
$form->addInput($icoUrl);
|
||||
$sticky = new Typecho_Widget_Helper_Form_Element_Text('sticky', NULL, NULL, _t('置顶文章cid'), _t('多篇文章以`|`符号隔开'), _t('会在首页展示置顶文章。'));
|
||||
$form->addInput($sticky);
|
||||
$travel = new Typecho_Widget_Helper_Form_Element_Text('travel', NULL, '3', _t('travel分类 Mid'), _t('多个分类以`|`符号隔开'), _t('指定分类ID,用于区别展示'));
|
||||
$form->addInput($travel);
|
||||
$instagramurl = new Typecho_Widget_Helper_Form_Element_Text('instagramurl', NULL, 'https://Instagram.com/', _t('Instagram'), _t('会在个人信息显示'));
|
||||
$form->addInput($instagramurl);
|
||||
$telegramurl = new Typecho_Widget_Helper_Form_Element_Text('telegramurl', NULL, 'https://t.me/', _t('电报'), _t('会在个人信息显示'));
|
||||
|
@ -51,7 +53,11 @@ function themeConfig($form) {
|
|||
array('0'=> _t('否'), '1'=> _t('是')),
|
||||
'0', _t('是否显示页面加载时间'), _t('选择“是”将在页脚显示加载时间。'));
|
||||
$form->addInput($showtime);
|
||||
}
|
||||
}
|
||||
function saveThemeConfig($config) {
|
||||
// 可以在这里添加额外的验证或处理逻辑
|
||||
return $config;
|
||||
}
|
||||
/*
|
||||
* 文章浏览数统计
|
||||
*/
|
||||
|
@ -243,6 +249,30 @@ Typecho_Plugin::factory('Widget_Abstract_Contents')->contentEx = function($conte
|
|||
* **
|
||||
*
|
||||
*/
|
||||
function get_article_summary($post) {
|
||||
// 首先尝试从自定义字段获取摘要
|
||||
$db = Typecho_Db::get();
|
||||
|
||||
// 查询自定义字段表
|
||||
$row = $db->fetchRow($db->select()
|
||||
->from('table.fields')
|
||||
->where('cid = ?', $post['cid'])
|
||||
->where('name = ?', 'summary'));
|
||||
|
||||
// 如果找到自定义摘要字段
|
||||
if ($row && !empty($row['str_value'])) {
|
||||
return $row['str_value'];
|
||||
}
|
||||
|
||||
// 如果没有自定义摘要,截取文章内容
|
||||
// 去除HTML标签
|
||||
$text = strip_tags($post['text']);
|
||||
|
||||
// 截取指定长度的摘要
|
||||
return Typecho_Common::subStr($text, 0, 100, '...');
|
||||
}
|
||||
|
||||
// 在原函数中使用
|
||||
function get_article_info($atts) {
|
||||
$default_atts = array(
|
||||
'id' => '',
|
||||
|
@ -250,6 +280,8 @@ function get_article_info($atts) {
|
|||
);
|
||||
$atts = array_merge($default_atts, $atts);
|
||||
$db = Typecho_Db::get();
|
||||
|
||||
// 根据 ID 或 URL 获取文章
|
||||
if (!empty($atts['id'])) {
|
||||
$post = $db->fetchRow($db->select()->from('table.contents')
|
||||
->where('cid = ?', $atts['id'])
|
||||
|
@ -261,27 +293,35 @@ function get_article_info($atts) {
|
|||
} else {
|
||||
return '请提供文章ID或URL';
|
||||
}
|
||||
|
||||
if (!$post) {
|
||||
return '未找到文章';
|
||||
}
|
||||
|
||||
// 将文章数据推送到抽象内容小部件中
|
||||
$post = Typecho_Widget::widget('Widget_Abstract_Contents')->push($post);
|
||||
|
||||
// 获取摘要
|
||||
$summary = get_article_summary($post);
|
||||
|
||||
// 获取缩略图
|
||||
$default_thumbnail = Helper::options()->themeUrl . '/assets/images/nopic.svg';
|
||||
$imageToDisplay = img_postthumb($post['cid']);
|
||||
if (empty($imageToDisplay)) {
|
||||
$imageToDisplay = 'https://pic.0tz.top/img/nopic.png'; // 设置一个默认图片路径
|
||||
$imageToDisplay = $default_thumbnail;
|
||||
}
|
||||
|
||||
// 构建输出
|
||||
$output = '<div class="graph--mixtapeEmbed">';
|
||||
$output .= '<a class="mixtapeContent" href="' . $post['permalink'] . '" target="_blank">';
|
||||
$output .= '<span class="markup--strong markup--mixtapeEmbed-strong">' . $post['title'] . '</span>';
|
||||
$output .= '<em class="markup--em markup--mixtapeEmbed-em">' . Typecho_Common::subStr(strip_tags($post['text']), 0, 100, '...') . '</em>';
|
||||
$output .= '<span class="markup--strong markup--mixtapeEmbed-strong">' . htmlspecialchars($post['title']) . '</span>';
|
||||
$output .= '<em class="markup--em markup--mixtapeEmbed-em">' . htmlspecialchars($summary) . '</em>';
|
||||
$output .= '</a>';
|
||||
$output .= '<a class="mixtapeImage" href="' . $post['permalink'] . '" target="_blank" style="background-image:url(' . $imageToDisplay . ')"></a>';
|
||||
$output .= '<a class="mixtapeImage" href="' . $post['permalink'] . '" target="_blank" style="background-image:url(' . htmlspecialchars($imageToDisplay) . ')"></a>';
|
||||
$output .= '</div>';
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
// 创建一个新的类来处理内容过滤
|
||||
class ContentFilter
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue