halo开源博客/cms系统
# halo介绍
环境要求:
jdk11以上, 如果只有jdk8, 可以采用docker方式安装。 halo1.4.3以下的可以运行在jdk8
mysql5.7+ ,字符集utf8mb4, innodb
create database halodb character set utf8mb4 collate utf8mb4_bin;
1
# 安装
下载halo源码,切换到java1.8对应的版本v1.4.3以下v1.4.2
git clone https://github.com.cnpmjs.org/halo-dev/halo.git
git checkout v1.4.2
git submodule init
git submodule update
1
2
3
4
5
2
3
4
5
# 第一步:创建工作目录并修改配置
Halo 的配置文件名为 application.yaml
,其必须位于工作目录 (opens new window) ~/.halo
下。 Halo 会读取该目录下的配置文件进行加载
mkdir ~/.halo && cd ~/.halo #创建工作目录
wget https://dl.halo.run/config/application-template-mysql.yaml -O ./application.yaml
vim application.yaml
1
2
3
2
3
docker pull halohub/halo:1.4.12 #下载拉取镜像
docker run -it -d --name halo -p 8090:8090 -v ~/.halo:/root/.halo --restart=unless-stopped halohub/halo:1.4.12
docker stop halo # start restart logs
1
2
3
4
2
3
4
server:
port: 8090
# Response data gzip.
compression:
enabled: false
spring:
datasource:
# MySQL database configuration.
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/halodb?characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
username: root
password: 123456
halo:
# Your admin client path is https://your-domain/{admin-path}
admin-path: admin
# memory or level
cache: memory
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
参考: 使用 Docker 部署 Halo | Halo Documents (opens new window)
# 运行
wget https://dl.halo.run/release/halo-1.4.13.jar -O halo.jar
nohup java -jar halo-1.4.13.jar --spring.profiles.active=dev >nohup.out 2>&1 &
1
2
2
# 数据库表
├── module // 公共模板目录
│ ├── comment.ftl // 比如:评论模板
│ ├── layout.ftl // 比如:布局模板
├── source // 静态资源目录
│ ├── css // 样式目录
│ ├── images // 图片目录
│ ├── js // JS 脚本目录
│ └── plugins // 前端库目录
├── index.ftl // 首页
├── post.ftl // 文章页
├── post_xxx.ftl // 自定义文章模板,如:post_diary.ftl。可在后台发布文章时选择。
├── sheet.ftl // 自定义页面
├── sheet_xxx.ftl // 自定义模板,如:sheet_search.ftl、sheet_author.ftl。可在后台发布页面时选择。
├── archives.ftl // 归档页
├── categories.ftl // 分类目录页
├── category.ftl // 单个分类的所属文章页
├── tags.ftl // 标签页面
├── tag.ftl // 单个标签的所属文章页
├── search.ftl // 搜索结果页
├── links.ftl // 内置页面:友情链接
├── photos.ftl // 内置页面:图库
├── journals.ftl // 内置页面:日志
├── 404.ftl // 404 页
├── 500.ftl // 500 页
├── README.md // README,一般用于主题介绍或说明
├── screenshot.png // 主题预览图
├── settings.yaml // 主题选项配置文件
└── theme.yaml // 主题描述文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# 开发主题
# 安装主题
- 直接在后台进行安装,可以编辑修改对应的模板文件
原主题地址:https://github.com/jinqilin721/halo-theme-xinac-fantastic -> https://github.com.cnpmjs.org/jinqilin721/halo-theme-xinac-fantastic.git
即将https://github.com由https://github.com.cnpmjs.org代替即
# 常用主题
# diy主题
下载主题模板:https://github.com.cnpmjs.org/halo-dev/halo-theme-quick-starter
# 技术点
# ByteBuddy读取目录下面的文件
SimpleFileVisitor快速遍历文件夹内容输出到文件 - TonyTaotao的个人空间 - OSCHINA - 中文开源技术交流社区 (opens new window)
# 类扫描器读取包下面的指定类
见类AutoGenerateConverterPersistenceUnitPostProcessor
private Set<Class<?>> findValueEnumClasses(String packagePath) {
ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(false);
// include ValueEnum class
scanner.addIncludeFilter(new AssignableTypeFilter(ValueEnum.class));
// 排除 exclude PropertyEnum class
//scanner.addExcludeFilter(new AssignableTypeFilter(PropertyEnum.class));
return scanner.findCandidateComponents(packagePath)
.stream()
.filter(bd -> bd.getBeanClassName() != null)
.map(bd -> ClassUtils.resolveClassName(bd.getBeanClassName(), null))
.collect(Collectors.toSet());
}
1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13