Skip to content

Commit

Permalink
Merge pull request #28 from ouyangyanhuo/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
ouyangyanhuo committed Jun 23, 2023
2 parents 1e75729 + 2bb8343 commit 01d236c
Show file tree
Hide file tree
Showing 12 changed files with 50 additions and 19 deletions.
10 changes: 6 additions & 4 deletions README.md
Expand Up @@ -29,10 +29,12 @@ _Haku,是 Tina 小姐最爱的喵喵,它在这里守卫着 Tina 小姐_
原主题:[https://github.com/WingLim/hugo-tania](https://github.com/WingLim/hugo-tania)

## 最近版本更新日志
- 调整了 自定义页脚部分的位置
- 更改为原版 Jquery Pjax 进行加载
- 使用原版 Jquery Pjax 进行加载后,支持了MathJax的加载
- 使用原版 Jquery Pjax 进行加载后,支持了对夜间模式的正常加载
- ✨ 新增对鼠标美化的UA检测,手机端将不再显示
- ✨ 新增代码块复制功能
- ✨ 新增图片Lazyload,需开启Jquery,开启图片灯箱即可开启Lazyload
- 精简底部版权信息
- ⚠️ TinaTheme 于 `2.1.2-Build30608-Dev-No.4` 版本更新了静态资源库,请自建静态资源的用户更新后及时比对[文档](https://tina.docs.fmcf.cc/optimization/public_cdn/)更新,以免资源失效


## 功能与特性

Expand Down
2 changes: 2 additions & 0 deletions assets/js/codecopy.js

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

2 changes: 1 addition & 1 deletion assets/js/cursor.js

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

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.

6 changes: 6 additions & 0 deletions core/functions.php
Expand Up @@ -306,6 +306,12 @@ function staticUrl($file = ''){
'cf' => 'cdnjs.cloudflare.com/ajax/libs/jquery.pjax/2.0.1/jquery.pjax.min.js',
'jd' => 'cdn.jsdelivr.net/npm/jquery-pjax@2.0.1/jquery.pjax.min.js',
'custom' => isset($lists[11]) ? $lists[11] : ''
],
'jquery.lazyload.min.js' => [
'bc' => 'cdn.bootcdn.net/ajax/libs/jquery_lazyload/1.9.7/jquery.lazyload.min.js',
'cf' => 'cdnjs.cloudflare.com/ajax/libs/jquery_lazyload/1.9.7/jquery.lazyload.min.js',
'jd' => 'cdn.jsdelivr.net/npm/jquery-lazyload@1.9.7/jquery.lazyload.min.js',
'custom' => isset($lists[12]) ? $lists[12] : ''
]
];
if (isset($cjCDNlinks[$file])) {
Expand Down
16 changes: 13 additions & 3 deletions footer.php
Expand Up @@ -4,7 +4,7 @@
<?php $this->options->FooterHTML() ?>
<?php endif; ?>
<nav class="footer-links">
<p><center>Copyright © 2021- <?php echo date("Y"); ?> Magneto<br>Theme <a href="https://fmcf.cc" target="_blank">TinaTheme</a> By Magneto</center></p>
<p><center>Theme <a href="https://fmcf.cc" target="_blank">TinaTheme</a> By Magneto</center></p>
</nav>
</section>
<!--KaTeX-->
Expand All @@ -23,17 +23,27 @@
<?php if ($this->options->MathRender == 'Close'): ?>
<?php endif; ?>
<script src="<?php $this->options->themeUrl('/assets/js/features.js'); ?>" data-enable-footnotes="true"></script>
<script src="<?php $this->options->themeUrl(); ?>/assets/js/codecopy.js"></script>
</footer>
<?php if ($this->options->WebPjax): ?>
<script src="<?= staticUrl('jquery.pjax.min.js') ?>"></script>
<link href="<?= staticUrl('nprogress.min.css') ?>" rel="stylesheet">
<script src="<?= staticUrl('nprogress.min.js') ?>"></script>
</div>
<script>$(document).pjax('a[href^="<?php Helper::options()->siteUrl()?>"]:not(a[target="_blank"],a[no-pjax]), a[href^="?"], a[href^="/"]',{container:'#pjax-load',fragment:'#pjax-load',timeout:8000}).on('pjax:send',function(){NProgress.start()}).on('pjax:complete',function(){NProgress.done();hljs.initHighlightingOnLoad();MathJax.typeset()});$(document).on('pjax:success',function(){$.getScript('<?php $this->options->themeUrl('/assets/js/features.js'); ?>',function(){})});</script>
<script>$(document).pjax('a[href^="<?php Helper::options()->siteUrl()?>"]:not(a[target="_blank"],a[no-pjax]), a[href^="?"], a[href^="/"]',{container:'#pjax-load',fragment:'#pjax-load',timeout:8000}).on('pjax:send',function(){NProgress.start()}).on('pjax:complete',function(){NProgress.done();hljs.initHighlightingOnLoad();MathJax.typeset()});$(document).on('pjax:success',function(){$.getScript('<?php $this->options->themeUrl('/assets/js/features.js'); ?>',function(){});$.getScript('<?php $this->options->themeUrl('/assets/js/codecopy.js'); ?>', function() {})});</script>
<?php endif; ?>
</body>
<?php if ($this->options->cursor): ?>
<script src="<?php $this->options->themeUrl('/assets/js/cursor.js'); ?>" data-enable-footnotes="true"></script>
<?php
$ua = $_SERVER['HTTP_USER_AGENT'];
$is_mobile = preg_match('/(iPhone|iPad|iPod|Android|BlackBerry|Windows Phone)/i', $ua);
$mobile = $is_mobile ? true : false;
if ($mobile == false) {
echo '<script src="';
$this->options->themeUrl('/assets/js/cursor.js');
echo '" data-enable-footnotes="true"></script>';
}
?>
<?php endif; ?>
<?php $this->footer(); ?>
</html>
Expand Down
8 changes: 4 additions & 4 deletions functions.php
Expand Up @@ -25,7 +25,7 @@ function themeConfig($form) {
),
0,
_t('鼠标美化'),
_t('开启后电脑端网页会对鼠标进行美化,默认关闭)')
_t('开启后电脑端网页会对鼠标进行美化,手机端不会美化,默认关闭')
);
$form->addInput($cursor);

Expand Down Expand Up @@ -98,7 +98,7 @@ function themeConfig($form) {
null,
null,
_t('公共静态资源自建地址'),
_t('只在上面的选项选择自建时需要')
_t('只在上面的选项选择自建时需要,<a href="https://tina.docs.fmcf.cc/optimization/public_cdn/" target="_blank">[查看建规则]</a>')
);
$form->addInput($cjCDNlink);

Expand All @@ -115,7 +115,7 @@ function themeConfig($form) {
),
1,
_t('JqueryControl'),
_t('默认开启,<font color="#ed5a65">如果要使用PJAX、Fancybox必须开启 Jquery 控件!</font>')
_t('默认开启,<font color="#ed5a65">如果要使用PJAX、Fancybox、Lazyload必须开启 Jquery 控件!</font>')
);
$form->addInput($JqueryControl);

