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.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ohmyga233 committed Jun 22, 2019
1 parent 9e4095e commit caffd84
Show file tree
Hide file tree
Showing 14 changed files with 116 additions and 67 deletions.
26 changes: 15 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
# Castle-Typecho-Theme
MD风格单栏主题<br>
Version 0.3.0
## LICENSE
GPL V3
# Castle
MD风格单栏主题
## 开始使用
1. Star本项目(<br>
2. 前往 releases 下载主题<br>
3. 将主题上传至 `/usr/themes` 目录并解压(记得重命名为 `Castle`~<br>
4. 前往 Typecho 后台启用主题即可食用ε=ε=ε=(~ ̄▽ ̄)~
## 开源协议
项目使用 GPL V3 进行许可。<br>
如果可以的话,请给本项目一个Star吧!<br>
或者可以前往 Food 给我投食ο(=•ω<=)ρ⌒☆
## 使用到的开源项目
详见 https://castle.ohmyga.cc/#/copy?id=%e4%bd%bf%e7%94%a8%e7%9a%84%e5%bc%80%e6%ba%90%e9%a1%b9%e7%9b%ae
## 链接
Blog https://ohmyga.cn<br>
Docs https://castle.ohmyga.cc/ (快写完了!)
## 提示
(继续偷懒不写README)<br>
如果觉得本主题还行的话,请给本项目一个Star吧!<br>
如果GitHub下载速度一直为0K/S的话请在QQ群群文件下载(群号在博客的关于页面)
作者博客 https://ohmyga.cn/
主题文档 https://castle.ohmyga.cc/ (快写完惹)
39 changes: 35 additions & 4 deletions functions.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
<?php
/**
* Functions
* Version 0.3.0
* Version 0.3.1
* Author ohmyga( https://ohmyga.cn/ )
* 2019/06/01
**/
if (!defined('__TYPECHO_ROOT_DIR__')) exit;

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

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

//错误是什么?
//error_reporting(0);

//设置时区
date_default_timezone_set("Asia/Shanghai");

/* 文章or页面类型 */
function themeFields($layout) {
?>
Expand Down Expand Up @@ -289,7 +292,32 @@ function themeResource($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;
$output = adSetting('resource', 'url').$content;
}

return $output;
}

/* 代码高亮静态文件源(Css */
function highlightResource() {
$setting = Helper::options()->themeResource;
$hls = Helper::options()->hls;

if ($setting == 'local') {
$hltd = Helper::options()->themeFile(getTheme(), "others/css/highlight/default.min.css");
if (file_exists($hltd)) {
if ($hls == 'default.min.css') {
$output = Helper::options()->themeUrl.'/others/css/highlight/default.min.css';
}elseif ($hls == 'jsdelivr') {
$output = 'https://cdn.jsdelivr.net/gh/ohmyga233/castle-Typecho-Theme@'.themeVer('current').'/others/css/highlight/default.min.css';
}else{
$output = Helper::options()->themeUrl.'/others/css/highlight/'.$hls;
}
}else{
$output = 'https://cdn.jsdelivr.net/gh/ohmyga233/castle-Typecho-Theme@'.themeVer('current').'/others/css/highlight/default.min.css';
}
}elseif ($setting == 'jsdelivr') {
$output = 'https://cdn.jsdelivr.net/gh/ohmyga233/castle-Typecho-Theme@'.themeVer('current').'/others/css/highlight/default.min.css';
}

return $output;
Expand Down Expand Up @@ -510,7 +538,7 @@ function DrawerMenu() {
<i class="mdui-icon material-icons mdui-list-item-icon mdui-collapse-item-arrow">keyboard_arrow_down</i>
</div>
<ul class="mdui-collapse-item-body mdui-list mdui-list-dense">';
Typecho_Widget::widget('Widget_Contents_Post_Date', 'type=month&format=F Y')->parse('<a href="{permalink}" class="mdui-list-item mdui-ripple" mdui-drawer-close>{date}</a>');
Typecho_Widget::widget('Widget_Contents_Post_Date', 'type=month&format='.lang('sidebar', 'time').'')->parse('<a href="{permalink}" class="mdui-list-item mdui-ripple" mdui-drawer-close>{date} &nbsp; <span class="moe-cl-a">{count}</span></a>');
echo '</ul>
</li>';
}elseif ($i['type'] == '2') {
Expand Down Expand Up @@ -712,6 +740,9 @@ public static function exportHead($moe){
$description = Typecho_Common::subStr(strip_tags($moe->excerpt), 0, 100, "...");
}
$type='article';
}else{
$description = Helper::options()->description;
$type='archive';
}
$wzimg = $moe->fields->wzimg;
if(!empty($wzimg)){
Expand Down
8 changes: 4 additions & 4 deletions includes/archive.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
<?php $PostType = $this->fields->PostType;
if($PostType == "nopic"){ ?>
<div class="mdui-card moe-card moe-card-day moe-card-tr">
<div class="moe-card-day-icon moe-headimg-xz"><i class="mdui-icon material-icons"><?php $Dicon = PSetting('Dicon'); if(!empty($Dicon)) { echo PSetting('Dicon'); }else{ echo 'message'; } ?></i></div>
<div class="moe-card-day-icon moe-headimg-xz"><i class="mdui-icon material-icons"><?php $Dicon = PSetting($this, 'Dicon'); if(!empty($Dicon)) { echo PSetting($this, 'Dicon'); }else{ echo 'message'; } ?></i></div>
<h2 class="moe-day-title"><a href="<?php $this->permalink() ?>" title="<?php echo sprintf(lang('archive', 'FloatingTitle'), $this->title); ?>"><?php $this->title() ?></a></h2>
<span class="moe-day-d"><?php $this->excerpt(100); ?></span>
<span class="moe-day-d"><?php if($this->fields->des){ $this->fields->des(); }else{ $this->excerpt(100); } ?></span>
<div class="mdui-divider"></div>
<div class="moe-day-info">
<i class="mdui-icon material-icons moe-author-icon">account_circle</i>
Expand All @@ -36,7 +36,7 @@
<div class="moe-day2">
<i class="mdui-icon material-icons">autorenew</i>
<span class="moe-body">
<span class="moe-t"><?php $Dtitle = PSetting('Dtitle'); if(!empty($Dtitle)) { echo PSetting('Dtitle'); }else{ $this->title(); } ?>(<a href="<?php $this->permalink() ?>"><?php echo lang('archive', 'LinkDynamic'); ?></a>)</span>
<span class="moe-t"><?php $Dtitle = PSetting($this, 'Dtitle'); if(!empty($Dtitle)) { echo PSetting($this, 'Dtitle'); }else{ $this->title(); } ?>(<a href="<?php $this->permalink() ?>"><?php echo lang('archive', 'LinkDynamic'); ?></a>)</span>
<span class="moe-info"><?php $this->date(lang('archive', 'time')); ?><?php echo sprintf(lang('archive', 'commentDynamic'), $this->commentsNum); ?><?php echo sprintf(lang('archive', 'viewDynamic'), PostView($this)); ?></span>
</span>
</div>
Expand All @@ -61,7 +61,7 @@
<div class="mdui-card-actions">
<div class="moe-post-margin"></div>
<span class="moe-post-text">
<?php $this->excerpt(100); ?>
<?php if($this->fields->des){ $this->fields->des(); }else{ $this->excerpt(100); } ?>
</span>
<div class="moe-post-margin"></div>
</div>
Expand Down
47 changes: 12 additions & 35 deletions includes/footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,19 @@
if ($this->options->other && in_array('copy', $this->options->other)){ $copyStatus = 'true'; }else{ $copyStatus = 'false'; }
if ($this->options->comment && in_array('ajax', $this->options->comment)){ $cajaxStatus = 'true'; }else{ $cajaxStatus = 'false'; }
if ($this->options->other && in_array('night', $this->options->other)){ $nightStatus = 'true'; }else{ $nightStatus = 'false'; }
if($this->options->ftt == '0'){
$fttr = '';
}elseif($this->options->ftt == '10'){
$fttr = ' moe-ft-tr-10';
}elseif($this->options->ftt == '20'){
$fttr = ' moe-ft-tr-20';
}elseif($this->options->ftt == '30'){
$fttr = ' moe-ft-tr-30';
}
?>
</div>

<footer class="moe-footer">
<footer class="moe-footer<?php echo $fttr; ?>">
<div class="mdui-container">
<div class="mdui-row">
<div class="mdui-col-xs-12 mdui-col-md-4 mdui-hidden-sm-down" style="float:left; margin-top:16px; margin-bottom:16px;">
Expand Down Expand Up @@ -48,41 +57,9 @@
<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'); ?>';
var NowTime = '19:00<?php //echo date('H:i'); ?>';
</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>
<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
3 changes: 2 additions & 1 deletion includes/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<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="stylesheet" href="<?php echo highlightResource(); ?>">
<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); ?>
Expand All @@ -42,7 +43,7 @@
<body class="mdui-theme-primary-<?php echo $ThemeColor; ?> mdui-theme-accent-<?php echo $AccentColor; ?> mdui-appbar-with-toolbar">
<div class="moe-bg" style="background-color: #EEEEEE;"></div>
<div class="moe-bg-after"></div>
<header class="mdui-appbar mdui-appbar-fixed moe-head">
<header class="mdui-appbar mdui-appbar-fixed moe-head<?php if ($this->options->other && in_array('toolbar', $this->options->other)){ echo ' mdui-appbar-scroll-hide'; } ?>">
<div class="mdui-toolbar">
<a class="mdui-btn mdui-btn-icon" mdui-drawer="{target: '#sidebar', swipe: 'true', overlay: 'true'}"><i class="mdui-icon material-icons">menu</i></a>
<a href="<?php $this->options->siteUrl(); ?>" class="mdui-typo-title"><?php $this->options->title(); ?></a>
Expand Down
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* @package Castle
* @author ohmyga
* @version 0.3.0
* @version 0.3.1
* @link https://ohmyga.cn/
*/
if (!defined('__TYPECHO_ROOT_DIR__')) exit;
Expand Down
3 changes: 2 additions & 1 deletion languages/prprpr.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"commentAllNumber": "咸鱼总数",
"home": "首页",
"pageAllNumber": "页面总数",
"postAllNumber": "水文总数"
"postAllNumber": "水文总数",
"time": "Y 年 n 月"
},
"post": {
"categories": "水文分类",
Expand Down
3 changes: 2 additions & 1 deletion languages/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"commentAllNumber": "评论总数",
"home": "首页",
"pageAllNumber": "页面总数",
"postAllNumber": "文章总数"
"postAllNumber": "文章总数",
"time": "Y 年 n 月"
},
"post": {
"categories": "文章分类",
Expand Down
3 changes: 2 additions & 1 deletion languages/zh-TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"commentAllNumber": "評論總數",
"home": "首頁",
"pageAllNumber": "頁面總數",
"postAllNumber": "文章總數"
"postAllNumber": "文章總數",
"time": "Y 年 n 月"
},
"post": {
"categories": "文章分類",
Expand Down
11 changes: 7 additions & 4 deletions libs/owo.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ public static function emoji($icon, $text) {
}

public static function getOwO() {
$getJson =file_get_contents(Helper::options()->siteUrl.'usr/themes/'.getTheme().'/libs/owo.json');
if (get_headers(Helper::options()->siteUrl.'usr/themes/'.getTheme().'/libs/owo.json',1)[0] == 'HTTP/1.1 200 OK') {
$getJson =file_get_contents(Helper::options()->siteUrl.'usr/themes/'.getTheme().'/libs/owo.json');
}else{
$getJson =file_get_contents(Helper::options()->themeFile(getTheme(), "libs/owo.json"));
}
$owoArray = json_decode($getJson, true);
$owoName = array_keys($owoArray);
for ($i=0; $i<count($owoName); $i++) {
Expand Down Expand Up @@ -86,7 +90,7 @@ public static function getTitle() {
}

public static function randIcon() {
$randNum = rand(0,11);
$randNum = rand(0,10);
$iconName = array('tag_faces',
'face',
'favorite',
Expand All @@ -97,8 +101,7 @@ public static function randIcon() {
'sentiment_very_dissatisfied',
'sentiment_very_satisfied',
'sentiment_dissatisfied',
'sentiment_neutral',
'OωO');
'sentiment_neutral');
$output = $iconName[$randNum];
return $output;
}
Expand Down
26 changes: 26 additions & 0 deletions libs/setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,20 @@ function themeConfig($form) {
_t('主题整体颜色'));
$form->addInput($tcs->multiMode());

$hltd = Helper::options()->themeFile(getTheme(), "others/css/highlight/default.min.css");
if (file_exists($hltd)) {
$hlts = array_map('basename', glob(dirname(__FILE__) . '/../others/css/highlight/*.css'));
$hlts = array_combine($hlts, $hlts);
$texts = '';
}else{
$hlts = array('jsdelivr' => '默认');
$texts = ' - <small style="color: red;">找不到 \'others/css/highlight/default.min.css\' 故将使用 JSdelivr 上的默认样式</small>';
}
$hls = new Typecho_Widget_Helper_Form_Element_Select('hls', $hlts, 'default.min.css',
_t('代码高亮样式'),
_t('代码高亮皮肤样式 (请参考文档)'.$texts));
$form->addInput($hls->multiMode());

$cardt = new Typecho_Widget_Helper_Form_Element_Select('cardt',array(
'0' => '不透明',
'10' => '10%',
Expand All @@ -181,6 +195,17 @@ function themeConfig($form) {
_t('全部卡片透明度'));
$form->addInput($cardt->multiMode());

$ftt = new Typecho_Widget_Helper_Form_Element_Select('ftt',array(
'0' => '不透明',
'10' => '10%',
'20' => '20%',
'30' => '30%',
),
'0',
_t('底部透明度'),
_t('底部的透明度'));
$form->addInput($ftt->multiMode());

$themeResource = new Typecho_Widget_Helper_Form_Element_Select('themeResource',array(
'local' => '本地',
'jsdelivr' => 'JSdelivr',
Expand Down Expand Up @@ -251,6 +276,7 @@ function themeConfig($form) {
'copy' => _t('复制内容提示'),
'pjax' => _t('启用PJAX无刷新'),
'gotop' => _t('右下返回顶部按钮'),
'toolbar' => _t('向下滑动顶栏自动收缩'),
'title' => _t('失去/恢复焦点标题变化'),
'night' => _t('显示夜间模式按钮(抽屉顶部)'),
'html' => _t('启用HTML压缩 (代码来自<a href="https://www.linpx.com/p/pinghsu-subject-integration-code-compression.html" target="_blank">LiNPX</A>,可能有部分插件不兼容)')
Expand Down
4 changes: 2 additions & 2 deletions others/css/castle.min.css

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions others/css/highlight/default.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit caffd84

Please sign in to comment.