Skip to content

Commit

Permalink
add font selector
Browse files Browse the repository at this point in the history
  • Loading branch information
Alomerry committed Oct 4, 2020
1 parent 6824b12 commit 4b3dada
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 15 deletions.
68 changes: 56 additions & 12 deletions Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
*
* @package Sky.Mo
* @author Alomerry
* @version 1.1.0
* @version 1.2.0
* @link http://alomerry.com
* version 1.0.0 基本特效
* version 1.1.0 新增配置单个特效
* version 1.2.0 新增字体设置
* https://api.github.com/repos/alomerry/skymo/releases/latest
*/
class SkyMo_Plugin implements Typecho_Plugin_Interface
Expand Down Expand Up @@ -55,11 +56,11 @@ public static function deactivate(){
public static function config(Typecho_Widget_Helper_Form $form)
{

$html = '<p>欢迎使用 Handsome 主题美化插件 SkyMo。</p>'.
$html = '<p>欢迎使用 Handsome 主题美化插件 SkyMo V1.2.0。</p>'.
'<p>此插件帮助你美化 Handsome 主题的一些细节。你可以对插件进行非商用的二次开发。</p>'.
'<p>有任何问题请联系发邮件至<strong><a href="mailto:[email protected]"> [email protected] </a></strong>'.
'<p>有任何问题请联系发邮件至<strong><a href="mailto:[email protected]"> [email protected] </a></strong>'.
'<p>更多信息请参阅 <b><a href="https://github.com/Alomerry/SkyMo">详细说明</a></b> '.
'<p><b><a href="https://github.com/Alomerry/SkyMo/releases/tag/1.1.0">最新版地址</a></b> '.
'<p><b><a href="https://github.com/Alomerry/SkyMo/releases/latest">最新版地址</a></b> '.
'<hr />';
echo $html;

Expand Down Expand Up @@ -107,18 +108,37 @@ public static function config(Typecho_Widget_Helper_Form $form)
),"github-badge.css","样式选择","<strong style='color: #00b8ff9e'> 要切换自定义样式,请替换插件目录下 <code>/css/foot</code> 的 <code>style.css</code> 文件 </strong>");
$form->addInput($footCSS);

//字体
$form->addInput(new ExTitle_Plugin('btnTitle', NULL, NULL, _t('字体'), NULL));
$fontStyle = new Typecho_Widget_Helper_Form_Element_Radio('fontStyle',array(
'open' => _t('开启'),
'close' => _t('关闭'),
),'close','',"");
$form->addInput($fontStyle);
$fontCSS = new Typecho_Widget_Helper_Form_Element_Select("fontCSS",array(
"ZCOOL-XiaoWei" => "ZCOOL-XiaoWei",
"Monaco" => "Monaco"
),"github-badge.css","样式选择","");
$form->addInput($fontCSS);
$form->addInput(new ExTitle_Plugin('btnTitle', NULL, NULL, _t('字体生效位置'), NULL));
$fontLocation = new Typecho_Widget_Helper_Form_Element_Select("fontLocation",array(
"body" => "body",
"md_handsome" => "md_handsome"
),"body","字体生效位置","<strong style='color: #00b8ff9e'>默认样式 ZCOOL XiaoWei,欢迎联系我添加更多字体。 </strong>");
$form->addInput($fontLocation);

//代码样式
$form->addInput(new ExTitle_Plugin('btnTitle', NULL, NULL, _t('代码样式'), NULL));
$codeStyle = new Typecho_Widget_Helper_Form_Element_Radio('codeStyle',array(
'open' => _t('开启'),
'close' => _t('关闭'),
),'open','',"<img src='https://alomerry.com/usr/uploads/2020/01/2908048897.png' style='width: 30rem;'>");
),'open','',"");
$form->addInput($codeStyle);
$codeCSS = new Typecho_Widget_Helper_Form_Element_Select("codeCSS",array(
"github-badge.css" => "github-badge.css",
"style.css" => "style.css"
),"github-badge.css","样式选择","<strong style='color: #00b8ff9e'> 要切换自定义样式,请替换插件目录下 <code>/css/foot</code> 的 <code>style.css</code> 文件 </strong>");
$form->addInput($codeCSS);
// $codeCSS = new Typecho_Widget_Helper_Form_Element_Select("codeCSS",array(
// "github-badge.css" => "github-badge.css",
// "style.css" => "style.css"
// ),"github-badge.css","样式选择","<strong style='color: #00b8ff9e'> 要切换自定义样式,请替换插件目录下 <code>/css/foot</code> 的 <code>style.css</code> 文件 </strong>");
// $form->addInput($codeCSS);

//背景彩带特效
$form->addInput(new ExTitle_Plugin('btnTitle', NULL, NULL, _t('背景彩带特效'), NULL));
Expand All @@ -138,6 +158,7 @@ public static function config(Typecho_Widget_Helper_Form $form)
"<img src='http://alomerry.com/usr/uploads/2020/01/3441578448.gif' style='width: 30rem;'>");
$form->addInput($headSpin);


//评论打字机特效
$form->addInput(new ExTitle_Plugin('btnTitle', NULL, NULL, _t('评论打字机特效'), NULL));
$typeWriter = new Typecho_Widget_Helper_Form_Element_Radio('typeWriter', array(
Expand Down Expand Up @@ -227,7 +248,30 @@ public static function footer()
echo "<script src='$tmp'></script>";
}


//代码样式
if($SkyMo->fontStyle == 'open'){
$css = "";
switch ($SkyMo->fontCSS)
{
case "ZCOOL-XiaoWei":
$css = "'ZCOOL XiaoWei'";
break;
case "Monaco":
$css = "Menlo,Monaco,Consolas,'Courier New',monospace";
break;
default:
break;
}
$location = '#' . $SkyMo->fontLocation;
$js .= '<script>';
$js .= <<<JS
jQuery(document).ready(function() {
$('$location').css("font-family","$css");
});
JS;
$js .= '</script>';
echo $js;
}
}

/**
Expand All @@ -242,7 +286,6 @@ public static function header()
$SkyMo = Helper::options()->plugin('SkyMo');
$path = self::STATIC_DIR;

echo '<link rel="stylesheet" type="text/css" href="' . $path . '/css/font.css" />';
echo '<link rel="stylesheet" type="text/css" href="' . $path . '/css/style.css" />';
echo '<link rel="stylesheet" type="text/css" href="' . $path . '/css/card.css" />';
echo '<link rel="stylesheet" type="text/css" href="' . $path . '/css/quote/quote.css" />';
Expand Down Expand Up @@ -289,6 +332,7 @@ public static function installDB(){

}
}

class ExTitle_Plugin extends Typecho_Widget_Helper_Form_Element
{

Expand Down
File renamed without changes.
7 changes: 4 additions & 3 deletions css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ div.dropdown.wrapper span img.normal-shadow {

#post-content {
/* 正文文字大小 */
font-size: 1.7rem !important;
font-size: 1.9rem !important;
font-weight: 400;
}

h5.text-md {
Expand Down Expand Up @@ -225,15 +226,15 @@ code:not(.hljs) {
#widget-tabs-4-comments h4,
#widget-tabs-4-random h4,
#widget-tabs-4-random a {
font-weight: 300;
font-weight: 500;
}


/* 热门文章 */

#widget-tabs-4-hots h5,
#widget-tabs-4-comments a {
font-weight: 300;
font-weight: 500;
}


Expand Down

0 comments on commit 4b3dada

Please sign in to comment.