2
0
Files
gitcaddy-server/templates/repo/view_content.tmpl
logikonline 8806fcecba
Some checks failed
Build and Release / Create Release (push) Successful in 0s
Build and Release / Unit Tests (push) Successful in 3m19s
Build and Release / Integration Tests (PostgreSQL) (push) Successful in 4m39s
Build and Release / Lint (push) Successful in 4m46s
Build and Release / Build Binary (linux/arm64) (push) Has been cancelled
Build and Release / Build Binaries (amd64, linux, linux-latest) (push) Has been cancelled
Build and Release / Build Binaries (amd64, windows, windows-latest) (push) Has been cancelled
Build and Release / Build Binaries (amd64, darwin, macos) (push) Has been cancelled
Build and Release / Build Binaries (arm64, darwin, macos) (push) Has been cancelled
docs(detached-note): add comprehensive API reference and user guide
Add API.md (3200+ lines) with complete REST API documentation covering authentication, repository management, issues, pull requests, organizations, package registry, Actions, and Vault APIs. Includes code examples and error handling.

Add GUIDE.md with user-focused documentation for getting started, repository operations, collaboration workflows, and CI/CD setup.

Implement documentation tab in repository view with automatic detection and rendering of API.md and GUIDE.md files alongside README. Add locale strings and template for doc tab navigation.
2026-01-27 22:43:56 -05:00

195 lines
8.6 KiB
Handlebars

