From 94efbd39125416c544fa69dd4f60120027bfce2a Mon Sep 17 00:00:00 2001 From: crocmons Date: Sat, 26 Oct 2024 03:45:21 +0600 Subject: [PATCH] Add tooltip feature with necessary files only --- assets/js/registrySearch.js | 5 + .../partials/ecosystem/registry/entry.html | 233 +++++++++--------- 2 files changed, 127 insertions(+), 111 deletions(-) diff --git a/assets/js/registrySearch.js b/assets/js/registrySearch.js index d91c590585a3..c15796154337 100644 --- a/assets/js/registrySearch.js +++ b/assets/js/registrySearch.js @@ -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) +}) diff --git a/layouts/partials/ecosystem/registry/entry.html b/layouts/partials/ecosystem/registry/entry.html index 9a282c4db0b9..e4234e0dc59a 100644 --- a/layouts/partials/ecosystem/registry/entry.html +++ b/layouts/partials/ecosystem/registry/entry.html @@ -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) }} + + native + {{ $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 -}} -
  • -
    +{{ $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 -}} +
  • +

    - {{- .title | markdownify -}} + {{- .title | markdownify -}}
    {{ if $isNew -}} @@ -105,7 +110,7 @@

    OTel Demo {{ end -}} {{ if $deprecated -}} - deprecated + deprecated {{ end -}} {{ if .cncfProjectLevel -}} @@ -116,37 +121,38 @@

    - by - {{ range $index, $author := .authors -}} + by + {{ range $index, $author := .authors -}} {{ if $index }}, {{ end }} {{ if eq $author.name "OpenTelemetry Authors" -}} - 🔭 {{ $author.name }} 🔭 + 🔭 {{ $author.name }} 🔭 {{ else if isset $author "url" }} - {{ $href := printf "href=%q" $author.url | safeHTMLAttr -}} - {{ $author.name }} + {{ $href := printf "href=%q" $author.url | safeHTMLAttr -}} + {{ $author.name }} {{ else -}} - {{ $author.name -}} + {{ $author.name -}} + {{ end -}} {{ end -}} - {{ end -}}

    {{ if $deprecated -}} - + {{ end -}} {{- .description | markdownify -}}
    {{ with $package -}} - {{ if not (eq .quickInstall false) }} -
    Quick Install
    -

    {{ (partial .installTemplate .) | markdownify -}} -

    - {{ end -}} + {{ if not (eq .quickInstall false) }} +
    Quick Install
    +

    {{ (partial .installTemplate .) | markdownify -}} +

    + + {{ end -}} {{- end -}}
    @@ -167,7 +173,7 @@
    Quick Install
    {{ $languageNames.Get . | default (humanize .) }}
    - Language + Language

  • {{- end }} @@ -177,7 +183,7 @@
    Quick Install
    {{ . | humanize }}
    - Component + Component {{- end -}} @@ -187,7 +193,7 @@
    Quick Install
    {{ . }}
    - License + License {{- end -}} @@ -198,15 +204,19 @@
    Quick Install
    {{ with .urls.website -}} {{ $websiteHref := printf "href=%q" . | safeHTMLAttr -}} -  Website +  Website {{- end -}} {{ with .urls.docs -}} {{ $docsHref := printf "href=%q" . | safeHTMLAttr -}} -  Documentation +  Documentation {{- end -}} {{ with $package -}} {{ $packageUrl := printf "href=%q" (printf .urlPattern .name) | safeHTMLAttr -}} -  Package Details ({{ .registry }}) + +  Package Details ({{ .registry }}) + {{- end -}} {{ with .urls.repo -}} {{ $icon := cond ( hasPrefix . "https://github.com/" ) "fa-brands fa-github" "fab fa-git-alt" -}} @@ -215,8 +225,9 @@
    Quick Install
    {{- end -}} {{ with .urls.demo -}} {{ $demoUrl := printf "href=%q" (printf .) | safeHTMLAttr -}} -  Demo Service +  Demo Service {{- end -}} - - - {{ end -}} + + +{{ end -}} \ No newline at end of file