Expand All @@ -126,7 +126,7 @@ function themeConfig($form) {
0 => _t('关闭')
),
1,
_t('图片灯箱'),
_t('图片灯箱及Lazyload'),
_t('默认开启,启用后可以优化图片浏览的体验')
);
$form->addInput($fancybox);
Expand Down
1 change: 1 addition & 0 deletions header.php
Expand Up @@ -38,6 +38,7 @@
<?php if ($this->options->fancybox): ?>
<link href="<?= staticUrl('jquery.fancybox.min.css') ?>" rel="stylesheet">
<script src="<?= staticUrl('jquery.fancybox.min.js') ?>"></script>
<script src="<?= staticUrl('jquery.lazyload.min.js') ?>"></script>
<?php endif; ?>
</head>
<body>
Expand Down
4 changes: 2 additions & 2 deletions index.php
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.1.1";var buildversion = "30317";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_update.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>
* <script>var simversion="2.1.2";var buildversion = "30608";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_update.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.1.1
* @version 2.1.2
* @link https://www.fmcf.cc
*/

Expand Down
2 changes: 1 addition & 1 deletion page-links.php
Expand Up @@ -25,7 +25,7 @@
<?php if ($this->options->fancybox): ?>
<?php
$pattern = '/\<img.*?src\=\"(.*?)\".*?alt\=\"(.*?)\".*?title\=\"(.*?)\"[^>]*>/i';
$replacement = '<a href="$1" data-fancybox="gallery" /><img src="$1" alt="$2" title="$3"></a>';
$replacement = '<a href="$1" data-fancybox="gallery" /><img class="lazy" data-original="$1" alt="$2" title="$3"></a>';
$content = preg_replace($pattern, $replacement, $this->content);
echo getContentTest($this->content);
?>
Expand Down
2 changes: 1 addition & 1 deletion page.php
Expand Up @@ -30,7 +30,7 @@
<?php if ($this->options->fancybox): ?>
<?php
$pattern = '/\<img.*?src\=\"(.*?)\".*?alt\=\"(.*?)\".*?title\=\"(.*?)\"[^>]*>/i';
$replacement = '<a href="$1" data-fancybox="gallery" /><img src="$1" alt="$2" title="$3"></a>';
$replacement = '<a href="$1" data-fancybox="gallery" /><img class="lazy" data-original="$1" alt="$2" title="$3"></a>';
$content = preg_replace($pattern, $replacement, $this->content);
echo getContentTest($this->content);
?>
Expand Down
12 changes: 11 additions & 1 deletion post.php
@@ -1,4 +1,14 @@
<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
/*
* @Author: Magneto github.com:ouyangyanhuo
* @Date: 2023-06-08 10:43:31
* @LastEditors: ouyangyanhuo ouyangyanhuo@vip.qq.com
* @LastEditTime: 2023-06-23 18:11:52
* @FilePath: \AdminMDf:\Github Projects\TinaTheme\post.php
* @Description:
* EMail:magneto@88.com
* Copyright (c) 2023 by Magneto, All Rights Reserved.
*/
<?php $this->need('header.php'); ?>
<main>
<div class="container">
Expand Down Expand Up @@ -33,7 +43,7 @@
<?php if ($this->options->fancybox): ?>
<?php
$pattern = '/\<img.*?src\=\"(.*?)\".*?alt\=\"(.*?)\".*?title\=\"(.*?)\"[^>]*>/i';
$replacement = '<a href="$1" data-fancybox="gallery" /><img src="$1" alt="$2" title="$3"></a>';
$replacement = '<a href="$1" data-fancybox="gallery" /><img class="lazy" data-original="$1" alt="$2" title="$3"></a>';
$content = preg_replace($pattern, $replacement, $this->content);
echo getContentTest($content)
?>
Expand Down

0 comments on commit 01d236c

Please sign in to comment.