Skip to content
This repository has been archived by the owner on Oct 25, 2023. It is now read-only.

Commit

Permalink
[Update] New Version 0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ohmyga233 committed Jun 9, 2019
1 parent 1346f62 commit 9e4095e
Show file tree
Hide file tree
Showing 24 changed files with 861 additions and 13,705 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Castle-Typecho-Theme
MD风格单栏主题<br>
Version 0.2.6
Version 0.3.0
## LICENSE
GPL V3
## 链接
Blog https://ohmyga.cn<br>
Docs https://castle.ohmyga.cc/ (目前还没写完)
Docs https://castle.ohmyga.cc/ (快写完了!)
## 提示
(继续偷懒不写README)<br>
如果觉得本主题还行的话,请给本项目一个Star吧!<br>
Expand Down
106 changes: 84 additions & 22 deletions functions.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<?php
/**
* Functions
* Version 0.2.6
* Version 0.3.0
* Author ohmyga( https://ohmyga.cn/ )
* 2019/04/21
* 2019/06/01
**/
if (!defined('__TYPECHO_ROOT_DIR__')) exit;

define("THEME_NAME", "Castle");
define("CASTLE_VERSION", "0.2.6");
define("CASTLE_VERSION", "0.3.0");

require_once("libs/setting.php");
require_once("libs/owo.php");

//鲁迅曾经说过:“看不见报错就是没有错误”。
//鲁迅本人:“???”。
error_reporting(0);
//错误是什么?
//error_reporting(0);

/* 文章or页面类型 */
function themeFields($layout) {
Expand Down Expand Up @@ -50,9 +50,9 @@ function themeFields($layout) {
$layout->addItem($PageType);
}

/*$PSetting = new Typecho_Widget_Helper_Form_Element_Textarea('PSetting', NULL, NULL,
$PSetting = new Typecho_Widget_Helper_Form_Element_Textarea('PSetting', NULL, NULL,
'高级设置', '文章/独立页高级设置,如果不懂此有何用请勿填写。');
$layout->addItem($PSetting);*/
$layout->addItem($PSetting);
}

