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 77226c8b220072ef8b6ce4070a2ea421de668ce4
Author: Bertrand Delacretaz <[email protected]>
AuthorDate: Tue Nov 21 09:26:23 2023 +0100

    Volunteers page and related code added
---
 layouts/_default/volunteers.html      |  6 +++
 source/contributors/asf-volunteers.md | 36 +++++++++++++++++
 static/css/main.css                   |  4 ++
 static/js/volunteers-list.js          | 75 +++++++++++++++++++++++++++++++++++
 4 files changed, 121 insertions(+)

diff --git a/layouts/_default/volunteers.html b/layouts/_default/volunteers.html
new file mode 100644
index 0000000..cbbbf20
--- /dev/null
+++ b/layouts/_default/volunteers.html
@@ -0,0 +1,6 @@
+{{ define "main" }}
+    <script type="module" src="/js/volunteers-list.js"></script>
+    <volunteers-list>
+    {{ .Content }}
+    </volunteers-list>
+{{ end }}
diff --git a/source/contributors/asf-volunteers.md 
b/source/contributors/asf-volunteers.md
new file mode 100644
index 0000000..619a158
--- /dev/null
+++ b/source/contributors/asf-volunteers.md
@@ -0,0 +1,36 @@
+---
+title: ASF volunteers (mentors, speakers)
+layout: volunteers
+tags: ["committers","newcomers","contributing","mentors","speakers"]
+---
+
+Here's a list of ASF community members who volunteer to mentor new community 
members
+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.
+
+## List of ASF volunteers
+
+<!--
+To add your name to this list, use the same 
+format as other entries and keep the list sorted
+alphabetically by ASF username. Adding location information
+in the last field is optional, use N/A if you don't want
+to add that info.
+
+This data is combined with public ASF info found under
+https://whimsy.apache.org/public/public_ldap_projects.json , 
+by a Web Component loaded for this page.
+-->
+
+* bdelacretaz # mentor, speaker # https://grep.codeconsult.ch # Switzerland
+* rbowen # mentor, speaker # https://drbacchus.com/ # N/A
+
+<!-- test entries
+* some_test_entries_follow_remove_when_this_is_merged
+* invalidID # just testing # cyberspace
+* bdelacretaz # duplicate, testing, no location field
+* bdelacretaz
+* bdelacretaz # 3rd copy, testing # with location
+-->
diff --git a/static/css/main.css b/static/css/main.css
index 3f1f210..b5e2427 100644
--- a/static/css/main.css
+++ b/static/css/main.css
@@ -85,4 +85,8 @@ ul.tags-list {
   text-align: center;
   margin-top: 1rem;
   margin-bottom: 1rem;
+}
+
+volunteers-list .projects {
+  font-size: 80%;
 }
\ No newline at end of file
diff --git a/static/js/volunteers-list.js b/static/js/volunteers-list.js
new file mode 100644
index 0000000..851bc0b
--- /dev/null
+++ b/static/js/volunteers-list.js
@@ -0,0 +1,75 @@
+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

Reply via email to