仰望星辰工作室

gitcat

gitcat/ webroot/templates/layout.html 12.6 KB · 229 行 原始文件
1{{define "av"}}{{if .U}}{{if .U.Avatar}}<img class="av" style="width:{{.S}}px;height:{{.S}}px" src="/media/avatars/{{.U.Avatar}}" alt="{{.U.Display}}">{{else}}<span class="av av-txt {{ava .U.Display}}" style="width:{{.S}}px;height:{{.S}}px;font-size:{{sub .S 14}}px">{{.U.Initial}}</span>{{end}}{{else}}<span class="av av-txt g0" style="width:{{.S}}px;height:{{.S}}px;font-size:{{sub .S 14}}px">?</span>{{end}}{{end}}
2
3{{define "flash"}}{{if .Flash}}<div class="flash ok" role="status"><span class="flash-ico">✓</span><span>{{.Flash}}</span><button class="flash-x" type="button" aria-label="关闭">×</button></div>{{end}}{{if .Error}}<div class="flash err" role="alert"><span class="flash-ico">!</span><span>{{.Error}}</span><button class="flash-x" type="button" aria-label="关闭">×</button></div>{{end}}{{end}}
4
5{{define "wizardSteps"}}{{$cur := .}}<ol class="wizard-steps" aria-label="安装进度"><li class="{{if eq $cur 1}}on{{end}}"><i></i><span>欢迎</span></li><li class="{{if eq $cur 2}}on{{end}}"><i></i><span>环境检测</span></li><li class="{{if eq $cur 3}}on{{end}}"><i></i><span>站点信息</span></li><li class="{{if eq $cur 4}}on{{end}}"><i></i><span>管理员</span></li><li class="{{if eq $cur 5}}on{{end}}"><i></i><span>完成</span></li></ol>{{end}}
6
7{{define "avin"}}<span class="av av-txt {{ava .N}}" style="width:{{.S}}px;height:{{.S}}px;font-size:{{sub .S 12}}px">{{initial .N}}</span>{{end}}
8
9{{define "pushbox"}}
10<article class="pushcard">
11 <header class="pushcard-h">
12 {{if .U}}{{template "av" (dict "U" .U "S" 34)}}{{else}}{{template "avin" (dict "N" .P.ActorDisplay "S" 34)}}{{end}}
13 <div class="pushcard-meta">
14 <div class="pushcard-line">
15 <strong>{{if .U}}{{.U.Display}}{{else}}{{.P.ActorDisplay}}{{end}}</strong>
16 <span class="muted">推送了</span>
17 <span class="pill">{{.P.CommitCount}} 个提交</span>
18 <span class="muted">到</span>
19 <code class="ref">{{.P.Ref}}</code>
20 </div>
21 <div class="pushcard-sub">
22 <a class="quiet" href="/{{.P.RepoName}}">{{.P.RepoName}}</a>
23 <span class="dot">·</span>
24 <span class="muted" title="{{datetime .P.CreatedAt}}">{{timeago .P.CreatedAt}}</span>
25 {{if eq .P.AIStatus "done"}}<span class="tag tag-ai">AI 摘要</span>{{else if eq .P.AIStatus "pending"}}<span class="tag tag-pending">AI 生成中…</span>{{else if eq .P.AIStatus "failed"}}<span class="tag tag-warn">AI 不可用 · 自动摘要</span>{{else if eq .P.AIStatus "rollback"}}<span class="tag tag-warn">回滚操作</span>{{else}}<span class="tag tag-plain">自动摘要</span>{{end}}
26 </div>
27 </div>
28 </header>
29 {{if .P.WhatsNew}}<div class="whatsnew">{{md .P.WhatsNew}}</div>{{end}}
30 {{if .P.Details}}
31 <details class="commitlist-wrap">
32 <summary>查看这次改动的 {{len .P.Details}} 个提交</summary>
33 <ul class="commitlist">
34 {{range .P.Details}}
35 <li>
36 <a class="csha" href="/{{$.P.RepoName}}/commit/{{.SHA}}">{{short .SHA}}</a>
37 <span class="cmsg">{{.Subject}}</span>
38 <span class="cmeta">{{.Author}} · {{timeago (unix .When)}}</span>
39 <span class="cstat"><span class="add">+{{.Additions}}</span> <span class="del">-{{.Deletions}}</span></span>
40 </li>
41 {{end}}
42 </ul>
43 </details>
44 {{end}}
45</article>
46{{end}}
47
48{{define "repotabs"}}
49<nav class="repotabs">
50 <a class="{{if eq .Tab "code"}}on{{end}}" href="/{{.Repo.Name}}{{if .Ref}}?ref={{.Ref}}{{end}}">代码</a>
51 <a class="{{if eq .Tab "issues"}}on{{end}}" href="/{{.Repo.Name}}/issues">议题 <span class="cnt">{{.IssueCount}}</span></a>
52 <a class="{{if eq .Tab "commits"}}on{{end}}" href="/{{.Repo.Name}}/commits/{{.Ref}}">提交 <span class="cnt">{{.CommitCount}}</span></a>
53 <a class="{{if eq .Tab "branches"}}on{{end}}" href="/{{.Repo.Name}}/branches">分支 <span class="cnt">{{.BranchCount}}</span></a>
54 <a class="{{if eq .Tab "releases"}}on{{end}}" href="/{{.Repo.Name}}/releases">发行版 <span class="cnt">{{.ReleaseCount}}</span></a>
55 <a class="{{if eq .Tab "activity"}}on{{end}}" href="/{{.Repo.Name}}/activity">动态</a>
56 {{if .CanManage}}<a class="{{if eq .Tab "settings"}}on{{end}}" href="/{{.Repo.Name}}/settings">设置</a>{{end}}
57</nav>
58{{end}}
59
60{{define "adminnav"}}
61<nav class="adminnav">
62 <a class="{{if eq .Tab "dash"}}on{{end}}" href="/admin">概览</a>
63 <a class="{{if eq .Tab "users"}}on{{end}}" href="/admin/users">用户</a>
64 <a class="{{if eq .Tab "repos"}}on{{end}}" href="/admin/repos">项目</a>
65 <a class="{{if eq .Tab "activity"}}on{{end}}" href="/admin/activity">操作动态</a>
66 <a class="{{if eq .Tab "ai"}}on{{end}}" href="/admin/ai">AI 接入</a>
67 <a class="{{if eq .Tab "settings"}}on{{end}}" href="/admin/settings">站点设置</a>
68 <a class="{{if eq .Tab "upgrade"}}on{{end}}" href="/admin/upgrade">升级</a>
69</nav>
70{{end}}
71
72{{define "layout.html"}}<!DOCTYPE html>
73<html lang="zh-CN">
74<head>
75<meta charset="utf-8">
76<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
77<meta name="color-scheme" content="light">
78<title>{{.Title}} · {{.SiteName}}</title>
79<link rel="icon" type="image/svg+xml" href="/static/favicon.svg">
80<link rel="stylesheet" href="/static/style.css">
81</head>
82<body>
83<div class="bg-deco" aria-hidden="true"></div>
84<header class="topbar">
85 <div class="wrap topbar-in">
86 <a class="brand" href="/">
87 <span class="brand-mark" aria-hidden="true">
88 <svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round">
89 <path d="M6.2 10.4 7.5 5.2l3.9 2.5"/>
90 <path d="M17.8 10.4 16.5 5.2l-3.9 2.5"/>
91 <path d="M6.2 9.9v2.6c0 3.7 2.6 5.9 5.8 5.9s5.8-2.2 5.8-5.9V9.9"/>
92 <path d="M3.3 13.8h1.8M3.3 15.8h1.8M20.7 13.8h-1.8M20.7 15.8h-1.8"/>
93 <path d="M12 9.9v1.2m0 0c0 1.4-2.2 1.2-2.2 2.6m2.2-2.6c0 1.4 2.2 1.2 2.2 2.6"/>
94 <path d="M11.2 17.2c.4.45 1.2.45 1.6 0"/>
95 </svg>
96 </span>
97 <span class="brand-name">{{.SiteName}}</span>
98 </a>
99 <form class="navsearch" action="/" method="get" role="search">
100 <svg viewBox="0 0 24 24" width="15" height="15" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="m20 20-3.6-3.6"/></svg>
101 <input type="search" name="q" placeholder="搜索项目…" value="{{if .Data}}{{if .Data.Query}}{{.Data.Query}}{{end}}{{end}}" aria-label="搜索项目">
102 </form>
103 <button class="navtoggle" type="button" aria-label="打开菜单" aria-expanded="false">
104 <span></span><span></span><span></span>
105 </button>
106 <nav class="navmenu">
107 <a class="navlink {{if eq .Active "home"}}on{{end}}" href="/">项目</a>
108 {{if .User}}
109 <a class="navlink {{if eq .Active "new"}}on{{end}}" href="/new">新建项目</a>
110 {{if .User.IsAdmin}}<a class="navlink {{if eq .Active "admin"}}on{{end}}" href="/admin">管理后台</a>{{end}}
111 {{end}}
112 <div class="navactions">
113 {{if .User}}
114 <div class="usermenu">
115 <button class="userbtn" type="button" aria-haspopup="true" aria-expanded="false">
116 {{template "av" (dict "U" .User "S" 28)}}
117 <span class="username">{{.User.Display}}</span>
118 <svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2.2" aria-hidden="true"><path d="m6 9 6 6 6-6"/></svg>
119 </button>
120 <div class="usermenu-pop" role="menu">
121 <div class="um-head">
122 {{template "av" (dict "U" .User "S" 40)}}
123 <div><strong>{{.User.Display}}</strong><span class="muted">@{{.User.Username}}</span></div>
124 </div>
125 <a href="/settings" role="menuitem">账号设置</a>
126 {{if .User.IsAdmin}}<a href="/admin" role="menuitem">管理后台</a>{{end}}
127 <form method="post" action="/logout">
128 <input type="hidden" name="csrf" value="{{.CSRF}}">
129 <button type="submit" role="menuitem" class="danger">退出登录</button>
130 </form>
131 </div>
132 </div>
133 {{else}}
134 <a class="btn btn-primary" href="/login">登录</a>
135 {{end}}
136 </div>
137 </nav>
138 </div>
139</header>
140
141<main class="page">
142 <div class="wrap">
143 {{template "flash" .}}
144 {{template "content" .}}
145 </div>
146</main>
147
148<footer class="foot">
149 <div class="wrap foot-in">
150 <span><strong>{{.SiteName}}</strong> · 工作室自建 Git 服务</span>
151 <span class="muted">Powered by gitcat {{.Version}}</span>
152 </div>
153</footer>
154
155{{if and .Data .Data.AssistantEnabled}}
156{{with .Data.Repo}}
157<!-- AI 项目助手:挂在 body 直属,避免被带动画/transform 的祖先容器改变
158 position: fixed 的定位基准,保证始终悬浮在可视区域右下角。 -->
159<div class="ai-assist" id="ai-assist" data-repo="{{.Name}}" data-csrf="{{if $.User}}{{$.CSRF}}{{end}}">
160 <button class="ai-fab" id="ai-fab" type="button" aria-label="打开 AI 项目助手" aria-expanded="false" aria-controls="ai-panel">
161 <span class="ai-fab-cat" aria-hidden="true">
162 <svg viewBox="0 0 24 24" width="27" height="27" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round">
163 <path d="M8.6 6.9 10 3.6l2.3 2.2"/>
164 <path d="M12.9 5.8 15.2 3.6 16.6 6.9"/>
165 <path d="M20 13.3a3.8 3.8 0 0 1-3.8 3.8h-4.1l-3.8 3v-3h-.5A3.8 3.8 0 0 1 4 13.3V9.9A3.8 3.8 0 0 1 7.8 6.1h8.4A3.8 3.8 0 0 1 20 9.9z"/>
166 <g fill="currentColor" stroke="none">
167 <path d="M11.6 9.4l.87 2.23 2.23.87-2.23.87-.87 2.23-.87-2.23-2.23-.87 2.23-.87z"/>
168 <path d="M16.5 8l.5 1.2 1.2.5-1.2.5-.5 1.2-.5-1.2-1.2-.5 1.2-.5z"/>
169 </g>
170 </svg>
171 </span>
172 <span class="ai-fab-spark" aria-hidden="true">
173 <svg viewBox="0 0 24 24" width="13" height="13" fill="currentColor"><path d="M12 2.4l1.8 5.3a1.9 1.9 0 0 0 1.2 1.2l5.3 1.8-5.3 1.8a1.9 1.9 0 0 0-1.2 1.2L12 19l-1.8-5.3a1.9 1.9 0 0 0-1.2-1.2L3.7 10.7l5.3-1.8a1.9 1.9 0 0 0 1.2-1.2z"/></svg>
174 </span>
175 </button>
176
177 <section class="ai-panel" id="ai-panel" role="dialog" aria-label="AI 项目助手" hidden>
178 <header class="ai-head">
179 <span class="ai-ava" aria-hidden="true">
180 <svg viewBox="0 0 24 24" width="19" height="19" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">
181 <path d="M8.6 6.9 10 3.6l2.3 2.2"/>
182 <path d="M12.9 5.8 15.2 3.6 16.6 6.9"/>
183 <path d="M20 13.3a3.8 3.8 0 0 1-3.8 3.8h-4.1l-3.8 3v-3h-.5A3.8 3.8 0 0 1 4 13.3V9.9A3.8 3.8 0 0 1 7.8 6.1h8.4A3.8 3.8 0 0 1 20 9.9z"/>
184 <g fill="currentColor" stroke="none">
185 <path d="M11.6 9.6l.8 2.05 2.05.8-2.05.8-.8 2.05-.8-2.05-2.05-.8 2.05-.8z"/>
186 <path d="M16.3 8.2l.45 1.1 1.1.45-1.1.45-.45 1.1-.45-1.1-1.1-.45 1.1-.45z"/>
187 </g>
188 </svg>
189 </span>
190 <div class="ai-head-txt">
191 <strong>项目助手</strong>
192 <span>{{.Name}} · 会阅读仓库代码回答</span>
193 </div>
194 <button class="ai-close" id="ai-close" type="button" aria-label="收起助手">
195 <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round"><path d="M6 6l12 12M18 6 6 18"/></svg>
196 </button>
197 </header>
198
199 <div class="ai-body" id="ai-body" aria-live="polite">
200 <div class="ai-msg bot">
201 <div class="ai-bubble">
202 <p>你好,我是这个项目的 AI 助手。我能阅读仓库里的代码,可以帮你了解它的结构、实现和用法。</p>
203 <div class="ai-suggests" id="ai-suggests">
204 <button type="button">这个项目是做什么的?</button>
205 <button type="button">代码应该从哪里开始看?</button>
206 <button type="button">怎么在本地把它跑起来?</button>
207 </div>
208 </div>
209 </div>
210 </div>
211
212 <div class="ai-foot">
213 <p class="ai-tip" id="ai-tip">{{if $.Data.AssistantGuest}}游客每分钟最多 5 个问题,<a href="/login">登录</a>后不限量{{else}}已登录 · 不限量使用{{end}}<span id="ai-tip-extra"></span></p>
214 <form class="ai-form" id="ai-form">
215 <textarea id="ai-input" rows="1" maxlength="1000" placeholder="问问这个项目的代码…" aria-label="提问内容"></textarea>
216 <button class="ai-send" id="ai-send" type="submit" aria-label="发送问题">
217 <svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4.5 12h14"/><path d="m13 6.5 5.5 5.5L13 17.5"/></svg>
218 </button>
219 </form>
220 </div>
221 </section>
222</div>
223<script src="/static/assistant.js" defer></script>
224{{end}}
225{{end}}
226<script src="/static/app.js" defer></script>
227</body>
228</html>
229{{end}}