Merge pull request 'fix: prod hotfixes - metadata Organization field + org wiki nav/links' (#789) from rc into main
Generic: Standards Compliance / Secret Scanning (push) Failing after 9s
Generic: Standards Compliance / License Header Validation (push) Successful in 9s
Generic: Standards Compliance / Repository Structure Validation (push) Successful in 8s
Generic: Standards Compliance / Coding Standards Check (push) Successful in 11s
Generic: Standards Compliance / Version Consistency Check (push) Successful in 1m28s
Generic: Standards Compliance / Workflow Configuration Check (push) Failing after 14s
Generic: Standards Compliance / Documentation Quality Check (push) Successful in 12s
Generic: Standards Compliance / README Completeness Check (push) Failing after 10s
Generic: Standards Compliance / Git Repository Hygiene (push) Successful in 2m2s
Generic: Standards Compliance / Script Integrity Validation (push) Successful in 19s
Generic: Standards Compliance / Line Length Check (push) Successful in 23s
Generic: Standards Compliance / File Naming Standards (push) Successful in 29s
Deploy (Prod) / Build & Deploy to Prod (push) Successful in 6m2s
Generic: Standards Compliance / Insecure Code Pattern Detection (push) Successful in 11s
Generic: Standards Compliance / Dead Code Detection (push) Successful in 10s
Generic: Standards Compliance / File Size Limits (push) Successful in 7s
Generic: Standards Compliance / Code Complexity Analysis (push) Successful in 54s
Generic: Standards Compliance / Code Duplication Detection (push) Successful in 55s
Generic: Standards Compliance / TODO/FIXME Tracking (push) Successful in 7s
Generic: Standards Compliance / Dependency Vulnerability Scanning (push) Successful in 56s
Generic: Standards Compliance / Unused Dependencies Check (push) Successful in 52s
Generic: Standards Compliance / API Documentation Coverage (push) Successful in 8s
Generic: Standards Compliance / Broken Link Detection (push) Successful in 11s
Generic: Standards Compliance / Binary File Detection (push) Successful in 1m38s
Generic: Standards Compliance / Accessibility Check (push) Successful in 6s
Generic: Standards Compliance / Performance Metrics (push) Successful in 6s
Generic: Standards Compliance / Terraform Configuration Validation (push) Successful in 19s
Generic: Standards Compliance / Enterprise Readiness Check (push) Successful in 53s
Generic: Standards Compliance / Repository Health Check (push) Successful in 59s
Generic: Standards Compliance / Compliance Summary (push) Has been cancelled
Generic: Standards Compliance / Secret Scanning (push) Failing after 9s
Generic: Standards Compliance / License Header Validation (push) Successful in 9s
Generic: Standards Compliance / Repository Structure Validation (push) Successful in 8s
Generic: Standards Compliance / Coding Standards Check (push) Successful in 11s
Generic: Standards Compliance / Version Consistency Check (push) Successful in 1m28s
Generic: Standards Compliance / Workflow Configuration Check (push) Failing after 14s
Generic: Standards Compliance / Documentation Quality Check (push) Successful in 12s
Generic: Standards Compliance / README Completeness Check (push) Failing after 10s
Generic: Standards Compliance / Git Repository Hygiene (push) Successful in 2m2s
Generic: Standards Compliance / Script Integrity Validation (push) Successful in 19s
Generic: Standards Compliance / Line Length Check (push) Successful in 23s
Generic: Standards Compliance / File Naming Standards (push) Successful in 29s
Deploy (Prod) / Build & Deploy to Prod (push) Successful in 6m2s
Generic: Standards Compliance / Insecure Code Pattern Detection (push) Successful in 11s
Generic: Standards Compliance / Dead Code Detection (push) Successful in 10s
Generic: Standards Compliance / File Size Limits (push) Successful in 7s
Generic: Standards Compliance / Code Complexity Analysis (push) Successful in 54s
Generic: Standards Compliance / Code Duplication Detection (push) Successful in 55s
Generic: Standards Compliance / TODO/FIXME Tracking (push) Successful in 7s
Generic: Standards Compliance / Dependency Vulnerability Scanning (push) Successful in 56s
Generic: Standards Compliance / Unused Dependencies Check (push) Successful in 52s
Generic: Standards Compliance / API Documentation Coverage (push) Successful in 8s
Generic: Standards Compliance / Broken Link Detection (push) Successful in 11s
Generic: Standards Compliance / Binary File Detection (push) Successful in 1m38s
Generic: Standards Compliance / Accessibility Check (push) Successful in 6s
Generic: Standards Compliance / Performance Metrics (push) Successful in 6s
Generic: Standards Compliance / Terraform Configuration Validation (push) Successful in 19s
Generic: Standards Compliance / Enterprise Readiness Check (push) Successful in 53s
Generic: Standards Compliance / Repository Health Check (push) Successful in 59s
Generic: Standards Compliance / Compliance Summary (push) Has been cancelled
This commit was merged in pull request #789.
This commit is contained in:
+23
-2
@@ -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="(?:https?://[^/"]+)?` + 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 {
|
||||
|
||||
@@ -40,9 +40,8 @@ func Metadata(ctx *context.Context) {
|
||||
}
|
||||
}
|
||||
ctx.Data["Manifest"] = manifest
|
||||
// Organization is derived from the org profile (repo owner), not stored.
|
||||
// It is displayed read-only. See issue #771.
|
||||
ctx.Data["DerivedOrg"] = ctx.Repo.Repository.DerivedOrgName(ctx)
|
||||
// Organization is derived from the org profile (repo owner), not stored,
|
||||
// and is no longer surfaced on the metadata page (redundant). See #771.
|
||||
|
||||
// Platform dropdown options come from the admin-configurable setting
|
||||
// (Admin -> Metadata). Keep the repo's current value selectable even if it
|
||||
|
||||
@@ -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}}
|
||||
|
||||
@@ -6,8 +6,7 @@
|
||||
<form class="ui form" method="post" action="{{.RepoLink}}/settings/metadata?action=manifest">
|
||||
{{.CsrfTokenHtml}}
|
||||
|
||||
<div class="two fields">
|
||||
<div class="field">
|
||||
<div class="field">
|
||||
{{if eq .Manifest.Platform "joomla"}}
|
||||
<label>Element Name</label>
|
||||
<input name="name" value="{{.Manifest.Name}}" placeholder="e.g. mokowaas">
|
||||
@@ -16,12 +15,6 @@
|
||||
<input name="name" value="{{.Manifest.Name}}" placeholder="Project name">
|
||||
{{end}}
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>Organization</label>
|
||||
<input value="{{.DerivedOrg}}" placeholder="Organization" readonly>
|
||||
<p class="help">Derived from the organization profile (repository owner).</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="three fields">
|
||||
<div class="field">
|
||||
<label>Version Prefix</label>
|
||||
|
||||
Reference in New Issue
Block a user