Skip to content

Commit

Permalink
refactor & fix: 重构部分代码; 废弃 MarkdownRender 渲染中间件
Browse files Browse the repository at this point in the history
  • Loading branch information
Done-0 committed Jan 25, 2025
1 parent 99ad69a commit 8171ca7
Show file tree
Hide file tree
Showing 55 changed files with 334 additions and 438 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ RUN apk --no-cache add ca-certificates tzdata
ENV TZ=Asia/Shanghai

# 设置工作目录
WORKDIR /jank
WORKDIR /app

# 从构建阶段复制编译好的应用
COPY --from=builder /jank/main .
Expand Down
63 changes: 27 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<p align="center">
<p style="text-align: center;">
<a><img src="https://s2.loli.net/2025/01/02/6F8fzMvrBDCATZk.png" alt="Jank"></a>
</p>
<p align="center">
<em>Jank,一个轻量级的博客系统,基于 Go 语言和 Echo 框架开发,强调极简、低耦合和高扩展</em>
<p style="text-align: center;">
<em>Jank,一个轻量级的博客系统,基于 Go 语言和 Echo 框架开发,强调极简、低耦合和高扩展</em>
</p>
<p align="center">
<p style="text-align: center;">
<a href="https://img.shields.io/github/stars/Done-0/Jank?style=social" target="_blank">
<img src="https://img.shields.io/github/stars/Done-0/Jank?style=social" alt="Stars">
</a> &nbsp;
Expand All @@ -24,14 +24,16 @@
<img src="https://img.shields.io/github/license/Done-0/Jank" alt="License">
</a>
</p>
<p align="center" style="margin: 0; padding: 0; position: relative; top: -5px;">
<p style="text-align: center; margin: 0; padding: 0; position: relative; top: -5px;">
<span style="text-decoration: underline; color: grey;">简体中文</span> | <a href="README_en.md" style="text-decoration: none;">English</a>
</p>

---

Jank 是一个轻量级的博客系统,基于 Go 语言和 Echo 框架开发,设计理念强调极简、低耦合和高扩展,旨在为用户提供功能丰富、界面简洁、操作简单且安全可靠的博客体验。

> 本项目仍处于开发阶段,欢迎提供宝贵意见!
## 技术栈

- **Go 语言**:热门后端开发语言,适合构建高并发应用。
Expand All @@ -40,7 +42,7 @@ Jank 是一个轻量级的博客系统,基于 Go 语言和 Echo 框架开发
- **Redis**:热门缓存解决方案,提供快速数据存取和持久化选项。
- **JWT**:安全的用户身份验证机制,确保数据传输的完整性和安全性。
- **Docker**:容器化部署工具,简化应用的打包和分发流程。
- **前端**:Vue 3 + Nuxt + Shadcn-vue(原项目已不再维护,诚邀前端大佬加入开发)。
- **前端**:Vue 3 + Nuxt + Shadcn-vue(原项目已不再维护,诚邀各位前端大佬共同开发)。

## 功能模块

Expand All @@ -54,23 +56,26 @@ Jank 是一个轻量级的博客系统,基于 Go 语言和 Echo 框架开发
- 使用 Logrus 实现日志记录
- 支持 CORS 跨域请求
- 提供 CSRF 和 XSS 防护
- 支持 Markdown 的服务端渲染

> **其他模块正在开发中**,欢迎提供宝贵意见和建议!
- 支持 Markdown 的服务端渲染(暂停维护)
- **其他模块正在开发中**,欢迎提供宝贵意见和建议!

## 本地开发

1. **安装依赖**

```bash
# 安装 swagger 工具
go install github.com/swaggo/swag/cmd/swag@latest

# 安装依赖包
go mod tidy
```

2. **配置数据库和邮箱**
修改 `configs/config.yaml` 文件中的数据库配置和邮箱配置,示例如下:

```yaml
# 数据库密码
# mysql 数据库密码
DB_PSW: "<DATABASE_PASSWORD>"

# QQ 邮箱和 SMTP 授权码(可选)
Expand All @@ -87,12 +92,18 @@ Jank 是一个轻量级的博客系统,基于 Go 语言和 Echo 框架开发

或使用 Air 进行热重载:

> 此方法最为便捷,但提前配置环境变量 GOPATH。
```bash
# 安装 air,需要 go 1.22 或更高版本
go install github.com/air-verse/air@latest

