From 74cd345f76dd01034c804f75e7f16b42e9c0643c Mon Sep 17 00:00:00 2001 From: Christoph Schlosser Date: Thu, 18 Sep 2025 22:05:48 +0200 Subject: g2h: Add breadcrumb navigations to file and tree pages --- g2h/file.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'g2h/file.py') diff --git a/g2h/file.py b/g2h/file.py index 8f683cd..e07f251 100644 --- a/g2h/file.py +++ b/g2h/file.py @@ -1,5 +1,16 @@ import os +def generate_breadcrumbs(content_subdir, commit, dir, files): + breadcrumbs = '[/](/{})'.format(os.path.join(content_subdir, tree_join(commit, ''))) + subpath = '' + for segment in dir.split(os.sep): + if not segment or len(segment) == 0: + continue + subpath = os.path.join(subpath, sanitize_file_name(segment, files)) + breadcrumbs += '/[{}](/{})'.format(segment, os.path.join(content_subdir, tree_join(commit, subpath))) + return breadcrumbs + + def sanitize_file_name(file_name, files): if not file_name.startswith('.'): return file_name -- cgit v1.2.3