Skip to content

Commit

Permalink
Merge pull request #15 from ouyangyanhuo/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
ouyangyanhuo authored Aug 13, 2022
2 parents 14715b2 + c4ef9b2 commit 47514e2
Show file tree
Hide file tree
Showing 13 changed files with 113 additions and 50 deletions.
37 changes: 13 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,14 @@ _Haku,是 Tina 小姐最爱的喵喵,它在这里守卫着 Tina 小姐_
<a href="https://www.teendreams.cn/" target="_blank" ><img width="100px" height="100px" src="https://s2.loli.net/2022/07/21/MmO4cGWazgjrlTd.png"></a>
</div>

## 更新前注意

此更新注意事项仅存在于 2.0.0 正式版本中,请务必认真!
- 在 2.0.0 版本,由于主题更名,因此主题文件夹名称会变更,与旧版本能够共存,但一定要删除旧版本的文件!!否则会导致更新检测冲突。
- 在 2.0.0 版本,由于主题更名,启用新主题时,会导致原主题的相关设置内容丢失,请启用前做好设置内容的备份!

## TinaTheme

一个为typecho移植的主题,源自于[hugo-tania](https://github.com/WingLim/hugo-tania)主题,原本是Hugo的主题,被移植到Typecho上在其基础上进行了深度修改的 TinaTheme 或许是你在Typecho上最好的选择

<div align="center">

[![AdminMD](https://img.shields.io/badge/Magneto-TinaTheme-brightgreen)](https://fmcf.cc/technology/523/)
![Version](https://img.shields.io/badge/Version-2.0.0-criticale)
![Version](https://img.shields.io/badge/Version-2.0.1-criticale)
![Repo-size](https://img.shields.io/github/languages/code-size/ouyangyanhuo/TinaTheme)
![License](https://img.shields.io/github/license/ouyangyanhuo/TinaTheme)
![Stars](https://img.shields.io/github/stars/ouyangyanhuo/TinaTheme)
Expand All @@ -44,23 +38,18 @@ _Haku,是 Tina 小姐最爱的喵喵,它在这里守卫着 Tina 小姐_

## 最近版本更新日志

- 🚀由 SmileTheme 更名为 TinaTheme
- ✨新增了 代码块
- ✨新增了滚动条样式
- ✨新增了针对上一篇、下一篇按钮的核心内容
- ✨新增了加密文章的输入框、提交按钮的样式
- ✨新增了对 MathJax 和 KaTeX 数学公式的渲染支持
- ✨重写了 代码高亮
- ✨重写了上一篇、下一篇按钮
- 🔪删除了在文章没有设置 标签 时显示的"No Tag"
- 🔪删除了评论头像(负)优化
- 修复了关闭后台夜间模式后存在的问题
- 修复评论过长,导致文本溢出的问题
- 优化更新检测请求的UI
- 完成所有所需页面的重构
- 调整评论区 取消回复 按钮位置
- 优化夜间模式评论区输入内容的显示效果
- 将更新检测请求由 GitHub 移至 Assets-FMCF
- 🌈更改 更新校验方式 将其更改为 内部版本号校验 以达到精确校验(大部分App应用商店的校验方式)
- ⭐新增 Gravatar头像源切换 功能,用于加速国内的Gravatar头像显示,经测试不会影响运行性能。
- ⭐新增 主题数据备份 功能,数据存储于数据库中,名称为 TinaThemebf
- 🔪删除了在 CSS 中部分无法正常使用的功能
- 🔪删除了冗余的核心JS
- 修复开启图片灯箱后对Tyoecho `<!---more-->` 标签的支持
- 修复了不开启图片灯箱无法正常使用PJAX的陈年Bug
- 修复了评论区头像的显示效果负优化
- 优化了 CSS 的书写,进而提高性能
- 优化了 友链 页面中 链接的显示效果
- 优化了 评论内容 的整体显示效果
- 优化了 图片 的显示效果

## 功能与特性

Expand Down
4 changes: 2 additions & 2 deletions assets/css/style.css

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions assets/js/features.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
</div>
<?php if ($comments->have()): ?>
<h4 class="comments-title-article-post"><?php $this->commentsNum(_t('暂无评论'), _t('仅有一条评论'), _t('已有 %d 条评论')); ?></h4>
<a class="article-post"><?php $comments->listComments(); ?></a>
<?php $comments->listComments(); ?>
<?php $comments->pageNav('&laquo; 前一页', '后一页 &raquo;'); ?>
<?php endif; ?>
<?php else: ?>
Expand Down
63 changes: 63 additions & 0 deletions core/backup.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<!--
- TinaTheme - Backup
- 主题数据备份
- Origin Link:https://blog.zezeshe.com/archives/typecho-templates-backup-and-restore.html
-->
<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit;
$db = Typecho_Db::get();
$sjdq=$db->fetchRow($db->select()->from ('table.options')->where ('name = ?', 'theme:TinaTheme'));
$ysj = $sjdq['value'];
if(isset($_POST['type'])){
if($_POST["type"]=="备份模板数据"){
if($db->fetchRow($db->select()->from ('table.options')->where ('name = ?', 'theme:TinaThemebf'))){
$update = $db->update('table.options')->rows(array('value'=>$ysj))->where('name = ?', 'theme:TinaThemebf');
$updateRows= $db->query($update);
echo '<div class="tongzhi">备份已更新,请等待自动刷新!如果等不到请点击';
?>
<a href="<?php Helper::options()->adminUrl('options-theme.php'); ?>">这里</a></div>
<script language="JavaScript">window.setTimeout("location=\'<?php Helper::options()->adminUrl('options-theme.php'); ?>\'", 2500);</script>
<?php
}else{
if($ysj){
$insert = $db->insert('table.options')->rows(array('name' => 'theme:TinaThemebf','user' => '0','value' => $ysj));
$insertId = $db->query($insert);
echo '<div class="tongzhi">备份完成,请等待自动刷新!如果等不到请点击';
?>
<a href="<?php Helper::options()->adminUrl('options-theme.php'); ?>">这里</a></div>
<script language="JavaScript">window.setTimeout("location=\'<?php Helper::options()->adminUrl('options-theme.php'); ?>\'", 2500);</script>
<?php
}
}
}
if($_POST["type"]=="还原模板数据"){
if($db->fetchRow($db->select()->from ('table.options')->where ('name = ?', 'theme:TinaThemebf'))){
$sjdub=$db->fetchRow($db->select()->from ('table.options')->where ('name = ?', 'theme:TinaThemebf'));
$bsj = $sjdub['value'];
$update = $db->update('table.options')->rows(array('value'=>$bsj))->where('name = ?', 'theme:TinaTheme');
$updateRows= $db->query($update);
echo '<div class="tongzhi">检测到模板备份数据,恢复完成,请等待自动刷新!如果等不到请点击';
?>
<a href="<?php Helper::options()->adminUrl('options-theme.php'); ?>">这里</a></div>
<script language="JavaScript">window.setTimeout("location=\'<?php Helper::options()->adminUrl('options-theme.php'); ?>\'", 2000);</script>
<?php
}else{
echo '<div class="tongzhi">没有模板备份数据,恢复不了哦!</div>';
}
}
if($_POST["type"]=="删除备份数据"){
if($db->fetchRow($db->select()->from ('table.options')->where ('name = ?', 'theme:TinaThemebf'))){
$delete = $db->delete('table.options')->where ('name = ?', 'theme:TinaThemebf');
$deletedRows = $db->query($delete);
echo '<div class="tongzhi">删除成功,请等待自动刷新,如果等不到请点击';
?>
<a href="<?php Helper::options()->adminUrl('options-theme.php'); ?>">这里</a></div>
<script language="JavaScript">window.setTimeout("location=\'<?php Helper::options()->adminUrl('options-theme.php'); ?>\'", 2500);</script>
<?php
}else{
echo '<div class="tongzhi">不用删了!备份不存在!!!</div>';
}
}
}
echo '<h2>主题备份</h2><form class="protected" action="?TinaThemebf" method="post">
<input type="submit" name="type" class="btn btn-s" value="备份模板数据" />&nbsp;&nbsp;<input type="submit" name="type" class="btn btn-s" value="还原模板数据" />&nbsp;&nbsp;<input type="submit" name="type" class="btn btn-s" value="删除备份数据" /></form>';
?>
4 changes: 2 additions & 2 deletions core/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ function Links($short = false)
foreach ($list as $val) {
list($name, $url, $description, $logo) = explode(',', $val);
if ($short) {
$link .= '<li><a target="_blank" rel="nofollow" href="' . $url . '"><img src="' . $logo . '"><h4>@' . $name . '</h4><p>' . $description . '</p></a></li>' . "\n";
$link .= '<li><a target="_blank" rel="nofollow" href="' . $url . '"><img src="' . $logo . '"><div class="linkpage_links">@' . $name . '</div><p>' . $description . '</p></a></li>' . "\n";
} else {
$link .= '<li><a target="_blank" rel="nofollow" href="' . $url . '"><img src="' . $logo . '"><h4>@' . $name . '</h4><p>' . $description . '</p></a></li>' . "\n";
$link .= '<li><a target="_blank" rel="nofollow" href="' . $url . '"><img src="' . $logo . '"><div class="linkpage_links">@' . $name . '</div><p>' . $description . '</p></a></li>' . "\n";
}
}
}
Expand Down
8 changes: 1 addition & 7 deletions footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,7 @@
<script src="<?php $this->options->themeUrl('/assets/js/katex.support.js'); ?>"></script>
<?php endif; ?>
<?php if ($this->options->MathRender == 'MathJax'): ?>
<script type="text/javascript">
window.MathJax = {
tex: {
inlineMath: [['$','$'], ['\\(','\\)']],
}
};
</script>
<script type="text/javascript">window.MathJax={tex:{inlineMath:[['$','$'],['\\(','\\)']],}};</script>
<script src="//cdn.bootcdn.net/ajax/libs/mathjax/3.2.2/es5/tex-mml-chtml.min.js"></script>
<?php endif; ?>
<?php if ($this->options->MathRender == 'Close'): ?>
Expand Down
24 changes: 24 additions & 0 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
require_once __DIR__ . '/core/functions.php';

function themeConfig($form) {
require_once __DIR__ . '/core/backup.php';
/* 外观 */
$TheNotice = new Typecho_Widget_Helper_Form_Element_Text('TheNotice', NULL, NULL, _t('<h2>基础外观</h2>'));
$TheNotice->input->setAttribute('style', 'display:none');
Expand Down Expand Up @@ -45,6 +46,18 @@ function themeConfig($form) {
);
$form->addInput($compressHtml);

$JqueryControl = new Typecho_Widget_Helper_Form_Element_Radio(
'JqueryControl',
array(
1 => _t('启用'),
0 => _t('关闭')
),
1,
_t('JqueryControl'),
_t('默认开启,<font color="#ed5a65">如果要使用PJAX、Fancybox必须开启 Jquery 控件!</font>')
);
$form->addInput($JqueryControl);

$fancybox = new Typecho_Widget_Helper_Form_Element_Radio(
'fancybox',
array(
Expand Down Expand Up @@ -145,6 +158,17 @@ function themeConfig($form) {
_t('评论区的加减法验证系统,关闭后反垃圾评论效果降低。')
);
$form->addInput($TheVerification);

$GravatarUrl = new Typecho_Widget_Helper_Form_Element_Radio('GravatarUrl',
array
(
false => _t('官方源'),
'https://cdn.helingqi.com/avatar/' => _t('禾令奇源'),
'https://sdn.geekzu.org/avatar/' => _t('极客族源'),
'https://dn-qiniu-avatar.qbox.me/avatar/' => _t('七牛源')
),
'https://cdn.helingqi.com/avatar/', _t('Gravatar头像源'), _t('默认禾令奇源'));
$form->addInput($GravatarUrl);

/* Notice */
$TheNotice = new Typecho_Widget_Helper_Form_Element_Text('TheNotice', NULL, NULL, _t('<h2>网站公告 <small>Notice</small></h2>'));
Expand Down
4 changes: 3 additions & 1 deletion header.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@
<link rel="stylesheet" type="text/css" href="//cdn.bootcdn.net/ajax/libs/highlight.js/11.6.0/styles/androidstudio.min.css"/>
<script src="//cdn.bootcdn.net/ajax/libs/highlight.js/11.6.0/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
<?php if ($this->options->JqueryControl): ?>
<script src="//cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<?php endif; ?>
<?php if ($this->options->fancybox): ?>
<link href="//cdn.bootcdn.net/ajax/libs//fancybox/3.5.7/jquery.fancybox.min.css" rel="stylesheet">
<script src="//cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script src="//cdn.bootcdn.net/ajax/libs/fancybox/3.5.7/jquery.fancybox.min.js"></script>
<?php endif; ?>
</head>
Expand Down
4 changes: 2 additions & 2 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
/**
* 移植自<a href="https://limxw.com/" target="_blank">WingLim</a>的<a href="https://github.com/WingLim/hugo-tania" target="_blank">hugo-tania</a>主题,在其基础上进行了深度修改的 TinaTheme 或许是你在Typecho上最好的选择
* <hr><div style="width:fit-content" id="TinaTheme">版本检测中...&nbsp;</div>
* <script>var simversion="2.0.0";function update_detec(){var container=document.getElementById("TinaTheme");if(!container){return}var ajax=new XMLHttpRequest();container.style.display="block";ajax.open("get","https://assets.fmcf.cc/Theme/tina.json");ajax.send();ajax.onreadystatechange=function(){if(ajax.readyState===4&&ajax.status===200){var obj=JSON.parse(ajax.responseText);var newest=obj.tag_name;if(newest>simversion){container.innerHTML="发现新主题版本:"+obj.name+'。下载地址:<a href="'+obj.zipball_url+'">点击下载</a>'+"<br>您目前的版本:"+String(simversion)+"。"+'<a target="_blank" href="'+obj.html_url+'">👉查看新版亮点</a>'}else{container.innerHTML="您目前的版本:"+String(simversion)+"。"+"您目前使用的是最新版。"}}}};update_detec();</script>
* <script>var simversion="2.0.1";var buildversion = "22815";function update_detec(){var container=document.getElementById("TinaTheme");if(!container){return}var ajax=new XMLHttpRequest();container.style.display="block";ajax.open("get","https://assets.fmcf.cc/Theme/tina.json");ajax.send();ajax.onreadystatechange=function(){if(ajax.readyState===4&&ajax.status===200){var obj=JSON.parse(ajax.responseText);var newest=obj.Build;if(newest>buildversion){container.innerHTML="发现新主题版本:"+obj.name+'。下载地址:<a href="'+obj.zipball_url+'">点击下载</a>'+"<br>您目前的版本:"+String(simversion)+"。"+'<a target="_blank" href="'+obj.html_url+'">👉查看新版亮点</a>'}else{container.innerHTML="您目前的版本:"+String(simversion)+"。"+"您目前使用的是最新版。"}}}};update_detec();</script>
*
* @package Tina Theme
* @author Magneto
* @version 2.0.0
* @version 2.0.1
* @link https://www.fmcf.cc
*/

Expand Down
3 changes: 0 additions & 3 deletions page-links.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@
$pattern = '/\<img.*?src\=\"(.*?)\".*?alt\=\"(.*?)\".*?title\=\"(.*?)\"[^>]*>/i';
$replacement = '<a href="$1" data-fancybox="gallery" /><img src="$1" alt="$2" title="$3"></a>';
$content = preg_replace($pattern, $replacement, $this->content);
//内容截断
$array=explode('<!--more-->', $content);
$content=$array[0];
echo getContentTest($this->content);
?>
<?php else: ?>
Expand Down
3 changes: 0 additions & 3 deletions page.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@
$pattern = '/\<img.*?src\=\"(.*?)\".*?alt\=\"(.*?)\".*?title\=\"(.*?)\"[^>]*>/i';
$replacement = '<a href="$1" data-fancybox="gallery" /><img src="$1" alt="$2" title="$3"></a>';
$content = preg_replace($pattern, $replacement, $this->content);
//内容截断
$array=explode('<!--more-->', $content);
$content=$array[0];
echo getContentTest($this->content);
?>
<?php else: ?>
Expand Down
3 changes: 0 additions & 3 deletions post.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@
$pattern = '/\<img.*?src\=\"(.*?)\".*?alt\=\"(.*?)\".*?title\=\"(.*?)\"[^>]*>/i';
$replacement = '<a href="$1" data-fancybox="gallery" /><img src="$1" alt="$2" title="$3"></a>';
$content = preg_replace($pattern, $replacement, $this->content);
//内容截断
$array=explode('<!--more-->', $content);
$content=$array[0];
echo getContentTest($content)
?>
<?php else: ?>
Expand Down

0 comments on commit 47514e2

Please sign in to comment.