From a588186c5436087d9e25048272392469162f72ae Mon Sep 17 00:00:00 2001 From: Sjur N Moshagen Date: Tue, 24 Oct 2023 23:18:26 +0200 Subject: [PATCH] Add special treatment of template repos --- SharedResources.md | 2 +- assets/js/langtable.js | 56 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/SharedResources.md b/SharedResources.md index dc9d7d03..ef8752e5 100644 --- a/SharedResources.md +++ b/SharedResources.md @@ -49,5 +49,5 @@ domCore.appendChild(addRepoTable({{core_repos}}, 'giella-', ['maturity'])) diff --git a/assets/js/langtable.js b/assets/js/langtable.js index fe7f525e..882f939c 100644 --- a/assets/js/langtable.js +++ b/assets/js/langtable.js @@ -8280,3 +8280,59 @@ function addDictTR(repo) { return row; } + +function addTemplateTable(repos, mainFilter, filters) { + let table = document.createElement('table'); + let thead = document.createElement('thead'); + let tbody = document.createElement('tbody'); + + table.appendChild(thead); + table.appendChild(tbody); + thead.appendChild(addTableHeader()); + + for (const repo of repos) { + if (repo.name.startsWith(mainFilter)) { + if (filters === null || filters.length === 0) { + tbody.appendChild(addTemplTR(repo)); + } else { + if (doesTopicsHaveSomeFilter(repo.topics, filters)) { + tbody.appendChild(addTemplTR(repo)); + } + } + } + } + // If no repos found, inform the user: + if (!tbody.firstChild) { + tbody.appendChild(addEmptyRow()); + } + return table; +} + +function addTemplTR(repo) { + let row = document.createElement('tr'); + + let row_lang = document.createElement('td'); + row_lang.appendChild(addr(reponame2templatename(repo.name), repo.name + '/')); + + row.appendChild(row_lang); + row.appendChild(addRepo(repo)); + row.appendChild(addRLicense(repo)); + row.appendChild(addIssues(repo)); + row.appendChild(addRDoc(repo)); + row.appendChild(addCI(repo)); + + return row; +} + +function reponame2templatename(reponame) { + parts = reponame.split('-'); + return code2templatename[parts[2]] +} + +const code2templatename { + "corpus": "Corpora", + "dict": "Dictionaries", + "keyboard": "Keyboards", + "lang": "Language models", + "shared": "Shared resources" +}