Skip to content

Commit

Permalink
Add tooltip feature with necessary files only
Browse files Browse the repository at this point in the history
  • Loading branch information
crocmons committed Oct 25, 2024
1 parent efffc3d commit 94efbd3
Show file tree
Hide file tree
Showing 2 changed files with 127 additions and 111 deletions.
5 changes: 5 additions & 0 deletions assets/js/registrySearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,3 +239,8 @@ function parseUrlParams() {
selectedLanguage = urlParams.get('language') || 'all';
selectedComponent = urlParams.get('component') || 'all';
}

var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
return new bootstrap.Tooltip(tooltipTriggerEl)
})
233 changes: 122 additions & 111 deletions layouts/partials/ecosystem/registry/entry.html
Original file line number Diff line number Diff line change
@@ -1,95 +1,100 @@
{{ $languageNames := .languageNames -}}

{{ with .value -}}
{{
$remoteRegistries := dict
"npm" (dict
"urlPattern" "https://npmjs.com/package/%s"
"installTemplate" "ecosystem/registry/quickinstall/default.md"
"installLine" "npm install %s"
"icon" "fab fa-npm")
"packagist" (dict
"urlPattern" "https://packagist.org/packages/%s"
"installLine" "composer require %s"
"installTemplate" "ecosystem/registry/quickinstall/default.md"
"icon" "fa-solid fa-box-open")
"gems" (dict
"urlPattern" "https://rubygems.org/gems/%s"
"installLine" "gem install %s"
"installTemplate" "ecosystem/registry/quickinstall/default.md"
"icon" "fa-solid fa-gem")
"go" (dict
"urlPattern" "https://pkg.go.dev/%s"
"installLine" "go get %s"
"installTemplate" "ecosystem/registry/quickinstall/default.md"
"icon" "fa-brands fa-golang")
"go-collector" (dict
"urlPattern" "https://pkg.go.dev/%s"
"installTemplate" "ecosystem/registry/quickinstall/collector.md"
"icon" "fa-solid fa-box-open")
"nuget" (dict
"urlPattern" "https://www.nuget.org/packages/%s"
"installLine" "dotnet add package %s"
"installTemplate" "ecosystem/registry/quickinstall/default.md"
"icon" "fa-solid fa-box-open")
"pip" (dict
"urlPattern" "https://pypi.org/project/%s"
"installLine" "pip install %s"
"installTemplate" "ecosystem/registry/quickinstall/default.md"
"icon" "fa-brands fa-python")
"hex" (dict
"urlPattern" "https://hex.pm/packages/%s"
"installTemplate" "ecosystem/registry/quickinstall/hex.md"
"icon" "fa-brands fa-erlang")
"crates" (dict
"urlPattern" "https://crates.io/crates/%s"
"installLine" "cargo add %s"
"installTemplate" "ecosystem/registry/quickinstall/default.md"
"icon" "fab fa-rust")
-}}
{{
$remoteRegistries := dict
"npm" (dict
"urlPattern" "https://npmjs.com/package/%s"
"installTemplate" "ecosystem/registry/quickinstall/default.md"
"installLine" "npm install %s"
"icon" "fab fa-npm")
"packagist" (dict
"urlPattern" "https://packagist.org/packages/%s"
"installLine" "composer require %s"
"installTemplate" "ecosystem/registry/quickinstall/default.md"
"icon" "fa-solid fa-box-open")
"gems" (dict
"urlPattern" "https://rubygems.org/gems/%s"
"installLine" "gem install %s"
"installTemplate" "ecosystem/registry/quickinstall/default.md"
"icon" "fa-solid fa-gem")
"go" (dict
"urlPattern" "https://pkg.go.dev/%s"
"installLine" "go get %s"
"installTemplate" "ecosystem/registry/quickinstall/default.md"
"icon" "fa-brands fa-golang")
"go-collector" (dict
"urlPattern" "https://pkg.go.dev/%s"
"installTemplate" "ecosystem/registry/quickinstall/collector.md"
"icon" "fa-solid fa-box-open")
"nuget" (dict
"urlPattern" "https://www.nuget.org/packages/%s"
"installLine" "dotnet add package %s"
"installTemplate" "ecosystem/registry/quickinstall/default.md"
"icon" "fa-solid fa-box-open")
"pip" (dict
"urlPattern" "https://pypi.org/project/%s"
"installLine" "pip install %s"
"installTemplate" "ecosystem/registry/quickinstall/default.md"
"icon" "fa-brands fa-python")
"hex" (dict
"urlPattern" "https://hex.pm/packages/%s"
"installTemplate" "ecosystem/registry/quickinstall/hex.md"
"icon" "fa-brands fa-erlang")
"crates" (dict
"urlPattern" "https://crates.io/crates/%s"
"installLine" "cargo add %s"
"installTemplate" "ecosystem/registry/quickinstall/default.md"
"icon" "fab fa-rust")
-}}

