fix(org-wiki): remove duplicated nav menu, fix intra-wiki links
Universal: PR Check / Branch Policy (pull_request) Failing after 2s
Generic: Project CI / Lint & Validate (pull_request) Successful in 48s
Universal: PR Check / Validate PR (pull_request) Successful in 12s
Generic: Repo Health / Access control (pull_request) Successful in 2s
Generic: Repo Health / Site Health (pull_request) Has been skipped
Generic: Standards Compliance / Secret Scanning (pull_request) Failing after 13s
Generic: Standards Compliance / License Header Validation (pull_request) Successful in 12s
Generic: Standards Compliance / Repository Structure Validation (pull_request) Successful in 10s
PR RC Release / Build RC Release (pull_request) Successful in 1m51s
Generic: Standards Compliance / Coding Standards Check (pull_request) Successful in 12s
Universal: PR Check / Secret Scan (pull_request) Successful in 1m41s
Generic: Standards Compliance / Workflow Configuration Check (pull_request) Failing after 9s
Generic: Standards Compliance / Documentation Quality Check (pull_request) Successful in 9s
Generic: Standards Compliance / README Completeness Check (pull_request) Failing after 8s
Generic: Standards Compliance / Script Integrity Validation (pull_request) Successful in 10s
Generic: Standards Compliance / Line Length Check (pull_request) Successful in 22s
Generic: Standards Compliance / File Naming Standards (pull_request) Successful in 9s
Generic: Standards Compliance / Version Consistency Check (pull_request) Successful in 1m10s
Generic: Standards Compliance / Insecure Code Pattern Detection (pull_request) Successful in 9s
Universal: Auto Version Bump / Version Bump (push) Successful in 16s
Generic: Standards Compliance / Git Repository Hygiene (pull_request) Successful in 1m26s
Generic: Standards Compliance / Dead Code Detection (pull_request) Successful in 10s
Generic: Standards Compliance / File Size Limits (pull_request) Successful in 7s
Generic: Standards Compliance / Code Complexity Analysis (pull_request) Successful in 1m7s
Generic: Standards Compliance / Code Duplication Detection (pull_request) Successful in 1m4s
Generic: Standards Compliance / TODO/FIXME Tracking (pull_request) Successful in 8s
Universal: Pre-Release / Build Pre-Release (${{ inputs.stability || github.ref_name }}) (push) Successful in 1m14s
Universal: Build & Release / Promote to RC (pull_request) Has been skipped
Universal: Build & Release / Build & Release Pipeline (pull_request) Has been skipped
Generic: Standards Compliance / Dependency Vulnerability Scanning (pull_request) Successful in 1m4s
Generic: Standards Compliance / Unused Dependencies Check (pull_request) Successful in 1m3s
Generic: Standards Compliance / Broken Link Detection (pull_request) Successful in 12s
Generic: Standards Compliance / API Documentation Coverage (pull_request) Successful in 9s
Generic: Standards Compliance / Accessibility Check (pull_request) Successful in 9s
Generic: Standards Compliance / Performance Metrics (pull_request) Successful in 8s
Generic: Standards Compliance / Binary File Detection (pull_request) Successful in 2m0s
Generic: Standards Compliance / Terraform Configuration Validation (pull_request) Successful in 14s
Generic: Standards Compliance / Enterprise Readiness Check (pull_request) Successful in 54s
Branch Cleanup / Delete merged branch (pull_request) Has been skipped
RC Revert / Rename rc/ back to dev/ (pull_request) Has been skipped
Generic: Standards Compliance / Repository Health Check (pull_request) Successful in 54s
Deploy (RC) / Build & Deploy to RC (push) Failing after 1m27s
Generic: Project CI / Tests (pull_request) Has been cancelled
Universal: PR Check / Build RC Package (pull_request) Has been cancelled
Universal: PR Check / Report Issues (pull_request) Has been cancelled
Generic: Repo Health / Scripts governance (pull_request) Has been cancelled
Generic: Repo Health / Repository health (pull_request) Has been cancelled
Generic: Repo Health / Report: Scripts Governance (pull_request) Has been cancelled
Generic: Repo Health / Report: Repository Health (pull_request) Has been cancelled
Generic: Standards Compliance / Compliance Summary (pull_request) Has been cancelled

- view.tmpl rendered both org/header (which already includes org/menu)
  and org/menu -> the org navigation bar showed twice. Drop the redundant
  org/menu include to match every other org page.
