Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Put items into sections #5348

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions assets/js/registrySearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ 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");
categoryElement.classList.add("d-none");
document.getElementById('search-loading').style.display = 'block';

const run = function (searchQuery) {
Expand Down Expand Up @@ -210,6 +212,12 @@ 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'));
Expand Down Expand Up @@ -239,3 +247,4 @@ function parseUrlParams() {
selectedLanguage = urlParams.get('language') || 'all';
selectedComponent = urlParams.get('component') || 'all';
}

1 change: 1 addition & 0 deletions assets/scss/_registry.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
&.badge-#{$component} {
color: white;
background-color: $color;
color: white;
}
}

Expand Down
7 changes: 7 additions & 0 deletions content/en/ecosystem/registry/_index.md
svrnm marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,11 @@ weight: 20

{{< ecosystem/registry/search-form >}}

{{< ecosystem/registry/categories>}}

{{< /blocks/section >}}





229 changes: 229 additions & 0 deletions layouts/partials/ecosystem/registry/category.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,229 @@


<div class="">
<div class="d-flex justify-content-between my-3">
<h4>{{ .Title }}</h4>
<a href="?s={{ .SearchTerm }}&component=&language=">View All</a>
</div>
<div class="d-flex flex-column flex-sm-row justify-content-between" style="gap:12px">
{{ $searchTerms := .SearchTerms }}
{{ $resultCount := 0 }}

{{ range .registry }}
{{ $entry := . }}
{{ $matched := false }}

{{ range $searchTerms }}
{{ if or (in $entry.title .) (in $entry.description .) (in $entry._key .) (in $entry.tags .) (in $entry.package.name .) (in $entry.flags .) (in $entry.license .) (in $entry.language .) (in $entry.registryType .) }}
{{ $matched = true }}
{{ end }}
{{ end }}

{{ if and $matched (lt $resultCount 3) }}
{{ $resultCount = add $resultCount 1 }}
{{/* Define variables */}}
{{ $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")
"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")
-}}

