Skip to content

Commit

Permalink
Extensions: Search for XEP number, title, and shortname
Browse files Browse the repository at this point in the history
  • Loading branch information
cal0pteryx committed Oct 18, 2023
1 parent b22f3a1 commit beb0033
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion themes/xmpp.org/layouts/shortcodes/extensions-table.html
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
{{- if .Site.Data.xeplist -}}
{{- range sort .Site.Data.xeplist ".number" -}}
{{- $number_str := printf "%04g" .number -}}
<tr class="XEP-{{- .status -}}" id="xep{{- $number_str -}}">
<tr class="XEP-{{- .status -}}" id="xep{{- $number_str -}}" data-shortname="{{- .shortname -}}">
<td><a href="/extensions/xep-{{- $number_str -}}.html">XEP-{{- $number_str -}}</a></td>
<td>{{- .title -}}</td>
<td>{{- .type -}}</td>
Expand Down
8 changes: 7 additions & 1 deletion themes/xmpp.org/static/js/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,14 @@ function filter_xeps() {
}
const rows = document.querySelectorAll("[class*=XEP-]")
for (const row of rows) {
const xep_number = row.id.slice(3)
const xep_name = row.querySelector('td:nth-child(2)').innerHTML.toLowerCase();
row.hidden = xep_name.includes(search_string) ? false : true
const xep_shortname = row.dataset.shortname
if (xep_number.includes(search_string) || xep_name.includes(search_string) || xep_shortname.includes(search_string)) {
row.hidden = false
} else {
row.hidden = true
}
}
return
}
Expand Down
5 changes: 5 additions & 0 deletions tools/prepare_xep_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,18 @@ def fix_status(status: str) -> str:
xeps: list[dict[str, Any]] = []
for xep in root.findall("xep"):
if xep.get("accepted") == "true":
shortname = xep.find("shortname")
if shortname is not None:
shortname = shortname.text
xeps.append(
{
"title": xep.find("title").text,
"shortname": shortname,
"status": fix_status(xep.find("status").text),
"number": int(xep.find("number").text),
"last_updated": xep.find("last-revision").find("date").text,
"type": xep.find("type").text,
"abstract": xep.find("abstract").text,
}
)
xeps_sorted = sorted(xeps, key=lambda xep: xep["number"])
Expand Down

0 comments on commit beb0033

Please sign in to comment.