summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBigCoke233 <hi@guhub.cn>2020-04-15 17:26:50 +0800
committerBigCoke233 <hi@guhub.cn>2020-04-15 17:26:50 +0800
commit3def1ca01fc20e6f6da887182202f10047e3a912 (patch)
treec9aac5f5fc2cefb94b4903a56fde0cbba0877bd5
parent7866c9f6a2353fd93a279b5a22872c52bb81b08b (diff)
:alien: Add: 添加 9jojo CDN 作为静态文件加速选择
-rw-r--r--footer.php49
-rw-r--r--functions.php21
-rw-r--r--includes/footer.php7
-rwxr-xr-xlibs/Options.php24
4 files changed, 38 insertions, 63 deletions
diff --git a/footer.php b/footer.php
deleted file mode 100644
index 731b2d7..0000000
--- a/footer.php
+++ /dev/null
@@ -1,49 +0,0 @@
-<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
- </div><!-- 结束 pjax-container -->
- <!-- Footer Information -->
- <footer>
- <div class="footer-info footer-dark">
- <?php $this->options->footerEcho(); ?>
- <p class="copyright">Powered by <a href="http://typecho.org">Typecho</a> | Theme <a href="https://guhub.cn/p/miracles.html">Miracles</a> by <a href="https://guhub.cn">Eltrac</a><br>
- Copyright &copy; <?php echo date('Y'); ?> <a href="<?php $this->options->SiteUrl(); ?>"><?php $this->options->title(); ?></a>, All rights reserved.<br>
- <?php
- echo $this->options->build_time?"记录已延续了 <span id=\"build-time\"></span>":"";
- if($faces=$this->options->anime_face){
- $faces = explode("&&",$faces);
- $faces = "<span class=\"anime-face\">".$faces[mt_rand(0,count($faces))]."</span>";
- }
- if($faces && $this->options->build_time)echo $faces;
- ?></p>
- </div>
- </footer>
-
- <!-- Raised Buttons -->
- <div class="fixed-tools">
- <button title="返回顶部" class="fixed-button gotop-button" id="gotop"><i class="iconfont icon-chevron-up"></i></button>
- </div>
- <!-- JavaScript -->
- <?php
- $js_files=array("jquery","pjax.jquery","jquery.fancybox","jquery.lazyload.min","nprogress","OwO.min","highlight","highlight-line-number","pangu");
- generate_require($js_files,"js",$this->options->CDN?"https://cdn.jsdelivr.net/gh/BigCoke233/miracles@":"");
- ?>
- <!-- Varribles and Functions -->
- <script>
- var allowNavAero = <?php if($this->options->navAero):?>false<?php else:?>true<?php endif;?>;
- var siteurl = '<?php $this->options->SiteUrl() ;?>';
- var owoJson = '<?php Utils::indexTheme('assets/OwO.json'); ?>';
- <?php if($this->options->pjax && $this->options->pjax!=0) :?>var loadPjax = true;
- beforePjax = function() {NProgress.start();};
- afterPjax = function() {owoLoad();<?php $this->options->pjax_complete(); ?>};<?php endif; ?></script>
- <!-- Script that must be after-->
- <script src="<?php Utils::indexTheme('assets/js/cmt.miracles.js'); ?>"></script>
- <script src="<?php Utils::indexTheme('assets/js/miracles.min.js'); ?>"></script>
- <!-- BuildTime -->
- <script>
- <?php if($this->options->build_time)echo "startTime(\"".$this->options->build_time."\");" ?>
- </script>
- <!-- Send News and Loaders -->
- <script><?php if($this->is('post') || $this->is('page')): ?>owoLoad();<?php endif; ?><?php $this->options->jsEcho(); ?></script>
- <!-- Others -->
- <?php $this->footer(); ?>
- </body>
-</html>
diff --git a/functions.php b/functions.php
index 1ddceb2..d6d4f73 100644
--- a/functions.php
+++ b/functions.php
@@ -82,24 +82,29 @@ array_push($views, $cid);
*/
function generate_require($files,$type,$cdn,$custom) {
if ($cdn=='1'){
- $path = 'https://cdn.jsdelivr.net/gh/BigCoke233/miracles@'.themeVersion()."/";
+ $path = 'https://cdn.jsdelivr.net/gh/BigCoke233/miracles@'.themeVersion()."/assets/";
}
elseif ($cdn=='2'){
- $path = 'https://raw.githack.com/BigCoke233/miracles/master/';
+ $path = 'https://raw.githack.com/BigCoke233/miracles/master/assets/';
}
elseif ($cdn=='4'){
- $path = 'https://rawcdn.githack.com/BigCoke233/miracles/master/';
+ $path = 'https://rawcdn.githack.com/BigCoke233/miracles/master/assets/';
+ }
+ elseif ($cdn=='5'){
+ $path = 'https://cdn.9jojo.cn/Miracles/';
}
elseif ($cdn=='3'){
$path = $custom;
}else{
- $path = Helper::options()->themeUrl("","Miracles");
+ $path = Helper::options()->themeUrl("","Miracles/assets");
}
foreach ($files as $file) {
- if ($type == "js")
- echo "<script src=".$path."assets/".$type."/".$file.".".$type."></script>";
- elseif ($type == "css")
- echo "<link rel=\"stylesheet\" href=".$path."assets/".$type."/".$file.".".$type." />";
+ if ($type == "js"){
+ echo "<script src=".$path. $type."/".$file.".".$type."></script>";
+ }
+ elseif ($type == "css"){
+ echo "<link rel=\"stylesheet\" href=".$path. $type."/".$file.".".$type." />";
+ }
}
}
diff --git a/includes/footer.php b/includes/footer.php
index 670367e..873e04c 100644
--- a/includes/footer.php
+++ b/includes/footer.php
@@ -36,8 +36,11 @@
beforePjax = function() {NProgress.start();};
afterPjax = function() {owoLoad();<?php $this->options->pjax_complete(); ?>};<?php endif; ?></script>
<!-- Script that must be after-->
- <script src="<?php Utils::indexTheme('assets/js/cmt.miracles.js'); ?>"></script>
- <script src="<?php Utils::indexTheme('assets/js/miracles.min.js'); ?>"></script>
+ <?php
+ $js_files=array("miracles.min","cmt.miracles");
+ if($this->options->customCDN): $custom=$this->options->customCDN; else: $custom=Helper::options()->themeUrl("","Miracles"); endif;
+ generate_require($js_files,"js",$this->options->CDN,$custom);
+ ?>
<!-- JavaScript -->
<script>
<?php if($this->options->build_time)echo "startTime(\"".$this->options->build_time."\");" ?>
diff --git a/libs/Options.php b/libs/Options.php
index b8e1b07..4f3bf6a 100755
--- a/libs/Options.php
+++ b/libs/Options.php
@@ -134,13 +134,23 @@ function themeConfig($form) {
$form->addInput($bannerHeight);
//pjax
- $pjax = new Typecho_Widget_Helper_Form_Element_Select('pjax',array('0'=>'关闭','1'=>'开启'),'1','<h2>Pjax 预加载</h2>是否开启','Pjax 预加载功能的开关');
+ $pjax = new Typecho_Widget_Helper_Form_Element_Select('pjax',array(
+ '0'=>'关闭',
+ '1'=>'开启'
+ ),'1','<h2>Pjax 预加载</h2>是否开启','Pjax 预加载功能的开关');
$form->addInput($pjax);
$pjax_complete = new Typecho_Widget_Helper_Form_Element_Textarea('pjax_complete', NULL, NULL, _t('完成后执行事件'), _t('Pjax 跳转页面后执行的事件,写入 js 代码,一般将 Pjax 重载(回调)函数写在这里。<hr>'));
$form->addInput($pjax_complete);
//improve
- $CDN = new Typecho_Widget_Helper_Form_Element_Select('CDN',array('0'=>'关闭','1'=>'jsDelivr','2'=>'GitHack(实时更新)','4'=>'GitHack CDN(较慢)','3'=>'自定义'),'0','<h2>优化</h2>CDN 加速加载静态资源(Beta)','开启后静态资源文件通过选择的 CDN 进行调用,加快网页加载速度。如果选择自定义则需要填写下一个设置项。<br>* 如果你使用开发版,请不要选择 jsDelivr 作为 CDN<br>* GitHack 是实时更新的,如果你不是要开发测试主题,最好不要选用');
+ $CDN = new Typecho_Widget_Helper_Form_Element_Select('CDN',array(
+ '0'=>'关闭',
+ '1'=>'jsDelivr',
+ '2'=>'GitHack(实时更新)',
+ '4'=>'GitHack CDN(较慢)',
+ '5'=>'9jojo CDN(实时更新)',
+ '3'=>'自定义'),'0','<h2>优化</h2>CDN 加速加载静态资源(Beta)',
+ '开启后静态资源文件通过选择的 CDN 进行调用,加快网页加载速度。如果选择自定义则需要填写下一个设置项。<br>* 如果你使用开发版,请不要选择 jsDelivr 作为 CDN<br>* GitHack 和 9jojo 是实时更新的,如果你不是随时更新开发版,最好不要选用<br>* GitHack CDN 速度较慢,国内不建议使用,<del>就是拿来凑数的</del><br>在这里感谢<a href="https://github.com/SatoSouta/9jojo">小太</a>为 Miracles 提供 9jojo CDN');
$form->addInput($CDN);
$customCDN = new Typecho_Widget_Helper_Form_Element_Text('customCDN', NULL, '', _t('自定义 CDN'), _t('输入 CDN 的链接,要保证写入的路径下,目录结构和主题的 assets 目录下一致'));
$form->addInput($customCDN);
@@ -150,9 +160,15 @@ function themeConfig($form) {
$form->addInput($pangu);
//custom style
- $grayTheme = new Typecho_Widget_Helper_Form_Element_Select('grayTheme',array('0'=>'关闭','1'=>'开启'),'0','<h2>个性化</h2>哀悼模式','打开后网站变为黑白');
+ $grayTheme = new Typecho_Widget_Helper_Form_Element_Select('grayTheme',array(
+ '0'=>'关闭',
+ '1'=>'开启'
+ ),'0','<h2>个性化</h2>哀悼模式','打开后网站变为黑白');
$form->addInput($grayTheme);
- $bodyFonts = new Typecho_Widget_Helper_Form_Element_Select('bodyFonts',array('0'=>'无衬线字体','1'=>'衬线字体'),'0','网站字体','选择网站的字体,无衬线字体即“思源黑体”,衬线字体即“思源宋体”');
+ $bodyFonts = new Typecho_Widget_Helper_Form_Element_Select('bodyFonts',array(
+ '0'=>'无衬线字体',
+ '1'=>'衬线字体'
+ ),'0','网站字体','选择网站的字体,无衬线字体即“思源黑体”,衬线字体即“思源宋体”');
$form->addInput($bodyFonts);
$randomBanner = new Typecho_Widget_Helper_Form_Element_Textarea('randomBanner', NULL, NULL, _t('随机文章缩略图'), _t('文章没有独立设置头图时调用,写入图片链接,用半角逗号分割'));
$form->addInput($randomBanner);