# 热重载启动
air -c ./configs/.air.toml
```

4. **访问接口**
打开浏览器,访问 [http://localhost:9010/ping](http://localhost:9010/ping)
本地启动应用后,浏览器访问 [http://localhost:9010/ping](http://localhost:9010/ping)

## Docker 容器部署

Expand All @@ -110,35 +121,15 @@ docker-compose up -d

**架构图及可视化接口文档**:在项目根目录中打开 `docs/jank_blog_architecture.drawio` 文件。

## 代码统计

```bash
-------------------------------------------------------------------------------
Language files blank comment code
-------------------------------------------------------------------------------
Go 74 556 566 4334
JSON 2 0 0 2259
YAML 3 7 5 1145
Markdown 28 76 0 257
TOML 1 6 0 36
-------------------------------------------------------------------------------
TOTAL 108 645 571 8031
-------------------------------------------------------------------------------
```
> 注:该文档由 draw.io 绘制,需要安装 draw.io 软件查看。
## 官方社区

如果有任何疑问或建议,欢迎加入官方社区交流。

<img src="https://s2.loli.net/2025/01/04/cVqDO7a4djAPmEJ.jpg" alt="官方社区" width="300" />

## 赞助

欢迎支持 Jank 项目的开发,您的支持是我前进的动力。

<img src="https://s2.loli.net/2025/01/08/8eaDgiHRGop67Ul.jpg" alt="赞助" width="300" />
<img src="https://s2.loli.net/2025/01/25/L9BspuHnrIeim7S.jpg" alt="官方社区" width="300" />

## 联系方式
## 联系合作

- **QQ**: 927171598
- **邮箱**:<EMAIL>[email protected]
Expand All @@ -149,8 +140,8 @@ TOTAL 108 645 571 8031

## GitHub 统计

<img src="https://github-readme-stats.vercel.app/api?username=Done-0&show_icons=true&hide_title=true&theme=radical" width="100%" height="65%">
<img src="https://github-readme-stats.vercel.app/api?username=Done-0&show_icons=true&hide_title=true&theme=radical" width="100%" height="65%" alt="GitHub Stats">

## 增长趋势

<img src="https://api.star-history.com/svg?repos=Done-0/Jank&type=timeline" width="100%" height="65%">
<img src="https://api.star-history.com/svg?repos=Done-0/Jank&type=timeline" width="100%" height="65%" alt="GitHub Stats">
45 changes: 16 additions & 29 deletions README_en.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<p align="center">
<p style="text-align: center;">
<a><img src="https://s2.loli.net/2025/01/02/6F8fzMvrBDCATZk.png" alt="Jank"></a>
</p>
<p align="center">
<em>Jank is a lightweight blogging system developed using Go and the Echo framework, focusing on simplicity, low coupling, and high extensibility.</em>
<p style="text-align: center;">
<em>Jank,一个轻量级的博客系统,基于 Go 语言和 Echo 框架开发,强调极简、低耦合和高扩展</em>
</p>
<p align="center">
<p style="text-align: center;">
<a href="https://img.shields.io/github/stars/Done-0/Jank?style=social" target="_blank">
<img src="https://img.shields.io/github/stars/Done-0/Jank?style=social" alt="Stars">
</a> &nbsp;
Expand All @@ -24,7 +24,7 @@
<img src="https://img.shields.io/github/license/Done-0/Jank" alt="License">
</a>
</p>
<p align="center" style="margin: 0; padding: 0;">
<p style="text-align: center; margin: 0; padding: 0; position: relative; top: -5px;">
<span style="text-decoration: underline; color: grey;">English</span> | <a href="README.md" style="text-decoration: none;">简体中文</a>
</p>

Expand Down Expand Up @@ -63,14 +63,18 @@ Jank is a lightweight blogging system developed using Go and the Echo framework,
1. **Install Dependencies**:

```bash
# install swagger utils
go install github.com/swaggo/swag/cmd/swag@latest

# install dependencies
go mod tidy
```

2. **Configure Database and Email**:
Modify the database and email configurations in the `configs/config.yaml` file as shown below:

```yaml
# Database Password
# MySQL Database password (required)
DB_PSW: "<DATABASE_PASSWORD>"

# QQ email and SMTP authorization code (optional)
Expand All @@ -88,11 +92,14 @@ Jank is a lightweight blogging system developed using Go and the Echo framework,
Or use Air for hot reloading:

