Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

适配友链插件和新增Cravatar头像源 #65

Merged
merged 7 commits into from
Jun 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ function themeConfig($form) {
"https://sdn.geekzu.org/avatar/" => '极客族',
"https://cdn.sep.cc/avatar/" => '九月的风',
"https://gravatar.com/avatar/" => '官方源(被墙)',
"https://cravatar.cn/avatar/" => '中国官方源(推荐)',
),
'loli',
'gravatar源选择',
Expand All @@ -226,6 +227,12 @@ function themeConfig($form) {
$GravatarSelect->setAttribute('id', 'gravatarlist');
$form->addInput($GravatarSelect->multiMode());

$baidustatistics = new Typecho_Widget_Helper_Form_Element_Text('baidustatistics', NULL,_t(''), _t('百度统计'), _t('仅需要https://hm.baidu.com/hm.js?xxxxxxxxxxxxxxxxxx部分即可'));
$form->addInput($baidustatistics);

$googleadsense = new Typecho_Widget_Helper_Form_Element_Text('googleadsense', NULL,_t(''), _t('谷歌广告'), _t('仅需要https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?xxxxxxxxx部分即可'));
$form->addInput($googleadsense);

$EnablePjax = new Typecho_Widget_Helper_Form_Element_Select('EnablePjax',
array(
'off' => '关闭(默认)',
Expand All @@ -246,6 +253,18 @@ function themeConfig($form) {
$form->addInput($PjaxCallBack);

/* 友链设置 */
$friendset = new Typecho_Widget_Helper_Form_Element_Select('friendset',
array(
'1' => '插件模式',
'2' => '主题模式',
),
'2',
'是否使用Link插件进行友链(需点击<a href="https://github.com/JoyNop/Typecho-Links">这里</a>下载)',
'介绍:新手和手残党极其友好,默认从主题读取防止报错'
);
$friendset->setAttribute('id', 'friendset');
$form->addInput($friendset);

$Friends = new Typecho_Widget_Helper_Form_Element_Textarea('Friends',NULL,NULL,
'友情链接(非必填)',
'介绍:用于填写友情链接 <br />
Expand Down
27 changes: 24 additions & 3 deletions header_com.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<!DOCTYPE HTML>
<html data-theme="light" class="">
<head>
<meta content="always" name="referrer">
<link rel="icon" type="image/png" href="<?php $this->options->Sitefavicon() ?>">
<meta charset="<?php $this->options->charset(); ?>">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
Expand All @@ -20,13 +21,30 @@
<!-- 使用url函数转换相关路径 -->
<link rel="preconnect" href="//<?php $this->options->jsdelivrLink() ?>" />
<link rel="preconnect" href="//cdn.staticfile.org" />
<link rel="preconnect" href="//static.nuoyis.com" />
<!--<link rel="stylesheet" href="https://gcore.jsdelivr.net/npm/justifiedGallery/dist/css/justifiedGallery.min.css">-->
<link rel="stylesheet" href="<?php $this->options->themeUrl('index.css?v1.7.3'); ?>">
<link rel="stylesheet" href="<?php $this->options->themeUrl('css/style.css?v1.7.4'); ?>">
<!--魔改美化-->
<?php if (!empty($this->options->beautifyBlock) && in_array('ShowBeautifyChange',$this->options->beautifyBlock)): ?>
<link rel="stylesheet" href="<?php $this->options->themeUrl('css/custom.css?v1.5.9'); ?>">
<?php endif; ?>
<!--百度统计-->
<?php if($this->options->baidustatistics != ""): ?>
<script>
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?<?php $this->options->baidustatistics(); ?>";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
<?php endif; ?>
<!--谷歌AdSense广告-->
<?php if($this->options->googleadsense != ""): ?>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?<?php $this->options->googleadsense(); ?>" crossorigin="anonymous"></script>
<?php endif; ?>
<!--图标库-->
<link href="https://at.alicdn.com/t/font_3159629_5bvsat8p5l.css" rel="stylesheet" />
<link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.1.1/css/all.min.css">
Expand Down Expand Up @@ -56,6 +74,9 @@
@media screen and (max-width:900px){
#aside-content .card-info,#aside-content .card-announcement,#aside-content .card-recent-post,#aside-content #card-newest-comments,#aside-content .card-categories,#aside-content .card-tags,#aside-content .card-archives,#aside-content .card-webinfo{display:none;}
}
ins.adsbygoogle[data-ad-status="unfilled"] {
display: none !important;
}
</style>
<?php endif; ?>
<!--额外的-->
Expand Down Expand Up @@ -112,8 +133,8 @@
},
source: {
justifiedGallery: {
js: "https://<?php $this->options->jsdelivrLink() ?>/npm/flickr-justified-gallery@2/dist/fjGallery.min.js",
css: "https://<?php $this->options->jsdelivrLink() ?>/npm/flickr-justified-gallery@2/dist/fjGallery.min.css"
js: "https://cdn.bootcdn.net/ajax/libs/flickr-justified-gallery/2.1.2/fjGallery.min.js",
css: "https://cdn.bootcdn.net/ajax/libs/flickr-justified-gallery/2.1.2/fjGallery.min.css"
}
},
isPhotoFigcaption: !1,
Expand Down Expand Up @@ -434,4 +455,4 @@ class="fa-fw fas fa-home"></i><span> 首页</span></a></div>
</div>
</div>
</div>
<!--移动导航栏-->
<!--移动导航栏-->
125 changes: 118 additions & 7 deletions link.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,28 @@
<div id="page">
<div id="article-container">
<div class="flink">
<div class="flink-list">
<?php if ($this->options->Friends) : ?>
<?php
<?php $this->content(); ?>
<div class="flink-list">
<?php
if($this->options->friendset==1){
if(array_key_exists("Links", Typecho_Plugin::export()['activated'])){
$shuffle = Helper::options()->linksshuffle;
$link_limit = Helper::options()->linksIndexNum;
$Links = Links_Plugin::output("
<div class='flink-list-item'>
<a target='_blank' href='{url}'>
<div class='flink-item-icon'>
<img onerror=\"this.onerror=null;this.src='/usr/themes/butterfly/img/friend_404.gif'\" src='{GetLazyLoad()}' data-lazy-src='{image}' alt='' class='entered'/></div>
<div class='flink-item-name'>{name}</div>
<div class='flink-item-desc' title='{description}'>{description}</div>
</a></div>");
$link_limit = (!$type || $link_limit > count($Links)) ? count($Links) : $link_limit;
for($i = 0; $i < $link_limit; $i++){
echo $Links[$i];
}
}
}else{
if ($this->options->Friends){
if (strpos($this->options->Friends, '||') !== false) {
$errorimg="'/usr/themes/butterfly/img/friend_404.gif'";
$list = "";
Expand All @@ -32,10 +51,102 @@
<div class="flink-item-desc" title="' . explode("||", $string_arr[$i])[3] . '">' . explode("||", $string_arr[$i])[3] . '</div>
</a>
</div>';
}echo $list;}?>
<?php endif; ?>
}
echo $list;
}<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
<?php
/**
* 友链
*
* @package custom
*/
$this->need('page_header.php');
?>
<main class="layout" id="content-inner">
<div id="page">
<div id="article-container">
<div class="flink">
<?php $this->content(); ?>
<div class="flink-list">
<?php
if($this->options->friendset==1){
if(array_key_exists("Links", Typecho_Plugin::export()['activated'])){
$errorimg="'/usr/themes/butterfly/img/friend_404.gif'";
$shuffle = Helper::options()->linksshuffle;
$link_limit = Helper::options()->linksIndexNum;
$Links = Links_Plugin::output("
<div class='flink-list-item'>
<a target='_blank' href='{url}'>
<div class='flink-item-icon'>
<img onerror=\"this.onerror=null;this.src='/usr/themes/butterfly/img/friend_404.gif'\" src='{GetLazyLoad()}' data-lazy-src='{image}' alt='' class='entered'/></div>
<div class='flink-item-name'>{name}</div>
<div class='flink-item-desc' title='{description}'>{description}</div>
</a></div>");
for($i = 0; $i < count($Links); $i++){
echo $Links[$i];
}
}
}else{
if ($this->options->Friends){
if (strpos($this->options->Friends, '||') !== false) {
$errorimg="'/usr/themes/butterfly/img/friend_404.gif'";
$list = "";
$txt = $this->options->Friends;
$string_arr = explode("\r\n", $txt);
$long = count($string_arr);
for ($i = 0; $i < $long; $i++) {
$list = $list .
' <div class="flink-list-item"">
<a target="_blank" title="' . explode("||", $string_arr[$i])[0] . '"
href="' . explode("||", $string_arr[$i])[1] . '">
<div class="flink-item-icon">
<img onerror="this.onerror=null;this.src=' .$errorimg. '" src="'.GetLazyLoad().'" data-lazy-src="' . explode("||", $string_arr[$i])[2] . '" alt=" '. explode("||", $string_arr[$i])[0] . '" class="entered"/>
</div>
<div class="flink-item-name"> '. explode("||", $string_arr[$i])[0] . ' </div>
<div class="flink-item-desc" title="' . explode("||", $string_arr[$i])[3] . '">' . explode("||", $string_arr[$i])[3] . '</div>
</a>
</div>';
}
echo $list;
}
}
}
?>

</div>
</div>
</div>

<?php $this->need('comments.php'); ?>
</div>
<?php $this->need('post_sidebar.php'); ?>
<script src="<?php $this->options->themeUrl('js/comjs.js'); ?>"></script>
<script type="text/javascript" src="<?php $this->options->themeUrl('js/prism.js?v1.0'); ?>"></script>
<script type="text/javascript" src="<?php $this->options->themeUrl('js/clipboard.min.js'); ?>"></script>
<script>
$(document).ready(function(){var tocState = $(".toc").html();if(tocState.length == "1") {
$("#card-toc,#mobile-toc-button").remove();}});
</script>
<?php if (!empty($this->options->beautifyBlock) && in_array('showLineNumber',
$this->options->beautifyBlock)): ?>
<script type="text/javascript">
(function(){
var pres = document.querySelectorAll('pre');
var lineNumberClassName = 'line-numbers';
pres.forEach(function (item, index) {
item.className = item.className == '' ? lineNumberClassName : item.className + ' ' + lineNumberClassName;
});
})();
</script>
<?php endif; ?>
</main>
<!-- end #main-->
<?php $this->need('footer.php'); ?>
}
}
?>

</div>
<?php $this->content(); ?>
</div>
</div>

Expand Down Expand Up @@ -63,4 +174,4 @@
<?php endif; ?>
</main>
<!-- end #main-->
<?php $this->need('footer.php'); ?>
<?php $this->need('footer.php'); ?>
16 changes: 15 additions & 1 deletion post.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,20 @@
}
echo $content;
?>
<?php if($this->options->googleadsense != ""): ?>
<div class="post-adsense" style="overflow: hidden;">
</br>谷歌推广区(增值备案在网站google.cn内查询)</br>
<ins class="adsbygoogle"
style="display:block; text-align:center;"
data-ad-layout="in-article"
data-ad-format="fluid"
data-ad-client="<?php $this->options->googleadsense(); ?>"
data-ad-slot="3926138616"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>
<?php endif; ?>
</article>
<div class="post-copyright">
<div class="post-copyright__author">
Expand Down Expand Up @@ -229,4 +243,4 @@
<?php endif?>
</main>
<!-- end #main-->
<?php $this->need('footer.php'); ?>
<?php $this->need('footer.php'); ?>