summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorEltrac <hi@guhub.cn>2022-11-09 10:43:03 +0800
committerGitHub <noreply@github.com>2022-11-09 10:43:03 +0800
commitb4e65c442b729ab6352b7a291daeb8af8a20fa82 (patch)
tree3ae8bfeb75308768c09b29f9794896551f1dcae3 /libs
parentbf285ac1dee6be5f9c7961549dd904c2f9066094 (diff)
parenta6c41081a273a023c48779f15f63dcd1b1b87517 (diff)
Merge pull request #11 from KurococLiu/main
Fix: 新增字数统计、preconnect,修正部分文本错误、更进文档内容
Diffstat (limited to 'libs')
-rw-r--r--libs/Comments.php4
-rw-r--r--libs/Matcha.php36
-rw-r--r--libs/Options.php12
3 files changed, 49 insertions, 3 deletions
diff --git a/libs/Comments.php b/libs/Comments.php
index 0d3b3b1..52a7c6a 100644
--- a/libs/Comments.php
+++ b/libs/Comments.php
@@ -36,13 +36,13 @@ Class Comments {
}
/**
- * 获取 Gravatar 头像链接
+ * 获取 Cravatar 头像链接
*/
public static function gravatar($email, int $size = 100, int $useCDN = NULL)
{
//MD5 EMail
$email = md5($email);
- $avatar = 'https://gravatar.loli.net/avatar/' . $email . '?s=' . $size;
+ $avatar = 'https://cravatar.cn/avatar/' . $email . '?s=' . $size;
return $avatar;
}
diff --git a/libs/Matcha.php b/libs/Matcha.php
index 1ec3c39..fd6135b 100644
--- a/libs/Matcha.php
+++ b/libs/Matcha.php
@@ -12,6 +12,7 @@ class Matcha
* 包括 css 引用、标题
*/
public static function head() {
+ Matcha::preconnect();
Matcha::linkCSS();
Matcha::iconfont();
Helper::options()->customHead();
@@ -68,7 +69,32 @@ class Matcha
echo '" />';
}
}
-
+
+ /**
+ * 输出 preconnect 标签
+ */
+ public static function preconnect() {
+ if(isset(Helper::options()->StaticCDN) && Helper::options()->StaticCDN!='local'){
+ if(Helper::options()->StaticCDN=='bytedance'){
+ $src_link = array(
+ '//lf3-cdn-tos.bytecdntp.com/',
+ '//lf9-cdn-tos.bytecdntp.com/',
+ '//lf26-cdn-tos.bytecdntp.com/',
+ );
+ }
+ elseif(Helper::options()->StaticCDN=='cdnjs'){
+ $src_link = array(
+ '://cdnjs.cloudflare.com/',
+ );
+ }
+ echo '<!-- 预连接 -->';
+ foreach($src_link as $value){
+ echo '<link rel="preconnect" href="'.$value.'" />';
+ }
+
+ }
+ }
+
/**
* 引用 iconfont
*/
@@ -290,6 +316,14 @@ class Matcha
*/
static public function footerInfo()
{
+ //字数统计
+ if (Helper::options()->EnableWordsCounter=='able') {
+
+ echo '<br />';
+ echo '一共书写了';
+ WordsCounter_Plugin::allOfCharacters();
+ echo '字';
+ }
//备案号
if (Helper::options()->icpNum!='') {
echo '<br />';
diff --git a/libs/Options.php b/libs/Options.php
index fde322b..65cbcce 100644
--- a/libs/Options.php
+++ b/libs/Options.php
@@ -133,6 +133,18 @@ function themeConfig($form) {
')
);
$form->addInput($EnableBusuanzi->addRule('required', _t('此处必须设置')));
+ //启用字数统计
+ $EnableWordsCounter = new Typecho_Widget_Helper_Form_Element_Radio('EnableWordsCounter', array(
+ 'able' => _t('启用'),
+ 'disable' => _t('停用'),
+ ),
+ 'disable',
+ _t('是否启用 <a rel="nofollow" target="_blank" href="https://github.com/elatisy/Typecho_WordsCounter">字数统计</a> 功能'),
+ _t('
+ <a rel="nofollow" target="_blank" href="https://github.com/elatisy/Typecho_WordsCounter">字数统计</a>是一个基于WordsCounter插件统计全站字数的
+ ')
+ );
+ $form->addInput($EnableWordsCounter->addRule('required', _t('此处必须设置')));
/**
* 自定义 & 开发者设置