Skip to content

Commit

Permalink
Update to v1.1
Browse files Browse the repository at this point in the history
Update to v1.1
  • Loading branch information
michaelliunsky committed Mar 3, 2024
1 parent e9b357c commit 6266887
Show file tree
Hide file tree
Showing 22 changed files with 811 additions and 299 deletions.
40 changes: 39 additions & 1 deletion 404.php
Original file line number Diff line number Diff line change
@@ -1,2 +1,40 @@
<!DOCTYPE html>
<html lang="zh_CN"><head><link rel="icon" href="<?php $this->options->favico(); ?>" /><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Page Not Found | <?php $this->options->title() ?></title><meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1"><meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no,viewport-fit=cover"><meta name="renderer" content="webkit"></head><body><div class="four04"><a href="<?php $this->options->siteUrl() ?>"><img src="<?php $this->options->pnfpic(); ?>"></a></div><style>html,body {background:#fff}body{margin:0}.four04{height:100vh;display:flex;align-items:center;justify-content:center}.four04 img{max-width: 96vw;max-height: 96vh}</style></body></html>
<html lang="zh_CN">
<head>
<link rel="icon" href="<?php $this->options->favico(); ?>" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Page Not Found | <?php $this->options->title() ?></title>
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />
<meta
name="viewport"
content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no,viewport-fit=cover"
/>
<meta name="renderer" content="webkit" />
</head>
<body>
<div class="four04">
<a href="<?php $this->options->siteUrl() ?>"
><img src="<?php $this->options->pnfpic(); ?>"
/></a>
</div>
<style>
html,
body {
background: #fff;
}
body {
margin: 0;
}
.four04 {
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
}
.four04 img {
max-width: 96vw;
max-height: 96vh;
}
</style>
</body>
</html>
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ typecho-Theme-niRvana 移植自 WordPress 版 niRvana 主题。

# 安装

环境要求:**PHP7.4 兼容最佳**
环境要求:**PHP8.3 兼容最佳**
[Release](https://github.com/michaelliunsky/typecho-theme-niRvana/releases) 页面下载 .zip 文件,上传到/usr/themes 并解压缩,在 typecho 后台找到外观并启用本主题。

# typecho 版相比 Wordpress 版
Expand Down Expand Up @@ -58,6 +58,13 @@ typecho-Theme-niRvana 移植自 WordPress 版 niRvana 主题。

# 更新日志

## 20240303 v1.1

- 适配**PHP8.3**
- 文章封面图支持**自动获取**
- 代码全部**格式化**
- **感谢 typecho.work 对本主题的贡献**

## 20230822 v1.0

- 新主题发布
Expand Down
76 changes: 55 additions & 21 deletions archive.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,56 @@
<!DOCTYPE html>
<html lang="zh-CN"><head><title><?php $this->options->title() ?> | <?php $this->options->description() ?></title><meta name="keywords" content="<?php $this->options->guanjianci(); ?>"/>
<meta name="description" content="<?php $this->options->miaoshu(); ?>"/>
<?php include('head.php'); ?>
</head><body class="black-color dark-slider"><div id="wrapper"><div class="row">
<?php include('sidebar.php'); ?>
</div></div><div id="main"><div class="container postListsModel"><div class="row"><div class="col-md-12 col-lg-12"><div class="categoryNav-wrapper" style="width: 100%;"><div pandatab="" class="categoryNav" active-class=".current-menu-item,.current-menu-ancestor" sub-class=".sub-menu"><ul id="menu-cattab" class="menu"><li class="anchor" style="position: absolute; left: 0px; width: 78px; opacity: 1;"></li>
<?php include('menu.php'); ?>
</ul></div></div>
<div class="col-xs-12"><div class="row"><div class="row postLists cards" height-to="sidebar">
<?php if ($this->have()): ?>
<?php while($this->next()): ?>
<div class="col-xxs-6 col-xs-4 col-lg-2_5 post-card-wrapper"><div class="card"><a href="<?php $this->permalink() ?>" class="cover" style="background-image: url(<?php $this->fields->toutu(); ?>);" showas="padding"></a><a href="<?php $this->permalink() ?>" showas="img"><img src="<?php $this->fields->toutu(); ?>" class="cover" alt=""></a><div class="meta"><h2><a href="<?php $this->permalink() ?>"><?php $this->title() ?></a></h2><div class="tags"><a class="color-<?php echo rand(1,8); ?>"><?php $this->category(' · ', false); ?></a>
</div><div class="summary"><span class="comments"><i class="icon font_family icon-clock"></i> <?php $this->date('n月j日 · Y年'); ?></span> </div></div></div></div>
<?php endwhile; ?></div><?php include('pagenav.php'); ?>
<?php else: ?>
</div>
<p style="font-size:28px;margin: 0 auto;text-align: center;color:#8492a6;padding-top: 80px;">没有发现文章的踪迹</p>
<?php include('sousuo.php'); ?>
<?php endif; ?>
</div></div></div></div></div>
<?php include('footer.php'); ?>
<html lang="zh-CN">

<head>
<title><?php $this->options->title() ?> | <?php $this->options->description() ?></title>
<meta name="keywords" content="<?php $this->options->guanjianci(); ?>" />
<meta name="description" content="<?php $this->options->miaoshu(); ?>" />
<?php include('head.php'); ?>
</head>

<body class="black-color dark-slider">
<div id="wrapper">
<div class="row">
<?php include('sidebar.php'); ?>
</div>
</div>
<div id="main">
<div class="container postListsModel">
<div class="row">
<div class="col-md-12 col-lg-12">
<div class="categoryNav-wrapper" style="width: 100%;">
<div pandatab="" class="categoryNav" active-class=".current-menu-item,.current-menu-ancestor" sub-class=".sub-menu">
<ul id="menu-cattab" class="menu">
<li class="anchor" style="position: absolute; left: 0px; width: 78px; opacity: 1;"></li>
<?php include('menu.php'); ?>
</ul>
</div>
</div>
<div class="col-xs-12">
<div class="row">
<div class="row postLists cards" height-to="sidebar">
<?php if ($this->have()): ?>
<?php while($this->next()): ?>
<div class="col-xxs-6 col-xs-4 col-lg-2_5 post-card-wrapper">
<div class="card"><a href="<?php $this->permalink() ?>" class="cover" style="background-image: url(<?php showThumbnail($this); ?>);" showas="padding"></a><a href="<?php $this->permalink() ?>" showas="img"><img src="<?php showThumbnail($this); ?>" class="cover" alt=""></a>
<div class="meta">
<h2><a href="<?php $this->permalink() ?>"><?php $this->title() ?></a></h2>
<div class="tags"><a class="color-<?php echo rand(1, 8); ?>"><?php $this->category(' · ', false); ?></a>
</div>
<div class="summary"><span class="comments"><i class="icon font_family icon-clock"></i> <?php $this->date('n月j日 · Y年'); ?></span> </div>
</div>
</div>
</div>
<?php endwhile; ?>
</div><?php include('pagenav.php'); ?>
<?php else: ?>
</div>
<p style="font-size:28px;margin: 0 auto;text-align: center;color:#8492a6;padding-top: 80px;">没有发现文章的踪迹</p>
<?php include('sousuo.php'); ?>
<?php endif; ?>
</div>
</div>
</div>
</div>
</div>
<?php include('footer.php'); ?>
2 changes: 1 addition & 1 deletion css.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dark.css.css

Large diffs are not rendered by default.

68 changes: 47 additions & 21 deletions footer.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,47 @@
<div class="pageLoader flex-row-middle flex-center" style="opacity: 0.9;visibility: unset;" id="p1"><div></div><div></div><div></div><div></div></div><footer id="footer"><div class="container"><div class="copyright silver-color"><?php $this->options->dibus(); ?></div><div class="beian"><?php $this->options->dibux(); ?></div><a href="https://blog.mkliu.top" id="banquan"><div class="copyright silver-color">Theme niRvana By michaelliunsky
</div></a></div></footer></div><div class="floatTools"><div class="tool-button backToTop unavailable" @click="this.backToTop()" style="transform: rotate(-45deg)"><i class="icon font_family icon-rocket"></i></div></div></div><script src="https://jsd.onmicrosoft.cn/gh/jquery/[email protected]/dist/jquery.min.js"></script><script src="<?php $this->options->themeUrl('js.js'); ?>"></script></body><script>$('body').on('click', 'a', function(){
var href = $(this).attr('href');
if(!href || /^(javascript:)|#/.test(href)) return;
loading();
setTimeout(window.location.href = href,300);
return false;
});
function openload(){
var p1 = document.getElementById("p1");
p1.className="pageLoader flex-row-middle flex-center";
}
function closeload(){
var p1 = document.getElementById("p1");
p1.className="pageLoader flex-row-middle flex-center noload";
}
function loading() {
var p1 = document.getElementById("p1");
p1.className="pageLoader flex-row-middle flex-center";
}
window.onload = setTimeout(closeload,300);</script>
<div class="pageLoader flex-row-middle flex-center" style="opacity: 0.9;visibility: unset;" id="p1">
<div></div>
<div></div>
<div></div>
<div></div>
</div>
<footer id="footer">
<div class="container">
<div class="copyright silver-color">
<?php $this->options->dibus(); ?>
</div>
<div class="beian">
<?php $this->options->dibux(); ?>
</div><a href="https://blog.mkliu.top" id="banquan">
<div class="copyright silver-color">Theme niRvana By michaelliunsky
</div>
</a>
</div>
</footer>
</div>
<div class="floatTools">
<div class="tool-button backToTop unavailable" @click="this.backToTop()" style="transform: rotate(-45deg)"><i class="icon font_family icon-rocket"></i></div>
</div>
</div>
<script src="https://jsd.onmicrosoft.cn/gh/jquery/[email protected]/dist/jquery.min.js"></script>
<script src="<?php $this->options->themeUrl('js.js'); ?>"></script>
</body>
<script>$('body').on('click', 'a', function () {
var href = $(this).attr('href');
if (!href || /^(javascript:)|#/.test(href)) return;
loading();
setTimeout(window.location.href = href, 300);
return false;
});
function openload() {
var p1 = document.getElementById("p1");
p1.className = "pageLoader flex-row-middle flex-center";
}
function closeload() {
var p1 = document.getElementById("p1");
p1.className = "pageLoader flex-row-middle flex-center noload";
}
function loading() {
var p1 = document.getElementById("p1");
p1.className = "pageLoader flex-row-middle flex-center";
}
window.onload = setTimeout(closeload, 300);</script>
95 changes: 70 additions & 25 deletions functions.php
Original file line number Diff line number Diff line change
@@ -1,46 +1,91 @@
<?php
function themeConfig($form) {
$logo = new Typecho_Widget_Helper_Form_Element_Text('logo', NULL, NULL, _t('LOGO'), _t(''));

function themeConfig($form)
{
$logo = new Typecho_Widget_Helper_Form_Element_Text('logo', null, null, _t('LOGO'), _t(''));
$form->addInput($logo);
$sourl = new Typecho_Widget_Helper_Form_Element_Text('sourl', NULL, NULL, _t('搜索地址'), _t(''));
$sourl = new Typecho_Widget_Helper_Form_Element_Text('sourl', null, null, _t('搜索地址'), _t(''));
$form->addInput($sourl);
$favico = new Typecho_Widget_Helper_Form_Element_Text('favico', NULL, NULL, _t('favico'), _t(''));
$favico = new Typecho_Widget_Helper_Form_Element_Text('favico', null, null, _t('favico'), _t(''));
$form->addInput($favico);
$pnfpic = new Typecho_Widget_Helper_Form_Element_Text('pnfpic', NULL, NULL, _t('404图片'), _t(''));
$pnfpic = new Typecho_Widget_Helper_Form_Element_Text('pnfpic', null, null, _t('404图片'), _t(''));
$form->addInput($pnfpic);
$dibus = new Typecho_Widget_Helper_Form_Element_Text('dibus', NULL, NULL, _t('网站版权'), _t(''));
$dibus = new Typecho_Widget_Helper_Form_Element_Text('dibus', null, null, _t('网站版权'), _t(''));
$form->addInput($dibus);
$dibux = new Typecho_Widget_Helper_Form_Element_Text('dibux', NULL, NULL, _t('备案号'), _t(''));
$dibux = new Typecho_Widget_Helper_Form_Element_Text('dibux', null, null, _t('备案号'), _t(''));
$form->addInput($dibux);
$miaoshu = new Typecho_Widget_Helper_Form_Element_Text('miaoshu', NULL, NULL, _t('描述'), _t(''));
$miaoshu = new Typecho_Widget_Helper_Form_Element_Text('miaoshu', null, null, _t('描述'), _t(''));
$form->addInput($miaoshu);
$guanjianci = new Typecho_Widget_Helper_Form_Element_Text('guanjianci', NULL, NULL, _t('关键词'), _t(''));
$guanjianci = new Typecho_Widget_Helper_Form_Element_Text('guanjianci', null, null, _t('关键词'), _t(''));
$form->addInput($guanjianci);
$haibaobq = new Typecho_Widget_Helper_Form_Element_Text('haibaobq', NULL, NULL, _t('海报版权'), _t(''));
$haibaobq = new Typecho_Widget_Helper_Form_Element_Text('haibaobq', null, null, _t('海报版权'), _t(''));
$form->addInput($haibaobq);
$xgwz = new Typecho_Widget_Helper_Form_Element_Text('xgwz', NULL, NULL, _t('相关文章'), _t(''));
$xgwz = new Typecho_Widget_Helper_Form_Element_Text('xgwz', null, null, _t('相关文章'), _t(''));
$form->addInput($xgwz);
}
function themeFields($layout) {
$toutu = new Typecho_Widget_Helper_Form_Element_Text('toutu', NULL, NULL, _t('文章头图'), _t(''));
$layout->addItem($toutu);
$guanjianci = new Typecho_Widget_Helper_Form_Element_Text('guanjianci', NULL, NULL, _t('关键词'), _t(''));
function themeFields($layout)
{
$thumb = new Typecho_Widget_Helper_Form_Element_Text('thumb', null, null, _t('文章头图'), _t(''));
$layout->addItem($thumb);
$guanjianci = new Typecho_Widget_Helper_Form_Element_Text('guanjianci', null, null, _t('关键词'), _t(''));
$layout->addItem($guanjianci);
$miaoshu = new Typecho_Widget_Helper_Form_Element_Text('miaoshu', NULL, NULL, _t('描述'), _t(''));
$miaoshu = new Typecho_Widget_Helper_Form_Element_Text('miaoshu', null, null, _t('描述'), _t(''));
$layout->addItem($miaoshu);
$biaoti = new Typecho_Widget_Helper_Form_Element_Text('biaoti', NULL, NULL, _t('标题'), _t(''));
$biaoti = new Typecho_Widget_Helper_Form_Element_Text('biaoti', null, null, _t('标题'), _t(''));
$layout->addItem($biaoti);
$ico = new Typecho_Widget_Helper_Form_Element_Text('ico', NULL, NULL, _t('图标'), _t(''));
$ico = new Typecho_Widget_Helper_Form_Element_Text('ico', null, null, _t('图标'), _t(''));
$layout->addItem($ico);
$pic = new Typecho_Widget_Helper_Form_Element_Text('pic', NULL, NULL, _t('长头图'), _t(''));
$pic = new Typecho_Widget_Helper_Form_Element_Text('pic', null, null, _t('长头图'), _t(''));
$layout->addItem($pic);
}
function spacing ($text)
function spacing($text)
{
$text = preg_replace ('~((?![年月日号])\p{Han})([a-zA-Z0-9+$@#\[\(\/‘“])~u', '\1 \2', $text);
$text = preg_replace ('~([a-zA-Z0-9+$’”\]\)@#!\/]|[\d [年月日]]{2,})((?![年月日号])\p{Han})~u', '\1 \2', $text);
$text = preg_replace ('~([a-zA-Z0-9]+)([\[\(‘“])~u', '\1 \2', $text);
$text = preg_replace ('~([\)\]’”])([a-zA-Z0-9]+)~u', '\1 \2', $text);
$text = preg_replace('~((?![年月日号])\p{Han})([a-zA-Z0-9+$@#\[\(\/‘“])~u', '\1 \2', $text);
$text = preg_replace('~([a-zA-Z0-9+$’”\]\)@#!\/]|[\d [年月日]]{2,})((?![年月日号])\p{Han})~u', '\1 \2', $text);
$text = preg_replace('~([a-zA-Z0-9]+)([\[\(‘“])~u', '\1 \2', $text);
$text = preg_replace('~([\)\]’”])([a-zA-Z0-9]+)~u', '\1 \2', $text);
return $text;
}
?>

function showThumbnail($widget, $type = 0)
{
$random = Helper::options()->themeUrl.'/mr.jpeg';
$pattern = '/\<img.*?\ssrc\=\"(.*?)\"[^>]*>/i';
$attach = $widget->widget('Widget_Contents_Attachment_Related@' . $widget->cid . '-' . uniqid(), array(
'parentId' => $widget->cid,'limit' => 1,'offset' => 0))->attachment;
$t = preg_match_all($pattern, $widget->markdown($widget->text), $thumbUrl);
$img = $random;


$name = md5($widget->cid);
$file1 = ".".__TYPECHO_PLUGIN_DIR__."/Thumb/uploads/".$name.'.webp';
$file2 = ".".__TYPECHO_PLUGIN_DIR__."/Thumb/uploads/".$name.'.jpg';
if(file_exists($file1)) {
$img = Helper::options()->rootUrl.__TYPECHO_PLUGIN_DIR__."/Thumb/uploads/".$name.'.webp?'.filemtime($file1);
} elseif(file_exists($file2)) {
$img = Helper::options()->rootUrl.__TYPECHO_PLUGIN_DIR__."/Thumb/uploads/".$name.'.jpg?'.filemtime($file2);
} elseif($widget->fields->thumb) {
$img = $widget->fields->thumb;
} elseif($widget->fields->img) {
$img = $widget->fields->img;
} elseif ($t && strpos($thumbUrl[1][0], 'icon.png') == false && strpos($thumbUrl[1][0], 'alipay') == false && strpos($thumbUrl[1][0], 'wechat') == false) {
$img = $thumbUrl[1][0];
} elseif (@$attach->isImage) {
$img = $attach->url;
}

if($type == 0) {
if($img == $random) {
echo $img;
} else {
echo $img.Helper::options()->thumbnail;
}
} else {
if($img == $random) {
return $img;
} else {
return $img.Helper::options()->thumbnail;
}
}

}
21 changes: 18 additions & 3 deletions head.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1"><meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no,viewport-fit=cover"><meta name="renderer" content="webkit"><link rel="icon" href="<?php $this->options->favico(); ?>"><script type="text/javascript">
var pandastudio_framework = {"current_user":{"logged_in":false,"name":false,"email":false,"id":0}};
</script><script>let prefersDarkMode=window.matchMedia('(prefers-color-scheme: dark)').matches;if(prefersDarkMode){document.write('<link href="<?php $this->options->themeUrl('dark.css.css'); ?>" rel="stylesheet" type="text/css"/>')}else{document.write('<link href="<?php $this->options->themeUrl('css.css'); ?>" rel="stylesheet" type="text/css"/>')};</script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><meta
http-equiv="X-UA-Compatible"
content="IE=Edge,chrome=1"
/><meta
name="viewport"
content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no,viewport-fit=cover"
/><meta name="renderer" content="webkit" /><link
rel="icon"
href="<?php $this->options->favico(); ?>"
/>
<script type="text/javascript">
var pandastudio_framework = {
current_user: { logged_in: false, name: false, email: false, id: 0 },
};
</script>
<script>
let prefersDarkMode=window.matchMedia('(prefers-color-scheme: dark)').matches;if(prefersDarkMode){document.write('<link href="<?php $this->options->themeUrl('dark.css.css'); ?>" rel="stylesheet" type="text/css"/>')}else{document.write('<link href="<?php $this->options->themeUrl('css.css'); ?>" rel="stylesheet" type="text/css"/>')};
</script>
Loading

0 comments on commit 6266887

Please sign in to comment.