forked from Adoream/typecho-theme-diaspora
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.php
More file actions
65 lines (61 loc) · 4.25 KB
/
Copy pathfunctions.php
File metadata and controls
65 lines (61 loc) · 4.25 KB
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
<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
<?php
/*
* @Author: Jin
* @Date: 2020-03-11 12:19:36
* @LastEditors: Jin
* @LastEditTime: 2020-03-12 21:54:05
* @FilePath: /diaspora/functions.php
*/
require_once("lib/Diaspora.php");
require_once("lib/Settings.php");
require_once("lib/Title.php");
require_once("lib/Content.php");
function themeInit(Widget_Archive $archive) {
Diaspora::init();
if ($archive->is('archive', 404)) {
$path_info = trim($archive->request->getPathinfo(), '/');
if ($path_info == 'action/like') {
header("HTTP/1.1 200 OK");
$cid = $archive->request->filter('int')->cid;
Content::likeUp($cid);
$archive->response->goBack();
exit();
}
}
}
function themeConfig ($form) {
echo Diaspora::welcome();
$form->addInput(new Title('imageTitle', NULL, NULL, _t('配图及图像管理'), NULL));
$defaultThumbnails = new Typecho_Widget_Helper_Form_Element_Textarea('defaultThumbnails', NULL, NULL, _t('默认背景图列表'), _t('每行填写一个链接(自动换行的视为同一行),缺省为Background/post0/1.webp'));
$form->addInput($defaultThumbnails);
$form->addInput(new Title('Gravatar', NULL, NULL, _t('评论头像源管理'), NULL));
$defaultGravatar = new Typecho_Widget_Helper_Form_Element_Textarea('defaultGravatar', NULL, NULL, _t('评论头像源'), _t('每行填写一个链接(自动换行的视为同一行),缺省为https://secure.gravatar.com/'));
$form->addInput($defaultGravatar);
$form->addInput(new Title('customExtendsTitle', NULL, NULL, _t('主题自定义扩展')));
$customHTMLInHeadTitle = new Typecho_Widget_Helper_Form_Element_Textarea('customHTMLInHeadTitle', NULL, NULL, _t('自定义 HTML 元素拓展 - 标签: head 头部 (meta 元素后)'), _t('在 head 标签头部(meta 元素后)添加你自己的 HTML 元素<br>你可以在这里拓展一些 meta 信息, 或一些其他信息。<br>某些统计代码可能要求被加入到尽可能靠前的位置, 那么你可以将其加入到这里。<br>不建议在这里添加 css'));
$form->addInput($customHTMLInHeadTitle);
$customHTMLInHeadBottom = new Typecho_Widget_Helper_Form_Element_Textarea('customHTMLInHeadBottom', NULL, NULL, _t('自定义 HTML 元素拓展 - 标签: head 尾部 (head 标签结束前)'), _t('在 head 尾部 (head 标签结束前)添加你自己的 HTML 元素<br>你可以在这里使用 link 标签引入你自己的 CSS 代码文件, 或直接使用 style 标签输出 css 代码, 或一些其他信息。<br>某些统计代码可能要求被加入到 head 标签中(如百度统计), 那么你可以将其加入到这里。'));
$form->addInput($customHTMLInHeadBottom);
$beforeBodyClose = new Typecho_Widget_Helper_Form_Element_Textarea('beforeBodyClose', NULL, NULL, _t('自定义 HTML 元素拓展 - 在 body 标签结束前'), _t('在 body 标签结束前添加你自己的 HTML 元素<br>你可以在这里使用 script 标签引入你自己的 js 代码文件, 或直接使用 script 标签输出 js 代码, 或一些其他信息。'));
$form->addInput($beforeBodyClose);
}
function themeFields ($layout) {
echo '
<style>.typecho-post-option .text, textarea { width:100% } textarea { height: 10em }</style>
<script>
window.addEventListener("keydown", function(e) {
if (e.keyCode == 83 && (navigator.platform.match("Mac") ? e.metaKey : e.ctrlKey)) {
e.preventDefault();
document.getElementById("btn-submit").click();
return true;
}
}, false);
</script>
';
$coverList = new Typecho_Widget_Helper_Form_Element_Textarea('coverList', NULL, NULL, _t('背景图列表'), _t('输入图片URL,如有多个则一行一个,随机选择展示。https://smoe.cc/Background/ContentImage/?.webp'));
$layout->addItem($coverList);
$bgMusicList = new Typecho_Widget_Helper_Form_Element_Textarea('bgMusicList', NULL, NULL, _t('音乐列表'), _t('输入音乐URL,如有多个则一行一个,随机选择播放。https://music.163.com/song/media/outer/url?id=?.mp3'));
$layout->addItem($bgMusicList);
}
?>