function themeInit($comment) {
Expand Down Expand Up @@ -145,8 +145,8 @@ function themeInit($comment) {
}

/* 文章阅读次数(含Cookie) */
function PostView($archive) {
$cid = $archive->cid;
function PostView($moe) {
$cid = $moe->cid;
$db = Typecho_Db::get();
$prefix = $db->getPrefix();
if (!array_key_exists('views', $db->fetchRow($db->select()->from('table.contents')))) {
Expand All @@ -156,7 +156,7 @@ function PostView($archive) {
}

$row = $db->fetchRow($db->select('views')->from('table.contents')->where('cid = ?', $cid));
if ($archive->is('single')) {
if ($moe->is('single')) {
$views = Typecho_Cookie::get('extend_contents_views');
if(empty($views)){
$views = array();
Expand All @@ -174,8 +174,8 @@ function PostView($archive) {
}

/* 文章or页面高级设置 */
function PSetting($type) {
$setting = Typecho_Widget::widget("Widget_Archive")->fields->PSetting;
function PSetting($moe, $type) {
$setting = $moe->fields->PSetting;
if (json_decode($setting) == null) {
$output = null;
} else {
Expand Down Expand Up @@ -210,6 +210,10 @@ function randPic() {
$img = array_rand($openfile);
preg_match('/\/random\/(.*).jpg/', $openfile[$img], $out);
$output = Helper::options()->siteUrl.'usr/themes/'.getTheme().'/random/'.$out[1].'.jpg';
}elseif ($setting == 'cdn'){
$output = adSetting('randPic', 'url').'?rand='.$rand;
}elseif ($setting == 'cdnno'){
$output = adSetting('randPic', 'url');
}
return $output;
}
Expand Down Expand Up @@ -284,6 +288,8 @@ function themeResource($content) {
$output = Helper::options()->themeUrl.'/'.$content;
}elseif ($setting == 'jsdelivr') {
$output = 'https://cdn.jsdelivr.net/gh/ohmyga233/castle-Typecho-Theme@'.themeVer('current').'/'.$content;
}elseif ($setting == 'cdn') {
$output = adSetting('resource', 'url').'/'.$content;
}

return $output;
Expand Down Expand Up @@ -381,10 +387,10 @@ function tcs() {
if (!empty($cookie)) {
if ($cookie == 'off') {
}else{
setcookie('nightSwitch', 'open');
setcookie('nightSwitch', 'open', NULL, '/');
}
}else{
setcookie('nightSwitch', 'open');
setcookie('nightSwitch', 'open', NULL, '/');
}
}
}
Expand Down Expand Up @@ -646,13 +652,9 @@ public static function getAdminMail(){
return $mail;
}

static public function parseAll($content,$parseBoard=false){
$new = self::parseBiaoQing(self::parseFancyBox(self::parseRuby($content)));
if($parseBoard){
return self::parseBoard($new);
}else{
return $new;
}
static public function parseAll($content){
$new = self::parseBiaoQing(self::parseFancyBox(self::parseRuby(self::parseTable($content))));
return $new;
}

static public function parseBiaoQing($content){
Expand Down Expand Up @@ -690,6 +692,66 @@ static public function parseRuby($string){
$new=preg_replace($reg,$rp,$string);
return $new;
}

static public function parseTable($content){
$reg = '/<table>(.*?)<\/table>/s';
$rp = '<div class="mdui-table-fluid"><table class="mdui-table mdui-table-hoverable">${1}</table></div>';
$new = preg_replace($reg,$rp,$content);
return $new;
}

public static function exportHead($moe){
$author = $moe->author->screenName;
if($moe->is("index")) {
$description = Helper::options()->description;
$type = 'website';
}elseif ($moe->is("post") || $moe->is("page")) {
if($moe->fields->des && $moe->fields->des!=''){
$description = $moe->fields->des;
}else{
$description = Typecho_Common::subStr(strip_tags($moe->excerpt), 0, 100, "...");
}
$type='article';
}
$wzimg = $moe->fields->wzimg;
if(!empty($wzimg)){
$img = $moe->fields->wzimg;
}elseif ($moe->is("index")) {
$img = siteHeadimg('ico');
}else{
$img = randPic();
}
echo ' <meta name="description" content="'.$description.'" />
<meta property="og:title" content="';
$moe->archiveTitle(array(
'category' => '分类 %s 下的文章',
'search' => '包含关键字 %s 的文章',
'tag' => '标签 %s 下的文章',
'author' => '%s 发布的文章'
), '', ' - ');
echo Helper::options()->title();
echo '" />
<meta name="author" content="'.$author.'" />
<meta property="og:site_name" content="'.Helper::options()->title.'" />
<meta property="og:type" content="'.$type.'" />
<meta property="og:description" content="'.$description.'" />
<meta property="og:url" content="'.$moe->permalink.'" />
<meta property="og:image" content="'.$img.'" />
<meta property="article:published_time" content="'.date('c', $moe->created).'" />
<meta property="article:modified_time" content="'.date('c', $moe->modified).'" />
<meta name="twitter:title" content="';
$moe->archiveTitle(array(
'category' => '分类 %s 下的文章',
'search' => '包含关键字 %s 的文章',
'tag' => '标签 %s 下的文章',
'author' => '%s 发布的文章'
), '', ' - ');
echo Helper::options()->title();
echo "\" />
<meta name=\"twitter:description\" content=\"".$description."\" />
<meta name=\"twitter:card\" content=\"summary_large_image\" />
<meta name=\"twitter:image\" content=\"".$img."\" />\n";
}
}

/* 获取浏览器信息 */
Expand Down
4 changes: 2 additions & 2 deletions includes/comments-links.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function threadedComments($comments, $options) {
<div class="mdui-textfield-helper"><?php echo lang('comment', 'markdown'); ?></div>
</div>

<button mdui-dialog="{target: '#OwO-ck'}" type="button" mdui-tooltip="{content: '<?php echo lang('comment', 'smile'); ?>'}" class="mdui-btn mdui-btn-icon mdui-float-right moe-owo-btn-login"><i class="mdui-icon material-icons">sentiment_very_satisfied</i></button>
<button onclick="openSmile()" type="button" mdui-tooltip="{content: '<?php echo lang('comment', 'smile'); ?>'}" class="mdui-btn mdui-btn-icon mdui-float-right moe-owo-btn-login"><i class="mdui-icon material-icons">sentiment_very_satisfied</i></button>
<?php if ($this->options->comment && in_array('ajax', $this->options->comment)){}else{ ?><div class="moe-comments-btn">
<?php $comments->cancelReply('<button class="mdui-btn mdui-ripple moe-comments-close-btn mdui-text-color-red" mdui-tooltip="{content: \''.lang('comment', 'cancelReply').'\'}" type="button"><i class="mdui-icon material-icons">close</i></button>'); ?>
<button class="mdui-btn mdui-color-theme mdui-ripple moe-comments-submit-btn mdui-btn-raised" mdui-tooltip="{content: '<?php echo lang('comment', 'sendComment'); ?>'}" type="submit"><i class="mdui-icon material-icons">send</i></button>
Expand All @@ -75,7 +75,7 @@ function threadedComments($comments, $options) {
<div class="mdui-textfield-helper"><?php echo lang('comment', 'markdown'); ?></div>
</div>

<button mdui-dialog="{target: '#OwO-ck'}" type="button" mdui-tooltip="{content: '<?php echo lang('comment', 'smile'); ?>'}" class="mdui-btn mdui-btn-icon mdui-float-right moe-owo-btn-usr"><i class="mdui-icon material-icons">sentiment_very_satisfied</i></button>
<button onclick="openSmile()" type="button" mdui-tooltip="{content: '<?php echo lang('comment', 'smile'); ?>'}" class="mdui-btn mdui-btn-icon mdui-float-right moe-owo-btn-usr"><i class="mdui-icon material-icons">sentiment_very_satisfied</i></button>

<div class="mdui-textfield mdui-textfield-floating-label moe-input-name">
<i class="mdui-icon"><img class="moe-comment-ajax-headimg moe-headimg-xz" data-original="<?php $this->options->themeUrl('others/img/huaji.png'); ?>" src="<?php echo themeResource('others/img/loading.gif'); ?>"></i>
Expand Down
4 changes: 2 additions & 2 deletions includes/comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function threadedComments($comments, $options) {
<div class="mdui-textfield-helper"><?php echo lang('comment', 'markdown'); ?></div>
</div>

<button mdui-dialog="{target: '#OwO-ck'}" type="button" mdui-tooltip="{content: '<?php echo lang('comment', 'smile'); ?>'}" class="mdui-btn mdui-btn-icon mdui-float-right moe-owo-btn-login"><i class="mdui-icon material-icons">sentiment_very_satisfied</i></button>
<button onclick="openSmile()" type="button" mdui-tooltip="{content: '<?php echo lang('comment', 'smile'); ?>'}" class="mdui-btn mdui-btn-icon mdui-float-right moe-owo-btn-login"><i class="mdui-icon material-icons">sentiment_very_satisfied</i></button>
<?php if ($this->options->comment && in_array('ajax', $this->options->comment)){}else{ ?><div class="moe-comments-btn">
<?php $comments->cancelReply('<button class="mdui-btn mdui-ripple moe-comments-close-btn mdui-text-color-red" mdui-tooltip="{content: \''.lang('comment', 'cancelReply').'\'}" type="button"><i class="mdui-icon material-icons">close</i></button>'); ?>
<button class="mdui-btn mdui-color-theme mdui-ripple moe-comments-submit-btn mdui-btn-raised" mdui-tooltip="{content: '<?php echo lang('comment', 'sendComment'); ?>'}" type="submit"><i class="mdui-icon material-icons">send</i></button>
Expand All @@ -75,7 +75,7 @@ function threadedComments($comments, $options) {
<div class="mdui-textfield-helper"><?php echo lang('comment', 'markdown'); ?></div>
</div>

<button mdui-dialog="{target: '#OwO-ck'}" type="button" mdui-tooltip="{content: '<?php echo lang('comment', 'smile'); ?>'}" class="mdui-btn mdui-btn-icon mdui-float-right moe-owo-btn-usr"><i class="mdui-icon material-icons">sentiment_very_satisfied</i></button>
<button onclick="openSmile()" type="button" mdui-tooltip="{content: '<?php echo lang('comment', 'smile'); ?>'}" class="mdui-btn mdui-btn-icon mdui-float-right moe-owo-btn-usr"><i class="mdui-icon material-icons">sentiment_very_satisfied</i></button>

<div class="mdui-textfield mdui-textfield-floating-label moe-input-name">
<i class="mdui-icon"><img class="moe-comment-ajax-headimg moe-headimg-xz" data-original="<?php $this->options->themeUrl('others/img/huaji.png'); ?>" src="<?php echo themeResource('others/img/loading.gif'); ?>"></i>
Expand Down
38 changes: 35 additions & 3 deletions includes/footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,41 @@
<script src="<?php echo themeResource('others/js/highlight.min.js'); ?>"></script>
<script src="<?php echo themeResource('others/js/jquery.lazyload.min.js'); ?>"></script>
<script src="<?php echo themeResource('others/js/jquery.fancybox.min.js'); ?>"></script>
<script>var siteurl = '<?php $this->options->siteUrl(); ?>';<?php if($pjaxStatus == 'true'): ?>var PJAXtimeout = 8000;beforePJAX = function() {NProgress.start();};afterPJAX = function() {NProgress.done();mdui.mutation();<?php Helper::options()->pjaxRelaod(); ?>};<?php endif; ?>var themeVer = '<?php echo themeVer('current'); ?>';</script>
<script src="<?php echo themeResource('others/js/castle.min.js'); ?>?v=<?php echo themeVer('current'); ?>"></script>
<script>var Castle = new CastleSetting ({PJAX: <?php echo $pjaxStatus; ?>,goTop: <?php echo $topStatus; ?>,title: <?php echo $titleStatus; ?>,copyPrompt: <?php echo $copyStatus; ?>,commentAJAX: <?php echo $cajaxStatus; ?>,textareaHTML: true,NightOrDay: <?php echo $nightStatus; ?>});var leaveTitle = '<?php $leaveTitle = adSetting('setting', 'leave', 'title'); if(!empty($leaveTitle)){ echo adSetting('setting', 'leave', 'title'); }else{ echo '???? (/?\) '; } ?>';var leaveIcon = '<?php $leaveIcon = adSetting('setting', 'leave', 'icon'); if(!empty($leaveIcon)){ echo adSetting('setting', 'leave', 'icon'); }else{ echo themeResource('others/img/huaji.png'); } ?>';var returnTitle = '<?php $returnTitle = adSetting('setting', 'return', 'title'); if(!empty($returnTitle)){ echo adSetting('setting', 'return', 'title'); }else{ echo '???? S(? °? °;)? '; } ?>';var returnIcon = '<?php $returnIcon = adSetting('setting', 'return', 'icon'); if(!empty($returnIcon)){ echo adSetting('setting', 'return', 'icon'); }else{ echo themeResource('others/img/OwO/tieba/a.png'); } ?>';var OriginIcon = '<?php echo siteHeadimg('ico'); ?>';var copyPromptText = '<?php $copyPromptText = adSetting('setting', 'copyPrompt', 'text'); if(!empty($copyPromptText)){ echo adSetting('setting', 'copyPrompt', 'text'); }else{ echo '?????????!'; } ?>';var copyPromptTitle = '<?php $copyPromptTitle = adSetting('setting', 'copyPrompt', 'title'); if(!empty($copyPromptTitle)){ echo adSetting('setting', 'copyPrompt', 'title'); }else{ echo '??'; }?>';var topText = '<?php $toTopText = adSetting('setting', 'toTopText'); if(!empty($toTopText)){ echo adSetting('setting', 'toTopText'); }else{ echo '????~'; } ?>';</script>
<script>
var siteurl = '<?php $this->options->siteUrl(); ?>';
<?php if($pjaxStatus == 'true'): ?>var PJAXtimeout = 8000;
beforePJAX = function() {
NProgress.start();
};

afterPJAX = function() {
NProgress.done();
mdui.mutation();
<?php Helper::options()->pjaxRelaod(); ?>
};<?php endif; ?>
var themeVer = '<?php echo themeVer('current'); ?>';
var NowTime = '19:00<?php //echo date('H:i'); ?>';
</script>
<script src="<?php echo themeResource('others/js/castle.min.js'); ?>"></script>
<script>
var Castle = new CastleSetting ({
PJAX: <?php echo $pjaxStatus; ?>,
goTop: <?php echo $topStatus; ?>,
title: <?php echo $titleStatus; ?>,
copyPrompt: <?php echo $copyStatus; ?>,
commentAJAX: <?php echo $cajaxStatus; ?>,
textareaHTML: true,
NightOrDay: <?php echo $nightStatus; ?>
});
var leaveTitle = '<?php $leaveTitle = adSetting('setting', 'leave', 'title'); if(!empty($leaveTitle)){ echo adSetting('setting', 'leave', 'title'); }else{ echo '???? (/?\) '; } ?>';
var leaveIcon = '<?php $leaveIcon = adSetting('setting', 'leave', 'icon'); if(!empty($leaveIcon)){ echo adSetting('setting', 'leave', 'icon'); }else{ echo themeResource('others/img/huaji.png'); } ?>';
var returnTitle = '<?php $returnTitle = adSetting('setting', 'return', 'title'); if(!empty($returnTitle)){ echo adSetting('setting', 'return', 'title'); }else{ echo '???? S(? °? °;)? '; } ?>';
var returnIcon = '<?php $returnIcon = adSetting('setting', 'return', 'icon'); if(!empty($returnIcon)){ echo adSetting('setting', 'return', 'icon'); }else{ echo themeResource('others/img/OwO/tieba/a.png'); } ?>';
var OriginIcon = '<?php echo siteHeadimg('ico'); ?>';
var copyPromptText = '<?php $copyPromptText = adSetting('setting', 'copyPrompt', 'text'); if(!empty($copyPromptText)){ echo adSetting('setting', 'copyPrompt', 'text'); }else{ echo '?????????!'; } ?>';
var copyPromptTitle = '<?php $copyPromptTitle = adSetting('setting', 'copyPrompt', 'title'); if(!empty($copyPromptTitle)){ echo adSetting('setting', 'copyPrompt', 'title'); }else{ echo '??'; }?>';
var topText = '<?php $toTopText = adSetting('setting', 'toTopText'); if(!empty($toTopText)){ echo adSetting('setting', 'toTopText'); }else{ echo '????~'; } ?>';
</script>

<?php $this->footer(''); ?>
</body>
Expand Down
11 changes: 6 additions & 5 deletions includes/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,19 @@
'author' => _t('%s 发布的文章')
), '', ' - '); ?><?php $this->options->title(); ?></title>
<script src="<?php echo themeResource('others/js/mdui.min.js'); ?>"></script>
<script src="<?php echo themeResource('others/js/nprogress.js'); ?>"></script>
<script src="<?php echo themeResource('others/js/nprogress.min.js'); ?>"></script>
<script src="<?php echo themeResource('others/js/jquery3.3.1.min.js'); ?>"></script>
<?php if ($this->options->other && in_array('pjax', $this->options->other)): ?><script src="<?php echo themeResource('others/js/jquery.pjax.min.js'); ?>"></script><?php endif; ?>
<link rel="stylesheet" href="<?php echo themeResource('others/css/iconfont.css'); ?>?v=<?php echo themeVer('current'); ?>" />
<link rel="stylesheet" href="<?php echo themeResource('others/css/iconfont.min.css'); ?>" />
<link rel="stylesheet" href="<?php echo themeResource('others/css/mdui.min.css'); ?>" />
<link rel="stylesheet" href="<?php echo themeResource('others/css/nprogress.css'); ?>" />
<link rel="stylesheet" href="<?php echo themeResource('others/css/castle.min.css'); ?>?v=<?php echo themeVer('current'); ?>" />
<link rel="stylesheet" href="<?php echo themeResource('others/css/nprogress.min.css'); ?>" />
<link rel="stylesheet" href="<?php echo themeResource('others/css/castle.min.css'); ?>" />
<link rel="stylesheet" href="<?php echo themeResource('others/css/fancybox.min.css'); ?>" />
<link rel="icon" type="image/x-icon" href="<?php echo siteHeadimg('ico'); ?>" id="Icon-title">
<meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=no">
<?php Castle::exportHead($this); ?>
<?php $this->need('includes/style.php')?>
<?php $this->header('generator=&pingback=&xmlrpc=&wlw=&commentReply='); ?>
<?php $this->header('generator=&pingback=&xmlrpc=&wlw=&commentReply=&description='); ?>
<script>var bgmURL = "<?php $this->options->siteUrl(); ?>?action=bangumi&bgmID=:id&auth=:auth";</script>
</head>

Expand Down
Loading

0 comments on commit 9e4095e

Please sign in to comment.