FossilRepo

Fix doc directory links and index file fallback - Directory-style links (www/caps/) fall back to index.html/md/wiki - Strip trailing slashes before file lookup - Fossil /setup_* routes left as-is (no good mapping) - Fixes "Back to Administering" link in www/caps/ref.html

lmata 2026-04-06 23:59 trunk
Commit 8c43f6668a54c68e3cee57ff0c119b6552726b55b5e84135a7050a66ae09daa3
1 file changed +17 -1
+17 -1
--- fossil/views.py
+++ fossil/views.py
@@ -161,10 +161,13 @@
161161
return f'href="{base}/docs/www/help.wiki"'
162162
# Bare .wiki or .md file paths (from relative link resolution)
163163
m = re.match(r"/([^/]+\.(?:wiki|md|html))", url)
164164
if m:
165165
return f'href="{base}/docs/www/{m.group(1)}"'
166
+ # /setup_*, /admin_* -> these are Fossil server routes, link to admin
167
+ if re.match(r"/(setup_|admin_)", url):
168
+ return match.group(0) # Keep as-is, no good mapping
166169
# Keep external and unrecognized links as-is
167170
return match.group(0)
168171
169172
def replace_scheme_link(match):
170173
"""Handle Fossil URI schemes like forum:/forumpost/HASH, wiki:PageName, info:HASH."""
@@ -770,14 +773,27 @@
770773
with reader:
771774
checkin_uuid = reader.get_latest_checkin_uuid()
772775
files = reader.get_files_at_checkin(checkin_uuid) if checkin_uuid else []
773776
774777
target = None
778
+ # Strip trailing slash for directory-style links
779
+ clean_path = doc_path.rstrip("/")
775780
for f in files:
776
- if f.name == doc_path:
781
+ if f.name == clean_path:
777782
target = f
778783
break
784
+
785
+ # If not found, try index files for directory links
786
+ if not target:
787
+ for index_name in [f"{clean_path}/index.html", f"{clean_path}/index.md", f"{clean_path}/index.wiki"]:
788
+ for f in files:
789
+ if f.name == index_name:
790
+ target = f
791
+ doc_path = index_name
792
+ break
793
+ if target:
794
+ break
779795
780796
if not target:
781797
raise Http404(f"Documentation file not found: {doc_path}")
782798
783799
content_bytes = reader.get_file_content(target.uuid)
784800
--- fossil/views.py
+++ fossil/views.py
@@ -161,10 +161,13 @@
161 return f'href="{base}/docs/www/help.wiki"'
162 # Bare .wiki or .md file paths (from relative link resolution)
163 m = re.match(r"/([^/]+\.(?:wiki|md|html))", url)
164 if m:
165 return f'href="{base}/docs/www/{m.group(1)}"'
 
 
 
166 # Keep external and unrecognized links as-is
167 return match.group(0)
168
169 def replace_scheme_link(match):
170 """Handle Fossil URI schemes like forum:/forumpost/HASH, wiki:PageName, info:HASH."""
@@ -770,14 +773,27 @@
770 with reader:
771 checkin_uuid = reader.get_latest_checkin_uuid()
772 files = reader.get_files_at_checkin(checkin_uuid) if checkin_uuid else []
773
774 target = None
 
 
775 for f in files:
776 if f.name == doc_path:
777 target = f
778 break
 
 
 
 
 
 
 
 
 
 
 
779
780 if not target:
781 raise Http404(f"Documentation file not found: {doc_path}")
782
783 content_bytes = reader.get_file_content(target.uuid)
784
--- fossil/views.py
+++ fossil/views.py
@@ -161,10 +161,13 @@
161 return f'href="{base}/docs/www/help.wiki"'
162 # Bare .wiki or .md file paths (from relative link resolution)
163 m = re.match(r"/([^/]+\.(?:wiki|md|html))", url)
164 if m:
165 return f'href="{base}/docs/www/{m.group(1)}"'
166 # /setup_*, /admin_* -> these are Fossil server routes, link to admin
167 if re.match(r"/(setup_|admin_)", url):
168 return match.group(0) # Keep as-is, no good mapping
169 # Keep external and unrecognized links as-is
170 return match.group(0)
171
172 def replace_scheme_link(match):
173 """Handle Fossil URI schemes like forum:/forumpost/HASH, wiki:PageName, info:HASH."""
@@ -770,14 +773,27 @@
773 with reader:
774 checkin_uuid = reader.get_latest_checkin_uuid()
775 files = reader.get_files_at_checkin(checkin_uuid) if checkin_uuid else []
776
777 target = None
778 # Strip trailing slash for directory-style links
779 clean_path = doc_path.rstrip("/")
780 for f in files:
781 if f.name == clean_path:
782 target = f
783 break
784
785 # If not found, try index files for directory links
786 if not target:
787 for index_name in [f"{clean_path}/index.html", f"{clean_path}/index.md", f"{clean_path}/index.wiki"]:
788 for f in files:
789 if f.name == index_name:
790 target = f
791 doc_path = index_name
792 break
793 if target:
794 break
795
796 if not target:
797 raise Http404(f"Documentation file not found: {doc_path}")
798
799 content_bytes = reader.get_file_content(target.uuid)
800

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button