-
Notifications
You must be signed in to change notification settings - Fork 3
/
Plugin.php
373 lines (326 loc) · 14.8 KB
/
Plugin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
<?php
/**
* <strong style='color:red'>Handsome 主题美化插件</strong>
*
* @package Sky.Mo
* @author Alomerry
* @version 1.2.1
* @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
{
const STATIC_DIR = '/usr/plugins/SkyMo';
/**
* 激活插件方法,如果激活失败,直接抛出异常
*
* @access public
* @return void
* @throws Typecho_Plugin_Exception
*/
public static function activate()
{
self::installDB();
Typecho_Plugin::factory('Widget_Archive')->header = array(__CLASS__, 'header');
Typecho_Plugin::factory('Widget_Archive')->footer = array(__CLASS__, 'footer');
return "插件启动成功";
}
/**
* 禁用插件方法,如果禁用失败,直接抛出异常
*
* @static
* @access public
* @return void
* @throws Typecho_Plugin_Exception
*/
public static function deactivate(){
return "插件禁用成功";
}
/**
* 获取插件配置面板
*
* @access public
* @param Typecho_Widget_Helper_Form $form 配置面板
* @return void
*/
public static function config(Typecho_Widget_Helper_Form $form)
{
$html = '<p>欢迎使用 Handsome 主题美化插件 SkyMo V1.2.0。</p>'.
'<p>此插件帮助你美化 Handsome 主题的一些细节。你可以对插件进行非商用的二次开发。</p>'.
'<p>有任何问题请联系发邮件至<strong><a href="mailto:[email protected]"> [email protected] </a></strong>'.
'<p>二次开发克隆地址 <b><a href="https://github.com/Alomerry/SkyMo">Github</a></b> '.
'<p>更多信息请参阅 <b><a href="http://alomerry.com/archives/211/">插件描述</a></b> '.
'<p><b><a href="https://github.com/Alomerry/SkyMo/releases/latest">最新版地址</a></b> '.
'<hr />';
echo $html;
//赞赏心跳特效
$form->addInput(new ExTitle_Plugin('btnTitle', NULL, NULL, _t('赞赏心跳特效'), NULL));
$heatBeat = new Typecho_Widget_Helper_Form_Element_Radio('heatBeat',array(
'open' => _t('开启'),
'close' => _t('关闭'),
),'open', '',"<img src='http://alomerry.com/usr/uploads/2020/01/673845452.gif' style='width: 7rem;'>");
$form->addInput($heatBeat);
//星星轨迹特效
$form->addInput(new ExTitle_Plugin('btnTitle', NULL, NULL, _t('星星轨迹特效'), NULL));
$starTrack = new Typecho_Widget_Helper_Form_Element_Radio('starTrack',array(
'open' => _t('开启'),
'close' => _t('关闭'),
),'open', '',"<img src='http://alomerry.com/usr/uploads/2020/01/286602434.gif' style='width: 30rem;'>");
$form->addInput($starTrack);
// $form->addInput(new ExTitle_Plugin('btnTitle', NULL, NULL, _t('炫光鼠标特效'), NULL));
// $clickThemes = new Typecho_Widget_Helper_Form_Element_Radio('clickThemes',array(
// 'open' => _t('开启'),
// 'close' => _t('关闭'),
// ),'open','',"");
// $form->addInput($clickThemes);
//复制添加版权信
$form->addInput(new ExTitle_Plugin('btnTitle', NULL, NULL, _t('复制添加版权信息'), NULL));
$copyright = new Typecho_Widget_Helper_Form_Element_Radio('copyright',array(
'open' => _t('开启'),
'close' => _t('关闭'),
),'open','',"");
$form->addInput($copyright);
//页脚
$form->addInput(new ExTitle_Plugin('btnTitle', NULL, NULL, _t('页脚'), NULL));
$footStyle = new Typecho_Widget_Helper_Form_Element_Radio('footStyle',array(
'open' => _t('开启'),
'close' => _t('关闭'),
),'open','',"<img src='http://alomerry.com/usr/uploads/2020/01/2908048897.png' style='width: 30rem;'>");
$form->addInput($footStyle);
$footCSS = new Typecho_Widget_Helper_Form_Element_Select("footCSS",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($footCSS);
//字体
$form->addInput(new ExTitle_Plugin('btnTitle', NULL, NULL,
"字体<span style='padding: .1em .4em .1em;background-color: #f05050;font-size: 14px;color: white;border-radius: 5px;'>New</span>", 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",
"Wawa" => "Wawa"
),"github-badge.css","样式选择",
"<img src='http://alomerry.com/usr/uploads/2020/10/2495026317.png' style='width: 15rem;'><img src='http://alomerry.com/usr/uploads/2020/10/2799388962.png' style='width: 15rem;'>");
$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'>md_handsome 为正文,body 为全页面。</strong><br><strong style='color: #00b8ff9e'>默认样式 ZCOOL XiaoWei,欢迎联系我添加更多字体。 </strong><br> Wawa 字体来源 nekox.cn");
$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','',"");
$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);
//背景彩带特效
$form->addInput(new ExTitle_Plugin('btnTitle', NULL, NULL, _t('背景彩带特效'), NULL));
$backgroundRibbon = new Typecho_Widget_Helper_Form_Element_Radio('backgroundRibbon', array(
'open' => _t('开启'),
'close' => _t('关闭'),
), 'open',_t('修改 ribbon.js 可以调整彩带参数、位置和样式。'),
"<img src='http://alomerry.com/usr/uploads/2020/01/499543144.gif' style='width: 30rem;'>");
$form->addInput($backgroundRibbon);
//首页头像 hover 旋转
$form->addInput(new ExTitle_Plugin('btnTitle', NULL, NULL, _t('首页头像 hover 旋转'), NULL));
$headSpin = new Typecho_Widget_Helper_Form_Element_Radio('headSpin', array(
'open' => _t('开启'),
'close' => _t('关闭'),
), 'open',_t(''),
"<img src='http://alomerry.com/usr/uploads/2020/01/3441578448.gif' style='width: 25rem;'>");
$form->addInput($headSpin);
//评论打字机特效
$form->addInput(new ExTitle_Plugin('btnTitle', NULL, NULL, _t('评论打字机特效'), NULL));
$typeWriter = new Typecho_Widget_Helper_Form_Element_Radio('typeWriter', array(
'open' => _t('开启'),
'close' => _t('关闭'),
), 'open','',"");
$form->addInput($typeWriter);
//失去焦点页面替换标签名
$form->addInput(new ExTitle_Plugin('btnTitle', NULL, NULL, _t('失去焦点页面替换标签名'), NULL));
$visibilityTextShow = new Typecho_Widget_Helper_Form_Element_Radio('visibilityTextShow', array(
'open' => _t('开启'),
'close' => _t('关闭'),
), 'close', '',"");
$form->addInput($visibilityTextShow);
$visibilityText = new Typecho_Widget_Helper_Form_Element_Text('visibilityText', null, _t('See you soon!'),'', "<strong style='color: red'>如果开启替换标签标题, 请填写文字</strong>");
$form->addInput($visibilityText);
}
/**
* 个人用户的配置面板
*
* @access public
* @param Typecho_Widget_Helper_Form $form
* @return void
*/
public static function personalConfig(Typecho_Widget_Helper_Form $form){}
/**
* 修改页面底部信息
*
* @access public
* @return void
*/
public static function footer()
{
echo "<script>console.log('%c SkyMo v1.1 %c by Alomerry | https://www.alomerry.com ','color:#fff; background: linear-gradient(to right , #7A88FF, #d27aff); padding:5px; border-radius: 10px;','color:#fff; background: linear-gradient(to right , #7A88FF, #d27aff); padding:5px; border-radius: 10px;');</script>";
$SkyMo = Helper::options()->plugin('SkyMo');
$path = self::STATIC_DIR;
//输出js文件
$src = $path . '/js/script.js';
echo "<script src='$src'></script>";
//页脚
if($SkyMo->footStyle == 'open'){
echo "<link rel='stylesheet' type='text/css' href='" . $path . "/css/foot/foot-require.css' />";
echo "<link rel='stylesheet' type='text/css' href='" . $path . "/css/foot/" .$SkyMo->footCSS."' />";
echo "<script src='" . $path . "/js/footer.js'></script>";
}
//代码样式
if($SkyMo->codeStyle == 'open'){
echo "<link rel='stylesheet' type='text/css' href='" . $path . "/css/code/code.css' />";
// echo "<link rel='stylesheet' type='text/css' href='" . $path . "/css/code/" .$SkyMo->codeCSS."' />";
}
//星星鼠标轨迹
if($SkyMo->starTrack == 'open'){
$tmp = $path . '/js/mouse/star/canvas.js';
echo "<script src='$tmp'></script>";
}
//鼠标点击特效
// if($SkyMo->clickThemes == 'open'){
$tmp = $path . '/js/mouse/click.js';
echo "<script src='$tmp'></script>";
// }
//背景彩带特效
if($SkyMo->backgroundRibbon == 'open'){
$tmp = $path . '/js/background/ribbon.js';
echo "<script src='$tmp'></script>";
}
//版权相关
if($SkyMo->copyright == 'open'){
$tmp= $path . '/js/copyright.js';
echo "<script src='$tmp'></script>";
}
//文本框打字机特效
if($SkyMo->typeWriter == 'open'){
$tmp = $path . '/js/commentTyping.js';
echo "<script src='$tmp'></script>";
}
//代码样式
if($SkyMo->fontStyle == 'open'){
$css = "";
$needSetCss = true;
switch ($SkyMo->fontCSS)
{
case "ZCOOL-XiaoWei":
echo "<link rel='stylesheet' type='text/css' href='" . $path . "/css/font/font-ZCOOL.css' />";
$css = "'ZCOOL XiaoWei'";
break;
case "Monaco":
$css = "Menlo,Monaco,Consolas,'Courier New',monospace";
break;
case "Wawa":
echo "<link rel='stylesheet' type='text/css' href='" . $path . "/css/font/font-Wawa.css' />";
$css = "Wawa";
break;
default:
$needSetCss = false;
break;
}
$location = '#' . $SkyMo->fontLocation;
$js .= '<script>';
$js .= <<<JS
jQuery(document).ready(function() {
if($needSetCss){
$('$location').css("font-family","$css");
}
});
JS;
$js .= '</script>';
echo $js;
}
}
/**
* 修改页面顶部信息
*
* @access public
* @return void
*/
public static function header()
{
$SkyMo = Helper::options()->plugin('SkyMo');
$path = self::STATIC_DIR;
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" />';
echo '<link rel="stylesheet" type="text/css" href="' . $path . '/css/head/head-title.css" />';
echo '<link rel="stylesheet" type="text/css" href="' . $path . '/css/comment.css" />';
echo '<link rel="stylesheet" type="text/css" href="' . $path . '/css/toc.css" />';
echo '<link rel="stylesheet" type="text/css" href="' . $path . '/css/tag.css" />';
if($SkyMo->headSpin == "open"){
echo '<link rel="stylesheet" type="text/css" href="' . $path . '/css/head/head-spin.css" />';
}
if($SkyMo->heatBeat == "open"){
echo '<link rel="stylesheet" type="text/css" href="' . $path . '/css/head/heat-beat.css" />';
}
if($SkyMo->visibilityTextShow == "open"){
$visibilityText = $SkyMo->visibilityText;
$js .= '<script>';
$js .= <<<JS
jQuery(document).ready(function() {
document.addEventListener('visibilitychange', function () {
if (document.visibilityState == 'hidden') {
normal_title = document.title;
document.title = "{$visibilityText}";
} else {
document.title = normal_title;
}
});});
JS;
$js .= '</script>';
echo $js;
}
}
/**
* 新建 MySQL 表
*
* @access public
* @return void
*/
public static function installDB(){
}
}
class ExTitle_Plugin extends Typecho_Widget_Helper_Form_Element
{
public function label($value)
{
/** 创建标题元素 */
if (empty($this->label)) {
$this->label = new Typecho_Widget_Helper_Layout('label', array('class' => 'typecho-label', 'style'=>'font-size: 2em;font-family: cursive;border-bottom: 1px #ddd solid;padding-top:0.5em;'));
$this->container($this->label);
}
$this->label->html($value);
return $this;
}
public function input($name = NULL, array $options = NULL)
{
$input = new Typecho_Widget_Helper_Layout('p', array());
$this->container($input);
$this->inputs[] = $input;
return $input;
}
protected function _value($value) {}
}