{{ $isNative := and (or (eq .registryType "instrumentation") (eq .registryType "application integration")) (.isNative) }}
<span class="badge rounded-pill text-bg-success text-white"
title="This is a native integration">
<i class="fa-solid fa-puzzle-piece"></i> native
</span>
{{ $isFirstParty := and (or (eq .registryType "instrumentation") (eq .registryType "application integration")) (.isFirstParty) }}
{{ $currentTime := (time now) -}}
{{ $delta := $currentTime.Sub (time.AsTime .createdAt) -}}
{{ $isNew := lt $delta.Hours 730 -}}
{{ $usedInDemo := and (isset . "urls") (isset .urls "demo") }}
{{ $deprecated := and (isset . "deprecated") (isset .deprecated "reason") }}
{{ $package := "" -}}
{{ if and (.package) (isset $remoteRegistries .package.registry) -}}
{{ $package = merge .package (index $remoteRegistries .package.registry) -}}
{{ $package = merge $package (dict "type" .registryType) -}}
{{ end -}}
{{ $highlightStyle := "" -}}
{{ if $isNew -}}
{{ $highlightStyle = "border-info" -}}
{{ end -}}
{{ if $isNative -}}
{{ $highlightStyle = "border-success" -}}
{{ end -}}
{{ if $isFirstParty -}}
{{ $highlightStyle = "border-success" -}}
{{ end -}}
{{ if $usedInDemo -}}
{{ $highlightStyle = "border-secondary" -}}
{{ end -}}
{{ if $deprecated -}}
{{ $highlightStyle = "border-danger" -}}
{{ end -}}
{{ $primaryUrl := "" -}}
{{ if .urls.repo -}}
{{ $primaryUrl = .urls.repo -}}
{{ else if .urls.website -}}
{{ $primaryUrl = .urls.website -}}
{{ else if .urls.docs -}}
{{ errorf "The %q registry entry requires a repo or website URL." .title }}
{{ end -}}
{{ $primaryHref := printf "href=%q" $primaryUrl | safeHTMLAttr -}}
<li class="card my-3 registry-entry {{ $highlightStyle }}" data-registry-id="{{ ._key }}" data-registrytype="{{ .registryType }}" data-registrylanguage="{{ .language }}">
<div class="card-body container">
{{ $currentTime := (time now) -}}
{{ $delta := $currentTime.Sub (time.AsTime .createdAt) -}}
{{ $isNew := lt $delta.Hours 730 -}}
{{ $usedInDemo := and (isset . "urls") (isset .urls "demo") }}
{{ $deprecated := and (isset . "deprecated") (isset .deprecated "reason") }}
{{ $package := "" -}}
{{ if and (.package) (isset $remoteRegistries .package.registry) -}}
{{ $package = merge .package (index $remoteRegistries .package.registry) -}}
{{ $package = merge $package (dict "type" .registryType) -}}
{{ end -}}
{{ $highlightStyle := "" -}}
{{ if $isNew -}}
{{ $highlightStyle = "border-info" -}}
{{ end -}}
{{ if $isNative -}}
{{ $highlightStyle = "border-success" -}}
{{ end -}}
{{ if $isFirstParty -}}
{{ $highlightStyle = "border-success" -}}
{{ end -}}
{{ if $usedInDemo -}}
{{ $highlightStyle = "border-secondary" -}}
{{ end -}}
{{ if $deprecated -}}
{{ $highlightStyle = "border-danger" -}}
{{ end -}}
{{ $primaryUrl := "" -}}
{{ if .urls.repo -}}
{{ $primaryUrl = .urls.repo -}}
{{ else if .urls.website -}}
{{ $primaryUrl = .urls.website -}}
{{ else if .urls.docs -}}
{{ errorf "The %q registry entry requires a repo or website URL." .title }}
{{ end -}}
{{ $primaryHref := printf "href=%q" $primaryUrl | safeHTMLAttr -}}
<li class="card my-3 registry-entry {{ $highlightStyle }}" data-registry-id="{{ ._key }}"
data-registrytype="{{ .registryType }}" data-registrylanguage="{{ .language }}">
<div class="card-body container">
<h4 class="card-title mb-0 d-flex flex-row">
<a {{ $primaryHref }} target="_blank" rel="noopener" class="me-auto">
{{- .title | markdownify -}}
{{- .title | markdownify -}}
</a>
<div class="ms-auto">
{{ if $isNew -}}
Expand All @@ -105,7 +110,7 @@ <h4 class="card-title mb-0 d-flex flex-row">
<span class="badge rounded-pill text-bg-secondary text-white" title="This package is used in the OpenTelemetry Demo!"><i class="fa-solid fa-shapes"></i> OTel Demo</span>
{{ end -}}
{{ if $deprecated -}}
<span class="badge rounded-pill text-bg-danger text-white" title=""><i class="fa-solid fa-ban"></i> deprecated</span>
<span class="badge rounded-pill text-bg-danger text-white" title="This package is deprecated."><i class="fa-solid fa-ban"></i> deprecated</span>
{{ end -}}
{{ if .cncfProjectLevel -}}
<span class="badge rounded-pill text-bg-primary text-white" title="CNCF {{ .cncfProjectLevel}} Project">
Expand All @@ -116,37 +121,38 @@ <h4 class="card-title mb-0 d-flex flex-row">
</h4>
<p class="card-text">
<small class="text-body-secondary">
by
{{ range $index, $author := .authors -}}
by
{{ range $index, $author := .authors -}}
{{ if $index }}, {{ end }}
{{ if eq $author.name "OpenTelemetry Authors" -}}
<a href="/" class="badge rounded-pill text-bg-primary">🔭 {{ $author.name }} 🔭</a>
<a href="/" class="badge rounded-pill text-bg-primary">🔭 {{ $author.name }} 🔭</a>
{{ else if isset $author "url" }}
{{ $href := printf "href=%q" $author.url | safeHTMLAttr -}}
<a {{ $href }} target="_blank" rel="noopener" class="card-link external-link">{{ $author.name }}</a>
{{ $href := printf "href=%q" $author.url | safeHTMLAttr -}}
<a {{ $href }} target="_blank" rel="noopener" class="card-link external-link">{{ $author.name }}</a>
{{ else -}}
{{ $author.name -}}
{{ $author.name -}}
{{ end -}}
{{ end -}}
{{ end -}}
</small>
</p>
<div class="row p-2">
<div class="col col-md-9 col-lg-10">
<div class="mb-3">
{{ if $deprecated -}}
<div class="alert alert-danger" role="alert">
<h4 class="alert-heading">Deprecated</h4>
{{ .deprecated.reason | markdownify }}
</div>
<div class="alert alert-danger" role="alert">
<h4 class="alert-heading">Deprecated</h4>
{{ .deprecated.reason | markdownify }}
</div>
{{ end -}}
{{- .description | markdownify -}}
</div>
{{ with $package -}}
{{ if not (eq .quickInstall false) }}
<h6><i class="fa-solid fa-forward"></i> Quick Install</h6>
<p>{{ (partial .installTemplate .) | markdownify -}}
</p>
{{ end -}}
{{ if not (eq .quickInstall false) }}
<h6><i class="fa-solid fa-forward"></i> Quick Install</h6>
<p>{{ (partial .installTemplate .) | markdownify -}}
</p>

