diff options
author | Arthur Zamarin <arthurzam@gentoo.org> | 2023-04-25 13:49:19 +0300 |
---|---|---|
committer | Arthur Zamarin <arthurzam@gentoo.org> | 2023-04-25 13:49:19 +0300 |
commit | 58a590a0ea32adea2866ea0937a1483667e66f35 (patch) | |
tree | 71b961e4bc32f879f3dc9dfe4b5f9642e35de59a /web | |
parent | updater/repology: truncate table only if repology responded (diff) | |
download | soko-58a590a0ea32adea2866ea0937a1483667e66f35.tar.gz soko-58a590a0ea32adea2866ea0937a1483667e66f35.tar.bz2 soko-58a590a0ea32adea2866ea0937a1483667e66f35.zip |
app/packages: move logic from template to Go
Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
Diffstat (limited to 'web')
-rw-r--r-- | web/templates/packages/components/qareport.tmpl | 21 | ||||
-rw-r--r-- | web/templates/packages/components/security.tmpl | 19 | ||||
-rw-r--r-- | web/templates/packages/packageheader.tmpl | 54 |
3 files changed, 34 insertions, 60 deletions
diff --git a/web/templates/packages/components/qareport.tmpl b/web/templates/packages/components/qareport.tmpl index 536e382..f8dff96 100644 --- a/web/templates/packages/components/qareport.tmpl +++ b/web/templates/packages/components/qareport.tmpl @@ -7,21 +7,18 @@ <li> <span class="text-muted">All Versions</span> <ul class="list-group"> - - {{ if .Package.PkgCheckResults }} - {{ range $.Package.PkgCheckResults }} - {{if $.UserPreferences.ContainsPkgcheckClass .Class}} - {{if not .Version}} + {{- if .Package.PkgCheckResults -}} + {{- range $.Package.PkgCheckResults -}} + {{- if $.UserPreferences.ContainsPkgcheckClass .Class -}} + {{- if not .Version -}} <li class="list-group-item"> <strong>{{ .Class }}</strong><br/> - <span class="kk-version kk-cell-sep-right text-muted"> - {{ .Message }} - </span> + <span class="kk-version kk-cell-sep-right text-muted">{{ .Message }}</span> </li> - {{end}} - {{end}} - {{end}} - {{end}} + {{- end -}} + {{- end -}} + {{- end -}} + {{- end -}} </ul> </li> diff --git a/web/templates/packages/components/security.tmpl b/web/templates/packages/components/security.tmpl index 8b4cd91..f9ff8c7 100644 --- a/web/templates/packages/components/security.tmpl +++ b/web/templates/packages/components/security.tmpl @@ -1,16 +1,7 @@ {{define "security"}} <div class="row"> <div class="col-md-9"> - - {{$security_bugs := 0}} - {{range .Package.AllBugs}} - {{if eq .Component "Vulnerabilities"}} - {{$security_bugs = (add $security_bugs 1)}} - {{end}} - {{end}} - - {{if $security_bugs}} - + {{- if .SecurityBugsCount -}} <h3 class="mb-4">Security Bug Reports</h3> <ul class="list-group"> {{range .Package.AllBugs}} @@ -29,9 +20,7 @@ {{end}} {{end}} </ul> - - {{else}} - + {{- else -}} <div class="row pt-5"> <div class="col-md-4"> <img style="width: 100%;" src="https://upload.wikimedia.org/wikipedia/commons/thumb/4/4f/Larry-the-cow-full.svg/1200px-Larry-the-cow-full.svg.png"/> @@ -41,9 +30,7 @@ <span>You think something is missing here? <br/> Start with filling a <a href="https://bugs.gentoo.org/">new security bug</a>.</span> </div> </div> - - {{end}} - + {{- end -}} </div> <div class="col-md-3 pt-5"> <h4> diff --git a/web/templates/packages/packageheader.tmpl b/web/templates/packages/packageheader.tmpl index 06a4ff0..1178d08 100644 --- a/web/templates/packages/packageheader.tmpl +++ b/web/templates/packages/packageheader.tmpl @@ -3,7 +3,6 @@ <div class="container"> <div class="row"> <div class="col-12"> - <div class="row mt-3"> <div class="col-md-5"> <h1 class="stick-top kk-package-title" id="package-title" data-atom="{{.Package.Atom}}" data-category="{{.Package.Category}}" data-name="{{.Package.Name}}"> @@ -16,52 +15,43 @@ </div> <div class="col-md-7"> <p class="lead kk-package-maindesc"> - {{(index .Versions 0).Description}} + {{- (index .Versions 0).Description -}} + </p> + {{ if (index .Versions 0).Homepage -}} + <p class="kk-package-homepage"> + <a href="{{ ( index (index .Versions 0).Homepage 0) }}">{{ ( index (index .Versions 0).Homepage 0) }}</a> </p> - {{if (index .Versions 0).Homepage}} - <p class="kk-package-homepage"> - <a href="{{ ( index (index .Versions 0).Homepage 0) }}">{{ ( index (index .Versions 0).Homepage 0) }}</a> - </p> - {{end}} + {{- end }} </div> - {{$security_bugs := 0}} - {{$non_security_bugs := 0}} - {{range .Package.AllBugs}} - {{if eq .Component "Vulnerabilities"}} - {{$security_bugs = (add $security_bugs 1)}} - {{else}} - {{$non_security_bugs = (add $non_security_bugs 1)}} - {{end}} - {{end}} <div class="col-md-12 pt-4 mt-1"> <nav class="nav kk-package-nav"> - {{if listContains $.UserPreferences.Packages.Tabs.Visible "Overview"}} + {{ if listContains $.UserPreferences.Packages.Tabs.Visible "Overview" -}} <a class="nav-link {{if eq .PageName "overview"}}active{{end}}" href="/packages/{{.Package.Atom}}"><i class="fa fa-info mr-1" aria-hidden="true"></i> Overview</a> - {{end}} + {{ end -}} - {{if listContains $.UserPreferences.Packages.Tabs.Visible "Dependencies"}} + {{- if listContains $.UserPreferences.Packages.Tabs.Visible "Dependencies" -}} <a class="nav-link {{if eq .PageName "dependencies" "reverse-dependencies"}}active{{end}}" href="/packages/{{.Package.Atom}}/{{.UserPreferences.Packages.Dependencies.Default}}"><i class="fa fa-link"></i> Dependencies</a> - {{end}} + {{ end}} - {{if listContains $.UserPreferences.Packages.Tabs.Visible "QA report"}} + {{- if listContains $.UserPreferences.Packages.Tabs.Visible "QA report" -}} <a class="nav-link {{if eq .PageName "qa-report"}}active{{end}}" href="/packages/{{.Package.Atom}}/qa-report"><i class="fa fa-fw fa-chain-broken"></i> QA report </a> - {{end}} + {{ end -}} - {{if listContains $.UserPreferences.Packages.Tabs.Visible "Pull requests"}} + {{- if listContains $.UserPreferences.Packages.Tabs.Visible "Pull requests" -}} <a class="nav-link {{if eq .PageName "pull-requests"}}active{{end}}" href="/packages/{{.Package.Atom}}/pull-requests"><span class="octicon octicon-git-pull-request opticon-resource-icon ml-1"></span> Pull requests <span class="ml-1 badge badge-pill kk-misc-badge">{{len .Package.PullRequests}}</span></a> - {{end}} + {{ end -}} - {{if listContains $.UserPreferences.Packages.Tabs.Visible "Bugs"}} - <a class="nav-link {{if eq .PageName "bugs"}}active{{end}}" href="/packages/{{.Package.Atom}}/bugs"><i class="fa fa-bug" aria-hidden="true"></i> Bugs <span class="ml-1 badge badge-pill kk-misc-badge">{{$non_security_bugs}}</span></a> - {{end}} + {{- if listContains $.UserPreferences.Packages.Tabs.Visible "Bugs" -}} + <a class="nav-link {{if eq .PageName "bugs"}}active{{end}}" href="/packages/{{.Package.Atom}}/bugs"><i class="fa fa-bug" aria-hidden="true"></i> Bugs <span class="ml-1 badge badge-pill kk-misc-badge">{{.NonSecurityBugsCount}}</span></a> + {{ end -}} - {{if listContains $.UserPreferences.Packages.Tabs.Visible "Security"}} - <a class="nav-link {{if eq .PageName "security"}}active{{end}}" href="/packages/{{.Package.Atom}}/security"><i class="fa fa-shield" aria-hidden="true"></i> Security <span class="ml-1 badge badge-pill kk-misc-badge">{{$security_bugs}}</span></a> - {{end}} + {{- if listContains $.UserPreferences.Packages.Tabs.Visible "Security" -}} + <a class="nav-link {{if eq .PageName "security"}}active{{end}}" href="/packages/{{.Package.Atom}}/security"><i class="fa fa-shield" aria-hidden="true"></i> Security <span class="ml-1 badge badge-pill kk-misc-badge">{{.SecurityBugsCount}}</span></a> + {{ end -}} - {{if listContains $.UserPreferences.Packages.Tabs.Visible "Changelog"}} + {{- if listContains $.UserPreferences.Packages.Tabs.Visible "Changelog" -}} <a class="nav-link {{if eq .PageName "changelog"}}active{{end}}" href="/packages/{{.Package.Atom}}/changelog"><i class="fa fa-fw fa-history"></i> Changelog</a> - {{end}} + {{- end }} </nav> </div> </div> |