FossilRepo
Rewrite fossil-scm.org/forum links to local forum view
Commit
893254eecec94dc6653697ecefc0473fb82792f7546f8faad67b611bd326dadc
Parent
c36c317aeaff2c2…
1 file changed
+10
+10
| --- fossil/views.py | ||
| +++ fossil/views.py | ||
| @@ -271,10 +271,20 @@ | ||
| 271 | 271 | if m: |
| 272 | 272 | return f'href="{base}/docs/{m.group(1)}"' |
| 273 | 273 | return match.group(0) |
| 274 | 274 | |
| 275 | 275 | html = re.sub(r'href="https?://(?:www\.)?fossil-scm\.org/home(/[^"]*)"', replace_external_fossil, html) |
| 276 | + | |
| 277 | + # Also rewrite fossil-scm.org/forum links to our local forum | |
| 278 | + def replace_external_forum(match): | |
| 279 | + path = match.group(1) | |
| 280 | + m = re.match(r"/forumpost/([0-9a-f]+)", path) | |
| 281 | + if m: | |
| 282 | + return f'href="{base}/forum/{m.group(1)}/"' | |
| 283 | + return f'href="{base}/forum/"' | |
| 284 | + | |
| 285 | + html = re.sub(r'href="https?://(?:www\.)?fossil-scm\.org/forum(/[^"]*)"', replace_external_forum, html) | |
| 276 | 286 | return html |
| 277 | 287 | |
| 278 | 288 | |
| 279 | 289 | def _get_repo_and_reader(slug): |
| 280 | 290 | """Return (project, fossil_repo, reader) or raise 404.""" |
| 281 | 291 |
| --- fossil/views.py | |
| +++ fossil/views.py | |
| @@ -271,10 +271,20 @@ | |
| 271 | if m: |
| 272 | return f'href="{base}/docs/{m.group(1)}"' |
| 273 | return match.group(0) |
| 274 | |
| 275 | html = re.sub(r'href="https?://(?:www\.)?fossil-scm\.org/home(/[^"]*)"', replace_external_fossil, html) |
| 276 | return html |
| 277 | |
| 278 | |
| 279 | def _get_repo_and_reader(slug): |
| 280 | """Return (project, fossil_repo, reader) or raise 404.""" |
| 281 |
| --- fossil/views.py | |
| +++ fossil/views.py | |
| @@ -271,10 +271,20 @@ | |
| 271 | if m: |
| 272 | return f'href="{base}/docs/{m.group(1)}"' |
| 273 | return match.group(0) |
| 274 | |
| 275 | html = re.sub(r'href="https?://(?:www\.)?fossil-scm\.org/home(/[^"]*)"', replace_external_fossil, html) |
| 276 | |
| 277 | # Also rewrite fossil-scm.org/forum links to our local forum |
| 278 | def replace_external_forum(match): |
| 279 | path = match.group(1) |
| 280 | m = re.match(r"/forumpost/([0-9a-f]+)", path) |
| 281 | if m: |
| 282 | return f'href="{base}/forum/{m.group(1)}/"' |
| 283 | return f'href="{base}/forum/"' |
| 284 | |
| 285 | html = re.sub(r'href="https?://(?:www\.)?fossil-scm\.org/forum(/[^"]*)"', replace_external_forum, html) |
| 286 | return html |
| 287 | |
| 288 | |
| 289 | def _get_repo_and_reader(slug): |
| 290 | """Return (project, fossil_repo, reader) or raise 404.""" |
| 291 |