{{/* Initialize variables */}}
{{ $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 ($entry.package) (isset $remoteRegistries $entry.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 }}
{{/* Define $primaryHref */}}
{{ $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 }}

<li class="card registry-entry {{ $highlightStyle }}" data-registry-id="{{ $entry._key }}" data-registrytype="{{ $entry.registryType }}" data-registrylanguage="{{ $entry.language }}" style="flex:1">
<div class="card-body container">
<h4 class="card-title mb-0 d-flex flex-row">
<a {{ $primaryHref }} target="_blank" rel="noopener" class="me-auto">
{{- $entry.title | markdownify -}}
</a>
</h4>

<p class="card-text">
<small class="text-body-secondary">
by
{{ range $index, $author := $entry.authors -}}
{{ if $index }}, {{ end }}
{{ if eq $author.name "OpenTelemetry Authors" -}}
<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 p-2">{{ $author.name }}</a>
{{ else -}}
{{ $author.name -}}
{{ end -}}
{{ end -}}
</small>
</p>
<div class="ms-auto">
{{ if $isNew -}}
<span class="badge rounded-pill text-bg-info"><i class="fa-regular fa-star"></i> new</span>
{{ end -}}
{{ if $isNative -}}
<span class="badge rounded-pill text-bg-success text-white"><i class="fa-solid fa-puzzle-piece"></i> native</span>
{{ end -}}
{{ if $isFirstParty -}}
<span class="badge rounded-pill text-bg-success text-white"><i class="fa-solid fa-heart"></i> first party integration</span>
{{ end -}}
{{ if $usedInDemo -}}
<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>
{{ end -}}
{{ if $entry.cncfProjectLevel -}}
<span class="badge rounded-pill text-bg-primary text-white" title="CNCF {{ $entry.cncfProjectLevel }} Project">
<img alt="CNCF" style="display: inline-block; width: 14px; height: 14px; border: none; margin:0px; padding: 0; vertical-align:middle" src="/img/cncf-icon-white.svg"> {{ $entry.cncfProjectLevel }}
</span>
{{ end -}}
</div>
<div class="col">
<div class="">
<div class="mb-3">
{{ if $deprecated -}}
<div class="alert alert-danger" role="alert">
<h4 class="alert-heading">Deprecated</h4>
{{ $entry.deprecated.reason | markdownify }}
</div>
{{ end -}}
{{- $entry.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 -}}
{{ end -}}
</div>

<div class="">
<ul class="list-group list-group-flush">
{{ if $entry.package.version -}}
<li class="list-group-item p-0">
<div class="me-auto">
<div class="fw-bold">{{ $entry.package.version }}</div>
<small>Version</small>
</div>
</li>
{{ end }}
{{ if $entry.language -}}
<li class="list-group-item p-0">
<div class="me-auto">
<div class="fw-bold">{{ $entry.language }}</div>
<small>Language</small>
</div>
</li>
{{ end }}
{{ if $entry.license -}}
<li class="list-group-item p-0">
<div class="me-auto">
<div class="fw-bold">{{ $entry.license }}</div>
<small>License</small>
</div>
</li>
{{ end }}
</ul>
</div>
</div>
</div>
{{ with $entry.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>
{{- end -}}
{{ with $entry.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>
{{- 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>&nbsp;Package Details ({{ .registry }})</a>
{{- end -}}
{{ with $entry.urls.repo -}}
{{ $icon := cond (hasPrefix . "https://github.com/") "fa-brands fa-github" "fab fa-git-alt" -}}
{{ $repoHref := printf "href=%q" . | safeHTMLAttr -}}
<a {{ $repoHref }} target="_blank" rel="noopener" class="card-link"><i class="{{ $icon }}" aria-hidden="true"></i>&nbsp;Repository</a>
{{- end -}}
{{ with $entry.urls.demo -}}
{{ $demoUrl := printf "href=%q" . | safeHTMLAttr -}}
<a {{ $demoUrl }} target="_blank" rel="noopener" class="card-link"><i class="fa-solid fa-shapes" aria-hidden="true"></i>&nbsp;Demo Service</a>
{{- end -}}
</li>
{{ end }}
{{ end }}
</div>

</div>
2 changes: 1 addition & 1 deletion layouts/partials/ecosystem/registry/entry.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

{{ with .value -}}
{{
$remoteRegistries := dict
$remoteRegistries := dict
svrnm marked this conversation as resolved.
Show resolved Hide resolved
"npm" (dict
"urlPattern" "https://npmjs.com/package/%s"
"installTemplate" "ecosystem/registry/quickinstall/default.md"
Expand Down
11 changes: 11 additions & 0 deletions layouts/shortcodes/ecosystem/registry/categories.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{{ $registry := .Site.Data.registry }}
<div class="d-flex flex-column gap-4" id="categories-section">
{{ partial "ecosystem/registry/category.html" (dict "Title" "Libraries" "SearchTerm" "library" "SearchTerms" (slice "library" "libraries") "registry" $registry) }}
{{ partial "ecosystem/registry/category.html" (dict "Title" "Plugins" "SearchTerm" "plugin" "SearchTerms" (slice "plugin" "plugins") "registry" $registry) }}
{{ partial "ecosystem/registry/category.html" (dict "Title" "Instrumentations" "SearchTerm" "instrumentation" "SearchTerms" (slice "instrumentation" "instrumentations") "registry" $registry) }}
</div>



<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/index.min.js" integrity="sha384-58p1D2xuw/76VRFUgDMRcrtnJAW5LWLE02ihn8aITu65c4vgo+BLy7raRKNC7KaL" crossorigin="anonymous"></script>
{{ partial "script.html" (dict "src" "js/registrySearch.js") -}}
10 changes: 9 additions & 1 deletion layouts/shortcodes/ecosystem/registry/search-form.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,14 @@
</form>
</div>


svrnm marked this conversation as resolved.
Show resolved Hide resolved
<div class="mx-auto">
<div class="text-center text-primary" style="display: none" id="search-loading">
<span class="spinner-border spinner-border-sm" aria-hidden="true"></span>
<span role="status">Loading results…</span>
</div>
<ul class="list-unstyled" id="search-results"></ul>
<ul class="list-unstyled" id="default-body">
<ul class="list-unstyled d-none" id="default-body">
{{ range $key, $value := $registry -}}
{{ $value = merge $value (dict "_key" $key) -}}
{{ partial "ecosystem/registry/entry" (dict "value" $value "languageNames" $languageNames) }}
Expand All @@ -108,3 +109,10 @@

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/index.min.js" integrity="sha384-58p1D2xuw/76VRFUgDMRcrtnJAW5LWLE02ihn8aITu65c4vgo+BLy7raRKNC7KaL" crossorigin="anonymous"></script>
{{ partial "script.html" (dict "src" "js/registrySearch.js") -}}







svrnm marked this conversation as resolved.
Show resolved Hide resolved