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

Commit

Permalink
pre sync;
Browse files Browse the repository at this point in the history
  • Loading branch information
FlyingSky-CN committed Jan 31, 2022
1 parent 6b2195c commit ae4af08
Show file tree
Hide file tree
Showing 10 changed files with 346 additions and 347 deletions.
66 changes: 29 additions & 37 deletions .build.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,31 @@
<?php if (php_sapi_name() !== 'cli') exit();
<?php

/**
* MDr theme build script.
*
* @author FlyingSky
* @package MDr
* @since petals
*/

/**
* 只允许在 CLI 下运行
*/
if (php_sapi_name() !== 'cli') exit();

/**
* 定义版权信息
*
* @var string
*/
define('Copyright', 'https://github.com/FlyingSky-CN/MDr');

/**
* 压缩 CSS 文件
*
* @param string $buffer CSS 内容
* @return string
*/
function compressCSS($buffer)
{
$buffer = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $buffer);
Expand All @@ -15,48 +39,16 @@ function compressCSS($buffer)
['{', ':', ',', '}', '!'],
$buffer
);
return '/* ' . Copyright . ' @time '.date('Y-m-d H:i:s').' */' . PHP_EOL . $buffer;
return '/* ' . Copyright . ' @time ' . date('Y-m-d H:i:s') . ' */' . PHP_EOL . $buffer;
}

/**
* 处理 CSS 文件
*/
file_put_contents(
__DIR__ . '/core/css/style.min.css',
compressCSS(
file_get_contents(__DIR__ . '/core/css/style.css') .
file_get_contents(__DIR__ . '/core/css/style-petals.css')
)
);

/**
* exceptFiles
* 排除的文件
*
* @var array
*/
define('exceptFiles', ['.git', '.github', '.build.php', 'style.css', 'hash.txt', '.gitignore']);

/**
* fetchFiles
* 扫描目录下所有文件
* 包含子目录
* 排除 exceptFiles
*
* @param string $subdir
* @return array
*/
function fetchFiles(string $subdir)
{
$items = array_reverse(array_diff(scandir($subdir), ['.', '..']));
$files = [];

foreach ($items as $item) {
if (is_file($subdir . $item))
if (!in_array($item, exceptFiles))
$files[] = $subdir . $item;
if (is_dir($subdir . $item))
if (!in_array($item, exceptFiles))
foreach (fetchFiles($subdir . $item . '/') as $file)
$files[] = $file;
}

return $files;
}
18 changes: 9 additions & 9 deletions archive.php
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
<?php $this->need('header.php'); ?>
<div id="main">
<div class="mdui-card breadcrumbs">
<span class="mdui-chip-icon"><i class="mdui-icon material-icons">chevron_right</i></span>
<div class="mdui-card mdr-breadcrumbs">
<span class="mdui-chip-icon"><i class="mdui-icon material-icons">&#xe5cc;</i></span>
<span class="mdui-chip-title mdui-p-l-0">
<a href="<?php $this->options->siteUrl(); ?>">首页</a> &nbsp;&raquo;&nbsp;
<?php $this->archiveTitle([
'category' => _t('分类 %s 下的文章'),
'search' => _t('包含关键字 %s 的文章'),
'tag' => _t('标签 %s 下的文章'),
'date' => _t(' %s 发布的文章'),
'author' => _t('作者 %s 发布的文章')
'category' => _t('分类「%s」下的文章'),
'search' => _t('包含关键字「%s」的文章'),
'tag' => _t('标签「%s」下的文章'),
'date' => _t('「%s」发布的文章'),
'author' => _t('作者「%s」发布的文章')
], '', ''); ?>
</span>
</div>
<?php if ($this->have()) : ?>
<?php while ($this->next()) : ?>
<?php if (is_status($this) && !$this->hidden) : /* Status Post */ ?>
<?php if (mdrIsStatus($this) && !$this->hidden) : /* Status Post */ ?>
<article class="mdui-card mdui-shadow-0 status post<?php if ($this->options->PjaxOption && $this->hidden) : ?> protected<?php endif; ?>">
<div class="tag"><i class="mdui-icon material-icons">message</i></div>
<div class="tag"><i class="mdui-icon material-icons">&#xe0c9;</i></div>
<div class="time mdui-text-right">
<i class="mdui-icon material-icons mdr-icon-info">&#xe192;</i> <?php $this->date(); ?>
</div>
Expand Down
Loading

0 comments on commit ae4af08

Please sign in to comment.