Skip to content

Commit

Permalink
v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
imjeff committed Dec 17, 2023
0 parents commit ade19e6
Show file tree
Hide file tree
Showing 9 changed files with 276 additions and 0 deletions.
8 changes: 8 additions & 0 deletions 404.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
<?php $this->need('header.php'); ?>
<div>
<h1>404</h1>
<p>出错了,这里什么都没有。</p>
<p><a href="<?php $this->options->siteUrl(); ?>">← 返回首页</a></p>
</div>
<?php $this->need('footer.php'); ?>
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Writing

主题介绍: Writing 是一款极致极简写作主题,支持自定义背景、自定义菜单、暗黑模式、自适应,保留搜索及评论功能;内置文章归档模板。主题无 JS、CSS 文件载入,对程序极简优化,仅9个文件约50kb。

关键词: 极简,博客,单栏,自适应,暗黑模式,免费

主题发布页: https://yayu.net/projects/typecho-writing

作者: Jeff Chen

作者网站: https://yayu.net/

最新版本: 1.0.0

授权方式: CC BY-NC-SA 4.0 DEED

授权介绍: https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh-hans


## 使用方法

1. 上传并激活主题,开箱即用。


## 页面模板/所有文章

1. 创建一个新的页面,或选择一个已有页面;
2. 编辑状态,在“页面属性”的“模板”一项中选择“文章归档”模板。