- Wiki content was rendered with a RepoFile context, so intra-wiki links
  pointed at /{owner}/{repo}/src/branch/main/PATH (repo file browser,
  missing .md -> 404). Rewrite rendered links (content/sidebar/footer) to
  /{owner}/-/wiki/PATH, which also hides the underlying wiki repo name.
- Reword empty-state hint to public / members-only wording.

Claude-Session: https://claude.ai/code/session_01Bqe7fAuHQeiLueYfeHFrHw
This commit is contained in:
2026-07-14 21:03:40 -05:00
parent c3b4418216
commit d73a40b734
2 changed files with 24 additions and 5 deletions
+23 -2
View File
@@ -4,8 +4,10 @@
package org
import (
htmltemplate "html/template"
"net/http"
"path"
"regexp"
"strings"
"code.mokoconsulting.tech/MokoConsulting/MokoGitea/models/renderhelper"
@@ -114,6 +116,11 @@ func Wiki(ctx *context.Context) {
ctx.ServerError("RenderString", err)
return
}
// Intra-wiki links render as repo-file URLs (/{owner}/{repo}/src/branch/...).
// Rewrite them to the org wiki route so they open the wiki viewer instead of
// the repo file browser, and don't leak the underlying wiki repo name.
wikiLinkBase := setting.AppSubURL + "/" + org.Name + "/-/wiki/"
renderedContent = rewriteOrgWikiLinks(renderedContent, wikiRepo, wikiLinkBase)
ctx.Data["WikiContent"] = renderedContent
// Render _Sidebar if it exists.
@@ -123,7 +130,7 @@ func Wiki(ctx *context.Context) {
if err == nil {
rendered, err := markdown.RenderString(rctx, sidebarContent)
if err == nil {
ctx.Data["WikiSidebarHTML"] = rendered
ctx.Data["WikiSidebarHTML"] = rewriteOrgWikiLinks(rendered, wikiRepo, wikiLinkBase)
}
}
}
@@ -135,7 +142,7 @@ func Wiki(ctx *context.Context) {
if err == nil {
rendered, err := markdown.RenderString(rctx, footerContent)
if err == nil {
ctx.Data["WikiFooterHTML"] = rendered
ctx.Data["WikiFooterHTML"] = rewriteOrgWikiLinks(rendered, wikiRepo, wikiLinkBase)
}
}
}
@@ -143,6 +150,20 @@ func Wiki(ctx *context.Context) {
ctx.HTML(http.StatusOK, tplOrgWiki)
}
// rewriteOrgWikiLinks rewrites links produced by the RepoFile render context
// (/{owner}/{repo}/src/branch/{branch}/PATH) into org wiki routes
// (/{owner}/-/wiki/PATH), stripping a trailing .md, so intra-wiki links open the
// wiki viewer instead of the repo file browser.
func rewriteOrgWikiLinks(html htmltemplate.HTML, wikiRepo *repo_model.Repository, wikiBase string) htmltemplate.HTML {
prefix := wikiRepo.Link() + "/src/branch/" + util.PathEscapeSegments(wikiRepo.DefaultBranch) + "/"
re := regexp.MustCompile(`href="` + regexp.QuoteMeta(prefix) + `([^"#?]*)([^"]*)"`)
out := re.ReplaceAllStringFunc(string(html), func(m string) string {
sm := re.FindStringSubmatch(m)
return `href="` + wikiBase + strings.TrimSuffix(sm[1], ".md") + sm[2] + `"`
})
return htmltemplate.HTML(out)
}
// buildOrgWikiTree builds a hierarchical folder tree from the org wiki git repo.
// Shows up to 2 levels deep (folders and their immediate children).
func buildOrgWikiTree(commit *git.Commit) []*OrgWikiTreeNode {
+1 -3
View File
@@ -1,7 +1,6 @@
{{template "base/head" .}}
<div role="main" aria-label="{{.Title}}" class="page-content organization wiki">
{{template "org/header" .}}
{{template "org/menu" .}}
<div class="ui container">
{{if .WikiEmpty}}
<div class="ui placeholder segment">
@@ -11,8 +10,7 @@
This organization doesn't have a wiki yet.
</div>
<p class="tw-text-center">
Enable the wiki on the <code>.mokogitea</code> (public) or <code>.mokogitea-private</code> (members-only)
repository to get started.
Enable a <strong>public</strong> or <strong>members-only</strong> wiki for this organization to get started.
</p>
</div>
{{else}}