fix: revert chart to embedded data - Kroki server-side rendering cannot fetch external URLs
This commit is contained in:
@@ -31,7 +31,7 @@ A collection of enhancements, plugins, and prompts for [OpenWebUI](https://githu
|
||||
| 6️⃣ | [Markdown Normalizer](https://openwebui.com/posts/markdown_normalizer_baaa8732) |  |  |  |  |
|
||||
|
||||
### 📈 Total Downloads Trend
|
||||

|
||||

|
||||
|
||||
*See full stats and charts in [Community Stats Report](./docs/community-stats.md)*
|
||||
<!-- STATS_END -->
|
||||
|
||||
@@ -28,7 +28,7 @@ OpenWebUI 增强功能集合。包含个人开发与收集的插件、提示词
|
||||
| 6️⃣ | [Markdown Normalizer](https://openwebui.com/posts/markdown_normalizer_baaa8732) |  |  |  |  |
|
||||
|
||||
### 📈 总下载量累计趋势
|
||||

|
||||

|
||||
|
||||
*完整统计与趋势图请查看 [社区统计报告](./docs/community-stats.zh.md)*
|
||||
<!-- STATS_END -->
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"total_posts": 22,
|
||||
"total_downloads": 4160,
|
||||
"total_views": 45978,
|
||||
"total_views": 45980,
|
||||
"total_upvotes": 231,
|
||||
"total_downvotes": 2,
|
||||
"total_saves": 274,
|
||||
@@ -71,7 +71,7 @@
|
||||
"author": "Fu-Jie",
|
||||
"description": "Reduces token consumption in long conversations while maintaining coherence through intelligent summarization and message compression.",
|
||||
"downloads": 363,
|
||||
"views": 3758,
|
||||
"views": 3759,
|
||||
"upvotes": 14,
|
||||
"saves": 34,
|
||||
"comments": 0,
|
||||
@@ -183,7 +183,7 @@
|
||||
"author": "Fu-Jie",
|
||||
"description": "Integrate GitHub Copilot SDK. Supports dynamic models, multi-turn conversation, streaming, multimodal input, infinite sessions, and frontend debug logging.",
|
||||
"downloads": 107,
|
||||
"views": 2410,
|
||||
"views": 2411,
|
||||
"upvotes": 14,
|
||||
"saves": 9,
|
||||
"comments": 6,
|
||||
@@ -311,7 +311,7 @@
|
||||
"author": "",
|
||||
"description": "",
|
||||
"downloads": 0,
|
||||
"views": 290,
|
||||
"views": 292,
|
||||
"upvotes": 5,
|
||||
"saves": 0,
|
||||
"comments": 0,
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
> 
|
||||
|
||||
### 📈 Growth & Trends (Last 14 Days)
|
||||

|
||||

|
||||
|
||||
> *Blue: Downloads | Purple: Views (Real-time dynamic)*
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
> 
|
||||
|
||||
### 📈 增长与趋势 (Last 14 Days)
|
||||

|
||||

|
||||
|
||||
> *蓝色: 总下载量 | 紫色: 总浏览量 (实时动态生成)*
|
||||
|
||||
|
||||
@@ -1084,7 +1084,7 @@
|
||||
"date": "2026-02-11",
|
||||
"total_posts": 22,
|
||||
"total_downloads": 4160,
|
||||
"total_views": 45978,
|
||||
"total_views": 45980,
|
||||
"total_upvotes": 231,
|
||||
"total_saves": 274,
|
||||
"followers": 220,
|
||||
|
||||
@@ -1170,50 +1170,20 @@ class OpenWebUIStats:
|
||||
f.write(content)
|
||||
print(f"✅ 文档图表已更新: {doc_path}")
|
||||
|
||||
def upload_chart_data(self, stats: dict):
|
||||
"""上传图表数据到 Gist (独立于徽章数据)"""
|
||||
if not (self.gist_token and self.gist_id):
|
||||
return
|
||||
|
||||
def generate_activity_chart(self, lang: str = "zh") -> str:
|
||||
"""生成 Vega-Lite 趋势图 (内嵌数据,Kroki 服务端渲染不支持外部 URL)"""
|
||||
history = self.load_history()
|
||||
if len(history) < 3:
|
||||
return
|
||||
|
||||
# 准备图表数据点
|
||||
chart_data = []
|
||||
for item in history:
|
||||
chart_data.append(
|
||||
{"date": item["date"], "downloads": item["total_downloads"]}
|
||||
)
|
||||
|
||||
try:
|
||||
url = f"https://api.github.com/gists/{self.gist_id}"
|
||||
headers = {"Authorization": f"token {self.gist_token}"}
|
||||
payload = {
|
||||
"files": {
|
||||
"chart-data.json": {
|
||||
"content": json.dumps(chart_data, ensure_ascii=False, indent=2)
|
||||
}
|
||||
}
|
||||
}
|
||||
resp = requests.patch(url, headers=headers, json=payload)
|
||||
if resp.status_code == 200:
|
||||
print(f"✅ 图表数据已同步至 Gist")
|
||||
except Exception as e:
|
||||
print(f"⚠️ 图表数据同步失败: {e}")
|
||||
|
||||
def generate_activity_chart(self, lang: str = "zh") -> str:
|
||||
"""生成 Vega-Lite 趋势图 (使用外部数据源,URL 固定)"""
|
||||
if not (self.gist_token and self.gist_id):
|
||||
return ""
|
||||
|
||||
# 准备数据点
|
||||
values = []
|
||||
for item in history:
|
||||
values.append({"date": item["date"], "downloads": item["total_downloads"]})
|
||||
|
||||
title = "Total Downloads Trend" if lang == "en" else "总下载量累计趋势"
|
||||
|
||||
# 使用 Gist Raw URL 作为数据源
|
||||
gist_user = "Fu-Jie" # Replace with your GitHub username
|
||||
data_url = f"https://gist.githubusercontent.com/{gist_user}/{self.gist_id}/raw/chart-data.json"
|
||||
|
||||
# Vega-Lite Spec (数据从外部 URL 加载)
|
||||
# Vega-Lite Spec (内嵌数据,Kroki 服务端渲染必须内嵌)
|
||||
vl_spec = {
|
||||
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
|
||||
"description": title,
|
||||
@@ -1225,7 +1195,7 @@ class OpenWebUIStats:
|
||||
"view": {"stroke": "transparent"},
|
||||
"axis": {"domain": False, "grid": False},
|
||||
},
|
||||
"data": {"url": data_url}, # 外部数据源
|
||||
"data": {"values": values},
|
||||
"mark": {
|
||||
"type": "area",
|
||||
"line": {"color": "#2563eb"},
|
||||
@@ -1334,9 +1304,6 @@ def main():
|
||||
# 生成 Shields.io endpoint JSON (用于动态徽章)
|
||||
badges_dir = script_dir / "docs" / "badges"
|
||||
|
||||
# 上传图表数据到 Gist (独立存储)
|
||||
stats_client.upload_chart_data(stats)
|
||||
|
||||
# 生成徽章
|
||||
stats_client.generate_shields_endpoints(stats, str(badges_dir))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user