该模板按年月展示博客所有文章。
37 changes: 37 additions & 0 deletions archives.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php
/**
* 文章归档
*
* @package custom
*/
if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
<?php $this->need('header.php'); ?>
<style>
details{margin:10px 0;}
details ul{list-style:none;padding:0 0 10px;margin:0;}
details li{margin:6px 0;font-weight:bold;font-size:1.1em;}
summary{color:#999;}
summary:hover{cursor: pointer;opacity:0.5;}
</style>
<h1 class="title"><?php $this->title() ?></h1><br />
<p>
<?php $this->widget('Widget_Contents_Post_Recent', 'pageSize=10000')->to($archives);
$year=0; $mon=0; $i=0; $j=0; $output='';
while($archives->next()):
$year_tmp = date('Y',$archives->created);
$mon_tmp = date('m',$archives->created);
$y=$year; $m=$mon;
if ($mon != $mon_tmp && $mon > 0) $output .= '</ul>';
if ($year != $year_tmp && $year > 0) $output .= '';
if ($year != $year_tmp && $mon != $mon_tmp) {
$year = $year_tmp;
$mon = $mon_tmp;
$output .= '<details><summary>'. $year .''. $mon .'月</summary><ul>';
}
$output .= '<li><a href="'.$archives->permalink .'" title="'. $archives->title .'">'. $archives->title .'</a></li>';
endwhile;
$output .= '</ul></details>';
echo $output;
?>
</p>
<?php $this->need('footer.php'); ?>
53 changes: 53 additions & 0 deletions comments.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
<div id="comments">
<?php $this->comments()->to($comments); ?>
<?php if ($comments->have()): ?>
<h3><?php $this->commentsNum(_t('暂无评论'), _t('仅有一条评论'), _t('已有 %d 条评论')); ?></h3>
<?php $comments->listComments(); ?>
<?php $comments->pageNav('&laquo; 前一页', '后一页 &raquo;'); ?>
<?php endif; ?>
<?php if ($this->allow('comment')): ?>
<div id="<?php $this->respondId(); ?>" class="respond">
<div class="cancel-comment-reply">
<?php $comments->cancelReply(); ?>
</div>
<h3 id="response"><?php _e('添加新评论'); ?></h3>
<form method="post" action="<?php $this->commentUrl() ?>" id="comment-form" role="form">
<?php if ($this->user->hasLogin()): ?>
<p><?php _e('登录身份: '); ?><a
href="<?php $this->options->profileUrl(); ?>"><?php $this->user->screenName(); ?></a>. <a
href="<?php $this->options->logoutUrl(); ?>" title="Logout"><?php _e('退出'); ?> &raquo;</a>
</p>
<?php else: ?>
<p>
<label for="author" class="required"><?php _e('称呼'); ?></label>
<input type="text" name="author" id="author" class="text"
value="<?php $this->remember('author'); ?>" required/>
</p>
<p>
<label
for="mail"<?php if ($this->options->commentsRequireMail): ?> class="required"<?php endif; ?>><?php _e('Email'); ?></label>
<input type="email" name="mail" id="mail" class="text"
value="<?php $this->remember('mail'); ?>"<?php if ($this->options->commentsRequireMail): ?> required<?php endif; ?> />
</p>
<p>
<label
for="url"<?php if ($this->options->commentsRequireURL): ?> class="required"<?php endif; ?>><?php _e('网站'); ?></label>
<input type="url" name="url" id="url" class="text" placeholder="<?php _e('http://'); ?>"
value="<?php $this->remember('url'); ?>"<?php if ($this->options->commentsRequireURL): ?> required<?php endif; ?> />
</p>
<?php endif; ?>
<p>
<label for="textarea" class="required"><?php _e('内容'); ?></label>
<textarea rows="8" cols="50" name="text" id="textarea" class="textarea"
required><?php $this->remember('text'); ?></textarea>
</p>
<p>
<button type="submit" class="submit"><?php _e('提交评论'); ?></button>
</p>
</form>
</div>
<?php else: ?>
<h3 style="text-align: center;"><?php _e('评论已关闭'); ?></h3>
<?php endif; ?>
</div>
11 changes: 11 additions & 0 deletions footer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
</main>
<footer>
<?php if ($this->is('index')){ ?><form id="search" method="post" action="<?php $this->options->siteUrl(); ?>" role="search">
<input type="text" id="s" name="s" class="text" placeholder="输入关键字"/>
<button type="submit" class="submit">搜索</button>
</form><?php } ?>
<span>&copy; <?php echo date( 'Y' ); ?> <a href="<?php $this->options->siteUrl(); ?>" title="<?php $this->options->title(); ?>"><?php $this->options->title(); ?></a> | <a href="<?php $this->options->feedUrl(); ?>">RSS</a> | <a href="#"> ↑↑ </a></span><br /><small>SHARED BY <a href="https://yayu.net" title="雅余">YAYU</a></small>
</footer>
<?php $this->footer(); ?>
</body>
</html>
2 changes: 2 additions & 0 deletions functions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
if (!defined('__TYPECHO_ROOT_DIR__')) exit;
100 changes: 100 additions & 0 deletions header.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="<?php $this->options->charset(); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><?php $this->archiveTitle(['category' => _t('%s'),'search' => _t('搜索结果:%s'),'tag' => _t('标签:%s'),'author' => _t('作者:%s')], '', ' - '); ?><?php $this->options->title(); ?></title>
<style>
:root {
--width: 600px;
--font-scale: 1em;
--background-color: #fff;
--heading-color: #222;
--nav-color:#777;
--text-color: #333;
--code-background-color: #f2f2f2;
--code-color: #222;
--blockquote-color: #222;
--gray-color: #aaa;
}
@media (prefers-color-scheme: dark) {
:root {
--background-color: #111;
--heading-color: #d9c48f;
--nav-color: #8f8873;
--text-color: #d9c48f;
--code-background-color: #000;
--code-color: #ddd;
--blockquote-color: #ccc;
--gray-color: #756a56;
}
}
body {
font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Ubuntu,"Helvetica Neue",Helvetica,Arial,"PingFangSC-Regular","Hiragino Sans GB","Lantinghei SC","Microsoft Yahei","Source Han Sans CN","WenQuanYi Micro Hei",SimSun,sans-serif;
font-size: var(--font-scale);
margin: auto;
padding: 20px;
max-width: var(--width);
text-align: center;
background-color: var(--background-color);
word-wrap: break-word;
overflow-wrap: break-word;
line-height: 1.8;
color: var(--text-color);
}
html{scroll-behavior:smooth;}
h1,h2,h3,h4,h5,h6{color:var(--heading-color);}
a{color:var(--text-color);cursor:pointer;text-decoration:none}
a:hover{opacity:0.5;}
nav a{margin:0 5px;}
strong,b{color:var(--heading-color)}
button{margin:0;cursor:pointer}
time,.commentmetadata a{color:var(--gray-color);font-size:0.8em;}
table{width:100%}
hr{border:0;border-top:1px dashed}
img{max-width:100%;height:auto}
code{font-family:monospace;padding:2px;background-color:var(--code-background-color);color:var(--code-color);border-radius:3px}
blockquote{border-left:1px solid var(--gray-color);color:var(--code-color);padding-left:20px;font-style:italic}
header,footer{margin: 10px 0;color:var(--gray-color);}
footer{padding-top:40px;}
header a,footer a{color:var(--nav-color)}
article{margin-bottom:30px;}
h1.title,h2.title {margin:50px 0 0;line-height:1.6;}
.intro{color:var(--gray-color);margin-bottom:50px;}
.home.intro:after{content:"✍";display: block;font-size:2em;margin-top: 40px;}
.content,.comlist,.respond{text-align:left;padding-top:40px;}
.content a,.comment-reply a,.respond a{border-bottom:1px solid var(--text-color);}
.content a:has(img){border:none}
.pages a{font-size:20px;padding:5px;}
.tags,.tags a{color:var(--gray-color);margin-right:10px;}
.comlist{max-width:450px;margin:0 auto;}
.comment-list,.comment-list .comment-children{list-style: none;padding:0;margin-bottom:40px;}
.comment-body{margin:30px 0;list-style: none;}
.comment-body .comment-children{margin-left:35px;}
.comment-author cite{font-weight:bold;font-style:normal;}
input,textarea{border-radius:4px;border:1px solid var(--gray-color);display:block;font-size:0.9em;margin:0 0 10px;padding:10px;width:calc(100% - 25px);background:var(--background-color);color:var(--heading-color)}
input:focus,textarea:focus{border:1px solid var(--text-color);outline:0}
button[type="submit"]{border:none;border-radius:4px;padding:10px 16px;width:initial;background:var(--heading-color);color:var(--background-color);font-size:0.9em}
button[type="submit"]:hover{cursor:pointer;opacity:.7;}
#search input{margin:20px auto;width: initial;display:inline-block;}
</style>
<?php $this->header(); ?>
</head>
<body>
<header>
<nav><?php if ($this->is('single') || $this->is('category') || $this->is('search') || $this->is('tag')) { ?>
<a href="<?php $this->options->siteUrl(); ?>">← 首页</a> | <?php } ?>
<?php if ($this->is('post')) { ?><?php $this->category(','); ?><?php } ?>
<?php if ($this->is('page') || $this->is('index') || $this->is('category') || $this->is('search') || $this->is('tag')) { ?>
<?php $this->widget('Widget_Metas_Category_List')->to($category); ?>
<?php while($category->next()): ?>
<a<?php if($this->is('category', $category->slug)): ?> class="current"<?php endif; ?> href="<?php $category->permalink(); ?>" title="<?php $category->name(); ?>"><?php $category->name(); ?></a>
<?php endwhile; ?>
<?php $this->widget('Widget_Contents_Page_List')->to($pages); ?>
<?php while ($pages->next()): ?>
<a<?php if ($this->is('page', $pages->slug)): ?> class="current"<?php endif; ?> href="<?php $pages->permalink(); ?>" title="<?php $pages->title(); ?>"><?php $pages->title(); ?></a>
<?php endwhile; ?>
<?php } ?></nav>
</header>
<main>
35 changes: 35 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php
/**
* Writing 是一款极致极简写作主题,支持自定义背景、自定义菜单、暗黑模式、自适应,保留搜索及评论功能;内置文章归档模板。主题无 JS、CSS 文件载入,对程序极简优化,仅9个文件约50kb。<br/>
* 发布页:<a href="https://yayu.net/projects/typecho-writing" target="_blank">https://yayu.net/projects/typecho-writing</a>
*
* @package Writing
* @author Jeff Chen
* @version 1.0.0
* @link https://yayu.net/
*/
if (!defined('__TYPECHO_ROOT_DIR__')) exit;
$this->need('header.php'); ?>
<?php if ($this->is('index')){ ?>
<h1 class="title"><a href="<?php $this->options->siteUrl(); ?>"><?php $this->options->title() ?></a></h1>
<div class="home intro"><?php $this->options->description() ?></div>
<?php }; if ($this->is('archive')) { ?>
<h1 class="title"><?php $this->archiveTitle(['category' => _t('%s'),'search' => _t('搜索结果'),'tag' => _t('标签:%s'),'author' => _t('作者:%s')], '', ''); ?></h1>
<div class="intro"><?php if ( $this->is('search') ) { ?>关键词:<?php echo $this->archiveTitle('','',''); ?><?php } else { ?><?php echo $this->getDescription(); ?><?php } ?></div>
<?php } ?>
<?php if ($this->have()): ?>
<?php while ($this->next()): ?>
<article>
<?php $site_title_elem = $this->is('single') ? 'h1' : 'h2'; ?>
<<?php echo $site_title_elem; ?> class="title"><a href="<?php $this->permalink() ?>"><?php $this->title() ?></a></<?php echo $site_title_elem; ?>>
<?php if ( $this->is('archive') || $this->is('index') || $this->is('post') ) { ?><time datetime="<?php $this->date('c'); ?>"><?php $this->date(); ?></time><?php } ?>
<?php if ( $this->is('single') ) { ?><div class="content"><?php $this->content(); ?></div><?php } ?>
</article>
<?php endwhile; ?>
<?php if ( $this->is('single') ) { ?>
<?php if ( $this->is('post') ) { ?><p class="tags"># <?php $this->tags('', true, '无标签'); ?></p><?php }; ?>
<div class="comlist"><br /><?php $this->need('comments.php'); ?></div>
<?php }; if ( $this->is('archive') || $this->is('index') ) { ?>
<div class="pages"><?php $this->pageLink('&nbsp;←&nbsp;'); ?><?php $this->pageLink('&nbsp;→&nbsp;','next'); ?></div>
<?php }; endif; ?>
<?php $this->need('footer.php'); ?>
Binary file added screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ade19e6

Please sign in to comment.