```bash
# install air, requires go 1.22+
go install github.com/air-verse/air@latest

air -c ./configs/.air.toml
```

4. **Access the API**:
Open your browser and go to [http://localhost:9010/ping](http://localhost:9010/ping).
Open your browser and go to [http://localhost:9010/ping](http://localhost:9010/ping) when you start the system locally.

## Docker Deployment

Expand All @@ -107,33 +114,13 @@ docker-compose up -d
## Architecture Diagram
Architecture Diagram and Visualized API Documentation: Open the `docs/jank_blog_architecture.drawio` file in the project root directory.

## Code Statistics

```bash
-------------------------------------------------------------------------------
Language files blank comment code
-------------------------------------------------------------------------------
Go 74 556 566 4334
JSON 2 0 0 2259
YAML 3 7 5 1145
Markdown 28 76 0 257
TOML 1 6 0 36
-------------------------------------------------------------------------------
TOTAL 108 645 571 8031
-------------------------------------------------------------------------------
```
> note: This document is drawn by draw.io, which requires the installation of the draw.io software to view.
## Official Community

If you have any questions or suggestions, feel free to join the official community for discussion.

<img src="https://s2.loli.net/2025/01/04/cVqDO7a4djAPmEJ.jpg" alt="Official Community" width="300" />

## Sponsorship

We welcome support for the development of the Jank project. Your support is the driving force behind its progress.

<img src="https://s2.loli.net/2025/01/08/8eaDgiHRGop67Ul.jpg" alt="Sponsorship" width="300" />
<img src="https://s2.loli.net/2025/01/25/L9BspuHnrIeim7S.jpg" alt="Official Community" width="300" />

## Contact Information

Expand Down
3 changes: 2 additions & 1 deletion cmd/jank_blog_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ import (
"jank.com/jank_blog/pkg/router"
)

// Start 启动服务
func Start() {
config, err := configs.LoadConfig()
if err != nil {
log.Fatalf("应用启动中, 加载配置失败: %v", err)
return
}

// 创建echo实例
// 创建 echo 实例
app := echo.New()
app.HideBanner = true
banner.InitBanner()
Expand Down
2 changes: 1 addition & 1 deletion configs/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ database:
DB_HOST: "127.0.0.1"
DB_PORT: "3306"
DB_USER: "root"
DB_PSW: "<DATABASE_PASSWORD>"
DB_PSW: "Lh20230623"

# Redis 相关
redis:
Expand Down
8 changes: 0 additions & 8 deletions docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1070,7 +1070,6 @@ const docTemplate = `{
"tags": [
"test"
],
"summary": "Hello API",
"responses": {
"200": {
"description": "Hello, Jank 🎉!\\n",
Expand All @@ -1093,7 +1092,6 @@ const docTemplate = `{
"tags": [
"test"
],
"summary": "长时间请求接口",
"responses": {
"200": {
"description": "模拟耗时请求处理完成!\\n",
Expand All @@ -1116,7 +1114,6 @@ const docTemplate = `{
"tags": [
"test"
],
"summary": "Ping API",
"responses": {
"200": {
"description": "Pong successfully!\\n",
Expand All @@ -1139,7 +1136,6 @@ const docTemplate = `{
"tags": [
"test"
],
"summary": "测试错误响应接口",
"responses": {
"500": {
"description": "Internal Server Error",
Expand All @@ -1162,7 +1158,6 @@ const docTemplate = `{
"tags": [
"test"
],
"summary": "测试错误处理中间件接口",
"responses": {
"500": {
"description": "Internal Server Error",
Expand All @@ -1185,7 +1180,6 @@ const docTemplate = `{
"tags": [
"test"
],
"summary": "测试日志接口",
"responses": {
"200": {
"description": "测试日志成功!",
Expand All @@ -1208,7 +1202,6 @@ const docTemplate = `{
"tags": [
"test"
],
"summary": "测试 Redis 接口",
"responses": {
"200": {
"description": "测试缓存功能完成!",
Expand All @@ -1231,7 +1224,6 @@ const docTemplate = `{
"tags": [
"test"
],
"summary": "测试成功响应接口",
"responses": {
"200": {
"description": "测试成功响应成功!",
Expand Down
Loading

0 comments on commit 8171ca7

Please sign in to comment.