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

Commit

Permalink
🩹 修复多处 BUG / 新增部分功能
Browse files Browse the repository at this point in the history
  • Loading branch information
bakaomg committed Feb 29, 2020
1 parent f4c68c3 commit c6db324
Show file tree
Hide file tree
Showing 11 changed files with 69 additions and 94 deletions.
39 changes: 39 additions & 0 deletions core/libs/Highlight.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
/**
* Castle highLight Class
* Last Update: 2020/02/29
*/
if (!defined('__TYPECHO_ROOT_DIR__')) exit;

class Castle_highLight {

/**
* 获取高亮样式
*
* @return $file 高亮文件路径
*/
public static function getFile() {
$loaclUrl = Helper::options()->themeUrl.'/core/highlight/';
$hl = (Helper::options()->highLight) ? $loaclUrl.Helper::options()->highLight : 'https://cdn.jsdelivr.net/gh/ohmyga233/castle-Typecho-Theme@'.CASTLE_VERSION.'/core/highlight/default.min.css';
return $hl;
}

/**
* 获取样式路径
*
* @return array
*/
public static function getHighLightConfig() {
$hltd = Helper::options()->themeFile(Castle_Libs::getTheme(), "core/highlight/default.min.css");
if (file_exists($hltd)) {
$hlts = array_map('basename', glob(__DIR__ . '/../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>';
}

return [$hlts, $texts];
}
}
7 changes: 7 additions & 0 deletions core/libs/Sidebar.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ public static function getMenuList() {
$sidebarMenu[$menuCount]['link'] = str_replace("{siteIndex}", Castle_Libs::index(), $sidebarMenu[$menuCount]['link']);
}

//类型为列表
if ($sidebarMenu[$menuCount]['type'] == 'list') {
for ($i=0; $i<count($sidebarMenu[$menuCount]['content']); $i++) {
$sidebarMenu[$menuCount]['content'][$i]['link'] = str_replace("{siteIndex}", Castle_Libs::index(), $sidebarMenu[$menuCount]['content'][$i]['link']);
}
}

//类型为归档
if ($sidebarMenu[$menuCount]['type'] == 'archives') {
//归档
Expand Down
9 changes: 9 additions & 0 deletions core/libs/themeConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@ function themeConfig($form) {

$Component->panel('404 页面', NULL,
$Component->input('Cover404', '404 页面卡片封面', '留空显示默认封面。', NULL)
).

$Component->panel('代码高亮', NULL,
$Component->radio("highLight", "代码高亮", '代码高亮',
Castle_highLight::getHighLightConfig()[0],'default.min.css').
Castle_highLight::getHighLightConfig()[1]
)
).

Expand Down Expand Up @@ -253,6 +259,9 @@ function themeConfig($form) {
);
}

/**
* 主题配置备份
*/
function themeBackup() {
$db = Typecho_Db::get();
$sjdq=$db->fetchRow($db->select()->from ('table.options')->where ('name = ?', 'theme:'.Castle_Libs::getTheme().''));
Expand Down
2 changes: 1 addition & 1 deletion functions.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Castle Functions
* Last Update: 2020/01/25
* Last Update: 2020/02/29
*/
if (!defined('__TYPECHO_ROOT_DIR__')) exit;

Expand Down
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* @package Castle
* @author ohmyga
* @version 0.9.0
* @version 0.9.1
* @link https://ohmyga.cn/
*/
if (!defined('__TYPECHO_ROOT_DIR__')) exit;
Expand Down
6 changes: 6 additions & 0 deletions static/css/APlayer.min.css

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

4 changes: 2 additions & 2 deletions static/css/castle.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion static/css/castle.setting.min.css

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

2 changes: 1 addition & 1 deletion static/css/castle.theme.min.css

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

2 changes: 1 addition & 1 deletion static/js/castle.min.js

Large diffs are not rendered by default.

88 changes: 1 addition & 87 deletions static/js/castle.setting.min.js

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

0 comments on commit c6db324

Please sign in to comment.