Skip to content

Commit f37ba98

Browse files
LightLight
Light
authored and
Light
committed
feat: 实现功能
0 parents  commit f37ba98

File tree

112 files changed

+46085
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+46085
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 Light
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<p align="center">
2+
<img src="img/[email protected]" />
3+
</p>
4+
5+
<h1 align="center">WebStack 网址导航 Typecho 主题</h1>
6+
7+
<p align="center">
8+
<a href="https://github.com/LightAPIs/WebStackTypechoTheme/releases/latest">
9+
<img src="https://img.shields.io/github/v/release/LightAPIs/WebStackTypechoTheme.svg?color=orange" alt="Release" />
10+
</a>
11+
<a href="./LICENSE">
12+
<img src="https://img.shields.io/badge/license-MIT-green.svg" alt="MIT License" />
13+
</a>
14+
</p>
15+
16+
> Typecho 网址导航主题
17+
18+
## 简介
19+
20+
这是一个基于开源项目[WebStack](https://github.com/WebStackPage/WebStackPage.github.io)[WebStack_钻芒二开版](https://github.com/wclk/WebStack_ZMKI)而制作的 Typecho 网址导航主题。
21+
22+
该项目主要是为了构建一个更适合~~~~个人使用的网址导航站点,一切从简,以简约实用为原则做个简单纯粹的网址导航。
23+
24+
因此对比一些其他的网址导航程序,本导航程序可能也更适合搭建在像 NAS 这样的私人服务器上面去使用。
25+
26+
## 预览
27+
28+
### 主页预览
29+
30+
- ![index_day](img/index_day.jpg)
31+
- ![index_dark](img/index_dark.jpg)
32+
33+
### 主题设置预览
34+
35+
- ![config](img/config.jpg)
36+
37+
## 安装
38+
39+
1. 前往 [Typecho](https://typecho.org/download) 下载 Typecho 博客程序,参照安装环境要求及[安装文档](http://docs.typecho.org/install),根据安装过程中的安装向导依次完成安装即可。
40+
2. 前往 [Releases](https://github.com/LightAPIs/WebStackTypechoTheme/releases/latest) 下载主题文件压缩包,解压得到 `WebStack` 目录,将其上传至服务器 Typecho 主题目录 `/usr/themes/`
41+
3. 在浏览器里打开 Typecho 后台页面(默认:`/admin/index.php`),点击"更换外观"进入外观设置页面,找到 WebStack Typecho Theme 主题并点击启用即可。此时回到博客首页便能看到导航主题效果了。
42+
43+
## 使用
44+
45+
### 添加分类
46+
47+
在后台的分类管理页面(默认:`/admin/manage-categories.php`)中可以添加或编辑分类,其对应导航页中左侧边栏里的菜单项,一般可以按照网址的类别来进行分类。
48+
49+
### 添加项目
50+
51+
在后台的文章管理页面(默认:`/admin/manage-posts.php`)中可以添加或编辑具体的网址导航项目。
52+
53+
![add](img/add.jpg)
54+
55+
其中可以填写的项目包括:
56+
57+
- 标题:即导航的标题
58+
- 跳转链接:即导航到的网址
59+
- 链接描述:可以补充一些关于该导航的信息描述
60+
- 链接 Logo:即导航显示的图标地址,也可以自行在附件中上传图标并将地址填入
61+
- 分类:选择导航网址的分类,不勾选则为默认分类
62+
- *排序:同分类下的导航项目默认按照创建时间进行排序,可以通过填写此值使该导航项目排序更靠前*(**注:该功能需要另外安装 [EnablePostsOrder](https://github.com/LightAPIs/EnablePostsOrder) 插件才能实现**)
63+
64+
### 主题设置
65+
66+
在后台的外观设置页面(默认:`/admin/options-theme.php`)中可以调整设置关于本主题的其他功能。
67+
68+
## 插件
69+
70+
一些提供功能增强的 Typecho 插件:
71+
72+
- [LightAPIs/EnablePostsOrder](https://github.com/LightAPIs/EnablePostsOrder):用于支持排序导航项目,推荐安装使用
73+
- [LightAPIs/EncryptYourSite](https://github.com/LightAPIs/EncryptYourSite):用于加密导航站点,若导航为私人使用且不想每个知道导航域名的都能看到站点内容,则可以安装使用该插件
74+
75+
## 相关项目
76+
77+
本项目的诞生离不开以下这些优秀的项目:
78+
79+
- [wclk/WebStack_ZMKI](https://github.com/wclk/WebStack_ZMKI)
80+
- [WebStackPage/WebStackPage.github.io](https://github.com/WebStackPage/WebStackPage.github.io)
81+
82+
## License
83+
84+
[MIT](./LICENSE) license

build.py

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# -*- coding: utf-8 -*-
2+
import os
3+
import tarfile
4+
import zipfile
5+
import argparse
6+
import json
7+
8+
9+
def make_zipfile(output_filename, source_dir, package_dir_name):
10+
with zipfile.ZipFile(output_filename, mode="w", compression=zipfile.ZIP_DEFLATED) as zf:
11+
for root, dirs, files in os.walk(source_dir):
12+
zf.write(root, os.path.join(package_dir_name, os.path.relpath(root, source_dir)))
13+
for file in files:
14+
filename = os.path.join(root, file)
15+
if os.path.isfile(filename):
16+
arcname = os.path.join(package_dir_name, os.path.relpath(filename, source_dir))
17+
zf.write(filename, arcname)
18+
19+
20+
if __name__ == "__main__":
21+
ap = argparse.ArgumentParser(description="打包项目")
22+
ap.add_argument("-s", "--src", required=False, help="自定义项目源文件所在目录")
23+
ap.add_argument("-i", "--info", required=False, help="自定义项目信息文件路径")
24+
25+
args = vars(ap.parse_args())
26+
build_dir = "build"
27+
print("************************************************")
28+
src_path = os.path.join(os.getcwd(), "src")
29+
if args["src"] and os.path.exists(args["src"]):
30+
src_path = args["src"]
31+
print("INFO:: 源文件路径: " + src_path)
32+
work_path = os.path.abspath(os.path.dirname(src_path))
33+
print("INFO:: 工作路径: " + work_path)
34+
35+
build_path = os.path.join(work_path, build_dir)
36+
if not os.path.exists(build_path):
37+
os.makedirs(build_path)
38+
39+
info_file = os.path.join(work_path, "info.json")
40+
if args["info"]:
41+
info_file = args["info"]
42+
if not os.path.exists(info_file):
43+
print("ERROR:: 没有找到需要打包的信息文件!")
44+
exit()
45+
46+
info = {"name": "unknow", "version": "0.1", "package": "src"}
47+
with open(info_file, encoding="utf-8") as load_f:
48+
info = json.load(load_f)
49+
50+
build_filename = info["name"] + "_v" + info["version"]
51+
print("INFO:: 打包文件名称: " + info["name"])
52+
print("INFO:: 打包文件版本: " + info["version"])
53+
print("INFO:: 压缩包根目录: " + info["package"])
54+
55+
build_tar_file = os.path.join(build_path, build_filename + ".tar.gz")
56+
if os.path.exists(build_tar_file):
57+
os.remove(build_tar_file)
58+
with tarfile.open(build_tar_file, mode="w:gz") as tar:
59+
tar.add(src_path, arcname=info["package"])
60+
print("INFO:: 打包 tar: " + src_path)
61+
tar.close()
62+
print("INFO:: 已经生成打包文件至: " + build_tar_file)
63+
64+
build_zip_file = os.path.join(build_path, build_filename + ".zip")
65+
if os.path.exists(build_zip_file):
66+
os.remove(build_zip_file)
67+
make_zipfile(build_zip_file, src_path, info["package"])
68+
print("INFO:: 已经生成打包文件至: " + build_zip_file)
69+
70+
print("SUCCESS:: 打包操作已经完成。")
71+
print("************************************************")

img/add.jpg

216 KB
Loading

img/config.jpg

289 KB
Loading

img/index_dark.jpg

347 KB
Loading

img/index_day.jpg

377 KB
Loading

img/logo.png

1.46 KB
Loading

img/[email protected]

3.58 KB
Loading

info.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "WebStackTypechoTheme",
3+
"version": "1.0.0",
4+
"package": "WebStack"
5+
}

src/404.php

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
if (!defined('__TYPECHO_ROOT_DIR__')) exit;
3+
define("THEME_URL", '/' . str_replace($this->options->siteUrl, "", $this->options->themeUrl));
4+
?>
5+
<!DOCTYPE HTML>
6+
<html lang="zh">
7+
<?php $this->need('header.php'); ?>
8+
<body class="page-body <?php echo $_COOKIE['night'] == '1' ? 'night' : ''; ?>">
9+
<div class="main-content">
10+
<div class="error-page text-center">
11+
<h1 class="error-page-title">404 - <?php _e('您要找的页面未找到。'); ?></h1>
12+
<p>看起来你似乎正在进入这个世界的未知领域,<b class="time_num">5</b> 秒后将自动逃离。</p>
13+
<p>如果逃离失败,请点击<a href="<?php $this->options->siteUrl(); ?>" rel="nofollow">这里</a>。</p>
14+
</div>
15+
</div>
16+
<br>
17+
<script type="text/javascript">
18+
function runAway() {
19+
const timeNum = document.querySelector('.time_num');
20+
if (timeNum) {
21+
let num = Number(timeNum.textContent)
22+
num -= 1;
23+
timeNum.textContent = num.toString();
24+
25+
if (num === 0) {
26+
location.href = "<?php $this->options->siteUrl(); ?>";
27+
} else {
28+
window.setTimeout(runAway, 1000);
29+
}
30+
}
31+
}
32+
window.setTimeout(runAway, 1000);
33+
</script>
34+
<style>
35+
.error-page-title {
36+
margin: 50px 0 25px 0;
37+
font-size: 25px;
38+
}
39+
footer.main-footer {
40+
margin-left: 0;
41+
margin-right: 0;
42+
}
43+
</style>
44+
<!-- Main Footer -->
45+
<?php $this->need('footer.php'); ?>
46+
</body>
47+
</html>

src/comments.php

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
2+
<div id="comments">
3+
<?php $this->comments()->to($comments); ?>
4+
<?php if ($comments->have()): ?>
5+
<h3><?php $this->commentsNum(_t('暂无评论'), _t('仅有一条评论'), _t('已有 %d 条评论')); ?></h3>
6+
7+
<?php $comments->listComments(); ?>
8+
9+
<?php $comments->pageNav('&laquo; 前一页', '后一页 &raquo;'); ?>
10+
11+
<?php endif; ?>
12+
13+
<?php if($this->allow('comment')): ?>
14+
<div id="<?php $this->respondId(); ?>" class="respond">
15+
<div class="cancel-comment-reply">
16+
<?php $comments->cancelReply(); ?>
17+
</div>
18+
19+
<h3 id="response"><?php _e('添加新评论'); ?></h3>
20+
<form method="post" action="<?php $this->commentUrl() ?>" id="comment-form" role="form">
21+
<?php if($this->user->hasLogin()): ?>
22+
<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>
23+
<?php else: ?>
24+
<ul class="compost">
25+
<li>
26+
<input type="text" name="author" id="author" class="text" placeholder="<?php _e('昵称(必填)'); ?>" value="<?php $this->remember('author'); ?>" required />
27+
</li>
28+
<li>
29+
<input type="email" name="mail" id="mail" class="text" placeholder="<?php _e('邮箱(必填)'); ?>" value="<?php $this->remember('mail'); ?>"<?php if ($this->options->commentsRequireMail): ?> required<?php endif; ?> />
30+
</li>
31+
<li>
32+
<input type="url" name="url" id="url" class="text" placeholder="<?php _e('网址(选填)'); ?>" value="<?php $this->remember('url'); ?>"<?php if ($this->options->commentsRequireURL): ?> required<?php endif; ?> />
33+
</li>
34+
</ul>
35+
<?php endif; ?>
36+
<div>
37+
<textarea rows="8" cols="50" name="text" id="textarea" placeholder="<?php _e('说点什么吧'); ?>" class="textarea" required><?php $this->remember('text'); ?></textarea>
38+
</div>
39+
<p>
40+
<button type="submit" class="submit"><?php _e('提交评论'); ?></button>
41+
</p>
42+
</form>
43+
</div>
44+
<?php else: ?>
45+
<h3><?php _e('评论已关闭'); ?></h3>
46+
<?php endif; ?>
47+
</div>
48+
<style>#comments{padding-top:15px}.comment-list,.comment-list ol{list-style:none;margin:0;padding:0}.comment-list li{padding:14px;margin-top:10px;border:1px solid #EEE}.comment-list li.comment-level-odd{background:#f6f6f3}.comment-list li.comment-level-even{background:#FFF}.comment-list li.comment-by-author{background:#fff9e8}.comment-list li .comment-reply{text-align:right;font-size:.92857em}.comment-meta a{color:#999;font-size:.92857em}.comment-author{display:block;margin-bottom:3px;color:#444}.comment-author .avatar{float:left;margin-right:10px}.comment-author cite{font-weight:bold;font-style:normal}.comment-list .respond{margin-top:15px;border-top:1px solid #EEE}.respond .cancel-comment-reply{float:right;margin-top:15px;font-size:.92857em}#comment-form label{display:block;margin-bottom:.5em;font-weight:bold}#comment-form .required:after{content:" *";color:#C00}.respond ul{margin:0}.respond .compost{overflow:hidden;padding:10px 0 0}.respond .compost li input{width:160px;height:24px;padding-left:4px;border:1px solid #ddd;color:#666}.respond .compost li{float:left;margin-right:6px;margin-bottom:10px;list-style-type:none}.respond .textarea{width:100%;border:1px solid #ddd}.comment-content{margin:10px 0 0 45px}</style>

src/css/bootstrap.css

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/css/font-awesome.min.css

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
/*
2+
Animation example, for spinners
3+
*/
4+
.animate-spin {
5+
-moz-animation: spin 2s infinite linear;
6+
-o-animation: spin 2s infinite linear;
7+
-webkit-animation: spin 2s infinite linear;
8+
animation: spin 2s infinite linear;
9+
display: inline-block;
10+
}
11+
@-moz-keyframes spin {
12+
0% {
13+
-moz-transform: rotate(0deg);
14+
-o-transform: rotate(0deg);
15+
-webkit-transform: rotate(0deg);
16+
transform: rotate(0deg);
17+
}
18+
19+
100% {
20+
-moz-transform: rotate(359deg);
21+
-o-transform: rotate(359deg);
22+
-webkit-transform: rotate(359deg);
23+
transform: rotate(359deg);
24+
}
25+
}
26+
@-webkit-keyframes spin {
27+
0% {
28+
-moz-transform: rotate(0deg);
29+
-o-transform: rotate(0deg);
30+
-webkit-transform: rotate(0deg);
31+
transform: rotate(0deg);
32+
}
33+
34+
100% {
35+
-moz-transform: rotate(359deg);
36+
-o-transform: rotate(359deg);
37+
-webkit-transform: rotate(359deg);
38+
transform: rotate(359deg);
39+
}
40+
}
41+
@-o-keyframes spin {
42+
0% {
43+
-moz-transform: rotate(0deg);
44+
-o-transform: rotate(0deg);
45+
-webkit-transform: rotate(0deg);
46+
transform: rotate(0deg);
47+
}
48+
49+
100% {
50+
-moz-transform: rotate(359deg);
51+
-o-transform: rotate(359deg);
52+
-webkit-transform: rotate(359deg);
53+
transform: rotate(359deg);
54+
}
55+
}
56+
@-ms-keyframes spin {
57+
0% {
58+
-moz-transform: rotate(0deg);
59+
-o-transform: rotate(0deg);
60+
-webkit-transform: rotate(0deg);
61+
transform: rotate(0deg);
62+
}
63+
64+
100% {
65+
-moz-transform: rotate(359deg);
66+
-o-transform: rotate(359deg);
67+
-webkit-transform: rotate(359deg);
68+
transform: rotate(359deg);
69+
}
70+
}
71+
@keyframes spin {
72+
0% {
73+
-moz-transform: rotate(0deg);
74+
-o-transform: rotate(0deg);
75+
-webkit-transform: rotate(0deg);
76+
transform: rotate(0deg);
77+
}
78+
79+
100% {
80+
-moz-transform: rotate(359deg);
81+
-o-transform: rotate(359deg);
82+
-webkit-transform: rotate(359deg);
83+
transform: rotate(359deg);
84+
}
85+
}

0 commit comments

Comments
 (0)