Commit

Author:

Hash:

Timestamp:

+222 -170 +/-18 browse

Kevin Schoon [me@kevinschoon.com]

07129643ccc7c94be1dffd7a7db6b807632578df

Sun, 14 Jan 2024 18:39:50 +0000 (1.3 years ago)

only show bugs page when gitbug support enabled
1diff --git a/src/web2/middleware/repository.rs b/src/web2/middleware/repository.rs
2index 17378a9..060270e 100644
3--- a/src/web2/middleware/repository.rs
4+++ b/src/web2/middleware/repository.rs
5 @@ -2,7 +2,7 @@ use std::path::PathBuf;
6 use std::time::SystemTime;
7
8 use axum::{
9- extract::{Path, State, Request},
10+ extract::{Path, Request, State},
11 middleware::Next,
12 response::{IntoResponse, Response},
13 };
14 @@ -10,6 +10,7 @@ use axum::{
15 use serde::Deserialize;
16
17 use crate::config::Config;
18+ use crate::gitbug::Wrapper as Gitbug;
19 use crate::web2::error::Error;
20 use ayllu_git::{Commit, Config as GitConfig, Wrapper as Repository};
21
22 @@ -32,6 +33,7 @@ pub struct Preamble {
23 pub collection_name: String,
24 pub refname: String,
25 pub config: GitConfig,
26+ pub gitbug_enabled: bool,
27 pub file_path: Option<PathBuf>,
28 pub latest_commit: Option<Commit>,
29 pub latest_commit_id: Option<String>,
30 @@ -56,6 +58,9 @@ impl Preamble {
31 return Err(Error::NotFound(String::from("collection not found")));
32 }
33 };
34+ let gitbug_enabled = Gitbug::new(&repo_path)
35+ .enabled()
36+ .is_ok_and(|enabled| enabled == true);
37 let repository = Repository::new(&repo_path)?;
38 let is_empty = repository.is_empty()?;
39 let config = repository.config()?;
40 @@ -83,6 +88,7 @@ impl Preamble {
41 collection_name,
42 refname,
43 config,
44+ gitbug_enabled,
45 file_path: file_path.map(PathBuf::from),
46 latest_commit: latest_commit.clone(),
47 latest_commit_id: latest_commit.map(|commit| commit.id),
48 diff --git a/src/web2/mod.rs b/src/web2/mod.rs
49index 6b5250b..3d0d739 100644
50--- a/src/web2/mod.rs
51+++ b/src/web2/mod.rs
52 @@ -4,6 +4,7 @@ mod error;
53 mod extractors;
54 mod highlight;
55 mod middleware;
56+ mod navigation;
57 mod routes;
58 mod server;
59 mod terautil;
60 diff --git a/src/web2/navigation.rs b/src/web2/navigation.rs
61new file mode 100644
62index 0000000..7be0f1c
63--- /dev/null
64+++ b/src/web2/navigation.rs
65 @@ -0,0 +1,138 @@
66+ pub type Items = Vec<(String, String, bool)>;
67+
68+ pub fn global(current_page: &str, mail_visible: bool) -> Items {
69+ let mut nav: Items = vec![
70+ (
71+ String::from("about"),
72+ String::from("/about"),
73+ current_page == "about",
74+ ),
75+ (
76+ String::from("config"),
77+ String::from("/config"),
78+ current_page == "config",
79+ ),
80+ ];
81+ if mail_visible {
82+ nav.push((
83+ String::from("mail"),
84+ String::from("/mail"),
85+ current_page == "mail",
86+ ))
87+ }
88+ nav
89+ }
90+
91+ pub fn primary(current_page: &str, collection: &str, name: &str, bugs_enabled: bool) -> Items {
92+ let mut nav = vec![
93+ (
94+ String::from("authors"),
95+ format!("/{}/{}/authors", collection, name,),
96+ current_page == "authors",
97+ ),
98+ (
99+ String::from("charts"),
100+ format!("/{}/{}/charts", collection, name),
101+ current_page == "charts",
102+ ),
103+ (
104+ String::from("log"),
105+ format!("/{}/{}/log", collection, name),
106+ current_page == "log",
107+ ),
108+ (
109+ String::from("project"),
110+ format!("/{}/{}", collection, name),
111+ current_page == "project",
112+ ),
113+ (
114+ String::from("refs"),
115+ format!("/{}/{}/refs", collection, name),
116+ current_page == "refs",
117+ ),
118+ ];
119+
120+ if bugs_enabled {
121+ nav.insert(
122+ 1,
123+ (
124+ String::from("bugs"),
125+ format!("/{}/{}/bugs", collection, name),
126+ current_page == "bugs",
127+ ),
128+ )
129+ };
130+ nav
131+ }
132+
133+ pub fn subnav(
134+ current_page: &str,
135+ collection: &str,
136+ name: &str,
137+ file_path: &str,
138+ ref_name: &str,
139+ commit_id: &str,
140+ ) -> Items {
141+ vec![
142+ (
143+ String::from("blob"),
144+ format!("/{}/{}/blob/{}/{}", collection, name, ref_name, file_path,),
145+ current_page == "blob",
146+ ),
147+ (
148+ String::from("blame"),
149+ format!("/{}/{}/blame/{}/{}", collection, name, ref_name, file_path),
150+ current_page == "blame",
151+ ),
152+ (
153+ String::from("log"),
154+ format!("/{}/{}/log/{}/{}", collection, name, ref_name, file_path,),
155+ current_page == "log",
156+ ),
157+ (
158+ String::from("permalink"),
159+ format!(
160+ "/{}/{}/{}/{}/{}",
161+ collection, name, current_page, commit_id, file_path
162+ ),
163+ false,
164+ ),
165+ (
166+ String::from("raw"),
167+ format!("/{}/{}/raw/{}/{}", collection, name, ref_name, file_path),
168+ false,
169+ ),
170+ ]
171+ }
172+
173+ pub fn chartnav(current_page: &str, collection: &str, name: &str, git_hash: Option<&str>) -> Items {
174+ let commit_path = git_hash.map_or(String::new(), |hash| String::from("/") + hash);
175+ vec![
176+ (
177+ String::from("activity"),
178+ format!("/{}/{}/chart/activity{}", collection, name, commit_path),
179+ current_page == "activity",
180+ ),
181+ (
182+ String::from("languages"),
183+ format!("/{}/{}/chart/languages{}", collection, name, commit_path),
184+ current_page == "languages",
185+ ),
186+ ]
187+ }
188+
189+ pub fn revnav(current_page: &str, collection: &str, name: &str) -> Items {
190+ vec![
191+ (
192+ String::from("tags"),
193+ format!("/{}/{}/refs/tags", collection, name),
194+ current_page == "tags",
195+ ),
196+ (
197+ String::from("branches"),
198+ format!("/{}/{}/refs/branches", collection, name),
199+ current_page == "branches",
200+ ),
201+ ]
202+ }
203+
204 diff --git a/src/web2/routes/about.rs b/src/web2/routes/about.rs
205index 71f1fd2..86c3983 100644
206--- a/src/web2/routes/about.rs
207+++ b/src/web2/routes/about.rs
208 @@ -6,7 +6,7 @@ use crate::config::Config;
209 use crate::web2::error::Error;
210 use crate::web2::highlight::TreeSitterAdapter;
211 use crate::web2::middleware::template::Template;
212- use crate::web2::util::navigation;
213+ use crate::web2::navigation;
214
215 pub async fn serve(
216 Extension(cfg): Extension<Config>,
217 diff --git a/src/web2/routes/authors.rs b/src/web2/routes/authors.rs
218index b265c5b..5cd219b 100644
219--- a/src/web2/routes/authors.rs
220+++ b/src/web2/routes/authors.rs
221 @@ -6,7 +6,7 @@ use crate::database_ext::contributors::ContributorsExt;
222 use crate::web2::error::Error;
223 use crate::web2::middleware::repository::Preamble;
224 use crate::web2::middleware::template::Template;
225- use crate::web2::util;
226+ use crate::web2::navigation;
227 use ayllu_database::Wrapper as Database;
228
229 pub async fn serve(
230 @@ -24,7 +24,12 @@ pub async fn serve(
231 ctx.insert("title", &format!("{} Authors", preamble.repo_name.clone()));
232 ctx.insert(
233 "nav_elements",
234- &util::navigation::primary("authors", &preamble.collection_name, &preamble.repo_name),
235+ &navigation::primary(
236+ "authors",
237+ &preamble.collection_name,
238+ &preamble.repo_name,
239+ preamble.gitbug_enabled,
240+ ),
241 );
242 ctx.insert("authors", &authors);
243 let body = templates.render("authors.html", &ctx)?;
244 diff --git a/src/web2/routes/blame.rs b/src/web2/routes/blame.rs
245index 2f5a411..595e936 100644
246--- a/src/web2/routes/blame.rs
247+++ b/src/web2/routes/blame.rs
248 @@ -8,7 +8,7 @@ use crate::web2::error::Error;
249 use crate::web2::highlight::Highlighter;
250 use crate::web2::middleware::repository::Preamble;
251 use crate::web2::middleware::template::Template;
252- use crate::web2::util;
253+ use crate::web2::navigation;
254 use ayllu_git::Wrapper;
255
256 #[derive(Serialize, Default, Clone)]
257 @@ -32,12 +32,17 @@ pub async fn serve(
258 ctx.insert("title", &title);
259 ctx.insert(
260 "nav_elements",
261- &util::navigation::primary("", &preamble.collection_name, &preamble.repo_name),
262+ &navigation::primary(
263+ "",
264+ &preamble.collection_name,
265+ &preamble.repo_name,
266+ preamble.gitbug_enabled,
267+ ),
268 );
269 ctx.insert("file_name", &preamble.file_name());
270 ctx.insert(
271 "subnav_elements",
272- &util::navigation::subnav(
273+ &navigation::subnav(
274 "blame",
275 &preamble.collection_name,
276 &preamble.repo_name,
277 diff --git a/src/web2/routes/blob.rs b/src/web2/routes/blob.rs
278index bf708a5..cc0dbad 100644
279--- a/src/web2/routes/blob.rs
280+++ b/src/web2/routes/blob.rs
281 @@ -15,6 +15,7 @@ use crate::web2::error::Error;
282 use crate::web2::highlight::{Highlighter, TreeSitterAdapter};
283 use crate::web2::middleware::repository::Preamble;
284 use crate::web2::middleware::template::Template;
285+ use crate::web2::navigation;
286 use crate::web2::util;
287 use ayllu_git::Wrapper;
288
289 @@ -86,9 +87,14 @@ pub async fn serve(
290 }
291 ctx.insert(
292 "nav_elements",
293- &util::navigation::primary("blob", &preamble.collection_name, &preamble.repo_name),
294+ &navigation::primary(
295+ "blob",
296+ &preamble.collection_name,
297+ &preamble.repo_name,
298+ preamble.gitbug_enabled,
299+ ),
300 );
301- let subnav = util::navigation::subnav(
302+ let subnav = navigation::subnav(
303 "blob",
304 &preamble.collection_name,
305 &preamble.repo_name,
306 diff --git a/src/web2/routes/bugs.rs b/src/web2/routes/bugs.rs
307index c6a4676..ed7c2f5 100644
308--- a/src/web2/routes/bugs.rs
309+++ b/src/web2/routes/bugs.rs
310 @@ -12,7 +12,7 @@ use crate::web2::highlight::TreeSitterAdapter;
311 use crate::web2::error::Error;
312 use crate::web2::middleware::repository::Preamble;
313 use crate::web2::middleware::template::Template;
314- use crate::web2::util;
315+ use crate::web2::navigation;
316
317 pub async fn bugs(
318 Extension(preamble): Extension<Preamble>,
319 @@ -36,7 +36,7 @@ pub async fn bugs(
320 ctx.insert("title", "Bugs");
321 ctx.insert(
322 "nav_elements",
323- &util::navigation::primary("bugs", &preamble.collection_name, &preamble.repo_name),
324+ &navigation::primary("bugs", &preamble.collection_name, &preamble.repo_name, true),
325 );
326 let body = templates.render("bugs.html", &ctx)?;
327 Ok(Html(body))
328 @@ -76,7 +76,7 @@ pub async fn bug(
329 ctx.insert("title", &details.title);
330 ctx.insert(
331 "nav_elements",
332- &util::navigation::primary("bugs", &preamble.collection_name, &preamble.repo_name),
333+ &navigation::primary("bugs", &preamble.collection_name, &preamble.repo_name, true),
334 );
335 let body = templates.render("bug.html", &ctx)?;
336 Ok(Html(body))
337 diff --git a/src/web2/routes/chart.rs b/src/web2/routes/chart.rs
338index 83ee008..d7204a6 100644
339--- a/src/web2/routes/chart.rs
340+++ b/src/web2/routes/chart.rs
341 @@ -15,7 +15,7 @@ use crate::web2::charts::Renderer;
342 use crate::web2::error::Error;
343 use crate::web2::middleware::repository::Preamble;
344 use crate::web2::middleware::template::Template;
345- use crate::web2::util;
346+ use crate::web2::navigation;
347 use ayllu_database::Wrapper as Database;
348
349 const MAXIMUM_SIZE: u32 = 2000;
350 @@ -63,11 +63,16 @@ pub async fn serve(
351
352 ctx.insert(
353 "nav_elements",
354- &util::navigation::primary("charts", &preamble.collection_name, &preamble.repo_name),
355+ &navigation::primary(
356+ "charts",
357+ &preamble.collection_name,
358+ &preamble.repo_name,
359+ preamble.gitbug_enabled,
360+ ),
361 );
362 ctx.insert(
363 "chartnav",
364- &util::navigation::chartnav(
365+ &navigation::chartnav(
366 &chart_kind,
367 &preamble.collection_name,
368 &preamble.repo_name,
369 diff --git a/src/web2/routes/commit.rs b/src/web2/routes/commit.rs
370index 509d8f7..ac09c69 100644
371--- a/src/web2/routes/commit.rs
372+++ b/src/web2/routes/commit.rs
373 @@ -7,7 +7,7 @@ use crate::web2::error::Error;
374 use crate::web2::highlight::Highlighter;
375 use crate::web2::middleware::repository::Preamble;
376 use crate::web2::middleware::template::Template;
377- use crate::web2::util;
378+ use crate::web2::navigation;
379 use ayllu_git::Wrapper;
380
381 pub async fn serve(
382 @@ -21,7 +21,12 @@ pub async fn serve(
383 ctx.insert("title", &title);
384 ctx.insert(
385 "nav_elements",
386- &util::navigation::primary("", &preamble.collection_name, &preamble.repo_name),
387+ &navigation::primary(
388+ "",
389+ &preamble.collection_name,
390+ &preamble.repo_name,
391+ preamble.gitbug_enabled,
392+ ),
393 );
394 ctx.insert("commit_hash", &commit_id);
395 let commit = repository.commit(Some(commit_id.to_string()))?.unwrap();
396 diff --git a/src/web2/routes/config.rs b/src/web2/routes/config.rs
397index 859122a..85d7184 100644
398--- a/src/web2/routes/config.rs
399+++ b/src/web2/routes/config.rs
400 @@ -10,7 +10,7 @@ use crate::web2::config::Config;
401 use crate::web2::error::Error;
402 use crate::web2::extractors::config::ConfigReader;
403 use crate::web2::middleware::template::Template;
404- use crate::web2::util::navigation;
405+ use crate::web2::navigation;
406
407 pub async fn serve(
408 Extension(cfg): Extension<SystemConfig>,
409 diff --git a/src/web2/routes/index.rs b/src/web2/routes/index.rs
410index 77f109d..ca1cf86 100644
411--- a/src/web2/routes/index.rs
412+++ b/src/web2/routes/index.rs
413 @@ -14,7 +14,7 @@ use crate::time as timeutil;
414 use crate::web2::charts;
415 use crate::web2::error::Error;
416 use crate::web2::middleware::template::Template;
417- use crate::web2::util::navigation;
418+ use crate::web2::navigation;
419 use ayllu_database::Wrapper as Database;
420 use ayllu_git::{Scanner, Wrapper};
421
422 diff --git a/src/web2/routes/log.rs b/src/web2/routes/log.rs
423index 0f55284..faa8e17 100644
424--- a/src/web2/routes/log.rs
425+++ b/src/web2/routes/log.rs
426 @@ -10,7 +10,7 @@ use crate::web2::error::Error;
427 use crate::web2::extractors::config::ConfigReader;
428 use crate::web2::middleware::repository::Preamble;
429 use crate::web2::middleware::template::Template;
430- use crate::web2::util;
431+ use crate::web2::navigation;
432 use ayllu_git::{Selector, Wrapper};
433
434 #[debug_handler]
435 @@ -23,7 +23,12 @@ pub async fn serve(
436 let repository = Wrapper::new(preamble.repo_path.as_path())?;
437 ctx.insert(
438 "nav_elements",
439- &util::navigation::primary("log", &preamble.collection_name, &preamble.repo_name),
440+ &navigation::primary(
441+ "log",
442+ &preamble.collection_name,
443+ &preamble.repo_name,
444+ preamble.gitbug_enabled,
445+ ),
446 );
447 ctx.insert("file_view", &false);
448 match preamble.file_path.clone() {
449 @@ -40,7 +45,7 @@ pub async fn serve(
450 );
451 ctx.insert(
452 "subnav_elements",
453- &util::navigation::subnav(
454+ &navigation::subnav(
455 "log",
456 &preamble.collection_name,
457 &preamble.repo_name,
458 diff --git a/src/web2/routes/mail.rs b/src/web2/routes/mail.rs
459index 2991176..e6a4977 100644
460--- a/src/web2/routes/mail.rs
461+++ b/src/web2/routes/mail.rs
462 @@ -12,7 +12,7 @@ use crate::web2::error::Error;
463 use crate::web2::highlight::Highlighter;
464 use crate::web2::middleware::rpc_initiator::{Initiator, Kind as InitiatorKind};
465 use crate::web2::middleware::template::Template;
466- use crate::web2::util::navigation;
467+ use crate::web2::navigation;
468 use ayllu_api::mail_capnp::server::Client as MailClient;
469 use ayllu_rpc::Client;
470
471 diff --git a/src/web2/routes/refs.rs b/src/web2/routes/refs.rs
472index 1996b25..968cecf 100644
473--- a/src/web2/routes/refs.rs
474+++ b/src/web2/routes/refs.rs
475 @@ -11,10 +11,9 @@ use tokio_util::io::ReaderStream;
476 use crate::web2::error::Error;
477 use crate::web2::middleware::repository::Preamble;
478 use crate::web2::middleware::template::Template;
479+ use crate::web2::navigation;
480 use ayllu_git::Wrapper;
481
482- use crate::web2::util;
483-
484 const INVALID_EXTENSION_MESSAGE: &str = "archive requests must have a .tar.gz extension";
485
486 #[derive(Serialize, Default)]
487 @@ -38,11 +37,16 @@ pub async fn branches(
488 ctx.insert("branches", &branches);
489 ctx.insert(
490 "nav_elements",
491- &util::navigation::primary("refs", &preamble.collection_name, &preamble.repo_name),
492+ &navigation::primary(
493+ "refs",
494+ &preamble.collection_name,
495+ &preamble.repo_name,
496+ preamble.gitbug_enabled,
497+ ),
498 );
499 ctx.insert(
500 "refnav",
501- &util::navigation::revnav(
502+ &navigation::revnav(
503 "branches",
504 preamble.collection_name.as_str(),
505 preamble.repo_name.as_str(),
506 @@ -62,11 +66,16 @@ pub async fn tags(
507 ctx.insert("tags", &tags);
508 ctx.insert(
509 "nav_elements",
510- &util::navigation::primary("refs", &preamble.collection_name, &preamble.repo_name),
511+ &navigation::primary(
512+ "refs",
513+ &preamble.collection_name,
514+ &preamble.repo_name,
515+ preamble.gitbug_enabled,
516+ ),
517 );
518 ctx.insert(
519 "refnav",
520- &util::navigation::revnav(
521+ &navigation::revnav(
522 "tags",
523 preamble.collection_name.as_str(),
524 preamble.repo_name.as_str(),
525 diff --git a/src/web2/routes/repo.rs b/src/web2/routes/repo.rs
526index 43d156a..4a5102d 100644
527--- a/src/web2/routes/repo.rs
528+++ b/src/web2/routes/repo.rs
529 @@ -24,6 +24,7 @@ use crate::web2::highlight::TreeSitterAdapter;
530 use crate::web2::middleware::repository::Preamble;
531 use crate::web2::middleware::rpc_initiator::{Initiator, Kind as InitiatorKind};
532 use crate::web2::middleware::template::Template;
533+ use crate::web2::navigation;
534 use crate::web2::util;
535 use ayllu_api::xmpp_capnp::server::Client as XmppClient;
536 use ayllu_database::Wrapper as Database;
537 @@ -318,7 +319,12 @@ pub async fn serve(
538 ctx.insert("show_details", &preamble.file_path.is_none());
539 ctx.insert(
540 "nav_elements",
541- &util::navigation::primary("project", &preamble.collection_name, &preamble.repo_name),
542+ &navigation::primary(
543+ "project",
544+ &preamble.collection_name,
545+ &preamble.repo_name,
546+ preamble.gitbug_enabled,
547+ ),
548 );
549 ctx.insert("commit_count", &materialized.commit_count);
550 ctx.insert("latest_commit", &preamble.latest_commit);
551 diff --git a/src/web2/routes/xmpp.rs b/src/web2/routes/xmpp.rs
552index a2dac61..749bdce 100644
553--- a/src/web2/routes/xmpp.rs
554+++ b/src/web2/routes/xmpp.rs
555 @@ -9,7 +9,7 @@ use crate::web2::error::Error;
556 use crate::web2::extractors::config::ConfigReader;
557 use crate::web2::middleware::rpc_initiator::{Initiator, Kind as InitiatorKind};
558 use crate::web2::middleware::template::Template;
559- use crate::web2::util::navigation;
560+ use crate::web2::navigation;
561 use ayllu_api::xmpp_capnp::server::Client as XmppClient;
562
563 #[derive(Debug, Serialize)]
564 diff --git a/src/web2/util.rs b/src/web2/util.rs
565index 79b1f3e..5ad6260 100644
566--- a/src/web2/util.rs
567+++ b/src/web2/util.rs
568 @@ -55,145 +55,6 @@ pub fn lfs_url(template: &str, collection: &str, name: &str, oid: &str) -> Strin
569 url.replace("{oid}", oid)
570 }
571
572- pub mod navigation {
573-
574- pub type Items = Vec<(String, String, bool)>;
575-
576- pub fn global(current_page: &str, mail_visible: bool) -> Items {
577- let mut nav: Items = vec![
578- (
579- String::from("about"),
580- String::from("/about"),
581- current_page == "about",
582- ),
583- (
584- String::from("config"),
585- String::from("/config"),
586- current_page == "config",
587- ),
588- ];
589- if mail_visible {
590- nav.push((
591- String::from("mail"),
592- String::from("/mail"),
593- current_page == "mail",
594- ))
595- }
596- nav
597- }
598-
599- pub fn primary(current_page: &str, collection: &str, name: &str) -> Items {
600- vec![
601- (
602- String::from("authors"),
603- format!("/{}/{}/authors", collection, name,),
604- current_page == "authors",
605- ),
606- (
607- String::from("bugs"),
608- format!("/{}/{}/bugs", collection, name),
609- current_page == "bugs",
610- ),
611- (
612- String::from("charts"),
613- format!("/{}/{}/charts", collection, name),
614- current_page == "charts",
615- ),
616- (
617- String::from("log"),
618- format!("/{}/{}/log", collection, name),
619- current_page == "log",
620- ),
621- (
622- String::from("project"),
623- format!("/{}/{}", collection, name),
624- current_page == "project",
625- ),
626- (
627- String::from("refs"),
628- format!("/{}/{}/refs", collection, name),
629- current_page == "refs",
630- ),
631- ]
632- }
633-
634- pub fn subnav(
635- current_page: &str,
636- collection: &str,
637- name: &str,
638- file_path: &str,
639- ref_name: &str,
640- commit_id: &str,
641- ) -> Items {
642- vec![
643- (
644- String::from("blob"),
645- format!("/{}/{}/blob/{}/{}", collection, name, ref_name, file_path,),
646- current_page == "blob",
647- ),
648- (
649- String::from("blame"),
650- format!("/{}/{}/blame/{}/{}", collection, name, ref_name, file_path),
651- current_page == "blame",
652- ),
653- (
654- String::from("log"),
655- format!("/{}/{}/log/{}/{}", collection, name, ref_name, file_path,),
656- current_page == "log",
657- ),
658- (
659- String::from("permalink"),
660- format!(
661- "/{}/{}/{}/{}/{}",
662- collection, name, current_page, commit_id, file_path
663- ),
664- false,
665- ),
666- (
667- String::from("raw"),
668- format!("/{}/{}/raw/{}/{}", collection, name, ref_name, file_path),
669- false,
670- ),
671- ]
672- }
673-
674- pub fn chartnav(
675- current_page: &str,
676- collection: &str,
677- name: &str,
678- git_hash: Option<&str>,
679- ) -> Items {
680- let commit_path = git_hash.map_or(String::new(), |hash| String::from("/") + hash);
681- vec![
682- (
683- String::from("activity"),
684- format!("/{}/{}/chart/activity{}", collection, name, commit_path),
685- current_page == "activity",
686- ),
687- (
688- String::from("languages"),
689- format!("/{}/{}/chart/languages{}", collection, name, commit_path),
690- current_page == "languages",
691- ),
692- ]
693- }
694-
695- pub fn revnav(current_page: &str, collection: &str, name: &str) -> Items {
696- vec![
697- (
698- String::from("tags"),
699- format!("/{}/{}/refs/tags", collection, name),
700- current_page == "tags",
701- ),
702- (
703- String::from("branches"),
704- format!("/{}/{}/refs/branches", collection, name),
705- current_page == "branches",
706- ),
707- ]
708- }
709- }
710-
711 const UNIT: f64 = 1024.0;
712 const SUFFIX: [&str; 4] = ["B", "KiB", "MiB", "GiB"];
713