plz / templates / tree.html
336 lines · 311 sloc · 15.67 KB · b4519526403f0df6949673296f327af605cce975
Raw
1<!DOCTYPE html>
2<html>
3 <head>
4 @include 'layout/head.html'
5 @css '/css/ci.css'
6 </head>
7 <body>
8 @include 'layout/header.html'
9
10 <script>
11 const TREE_BRANCH_PATH_TEMPLATE = "/@repo.user_name/@repo.name/tree/";
12 const BRANCH_NAME = "@branch_name";
13 const REPO_ID = @repo.id;
14 const CURRENT_PATH = "@ctx.current_path";
15 const REPO_USER = "@repo.user_name";
16 const REPO_NAME = "@repo.name";
17 const TREE_MODE = "@tree_mode";
18 const TREE_FOLDER_SIZE_ENABLED = "@{show_folder_size}" === "true";
19 </script>
20
21 <div class="content">
22 <div class="repo-header-area">
23 @include 'layout/repo_menu.html'
24
25 @if is_top_directory
26 <div class="repo-actions">
27 @if is_repo_starred
28 <button class="star-button">
29 @include 'svgs/unstar.html'
30 %starred @{repo.nr_stars}
31 </button>
32 @else
33 <button class="star-button">
34 @include 'svgs/star.html'
35 %star_action @{repo.nr_stars}
36 </button>
37 @end
38
39 @if is_repo_watcher
40 <button class="watch-button">
41 @include 'svgs/unwatch.html'
42 %unwatch_action @{watcher_count}
43 </button>
44 @else
45 <button class="watch-button">
46 @include 'svgs/watch.html'
47 %watch_action @{watcher_count}
48 </button>
49 @end
50 </div>
51 @end
52 </div>
53
54 @if is_top_directory
55 <div class="repo-wrapper repo-wrapper--with-sidebar">
56 @else
57 <div class="repo-wrapper">
58 @end
59 <span class="branch-specific-container">
60 <select class="branch-select" name="branch">
61 @for name in app.get_all_repo_branch_names(repo.id)
62 <option value="@name">@name</option>
63 @end
64 </select>
65
66 <a class="branches-link" href="/@repo.user_name/@repo.name/branches">
67 <svg aria-hidden="true" focusable="false" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><path fill="currentColor" d="M384 144c0-44.2-35.8-80-80-80s-80 35.8-80 80c0 36.4 24.3 67.1 57.5 76.8-.6 16.1-4.2 28.5-11 36.9-15.4 19.2-49.3 22.4-85.2 25.7-28.2 2.6-57.4 5.4-81.3 16.9v-144c32.5-10.2 56-40.5 56-76.3 0-44.2-35.8-80-80-80S0 35.8 0 80c0 35.8 23.5 66.1 56 76.3v199.3C23.5 365.9 0 396.2 0 432c0 44.2 35.8 80 80 80s80-35.8 80-80c0-34-21.2-63.1-51.2-74.6 3.1-5.2 7.8-9.8 14.9-13.4 16.2-8.2 40.4-10.4 66.1-12.8 42.2-3.9 90-8.4 118.2-43.4 14-17.4 21.1-39.8 21.6-67.9 31.6-10.8 54.4-40.7 54.4-75.9zM80 64c8.8 0 16 7.2 16 16s-7.2 16-16 16-16-7.2-16-16 7.2-16 16-16zm0 384c-8.8 0-16-7.2-16-16s7.2-16 16-16 16 7.2 16 16-7.2 16-16 16zm224-320c8.8 0 16 7.2 16 16s-7.2 16-16 16-16-7.2-16-16 7.2-16 16-16z"></path></svg>
68 @repo.format_nr_branches(ctx.lang)
69 </a>
70
71 <div class="repo-mode-switch">
72 @if is_top_files_mode
73 <a class="repo-mode-link" href="@tree_url">Tree</a>
74 <span class="repo-mode-link active">Top files</span>
75 @else
76 <span class="repo-mode-link active">Tree</span>
77 <a class="repo-mode-link" href="@top_files_url">Top files</a>
78 @end
79 </div>
80
81 <div class="branch-right-actions">
82 @if repo.user_id == ctx.user.id
83 <a class="add-file-btn" href="/@repo.user_name/@repo.name/new/@branch_name">+</a>
84 @end
85
86 <div class="repo-code-container">
87 <div class="repo-code-button">Code</div>
88
89 <div class="repo-clone-dropdown">
90 Clone with HTTPS:
91 <div class="clone-input-group">
92 <input disabled value="@{app.generate_clone_url(repo)}">
93 <button class="copy-clone-url-button">Copy</button>
94 </div>
95 </div>
96 </div>
97 </div>
98 </span>
99 </div>
100
101 @if is_top_directory
102 <div class="repo-layout">
103 <div class="repo-main">
104 @end
105
106 @if has_commits && repo.lang_stats.len > 0
107 .lang-stats-header {
108 .langs {
109 @for stat in repo.lang_stats
110 .lang-stat {
111 <span class='lang-stat-dot' style='background-color:@{stat.color}'> </span>
112 <b>@stat.name</b>
113 @{stat.pct_html()}
114 }
115 @end
116 }
117
118 .lang-stats-bar {
119 @for stat in repo.lang_stats
120 <div style='flex:@{stat.pct}; background-color:@stat.color'></div>
121 @end
122 }
123 }
124 @end
125
126 @if is_top_files_mode
127 <div class="files files--top-files">
128 <div class="top-files-header">
129 <b>Top files</b>
130 <span>Largest @top_files_limit files in @branch_name</span>
131 </div>
132
133 @if top_files.len == 0
134 <div class="top-files-empty">No files found</div>
135 @end
136
137 @for file in top_files
138 <div class="file top-file" data-name="@file.full_path()">
139 span.file-ico {
140 <svg aria-hidden="true" focusable="false" data-prefix="far" data-icon="file-alt" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><path fill="currentColor" d="M288 248v28c0 6.6-5.4 12-12 12H108c-6.6 0-12-5.4-12-12v-28c0-6.6 5.4-12 12-12h168c6.6 0 12 5.4 12 12zm-12 72H108c-6.6 0-12 5.4-12 12v28c0 6.6 5.4 12 12 12h168c6.6 0 12-5.4 12-12v-28c0-6.6-5.4-12-12-12zm108-188.1V464c0 26.5-21.5 48-48 48H48c-26.5 0-48-21.5-48-48V48C0 21.5 21.5 0 48 0h204.1C264.8 0 277 5.1 286 14.1L369.9 98c9 8.9 14.1 21.2 14.1 33.9zm-128-80V128h76.1L256 51.9zM336 464V176H232c-13.3 0-24-10.7-24-24V48H48v416h288z"></path></svg>
141 }
142 span.file-name {
143 <a href='/@repo.user_name/@repo.name/blob/@branch_name/@file.full_path()'>@file.full_path()</a>
144 }
145 <span class="file-size">
146 @file.pretty_size()
147 </span>
148 </div>
149 @end
150 </div>
151 @else
152 @if show_folder_size
153 <div class="files files--with-size">
154 @else
155 <div class="files">
156 @end
157 .last_commit {
158 <b>@last_commit.author</b>
159 span.last_commit_message {
160 @last_commit.message
161 }
162 <a href="/@repo.user_name/@repo.name/commit/@last_commit.hash" class="last_commit_hash">@last_commit.hash</a>
163 @if has_ci
164 <a href="/@repo.user_name/@repo.name/ci/@ci_status.ci_run_id" title="CI: @{ci_status.status.str()}">
165 <span class="ci-badge-inline @{ci_status.status.css_class()}"></span>
166 </a>
167 @end
168 span.time {
169 @last_commit.relative()
170 }
171 }
172
173 @if can_up
174 .file {
175 span.file-ico {
176 <svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="folder" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="currentColor" d="M464 128H272l-64-64H48C21.49 64 0 85.49 0 112v288c0 26.51 21.49 48 48 48h416c26.51 0 48-21.49 48-48V176c0-26.51-21.49-48-48-48z"></path></svg>
177 }
178 span.file-name {
179 <a href="@up">..</a>
180 }
181 @if show_folder_size
182 <span class="file-size"></span>
183 @end
184 }
185 @end
186 @for file in items
187 <div class="file" data-name="@file.name">
188 span.file-ico {
189 @if file.is_dir
190 <svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="folder" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="currentColor" d="M464 128H272l-64-64H48C21.49 64 0 85.49 0 112v288c0 26.51 21.49 48 48 48h416c26.51 0 48-21.49 48-48V176c0-26.51-21.49-48-48-48z"></path></svg>
191 @else
192 <svg aria-hidden="true" focusable="false" data-prefix="far" data-icon="file-alt" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><path fill="currentColor" d="M288 248v28c0 6.6-5.4 12-12 12H108c-6.6 0-12-5.4-12-12v-28c0-6.6 5.4-12 12-12h168c6.6 0 12 5.4 12 12zm-12 72H108c-6.6 0-12 5.4-12 12v28c0 6.6 5.4 12 12 12h168c6.6 0 12-5.4 12-12v-28c0-6.6-5.4-12-12-12zm108-188.1V464c0 26.5-21.5 48-48 48H48c-26.5 0-48-21.5-48-48V48C0 21.5 21.5 0 48 0h204.1C264.8 0 277 5.1 286 14.1L369.9 98c9 8.9 14.1 21.2 14.1 33.9zm-128-80V128h76.1L256 51.9zM336 464V176H232c-13.3 0-24-10.7-24-24V48H48v416h288z"></path></svg>
193 @end
194 }
195 span.file-name {
196 <a href='/@repo.user_name/@repo.name/@file.url()'>@file.name</a>
197 }
198 <span class="file-msg" data-msg-for="@file.name">
199 <a href="/@repo.user_name/@repo.name/commit/@file.last_hash#@file.full_path()">@file.format_commit_message()</a>
200 </span>
201 <span class="file-time" data-time-for="@file.name">
202 @file.pretty_last_time()
203 </span>
204 @if show_folder_size
205 @if file.is_dir
206 <span class="file-size" data-size-for="@file.name">
207 @file.pretty_tree_size()
208 </span>
209 @else
210 <span class="file-size">@file.pretty_size()</span>
211 @end
212 @end
213 </div>
214 @end
215 @if is_top_directory
216 <div class="file file-total">
217 <span class="file-size">
218 <svg aria-hidden="true" focusable="false" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path fill="currentColor" d="M448 73.143v45.714C448 159.143 347.667 192 224 192S0 159.143 0 118.857V73.143C0 32.857 100.333 0 224 0s224 32.857 224 73.143zM448 176v102.857C448 319.143 347.667 512 224 512S0 479.143 0 438.857V336c48.125 33.143 136.208 48.572 224 48.572S399.874 369.143 448 336z"></path></svg>
219 @repo.format_size()
220 </span>
221 </div>
222 @end
223 </div>
224
225 @if readme.len > 0
226 <div class="readme" id="readme">
227 @readme
228 </div>
229 @end
230 @end
231
232 @if is_top_directory
233 </div>
234
235 <aside class="repo-sidebar">
236 <section class="sidebar-section">
237 <div class="sidebar-section-header">
238 <h3>%about_section</h3>
239 </div>
240 @if repo.description != ''
241 <p class="sidebar-description">@repo.description</p>
242 @else
243 <p class="sidebar-description sidebar-description--empty">%no_description</p>
244 @end
245 <ul class="sidebar-meta">
246 @if readme.len > 0
247 <li>
248 <svg aria-hidden="true" viewBox="0 0 16 16" width="16" height="16"><path fill="currentColor" d="M0 1.75A.75.75 0 0 1 .75 1h4.253c1.227 0 2.317.59 3 1.501A3.743 3.743 0 0 1 11.006 1h4.245a.75.75 0 0 1 .75.75v10.5a.75.75 0 0 1-.75.75h-4.507a2.25 2.25 0 0 0-1.591.659l-.622.621a.75.75 0 0 1-1.06 0l-.622-.621A2.25 2.25 0 0 0 5.258 13H.75a.75.75 0 0 1-.75-.75Zm7.251 10.324.004-5.073-.002-2.253A2.25 2.25 0 0 0 5.003 2.5H1.5v9h3.757a3.75 3.75 0 0 1 1.994.574ZM8.755 4.75l-.004 7.322a3.752 3.752 0 0 1 1.992-.572H14.5v-9h-3.495a2.25 2.25 0 0 0-2.25 2.25Z"/></svg>
249 <a href="#readme">%readme_link</a>
250 </li>
251 @end
252 @if license_file_path.len > 0
253 <li>
254 <svg aria-hidden="true" viewBox="0 0 16 16" width="16" height="16"><path fill="currentColor" d="M8.75.75V2h.985c.304 0 .603.08.867.231l1.29.736c.038.022.08.033.124.033h2.234a.75.75 0 0 1 0 1.5h-.427l2.111 4.692a.75.75 0 0 1-.154.838l-.53-.53.529.531-.001.002-.002.002-.006.006-.006.005-.01.01-.045.04c-.21.176-.441.327-.686.45C14.556 10.78 13.88 11 13 11a4.498 4.498 0 0 1-2.023-.454 3.544 3.544 0 0 1-.686-.45l-.045-.04-.016-.015-.006-.006-.004-.004v-.001a.75.75 0 0 1-.154-.838L12.178 4.5h-.162c-.305 0-.604-.079-.868-.231l-1.29-.736a.245.245 0 0 0-.124-.033H8.75V13h2.5a.75.75 0 0 1 0 1.5h-6.5a.75.75 0 0 1 0-1.5h2.5V3.5h-.984a.244.244 0 0 0-.124.033l-1.289.737c-.265.15-.564.23-.869.23h-.162l2.112 4.692a.75.75 0 0 1-.154.838l-.53-.53.529.531-.001.002-.002.002-.006.006-.016.015-.045.04c-.21.176-.441.327-.686.45C4.556 10.78 3.88 11 3 11a4.498 4.498 0 0 1-2.023-.454 3.544 3.544 0 0 1-.686-.45l-.045-.04-.016-.015-.006-.006-.004-.004v-.001a.75.75 0 0 1-.154-.838L2.178 4.5H1.75a.75.75 0 0 1 0-1.5h2.234a.249.249 0 0 0 .125-.033l1.288-.737c.265-.15.564-.23.869-.23h.984V.75a.75.75 0 0 1 1.5 0Zm2.945 8.477c.285.135.718.273 1.305.273s1.02-.138 1.305-.273L13 6.327Zm-10 0c.285.135.718.273 1.305.273s1.02-.138 1.305-.273L3 6.327Z"/></svg>
255 <a href="@{license_file_path}">%license_link</a>
256 </li>
257 @end
258 <li>
259 <svg aria-hidden="true" viewBox="0 0 16 16" width="16" height="16"><path fill="currentColor" d="M8 .25a.75.75 0 0 1 .673.418l1.882 3.815 4.21.612a.75.75 0 0 1 .416 1.279l-3.046 2.97.719 4.192a.75.75 0 0 1-1.088.791L8 12.347l-3.766 1.98a.75.75 0 0 1-1.088-.79l.72-4.194L.818 6.374a.75.75 0 0 1 .416-1.28l4.21-.611L7.327.668A.75.75 0 0 1 8 .25Z"/></svg>
260 @repo.nr_stars %stars_label
261 </li>
262 <li>
263 <svg aria-hidden="true" viewBox="0 0 16 16" width="16" height="16"><path fill="currentColor" d="M8 2c1.981 0 3.671.992 4.933 2.078 1.27 1.091 2.187 2.345 2.637 3.023a1.62 1.62 0 0 1 0 1.798c-.45.678-1.367 1.932-2.637 3.023C11.67 13.008 9.981 14 8 14c-1.981 0-3.671-.992-4.933-2.078C1.797 10.83.88 9.576.43 8.898a1.62 1.62 0 0 1 0-1.798c.45-.677 1.367-1.931 2.637-3.022C4.33 2.992 6.019 2 8 2ZM1.679 7.932a.12.12 0 0 0 0 .136c.411.622 1.241 1.75 2.366 2.717C5.176 11.758 6.527 12.5 8 12.5c1.473 0 2.825-.742 3.955-1.715 1.124-.967 1.954-2.096 2.366-2.717a.12.12 0 0 0 0-.136c-.412-.621-1.242-1.75-2.366-2.717C10.824 4.242 9.473 3.5 8 3.5c-1.473 0-2.825.742-3.955 1.715-1.124.967-1.954 2.096-2.366 2.717ZM8 10a2 2 0 1 1-.001-3.999A2 2 0 0 1 8 10Z"/></svg>
264 @watcher_count %watching_label
265 </li>
266 </ul>
267 </section>
268
269 <section class="sidebar-section">
270 <div class="sidebar-section-header">
271 <h3><a href="#sponsor">%sponsor_section</a></h3>
272 </div>
273 <a class="sponsor-button" href="#sponsor">
274 <svg aria-hidden="true" viewBox="0 0 16 16" width="16" height="16"><path fill="#bf3989" d="m8 14.25.345.666a.75.75 0 0 1-.69 0l-.008-.004-.018-.01a7.152 7.152 0 0 1-.31-.17 22.055 22.055 0 0 1-3.434-2.414C2.045 10.731 0 8.35 0 5.5 0 2.836 2.086 1 4.25 1 5.797 1 7.153 1.802 8 3.02 8.847 1.802 10.203 1 11.75 1 13.914 1 16 2.836 16 5.5c0 2.85-2.045 5.231-3.885 6.818a22.066 22.066 0 0 1-3.744 2.584l-.018.01-.006.003h-.002ZM4.25 2.5c-1.336 0-2.75 1.164-2.75 3 0 2.15 1.58 4.144 3.365 5.682A20.58 20.58 0 0 0 8 13.393a20.58 20.58 0 0 0 3.135-2.211C12.92 9.644 14.5 7.65 14.5 5.5c0-1.836-1.414-3-2.75-3-1.373 0-2.609.986-3.029 2.456a.749.749 0 0 1-1.442 0C6.859 3.486 5.623 2.5 4.25 2.5Z"/></svg>
275 %sponsor_action
276 </a>
277 </section>
278
279 <section class="sidebar-section">
280 <div class="sidebar-section-header">
281 <h3><a href="/@repo.user_name/@repo.name/releases">%releases_section</a></h3>
282 @if repo.nr_releases > 0
283 <span class="sidebar-count">@repo.nr_releases</span>
284 @end
285 </div>
286 @if sidebar_releases.len > 0
287 <a class="sidebar-release-latest" href="/@repo.user_name/@repo.name/releases">
288 <span class="sidebar-release-badge">%latest_label</span>
289 <span class="sidebar-release-name">@sidebar_releases[0].tag_name</span>
290 <span class="sidebar-release-date">@sidebar_releases[0].date.relative()</span>
291 </a>
292 @if sidebar_releases.len > 1
293 <a class="sidebar-release-more" href="/@repo.user_name/@repo.name/releases">
294 + @{sidebar_releases.len - 1} %releases_more
295 </a>
296 @end
297 @else
298 <p class="sidebar-empty">%no_releases</p>
299 @end
300 </section>
301
302 <section class="sidebar-section">
303 <div class="sidebar-section-header">
304 <h3><a href="/@repo.user_name/@repo.name/contributors">%contributors_section</a></h3>
305 @if repo.nr_contributors > 0
306 <span class="sidebar-count">@repo.nr_contributors</span>
307 @end
308 </div>
309 @if sidebar_contributors.len > 0
310 <div class="sidebar-contributors">
311 @for contributor in sidebar_contributors
312 @if contributor.is_registered
313 <a class="sidebar-contributor" href="/@contributor.username" title="@contributor.username">
314 <img src="@{app.prepare_user_avatar_url(contributor.avatar)}" alt="@contributor.username">
315 </a>
316 @else
317 <span class="sidebar-contributor sidebar-contributor--shadow" title="@contributor.username">
318 <img src="@{app.prepare_user_avatar_url(contributor.avatar)}" alt="@contributor.username">
319 </span>
320 @end
321 @end
322 </div>
323 @else
324 <p class="sidebar-empty">%no_contributors</p>
325 @end
326 </section>
327 </aside>
328 </div>
329 @end
330
331 </div>
332
333 @js '/js/tree.js'
334 @include 'layout/footer.html'
335 </body>
336</html>
337