🔧 修复社区统计功能
- 修正 README 结构:标题 → 语言切换 → 简介 → 统计 → 内容
- 英文版使用英文统计文本,中文版使用中文统计文本
- 修正插件 URL 为 /posts/{slug} 格式
- 清理 README_CN.md 中的重复内容
This commit is contained in:
47
README.md
47
README.md
@@ -1,33 +1,30 @@
|
||||
# OpenWebUI Extras
|
||||
|
||||
|
||||
<!-- STATS_START -->
|
||||
## 📊 社区统计
|
||||
|
||||
> 🕐 自动更新于 2026-01-06
|
||||
|
||||
| 📝 发布 | ⬇️ 下载 | 👁️ 浏览 | 👍 点赞 | 💾 收藏 |
|
||||
|:---:|:---:|:---:|:---:|:---:|
|
||||
| **11** | **729** | **7627** | **54** | **43** |
|
||||
|
||||
### 🔥 热门插件 Top 5
|
||||
|
||||
| 排名 | 插件 | 下载 | 浏览 |
|
||||
|:---:|------|:---:|:---:|
|
||||
| 🥇 | [Turn Any Text into Beautiful Mind Maps](https://openwebui.com/f/turn_any_text_into_beautiful_mind_maps_3094c59a) | 212 | 1892 |
|
||||
| 🥈 | [Export to Excel](https://openwebui.com/f/export_mulit_table_to_excel_244b8f9d) | 167 | 433 |
|
||||
| 🥉 | [Async Context Compression](https://openwebui.com/f/async_context_compression_b1655bc8) | 110 | 1185 |
|
||||
| 4️⃣ | [Flash Card ](https://openwebui.com/f/flash_card_65a2ea8f) | 70 | 1332 |
|
||||
| 5️⃣ | [Smart Infographic](https://openwebui.com/f/smart_infographic_ad6f0c7f) | 62 | 850 |
|
||||
|
||||
*完整统计请查看 [社区统计报告](./docs/community-stats.md)*
|
||||
<!-- STATS_END -->
|
||||
|
||||
English | [中文](./README_CN.md)
|
||||
|
||||
A collection of enhancements, plugins, and prompts for [OpenWebUI](https://github.com/open-webui/open-webui), developed and curated for personal use to extend functionality and improve experience.
|
||||
|
||||
[Contributing](./CONTRIBUTING.md)
|
||||
<!-- STATS_START -->
|
||||
## 📊 Community Stats
|
||||
|
||||
> 🕐 Auto-updated on 2026-01-06
|
||||
|
||||
| 📝 Posts | ⬇️ Downloads | 👁️ Views | 👍 Upvotes | 💾 Saves |
|
||||
|:---:|:---:|:---:|:---:|:---:|
|
||||
| **11** | **731** | **7648** | **54** | **43** |
|
||||
|
||||
### 🔥 Top 5 Popular Plugins
|
||||
|
||||
| Rank | Plugin | Downloads | Views |
|
||||
|:---:|------|:---:|:---:|
|
||||
| 🥇 | [Turn Any Text into Beautiful Mind Maps](https://openwebui.com/posts/turn_any_text_into_beautiful_mind_maps_3094c59a) | 213 | 1896 |
|
||||
| 🥈 | [Export to Excel](https://openwebui.com/posts/export_mulit_table_to_excel_244b8f9d) | 167 | 433 |
|
||||
| 🥉 | [Async Context Compression](https://openwebui.com/posts/async_context_compression_b1655bc8) | 110 | 1185 |
|
||||
| 4️⃣ | [Flash Card ](https://openwebui.com/posts/flash_card_65a2ea8f) | 70 | 1334 |
|
||||
| 5️⃣ | [Smart Infographic](https://openwebui.com/posts/smart_infographic_ad6f0c7f) | 62 | 850 |
|
||||
|
||||
*See full stats in [Community Stats Report](./docs/community-stats.md)*
|
||||
<!-- STATS_END -->
|
||||
|
||||
## 📦 Project Contents
|
||||
|
||||
@@ -100,3 +97,5 @@ If you have great prompts or plugins to share:
|
||||
1. Fork this repository.
|
||||
2. Add your files to the appropriate `prompts/` or `plugins/` directory.
|
||||
3. Submit a Pull Request.
|
||||
|
||||
[Contributing](./CONTRIBUTING.md)
|
||||
|
||||
56
README_CN.md
56
README_CN.md
@@ -1,5 +1,8 @@
|
||||
# OpenWebUI Extras
|
||||
|
||||
[English](./README.md) | 中文
|
||||
|
||||
OpenWebUI 增强功能集合。包含个人开发与收集的插件、提示词等资源。
|
||||
|
||||
<!-- STATS_START -->
|
||||
## 📊 社区统计
|
||||
@@ -8,24 +11,24 @@
|
||||
|
||||
| 📝 发布 | ⬇️ 下载 | 👁️ 浏览 | 👍 点赞 | 💾 收藏 |
|
||||
|:---:|:---:|:---:|:---:|:---:|
|
||||
| **11** | **729** | **7627** | **54** | **43** |
|
||||
| **11** | **731** | **7648** | **54** | **43** |
|
||||
|
||||
### 🔥 热门插件 Top 5
|
||||
|
||||
| 排名 | 插件 | 下载 | 浏览 |
|
||||
|:---:|------|:---:|:---:|
|
||||
| 🥇 | [Turn Any Text into Beautiful Mind Maps](https://openwebui.com/f/turn_any_text_into_beautiful_mind_maps_3094c59a) | 212 | 1892 |
|
||||
| 🥈 | [Export to Excel](https://openwebui.com/f/export_mulit_table_to_excel_244b8f9d) | 167 | 433 |
|
||||
| 🥉 | [Async Context Compression](https://openwebui.com/f/async_context_compression_b1655bc8) | 110 | 1185 |
|
||||
| 4️⃣ | [Flash Card ](https://openwebui.com/f/flash_card_65a2ea8f) | 70 | 1332 |
|
||||
| 5️⃣ | [Smart Infographic](https://openwebui.com/f/smart_infographic_ad6f0c7f) | 62 | 850 |
|
||||
| 🥇 | [Turn Any Text into Beautiful Mind Maps](https://openwebui.com/posts/turn_any_text_into_beautiful_mind_maps_3094c59a) | 213 | 1896 |
|
||||
| 🥈 | [Export to Excel](https://openwebui.com/posts/export_mulit_table_to_excel_244b8f9d) | 167 | 433 |
|
||||
| 🥉 | [Async Context Compression](https://openwebui.com/posts/async_context_compression_b1655bc8) | 110 | 1185 |
|
||||
| 4️⃣ | [Flash Card ](https://openwebui.com/posts/flash_card_65a2ea8f) | 70 | 1334 |
|
||||
| 5️⃣ | [Smart Infographic](https://openwebui.com/posts/smart_infographic_ad6f0c7f) | 62 | 850 |
|
||||
|
||||
*完整统计请查看 [社区统计报告](./docs/community-stats.md)*
|
||||
<!-- STATS_END -->
|
||||
|
||||
[English](./README.md) | 中文
|
||||
## 📦 项目内容
|
||||
|
||||
OpenWebUI 增强功能集合。包含个人开发与收集的### 🧩 插件 (Plugins)
|
||||
### 🧩 插件 (Plugins)
|
||||
|
||||
位于 `plugins/` 目录,包含各类 Python 编写的功能增强插件:
|
||||
|
||||
@@ -42,7 +45,6 @@ OpenWebUI 增强功能集合。包含个人开发与收集的### 🧩 插件 (Pl
|
||||
- **Context Enhancement** (`context_enhancement_filter`): 上下文增强过滤器。
|
||||
- **Gemini Manifold Companion** (`gemini_manifold_companion`): Gemini Manifold 配套增强。
|
||||
|
||||
|
||||
#### Pipes (模型管道)
|
||||
- **Gemini Manifold** (`gemini_mainfold`): 集成 Gemini 模型的管道。
|
||||
|
||||
@@ -54,40 +56,10 @@ OpenWebUI 增强功能集合。包含个人开发与收集的### 🧩 插件 (Pl
|
||||
位于 `prompts/` 目录,包含精心调优的 System Prompts:
|
||||
|
||||
- **Coding**: 编程辅助类提示词。
|
||||
- **Marketing**: 营销文案类提示词。(`/prompts/marketing`): 内容创作、品牌策划、市场分析相关的提示词
|
||||
- **Marketing**: 营销文案类提示词。
|
||||
|
||||
每个提示词都独立保存为 Markdown 文件,可直接在 OpenWebUI 中使用。
|
||||
|
||||
### 🔧 插件 (Plugins)
|
||||
|
||||
{{ ... }}
|
||||
|
||||
[贡献指南](./CONTRIBUTING.md) | [更新日志](./CHANGELOG.md)
|
||||
|
||||
## 📦 项目内容
|
||||
|
||||
### 🎯 提示词 (Prompts)
|
||||
|
||||
位于 `/prompts` 目录,包含针对不同领域的优质提示词模板:
|
||||
|
||||
- **编程类** (`/prompts/coding`): 代码生成、调试、优化相关的提示词
|
||||
- **营销类** (`/prompts/marketing`): 内容创作、品牌策划、市场分析相关的提示词
|
||||
|
||||
每个提示词都独立保存为 Markdown 文件,可直接在 OpenWebUI 中使用。
|
||||
|
||||
### 🔧 插件 (Plugins)
|
||||
|
||||
位于 `/plugins` 目录,提供三种类型的插件扩展:
|
||||
|
||||
- **过滤器 (Filters)** - 在用户输入发送给 LLM 前进行处理和优化
|
||||
- 异步上下文压缩:智能压缩长上下文,优化 token 使用效率
|
||||
|
||||
- **动作 (Actions)** - 自定义功能,从聊天中触发
|
||||
- 思维导图生成:快速生成和导出思维导图
|
||||
|
||||
- **管道 (Pipes)** - 对 LLM 响应进行处理和增强
|
||||
- 各类响应处理和格式化插件
|
||||
|
||||
## 📖 开发文档
|
||||
|
||||
位于 `docs/zh/` 目录:
|
||||
@@ -96,7 +68,7 @@ OpenWebUI 增强功能集合。包含个人开发与收集的### 🧩 插件 (Pl
|
||||
- **[从问一个AI到运营一支AI团队](./docs/zh/从问一个AI到运营一支AI团队.md)** - 深度运营经验分享。
|
||||
|
||||
更多示例请查看 `docs/examples/` 目录。
|
||||
|
||||
|
||||
## 🚀 快速开始
|
||||
|
||||
本项目是一个资源集合,无需安装 Python 环境。你只需要下载对应的文件并导入到你的 OpenWebUI 实例中即可。
|
||||
@@ -127,3 +99,5 @@ OpenWebUI 增强功能集合。包含个人开发与收集的### 🧩 插件 (Pl
|
||||
1. Fork 本仓库。
|
||||
2. 将你的文件添加到对应的 `prompts/` 或 `plugins/` 目录。
|
||||
3. 提交 Pull Request。
|
||||
|
||||
[贡献指南](./CONTRIBUTING.md) | [更新日志](./CHANGELOG.md)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"total_posts": 11,
|
||||
"total_downloads": 729,
|
||||
"total_views": 7627,
|
||||
"total_downloads": 731,
|
||||
"total_views": 7648,
|
||||
"total_upvotes": 54,
|
||||
"total_downvotes": 0,
|
||||
"total_saves": 43,
|
||||
@@ -15,14 +15,14 @@
|
||||
"slug": "turn_any_text_into_beautiful_mind_maps_3094c59a",
|
||||
"type": "unknown",
|
||||
"version": "",
|
||||
"downloads": 212,
|
||||
"views": 1892,
|
||||
"downloads": 213,
|
||||
"views": 1896,
|
||||
"upvotes": 10,
|
||||
"saves": 15,
|
||||
"comments": 8,
|
||||
"created_at": "2025-12-31",
|
||||
"updated_at": "2026-01-04",
|
||||
"url": "https://openwebui.com/f/turn_any_text_into_beautiful_mind_maps_3094c59a"
|
||||
"url": "https://openwebui.com/posts/turn_any_text_into_beautiful_mind_maps_3094c59a"
|
||||
},
|
||||
{
|
||||
"title": "Export to Excel",
|
||||
@@ -36,7 +36,7 @@
|
||||
"comments": 0,
|
||||
"created_at": "2025-05-30",
|
||||
"updated_at": "2026-01-03",
|
||||
"url": "https://openwebui.com/f/export_mulit_table_to_excel_244b8f9d"
|
||||
"url": "https://openwebui.com/posts/export_mulit_table_to_excel_244b8f9d"
|
||||
},
|
||||
{
|
||||
"title": "Async Context Compression",
|
||||
@@ -50,7 +50,7 @@
|
||||
"comments": 0,
|
||||
"created_at": "2025-11-08",
|
||||
"updated_at": "2025-12-31",
|
||||
"url": "https://openwebui.com/f/async_context_compression_b1655bc8"
|
||||
"url": "https://openwebui.com/posts/async_context_compression_b1655bc8"
|
||||
},
|
||||
{
|
||||
"title": "Flash Card ",
|
||||
@@ -58,13 +58,13 @@
|
||||
"type": "unknown",
|
||||
"version": "",
|
||||
"downloads": 70,
|
||||
"views": 1332,
|
||||
"views": 1334,
|
||||
"upvotes": 8,
|
||||
"saves": 5,
|
||||
"comments": 2,
|
||||
"created_at": "2025-12-30",
|
||||
"updated_at": "2026-01-04",
|
||||
"url": "https://openwebui.com/f/flash_card_65a2ea8f"
|
||||
"url": "https://openwebui.com/posts/flash_card_65a2ea8f"
|
||||
},
|
||||
{
|
||||
"title": "Smart Infographic",
|
||||
@@ -78,21 +78,21 @@
|
||||
"comments": 2,
|
||||
"created_at": "2025-12-28",
|
||||
"updated_at": "2026-01-04",
|
||||
"url": "https://openwebui.com/f/smart_infographic_ad6f0c7f"
|
||||
"url": "https://openwebui.com/posts/smart_infographic_ad6f0c7f"
|
||||
},
|
||||
{
|
||||
"title": "Export to Word (Enhanced Formatting)",
|
||||
"slug": "export_to_word_enhanced_formatting_fca6a315",
|
||||
"type": "unknown",
|
||||
"version": "",
|
||||
"downloads": 37,
|
||||
"views": 419,
|
||||
"downloads": 38,
|
||||
"views": 422,
|
||||
"upvotes": 5,
|
||||
"saves": 2,
|
||||
"comments": 0,
|
||||
"created_at": "2026-01-03",
|
||||
"updated_at": "2026-01-05",
|
||||
"url": "https://openwebui.com/f/export_to_word_enhanced_formatting_fca6a315"
|
||||
"url": "https://openwebui.com/posts/export_to_word_enhanced_formatting_fca6a315"
|
||||
},
|
||||
{
|
||||
"title": "智能信息图",
|
||||
@@ -106,7 +106,7 @@
|
||||
"comments": 0,
|
||||
"created_at": "2025-12-28",
|
||||
"updated_at": "2025-12-29",
|
||||
"url": "https://openwebui.com/f/智能信息图_e04a48ff"
|
||||
"url": "https://openwebui.com/posts/智能信息图_e04a48ff"
|
||||
},
|
||||
{
|
||||
"title": "导出为 Word-支持公式、流程图、表格和代码块",
|
||||
@@ -114,13 +114,13 @@
|
||||
"type": "unknown",
|
||||
"version": "",
|
||||
"downloads": 13,
|
||||
"views": 502,
|
||||
"views": 514,
|
||||
"upvotes": 7,
|
||||
"saves": 1,
|
||||
"comments": 1,
|
||||
"created_at": "2026-01-04",
|
||||
"updated_at": "2026-01-05",
|
||||
"url": "https://openwebui.com/f/导出为_word_支持公式流程图表格和代码块_8a6306c0"
|
||||
"url": "https://openwebui.com/posts/导出为_word_支持公式流程图表格和代码块_8a6306c0"
|
||||
},
|
||||
{
|
||||
"title": "闪记卡生成插件",
|
||||
@@ -134,7 +134,7 @@
|
||||
"comments": 0,
|
||||
"created_at": "2025-12-30",
|
||||
"updated_at": "2026-01-01",
|
||||
"url": "https://openwebui.com/f/闪记卡生成插件_4a31eac3"
|
||||
"url": "https://openwebui.com/posts/闪记卡生成插件_4a31eac3"
|
||||
},
|
||||
{
|
||||
"title": "智能生成交互式思维导图,帮助用户可视化知识",
|
||||
@@ -148,7 +148,7 @@
|
||||
"comments": 0,
|
||||
"created_at": "2025-12-31",
|
||||
"updated_at": "2025-12-31",
|
||||
"url": "https://openwebui.com/f/智能生成交互式思维导图帮助用户可视化知识_8d4b097b"
|
||||
"url": "https://openwebui.com/posts/智能生成交互式思维导图帮助用户可视化知识_8d4b097b"
|
||||
},
|
||||
{
|
||||
"title": "异步上下文压缩",
|
||||
@@ -162,7 +162,7 @@
|
||||
"comments": 0,
|
||||
"created_at": "2025-11-08",
|
||||
"updated_at": "2025-12-31",
|
||||
"url": "https://openwebui.com/f/异步上下文压缩_5c0617cb"
|
||||
"url": "https://openwebui.com/posts/异步上下文压缩_5c0617cb"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,14 +1,14 @@
|
||||
# 📊 OpenWebUI 社区统计报告
|
||||
|
||||
> 📅 更新时间: 2026-01-06 01:31:12
|
||||
> 📅 更新时间: 2026-01-06 01:47:55
|
||||
|
||||
## 📈 总览
|
||||
|
||||
| 指标 | 数值 |
|
||||
|------|------|
|
||||
| 📝 发布数量 | 11 |
|
||||
| ⬇️ 总下载量 | 729 |
|
||||
| 👁️ 总浏览量 | 7627 |
|
||||
| ⬇️ 总下载量 | 731 |
|
||||
| 👁️ 总浏览量 | 7648 |
|
||||
| 👍 总点赞数 | 54 |
|
||||
| 💾 总收藏数 | 43 |
|
||||
| 💬 总评论数 | 13 |
|
||||
@@ -21,14 +21,14 @@
|
||||
|
||||
| 排名 | 标题 | 类型 | 版本 | 下载 | 浏览 | 点赞 | 收藏 | 更新日期 |
|
||||
|:---:|------|:---:|:---:|:---:|:---:|:---:|:---:|:---:|
|
||||
| 1 | [Turn Any Text into Beautiful Mind Maps](https://openwebui.com/f/turn_any_text_into_beautiful_mind_maps_3094c59a) | unknown | | 212 | 1892 | 10 | 15 | 2026-01-04 |
|
||||
| 2 | [Export to Excel](https://openwebui.com/f/export_mulit_table_to_excel_244b8f9d) | unknown | | 167 | 433 | 3 | 2 | 2026-01-03 |
|
||||
| 3 | [Async Context Compression](https://openwebui.com/f/async_context_compression_b1655bc8) | unknown | | 110 | 1185 | 5 | 9 | 2025-12-31 |
|
||||
| 4 | [Flash Card ](https://openwebui.com/f/flash_card_65a2ea8f) | unknown | | 70 | 1332 | 8 | 5 | 2026-01-04 |
|
||||
| 5 | [Smart Infographic](https://openwebui.com/f/smart_infographic_ad6f0c7f) | unknown | | 62 | 850 | 6 | 7 | 2026-01-04 |
|
||||
| 6 | [Export to Word (Enhanced Formatting)](https://openwebui.com/f/export_to_word_enhanced_formatting_fca6a315) | unknown | | 37 | 419 | 5 | 2 | 2026-01-05 |
|
||||
| 7 | [智能信息图](https://openwebui.com/f/智能信息图_e04a48ff) | unknown | | 31 | 372 | 3 | 0 | 2025-12-29 |
|
||||
| 8 | [导出为 Word-支持公式、流程图、表格和代码块](https://openwebui.com/f/导出为_word_支持公式流程图表格和代码块_8a6306c0) | unknown | | 13 | 502 | 7 | 1 | 2026-01-05 |
|
||||
| 9 | [闪记卡生成插件](https://openwebui.com/f/闪记卡生成插件_4a31eac3) | unknown | | 12 | 305 | 3 | 1 | 2026-01-01 |
|
||||
| 10 | [智能生成交互式思维导图,帮助用户可视化知识](https://openwebui.com/f/智能生成交互式思维导图帮助用户可视化知识_8d4b097b) | unknown | | 10 | 233 | 2 | 0 | 2025-12-31 |
|
||||
| 11 | [异步上下文压缩](https://openwebui.com/f/异步上下文压缩_5c0617cb) | unknown | | 5 | 104 | 2 | 1 | 2025-12-31 |
|
||||
| 1 | [Turn Any Text into Beautiful Mind Maps](https://openwebui.com/posts/turn_any_text_into_beautiful_mind_maps_3094c59a) | unknown | | 213 | 1896 | 10 | 15 | 2026-01-04 |
|
||||
| 2 | [Export to Excel](https://openwebui.com/posts/export_mulit_table_to_excel_244b8f9d) | unknown | | 167 | 433 | 3 | 2 | 2026-01-03 |
|
||||
| 3 | [Async Context Compression](https://openwebui.com/posts/async_context_compression_b1655bc8) | unknown | | 110 | 1185 | 5 | 9 | 2025-12-31 |
|
||||
| 4 | [Flash Card ](https://openwebui.com/posts/flash_card_65a2ea8f) | unknown | | 70 | 1334 | 8 | 5 | 2026-01-04 |
|
||||
| 5 | [Smart Infographic](https://openwebui.com/posts/smart_infographic_ad6f0c7f) | unknown | | 62 | 850 | 6 | 7 | 2026-01-04 |
|
||||
| 6 | [Export to Word (Enhanced Formatting)](https://openwebui.com/posts/export_to_word_enhanced_formatting_fca6a315) | unknown | | 38 | 422 | 5 | 2 | 2026-01-05 |
|
||||
| 7 | [智能信息图](https://openwebui.com/posts/智能信息图_e04a48ff) | unknown | | 31 | 372 | 3 | 0 | 2025-12-29 |
|
||||
| 8 | [导出为 Word-支持公式、流程图、表格和代码块](https://openwebui.com/posts/导出为_word_支持公式流程图表格和代码块_8a6306c0) | unknown | | 13 | 514 | 7 | 1 | 2026-01-05 |
|
||||
| 9 | [闪记卡生成插件](https://openwebui.com/posts/闪记卡生成插件_4a31eac3) | unknown | | 12 | 305 | 3 | 1 | 2026-01-01 |
|
||||
| 10 | [智能生成交互式思维导图,帮助用户可视化知识](https://openwebui.com/posts/智能生成交互式思维导图帮助用户可视化知识_8d4b097b) | unknown | | 10 | 233 | 2 | 0 | 2025-12-31 |
|
||||
| 11 | [异步上下文压缩](https://openwebui.com/posts/异步上下文压缩_5c0617cb) | unknown | | 5 | 104 | 2 | 1 | 2025-12-31 |
|
||||
|
||||
@@ -154,7 +154,7 @@ class OpenWebUIStats:
|
||||
"comments": post.get("commentCount", 0),
|
||||
"created_at": created_at.strftime("%Y-%m-%d"),
|
||||
"updated_at": updated_at.strftime("%Y-%m-%d"),
|
||||
"url": f"https://openwebui.com/f/{post.get('slug', '')}",
|
||||
"url": f"https://openwebui.com/posts/{post.get('slug', '')}",
|
||||
}
|
||||
)
|
||||
|
||||
@@ -260,20 +260,48 @@ class OpenWebUIStats:
|
||||
json.dump(stats, f, ensure_ascii=False, indent=2)
|
||||
print(f"✅ JSON 数据已保存到: {filepath}")
|
||||
|
||||
def generate_readme_stats(self, stats: dict) -> str:
|
||||
"""生成 README 统计徽章区域"""
|
||||
def generate_readme_stats(self, stats: dict, lang: str = "zh") -> str:
|
||||
"""
|
||||
生成 README 统计徽章区域
|
||||
|
||||
Args:
|
||||
stats: 统计数据
|
||||
lang: 语言 ("zh" 中文, "en" 英文)
|
||||
"""
|
||||
# 获取 Top 5 插件
|
||||
top_plugins = stats["posts"][:5]
|
||||
|
||||
# 中英文文本
|
||||
texts = {
|
||||
"zh": {
|
||||
"title": "## 📊 社区统计",
|
||||
"updated": f"> 🕐 自动更新于 {datetime.now().strftime('%Y-%m-%d')}",
|
||||
"header": "| 📝 发布 | ⬇️ 下载 | 👁️ 浏览 | 👍 点赞 | 💾 收藏 |",
|
||||
"top5_title": "### 🔥 热门插件 Top 5",
|
||||
"top5_header": "| 排名 | 插件 | 下载 | 浏览 |",
|
||||
"full_stats": "*完整统计请查看 [社区统计报告](./docs/community-stats.md)*",
|
||||
},
|
||||
"en": {
|
||||
"title": "## 📊 Community Stats",
|
||||
"updated": f"> 🕐 Auto-updated on {datetime.now().strftime('%Y-%m-%d')}",
|
||||
"header": "| 📝 Posts | ⬇️ Downloads | 👁️ Views | 👍 Upvotes | 💾 Saves |",
|
||||
"top5_title": "### 🔥 Top 5 Popular Plugins",
|
||||
"top5_header": "| Rank | Plugin | Downloads | Views |",
|
||||
"full_stats": "*See full stats in [Community Stats Report](./docs/community-stats.md)*",
|
||||
},
|
||||
}
|
||||
|
||||
t = texts.get(lang, texts["en"])
|
||||
|
||||
lines = []
|
||||
lines.append("<!-- STATS_START -->")
|
||||
lines.append("## 📊 社区统计")
|
||||
lines.append(t["title"])
|
||||
lines.append("")
|
||||
lines.append(f"> 🕐 自动更新于 {datetime.now().strftime('%Y-%m-%d')}")
|
||||
lines.append(t["updated"])
|
||||
lines.append("")
|
||||
|
||||
# 统计徽章 - 使用 shields.io 风格的表格
|
||||
lines.append("| 📝 发布 | ⬇️ 下载 | 👁️ 浏览 | 👍 点赞 | 💾 收藏 |")
|
||||
# 统计徽章表格
|
||||
lines.append(t["header"])
|
||||
lines.append("|:---:|:---:|:---:|:---:|:---:|")
|
||||
lines.append(
|
||||
f"| **{stats['total_posts']}** | **{stats['total_downloads']}** | "
|
||||
@@ -282,9 +310,9 @@ class OpenWebUIStats:
|
||||
lines.append("")
|
||||
|
||||
# Top 5 热门插件
|
||||
lines.append("### 🔥 热门插件 Top 5")
|
||||
lines.append(t["top5_title"])
|
||||
lines.append("")
|
||||
lines.append("| 排名 | 插件 | 下载 | 浏览 |")
|
||||
lines.append(t["top5_header"])
|
||||
lines.append("|:---:|------|:---:|:---:|")
|
||||
|
||||
medals = ["🥇", "🥈", "🥉", "4️⃣", "5️⃣"]
|
||||
@@ -295,13 +323,20 @@ class OpenWebUIStats:
|
||||
)
|
||||
|
||||
lines.append("")
|
||||
lines.append("*完整统计请查看 [社区统计报告](./docs/community-stats.md)*")
|
||||
lines.append(t["full_stats"])
|
||||
lines.append("<!-- STATS_END -->")
|
||||
|
||||
return "\n".join(lines)
|
||||
|
||||
def update_readme(self, stats: dict, readme_path: str):
|
||||
"""更新 README 文件中的统计区域"""
|
||||
def update_readme(self, stats: dict, readme_path: str, lang: str = "zh"):
|
||||
"""
|
||||
更新 README 文件中的统计区域
|
||||
|
||||
Args:
|
||||
stats: 统计数据
|
||||
readme_path: README 文件路径
|
||||
lang: 语言 ("zh" 中文, "en" 英文)
|
||||
"""
|
||||
import re
|
||||
|
||||
# 读取现有内容
|
||||
@@ -309,7 +344,7 @@ class OpenWebUIStats:
|
||||
content = f.read()
|
||||
|
||||
# 生成新的统计区域
|
||||
new_stats = self.generate_readme_stats(stats)
|
||||
new_stats = self.generate_readme_stats(stats, lang)
|
||||
|
||||
# 检查是否已有统计区域
|
||||
pattern = r"<!-- STATS_START -->.*?<!-- STATS_END -->"
|
||||
@@ -317,19 +352,35 @@ class OpenWebUIStats:
|
||||
# 替换现有区域
|
||||
new_content = re.sub(pattern, new_stats, content, flags=re.DOTALL)
|
||||
else:
|
||||
# 在文件开头(标题之后)插入统计区域
|
||||
# 找到第一个 ## 标题或在第一个空行后插入
|
||||
# 在简介段落之后插入统计区域
|
||||
# 查找模式:标题 -> 语言切换行 -> 简介段落 -> 插入位置
|
||||
lines = content.split("\n")
|
||||
insert_pos = 0
|
||||
found_intro = False
|
||||
|
||||
for i, line in enumerate(lines):
|
||||
# 跳过标题
|
||||
if line.startswith("# "):
|
||||
# 找到主标题后继续
|
||||
continue
|
||||
if line.startswith("[") or line.strip() == "":
|
||||
insert_pos = i + 1
|
||||
if line.strip() == "":
|
||||
break
|
||||
# 跳过空行
|
||||
if line.strip() == "":
|
||||
continue
|
||||
# 跳过语言切换行 (如 "English | [中文]" 或 "[English] | 中文")
|
||||
if ("English" in line or "中文" in line) and "|" in line:
|
||||
continue
|
||||
# 找到第一个非空、非标题、非语言切换的段落(简介)
|
||||
if not found_intro:
|
||||
found_intro = True
|
||||
# 继续到这个段落结束
|
||||
continue
|
||||
# 简介段落后的空行或下一个标题就是插入位置
|
||||
if line.strip() == "" or line.startswith("#"):
|
||||
insert_pos = i
|
||||
break
|
||||
|
||||
# 如果没找到合适位置,就放在第3行(标题和语言切换后)
|
||||
if insert_pos == 0:
|
||||
insert_pos = 3
|
||||
|
||||
# 在适当位置插入
|
||||
lines.insert(insert_pos, "")
|
||||
@@ -394,8 +445,8 @@ def main():
|
||||
# 更新 README 文件
|
||||
readme_path = script_dir / "README.md"
|
||||
readme_cn_path = script_dir / "README_CN.md"
|
||||
stats_client.update_readme(stats, str(readme_path))
|
||||
stats_client.update_readme(stats, str(readme_cn_path))
|
||||
stats_client.update_readme(stats, str(readme_path), lang="en")
|
||||
stats_client.update_readme(stats, str(readme_cn_path), lang="zh")
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user