diff --git a/assets/js/registrySearch.js b/assets/js/registrySearch.js index d91c590585a3..c1a9055d5adf 100644 --- a/assets/js/registrySearch.js +++ b/assets/js/registrySearch.js @@ -129,6 +129,10 @@ function executeSearch(searchQuery) { document.querySelector('#input-s').value = searchQuery; document.querySelector('#default-body').style.display = 'none'; document.querySelector('#search-results').innerHTML = ''; + let categoryElement = document.getElementById('categories-section'); + if (categoryElement) { + categoryElement.classList.add('d-none'); + } document.getElementById('search-loading').style.display = 'block'; const run = function (searchQuery) { @@ -210,6 +214,11 @@ function setInput(key, value) { // Filters items based on language and component filters function updateFilters() { + let element = document.getElementById('default-body'); + element.classList.remove('d-none'); + let categoryElement = document.getElementById('categories-section'); + categoryElement.classList.add('d-none'); + let allItems = [...document.getElementsByClassName('registry-entry')]; if (selectedComponent === 'all' && selectedLanguage === 'all') { allItems.forEach((element) => element.classList.remove('d-none')); diff --git a/assets/scss/_registry.scss b/assets/scss/_registry.scss index 06ed0693de9f..376b191c990d 100644 --- a/assets/scss/_registry.scss +++ b/assets/scss/_registry.scss @@ -10,6 +10,7 @@ &.badge-#{$component} { color: white; background-color: $color; + color: white; } } diff --git a/content/en/ecosystem/registry/_index.md b/content/en/ecosystem/registry/_index.md index 0b671e5499d2..488d156a3173 100644 --- a/content/en/ecosystem/registry/_index.md +++ b/content/en/ecosystem/registry/_index.md @@ -33,4 +33,6 @@ weight: 20 {{< ecosystem/registry/search-form >}} +{{< ecosystem/registry/categories>}} + {{< /blocks/section >}} diff --git a/layouts/partials/ecosystem/registry/category.html b/layouts/partials/ecosystem/registry/category.html new file mode 100644 index 000000000000..ec373f1b5dd2 --- /dev/null +++ b/layouts/partials/ecosystem/registry/category.html @@ -0,0 +1,243 @@ +
+
+

{{ .Title }}

+ View All +
+
+ {{ $searchTerms := .SearchTerms }} + {{ $resultCount := 0 }} + + {{ range $key, $entry := .registry }} + {{ $matched := false }} + {{ range $searchTerms }} + {{ if or (in $entry.title .) (in $entry.description .) (in $entry._key .) (in $entry.tags .) }} + {{ $matched = true }} + {{ end }} + {{ end }} + + {{ if and $matched (lt $resultCount 3) }} + {{ $resultCount = add $resultCount 1 }} + {{ $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 $entry.registryType "instrumentation") (eq $entry.registryType "application integration")) ($entry.isNative) }} + {{ $isFirstParty := and (or (eq $entry.registryType "instrumentation") (eq $entry.registryType "application integration")) ($entry.isFirstParty) }} + {{ $currentTime := time.Now }} + {{ $delta := $currentTime.Sub (time.AsTime $entry.createdAt) }} + {{ $isNew := lt $delta.Hours 730 }} + {{ $usedInDemo := and (isset $entry "urls") (isset $entry.urls "demo") }} + {{ $deprecated := and (isset $entry "deprecated") (isset $entry.deprecated "reason") }} + {{ $package := "" -}} + {{ if and (.package) (isset $remoteRegistries .package.registry) -}} + {{ $package = merge $entry.package (index $remoteRegistries $entry.package.registry) -}} + {{ $package = merge $package (dict "type" $entry.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 $entry.urls.repo }} + {{ $primaryUrl = $entry.urls.repo }} + {{ else if $entry.urls.website }} + {{ $primaryUrl = $entry.urls.website }} + {{ else if $entry.urls.docs }} + {{ errorf "The %q registry entry requires a repo or website URL." $entry.title }} + {{ end }} + {{ $primaryHref := printf "href=%q" $primaryUrl | safeHTMLAttr }} +
  • +
    +

    + + {{- $entry.title | markdownify -}} + +

    +

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

    +
    + {{ if $isNew -}} + new + {{ end -}} + {{ if $isNative -}} + native + {{ end -}} + {{ if $isFirstParty -}} + first party integration + {{ end -}} + {{ if $usedInDemo -}} + OTel Demo + {{ end -}} + {{ if $deprecated -}} + deprecated + {{ end -}} + {{ if $entry.cncfProjectLevel -}} + + CNCF {{ $entry.cncfProjectLevel }} + + {{ end -}} +
    +
    +
    +
    + {{ if $deprecated -}} + + {{ end -}} + {{- $entry.description | markdownify -}} +
    + {{ with $package -}} + {{ if not (eq .quickInstall false) }} +
    Quick Install
    +

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

    + {{ end -}} + {{- end -}} +
    + +
    +
      + {{ if $entry.package.version -}} +
    • +
      +
      {{ $entry.package.version }}
      + Version +
      +
    • + {{ end }} + {{ if $entry.language -}} +
    • +
      +
      {{ $entry.language }}
      + Language +
      +
    • + {{ end }} + {{ if $entry.registryType -}} +
    • +
      +
      + {{ $entry.registryType }} +
      + Component +
      +
    • + {{- end -}} + {{ if $entry.license -}} +
    • +
      +
      {{ $entry.license }}
      + License +
      +
    • + {{ end }} +
    +
    +
    +
    + {{ with $entry.urls.website -}} + {{ $websiteHref := printf "href=%q" . | safeHTMLAttr -}} +  Website + {{- end -}} + {{ with $entry.urls.docs -}} + {{ $docsHref := printf "href=%q" . | safeHTMLAttr -}} +  Documentation + {{- end -}} + {{ with $package -}} + {{ $packageUrl := printf "href=%q" (printf .urlPattern .name) | safeHTMLAttr -}} +  Package Details ({{ .registry }}) + {{- end -}} + {{ with $entry.urls.repo -}} + {{ $icon := cond (hasPrefix . "https://github.com/") "fa-brands fa-github" "fab fa-git-alt" -}} + {{ $repoHref := printf "href=%q" . | safeHTMLAttr -}} +  Repository + {{- end -}} + {{ with $entry.urls.demo -}} + {{ $demoUrl := printf "href=%q" . | safeHTMLAttr -}} +  Demo Service + {{- end -}} +
    + +
    + +
  • + {{ end }} + {{ end }} +
    + +
    + + + + diff --git a/layouts/shortcodes/ecosystem/registry/categories.html b/layouts/shortcodes/ecosystem/registry/categories.html new file mode 100644 index 000000000000..46a43353650a --- /dev/null +++ b/layouts/shortcodes/ecosystem/registry/categories.html @@ -0,0 +1,18 @@ +{{ $registry := .Site.Data.registry }} +{{ $updatedRegistry := dict }} + +{{ range $key, $value := $registry }} + {{ $updatedRegistry = merge $updatedRegistry (dict $key (merge $value (dict "_key" $key))) }} +{{ end }} + + +
    + {{ partial "ecosystem/registry/category.html" (dict "Title" "Libraries" "SearchTerm" "library" "SearchTerms" (slice "library" "libraries") "registry" $updatedRegistry) }} + {{ partial "ecosystem/registry/category.html" (dict "Title" "Plugins" "SearchTerm" "plugin" "SearchTerms" (slice "plugin" "plugins") "registry" $updatedRegistry) }} + {{ partial "ecosystem/registry/category.html" (dict "Title" "Instrumentations" "SearchTerm" "instrumentation" "SearchTerms" (slice "instrumentation" "instrumentations") "registry" $updatedRegistry) }} +
    + + + + +{{ partial "script.html" (dict "src" "js/registrySearch.js") -}} \ No newline at end of file diff --git a/layouts/shortcodes/ecosystem/registry/search-form.html b/layouts/shortcodes/ecosystem/registry/search-form.html index 4e2fc00028c1..13a516447726 100644 --- a/layouts/shortcodes/ecosystem/registry/search-form.html +++ b/layouts/shortcodes/ecosystem/registry/search-form.html @@ -98,7 +98,7 @@ Loading results… -