{{ end -}}
{{- end -}}
</div>
<div class="col col-md-3 col-lg-2">
Expand All @@ -167,7 +173,7 @@ <h6><i class="fa-solid fa-forward"></i> Quick Install</h6>
<div class="fw-bold">
{{ $languageNames.Get . | default (humanize .) }}
</div>
<small>Language</small>
<small data-bs-toggle="tooltip" title="This indicates the programming language used.">Language</small>
</div>
</li>
{{- end }}
Expand All @@ -177,7 +183,7 @@ <h6><i class="fa-solid fa-forward"></i> Quick Install</h6>
<div class="fw-bold">
{{ . | humanize }}
</div>
<small>Component</small>
<small data-bs-toggle="tooltip" title="This refers to the type of registry component.">Component</small>
</div>
</li>
{{- end -}}
Expand All @@ -187,7 +193,7 @@ <h6><i class="fa-solid fa-forward"></i> Quick Install</h6>
<div class="fw-bold">
{{ . }}
</div>
<small>License</small>
<small data-bs-toggle="tooltip" title="This is the type of license for the project.">License</small>
</div>
</li>
{{- end -}}
Expand All @@ -198,15 +204,19 @@ <h6><i class="fa-solid fa-forward"></i> Quick Install</h6>
</div>
{{ with .urls.website -}}
{{ $websiteHref := printf "href=%q" . | safeHTMLAttr -}}
<a {{ $websiteHref }} target="_blank" rel="noopener" class="card-link"><i class="fas fa-house" aria-hidden="true"></i>&nbsp;Website</a>
<a {{ $websiteHref }} target="_blank" rel="noopener" class="card-link"><i class="fas fa-house"
aria-hidden="true"></i>&nbsp;Website</a>
{{- end -}}
{{ with .urls.docs -}}
{{ $docsHref := printf "href=%q" . | safeHTMLAttr -}}
<a {{ $docsHref }} target="_blank" rel="noopener" class="card-link"><i class="fas fa-book" aria-hidden="true"></i>&nbsp;Documentation</a>
<a {{ $docsHref }} target="_blank" rel="noopener" class="card-link" ><i class="fas fa-book" aria-hidden="true"></i>&nbsp;Documentation</a>
{{- end -}}
{{ with $package -}}
{{ $packageUrl := printf "href=%q" (printf .urlPattern .name) | safeHTMLAttr -}}
<a {{ $packageUrl }} target="_blank" rel="noopener" class="card-link"><i class="{{ .icon }}" aria-hidden="true"></i>&nbspPackage Details ({{ .registry }})</a>
<a {{ $packageUrl }} target="_blank" rel="noopener" class="card-link"
title="View package details on {{ .registry }}">
<i class="{{ .icon }}" aria-hidden="true"></i>&nbspPackage Details ({{ .registry }})
</a>
{{- end -}}
{{ with .urls.repo -}}
{{ $icon := cond ( hasPrefix . "https://github.com/" ) "fa-brands fa-github" "fab fa-git-alt" -}}
Expand All @@ -215,8 +225,9 @@ <h6><i class="fa-solid fa-forward"></i> Quick Install</h6>
{{- end -}}
{{ with .urls.demo -}}
{{ $demoUrl := printf "href=%q" (printf .) | safeHTMLAttr -}}
<a {{ $demoUrl }} target="_blank" rel="noopener" class="card-link"><i class="fa-solid fa-shapes" aria-hidden="true"></i>&nbsp;Demo Service</a>
<a {{ $demoUrl }} target="_blank" rel="noopener" class="card-link"><i class="fa-solid fa-shapes"
aria-hidden="true"></i>&nbsp;Demo Service</a>
{{- end -}}
</div>
</li>
{{ end -}}
</div>
</li>
{{ end -}}

0 comments on commit 94efbd3

Please sign in to comment.