{{$isTreePathRoot := not .TreeNames}}
<div class="repo-view-content-data tw-hidden" data-document-title="{{ctx.RootData.Title}}" data-document-title-common="{{ctx.RootData.PageTitleCommon}}"></div>
{{template "repo/sub_menu" .}}
<div class="repo-button-row">
<div class="repo-button-row-left">
{{if not $isTreePathRoot}}
{{template "repo/view_file_tree_toggle_button" .}}
{{end}}
{{template "repo/branch_dropdown" dict
"Repository" .Repository
"ShowTabBranches" true
"ShowTabTags" true
"CurrentRefType" .RefFullName.RefType
"CurrentRefShortName" .RefFullName.ShortName
"CurrentTreePath" .TreePath
"RefLinkTemplate" "{RepoLink}/src/{RefType}/{RefShortName}/{TreePath}"
"AllowCreateNewRef" .CanCreateBranch
"ShowViewAllRefsEntry" true
}}
{{if and .CanCompareOrPull .RefFullName.IsBranch (not .Repository.IsArchived)}}
{{$cmpBranch := ""}}
{{if ne .Repository.ID .BaseRepo.ID}}
{{$cmpBranch = printf "%s/%s:" (.Repository.OwnerName|PathEscape) (.Repository.Name|PathEscape)}}
{{end}}
{{$cmpBranch = print $cmpBranch (.BranchName|PathEscapeSegments)}}
{{$compareLink := printf "%s/compare/%s...%s" .BaseRepo.Link (.BaseRepo.DefaultBranch|PathEscapeSegments) $cmpBranch}}
<a id="new-pull-request" role="button" class="ui compact basic button" href="{{QueryBuild $compareLink "expand" 1}}"
data-tooltip-content="{{if .PullRequestCtx.Allowed}}{{ctx.Locale.Tr "repo.pulls.compare_changes"}}{{else}}{{ctx.Locale.Tr "action.compare_branch"}}{{end}}">
{{svg "octicon-git-pull-request"}}
</a>
{{end}}
{{if and $isTreePathRoot .Repository.IsTemplate}}
<a role="button" class="ui primary compact button" href="{{AppSubUrl}}/repo/create?template_id={{.Repository.ID}}">
{{ctx.Locale.Tr "repo.use_template"}}
</a>
{{end}}
{{if not $isTreePathRoot}}
{{$treeNameIdxLast := Eval (len .TreeNames) "-" 1}}
<span class="breadcrumb">
<a class="section" href="{{.RepoLink}}/src/{{.RefTypeNameSubURL}}" title="{{.Repository.Name}}">{{StringUtils.EllipsisString .Repository.Name 30}}</a>
{{- range $i, $v := .TreeNames -}}
<span class="breadcrumb-divider">/</span>
{{- if eq $i $treeNameIdxLast -}}
<span class="active section" title="{{$v}}">{{$v}}</span>
<button class="btn interact-fg tw-mx-1" data-clipboard-text="{{$.TreePath}}" data-tooltip-content="{{ctx.Locale.Tr "copy_path"}}">{{svg "octicon-copy" 14}}</button>
{{- else -}}
{{$p := index $.Paths $i}}<span class="section"><a href="{{$.BranchLink}}/{{PathEscapeSegments $p}}" title="{{$v}}">{{$v}}</a></span>
{{- end -}}
{{- end -}}
</span>
{{end}}
</div>
<div class="repo-button-row-right">
<div class="repo-file-search-container"
data-global-init="initRepoFileSearch"
data-repo-link="{{.RepoLink}}"
data-current-ref-name-sub-url="{{.RefTypeNameSubURL}}"
data-tree-list-url="{{.RepoLink}}/tree-list/{{.RefTypeNameSubURL}}"
data-no-results-text="{{ctx.Locale.Tr "repo.find_file.no_matching"}}"
data-placeholder="{{ctx.Locale.Tr "repo.find_file.go_to_file"}}"
></div>
{{if .RefFullName.IsBranch}}
{{$addFilePath := .TreePath}}
{{if .IsViewFile}}
{{if gt (len .TreeNames) 1}}
{{$addFilePath = StringUtils.Join (slice .TreeNames 0 (Eval (len .TreeNames) "-" 1)) "/"}}
{{else}}
{{$addFilePath = ""}}
{{end}}
{{end}}
<button class="ui dropdown basic compact jump button repo-add-file" {{if not .Repository.CanEnableEditor}}disabled{{end}}>
{{ctx.Locale.Tr "repo.editor.add_file"}}
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
<div class="menu">
<a class="item" href="{{.RepoLink}}/_new/{{.BranchName | PathEscapeSegments}}/{{$addFilePath | PathEscapeSegments}}">
{{svg "octicon-file-added" 16 "tw-mr-2"}}{{ctx.Locale.Tr "repo.editor.new_file"}}
</a>
{{if .RepositoryUploadEnabled}}
<a class="item" href="{{.RepoLink}}/_upload/{{.BranchName | PathEscapeSegments}}/{{$addFilePath | PathEscapeSegments}}">
{{svg "octicon-upload" 16 "tw-mr-2"}}{{ctx.Locale.Tr "repo.editor.upload_file"}}
</a>
{{end}}
<a class="item" href="{{.RepoLink}}/_diffpatch/{{.BranchName | PathEscapeSegments}}/{{$addFilePath | PathEscapeSegments}}">
{{svg "octicon-diff" 16 "tw-mr-2"}}{{ctx.Locale.Tr "repo.editor.patch"}}
</a>
</div>
</button>
{{if and (not .IsViewFile) (not $isTreePathRoot)}}
<button class="ui dropdown basic compact jump button tw-px-3" data-tooltip-content="{{ctx.Locale.Tr "repo.more_operations"}}">
{{svg "octicon-kebab-horizontal"}}
<div class="menu">
<a class="item" data-clipboard-text="{{.Repository.Link}}/src/commit/{{.CommitID}}/{{PathEscapeSegments .TreePath}}" data-clipboard-text-type="url">
{{svg "octicon-link" 16}}{{ctx.Locale.Tr "repo.file_copy_permalink"}}
</a>
{{if and (.Permission.CanWrite ctx.Consts.RepoUnitTypeCode) (not .Repository.IsArchived) (not $isTreePathRoot)}}
<div class="divider"></div>
<a class="item tw-text-danger" href="{{.RepoLink}}/_delete/{{.BranchName | PathEscapeSegments}}/{{.TreePath | PathEscapeSegments}}">
{{svg "octicon-trash" 16}}{{ctx.Locale.Tr "repo.editor.delete_this_directory"}}
</a>
{{end}}
</div>
</button>
{{end}}
{{end}}
<!-- Only show clone panel in repository home page -->
{{if $isTreePathRoot}}
{{template "repo/clone_panel" .}}
{{end}}
{{if and (not $isTreePathRoot) (not .IsViewFile) (not .IsBlame)}}{{/* IsViewDirectory (not home), TODO: split the templates, avoid using "if" tricks */}}
<a class="ui compact button" href="{{.RepoLink}}/commits/{{.RefTypeNameSubURL}}/{{.TreePath | PathEscapeSegments}}">
{{svg "octicon-history" 16 "tw-mr-2"}}{{ctx.Locale.Tr "repo.file_history"}}
</a>
{{end}}
</div>
</div>
{{if .IsViewFile}}
{{template "repo/view_file" .}}
{{else if .IsBlame}}
{{template "repo/blame" .}}
{{else}}{{/* IsViewDirectory */}}
{{if $isTreePathRoot}}
{{template "repo/code/upstream_diverging_info" .}}
{{end}}
{{template "repo/view_list" .}}
{{/* Tabs for Readme, Guide, API, License, Gallery - only shown at repo root */}}
{{$hasReadme := and .ReadmeExist (or .IsMarkup .IsPlainText)}}
{{if and $isTreePathRoot (or $hasReadme .GuideTabExist .APIDocTabExist .LicenseTabExist .GalleryTabExist)}}
<div class="ui top attached tabular menu" id="repo-home-tabs">
{{if $hasReadme}}
<a class="active item" data-tab="readme">
{{svg "octicon-book" 16}} {{ctx.Locale.Tr "repo.readme"}}
</a>
{{end}}
{{if .GuideTabExist}}
<a class="{{if not $hasReadme}}active {{end}}item" data-tab="guide">
{{svg "octicon-mortar-board" 16}} {{ctx.Locale.Tr "repo.guide"}}
</a>
{{end}}
{{if .APIDocTabExist}}
<a class="{{if and (not $hasReadme) (not .GuideTabExist)}}active {{end}}item" data-tab="apidoc">
{{svg "octicon-plug" 16}} {{ctx.Locale.Tr "repo.api_doc"}}
</a>
{{end}}
{{if .LicenseTabExist}}
<a class="{{if and (not $hasReadme) (not .GuideTabExist) (not .APIDocTabExist)}}active {{end}}item" data-tab="license">
{{svg "octicon-law" 16}} {{ctx.Locale.Tr "repo.license"}}
</a>
{{end}}
{{if .GalleryTabExist}}
<a class="{{if and (not $hasReadme) (not .GuideTabExist) (not .APIDocTabExist) (not .LicenseTabExist)}}active {{end}}item" data-tab="gallery">
{{svg "octicon-image" 16}} {{ctx.Locale.Tr "repo.gallery"}}
</a>
{{end}}
</div>
<div class="ui bottom attached segment tw-p-0">
{{if $hasReadme}}
<div class="ui active tab" data-tab="readme">
{{template "repo/view_file" .}}
</div>
{{end}}
{{if .GuideTabExist}}
<div class="ui {{if not $hasReadme}}active {{end}}tab" data-tab="guide">
{{template "repo/view_doc_tab" dict "ctxData" . "FileName" .GuideTabFileName "Content" .GuideTabContent "IsMarkdown" .GuideTabIsMarkdown "Icon" "octicon-mortar-board"}}
</div>
{{end}}
{{if .APIDocTabExist}}
<div class="ui {{if and (not $hasReadme) (not .GuideTabExist)}}active {{end}}tab" data-tab="apidoc">
{{template "repo/view_doc_tab" dict "ctxData" . "FileName" .APIDocTabFileName "Content" .APIDocTabContent "IsMarkdown" .APIDocTabIsMarkdown "Icon" "octicon-plug"}}
</div>
{{end}}
{{if .LicenseTabExist}}
<div class="ui {{if and (not $hasReadme) (not .GuideTabExist) (not .APIDocTabExist)}}active {{end}}tab" data-tab="license">
{{template "repo/view_license_tab" .}}
</div>
{{end}}
{{if .GalleryTabExist}}
<div class="ui {{if and (not $hasReadme) (not .GuideTabExist) (not .APIDocTabExist) (not .LicenseTabExist)}}active {{end}}tab" data-tab="gallery">
{{template "repo/view_gallery_tab" .}}
</div>
{{end}}
</div>
{{else if $hasReadme}}
{{/* Fallback: show README without tabs if it's the only content */}}
{{template "repo/view_file" .}}
{{end}}
{{end}}