This is an automated email from the ASF dual-hosted git repository. bdelacretaz pushed a commit to branch preview/volunteers in repository https://gitbox.apache.org/repos/asf/comdev-site.git
commit 0106cf593c3deaa5f02de434f833c1cf65379c2c Author: Bertrand Delacretaz <[email protected]> AuthorDate: Tue Nov 21 09:45:35 2023 +0100 Volunteers page and related code added --- layouts/_default/volunteers.html | 3 +- source/contributors/asf-volunteers.md | 5 ++- static/js/components/person-projects.js | 45 ++++++++++++++++++++ static/js/components/volunteers-list.js | 38 +++++++++++++++++ static/js/components/whimsy-loader.js | 11 +++++ static/js/volunteers-list.js | 75 --------------------------------- 6 files changed, 100 insertions(+), 77 deletions(-) diff --git a/layouts/_default/volunteers.html b/layouts/_default/volunteers.html index cbbbf20..3d9d276 100644 --- a/layouts/_default/volunteers.html +++ b/layouts/_default/volunteers.html @@ -1,5 +1,6 @@ {{ define "main" }} - <script type="module" src="/js/volunteers-list.js"></script> + <script type="module" src="/js/components/volunteers-list.js"></script> + <script type="module" src="/js/components/person-projects.js"></script> <volunteers-list> {{ .Content }} </volunteers-list> diff --git a/source/contributors/asf-volunteers.md b/source/contributors/asf-volunteers.md index 619a158..88e43d7 100644 --- a/source/contributors/asf-volunteers.md +++ b/source/contributors/asf-volunteers.md @@ -1,5 +1,5 @@ --- -title: ASF volunteers (mentors, speakers) +title: ASF volunteers layout: volunteers tags: ["committers","newcomers","contributing","mentors","speakers"] --- @@ -10,6 +10,9 @@ and/or to be speakers at ASF-related events. Project names shown in <strong>bold</strong> mean that the corresponding person is a PMC member of that project. +**TODO**: a [number of pages](/tags/speakers.html) explain how to register yourself as a potential speaker. +These will need to be adapted if we decide to use this page. + ## List of ASF volunteers <!-- diff --git a/static/js/components/person-projects.js b/static/js/components/person-projects.js new file mode 100644 index 0000000..f1ccd7d --- /dev/null +++ b/static/js/components/person-projects.js @@ -0,0 +1,45 @@ +import fetchPublicData from "./whimsy-loader.js"; +const projects = await fetchPublicData('public_ldap_projects.json'); +var projectsById = {}; + +{ + Object.keys(projects.projects).forEach(project => { + projects.projects[project].members.forEach(m => { + if (!projectsById[m]) { + projectsById[m] = {}; + } + projectsById[m][project] = { pmc: false }; + }) + projects.projects[project].owners.forEach(m => { + if (!projectsById[m]) { + projectsById[m] = {}; + } + projectsById[m][project] = { pmc: true }; + }) + }) +} + +// Component that replaces its content with a list of links +// to the projects that an ASF id belongs to +class PersonProjects extends HTMLElement { + async connectedCallback() { + let projectsHTML = ''; + const asfid = this.getAttribute('asfid'); + const theirProjects = projectsById[asfid]; + if (theirProjects) { + Object.keys(theirProjects).forEach(project => { + const isPmc = theirProjects[project].pmc; + if (projectsHTML != '') { + projectsHTML += ', '; + } + projectsHTML += `<a href=https://${project}.apache.org>${isPmc ? '<strong>' : ''}${project}${isPmc ? '</strong>' : ''}</a>`; + }) + } + + if (projectsHTML.length > 0) { + this.innerHTML = projectsHTML; + } + } +} + +customElements.define('person-projects', PersonProjects); \ No newline at end of file diff --git a/static/js/components/volunteers-list.js b/static/js/components/volunteers-list.js new file mode 100644 index 0000000..b198794 --- /dev/null +++ b/static/js/components/volunteers-list.js @@ -0,0 +1,38 @@ +import fetchPublicData from "./whimsy-loader.js"; + +// Component that enriches a list of volunteers where each +// entry is formatted in Markdown like +// * bdelacretaz # mentor, speaker # https://grep.codeconsult.ch # Switzerland +// +class VolunteersList extends HTMLElement { + async connectedCallback() { + const people = await fetchPublicData('public_ldap_people.json'); + this.querySelectorAll('li').forEach(li => { + const d = this._parseEntry(li.textContent); + + // set volunteer information + const name = people.people[d.id]?.name ? people.people[d.id]?.name : d.id; + li.innerHTML = ` + <a rel="nofollow" href="${d.url}">${name}</a> + (${d.id}) + - ${d.roles} + ${d.location && d.location != 'N/A' ? '- ' + d.location : ''} + <br/><span class='projects'><em>projects: </em><person-projects asfid="${d.id}"></person-projects></span> + `; + }) + } + + _parseEntry(txt) { + const fields = txt.split('#'); + var i = 0; + return { + id: fields[i++]?.trim(), + roles: fields[i++]?.trim(), + url: fields[i++]?.trim(), + location: fields[i++]?.trim() + } + } + +} + +customElements.define('volunteers-list', VolunteersList); \ No newline at end of file diff --git a/static/js/components/whimsy-loader.js b/static/js/components/whimsy-loader.js new file mode 100644 index 0000000..7055082 --- /dev/null +++ b/static/js/components/whimsy-loader.js @@ -0,0 +1,11 @@ +const fetchPublicData = async whimsyFilename => { + var result = {}; + const response = await fetch(`https://whimsy.apache.org/public/${whimsyFilename}`); + if (response.status == 200) { + const data = await response.text(); + result = JSON.parse(data); + } + return result; +} + +export default fetchPublicData; \ No newline at end of file diff --git a/static/js/volunteers-list.js b/static/js/volunteers-list.js deleted file mode 100644 index 851bc0b..0000000 --- a/static/js/volunteers-list.js +++ /dev/null @@ -1,75 +0,0 @@ -class VolunteersList extends HTMLElement { - async connectedCallback() { - const people = await this._fetchPublicData('public_ldap_people.json'); - const projects = await this._fetchPublicData('public_ldap_projects.json'); - const projectsById = this._indexProjectsById(projects); - this.querySelectorAll('li').forEach(li => { - const d = this._parseEntry(li.textContent); - - // build list of projects for this person - let projectsHTML = ''; - const theirProjects = projectsById[d.id]; - if(theirProjects) { - Object.keys(theirProjects).forEach(project => { - const isPmc = theirProjects[project].pmc; - if(projectsHTML != '') { - projectsHTML += ', '; - } - projectsHTML += `<a href=https://${project}.apache.org>${isPmc ? '<strong>' : ''}${project}${isPmc ? '</strong>' : ''}</a>`; - }) - } - - // set volunteer information - const name = people.people[d.id]?.name ? people.people[d.id]?.name : d.id; - li.innerHTML = ` - <a rel="nofollow" href="${d.url}">${name}</a> - (${d.roles}) - ${d.location && d.location != 'N/A' ? ', ' + d.location : ''} - <br/><span class='projects'><em>projects: </em>${projectsHTML}</span> - `; - }) - } - - async _fetchPublicData(whimsyFilename) { - var result = {}; - const response = await fetch(`https://whimsy.apache.org/public/${whimsyFilename}`); - if(response.status == 200) { - const data = await response.text(); - result = JSON.parse(data); - } - return result; - } - - _parseEntry(txt) { - const fields = txt.split('#'); - var i = 0; - return { - id: fields[i++]?.trim(), - roles: fields[i++]?.trim(), - url: fields[i++]?.trim(), - location: fields[i++]?.trim() - } - } - - _indexProjectsById(projects) { - var index = {}; - Object.keys(projects.projects).forEach(project => { - projects.projects[project].members.forEach(m => { - if(!index[m]) { - index[m] = {}; - } - index[m][project] = { pmc:false }; - }) - projects.projects[project].owners.forEach(m => { - if(!index[m]) { - index[m] = {}; - } - index[m][project] = { pmc:true }; - }) - }) - return index; - } - -} - -customElements.define('volunteers-list', VolunteersList); \ No newline at end of file
