From 76b8b2c6d1d613735765d6a44a8c974cd9adcbab Mon Sep 17 00:00:00 2001 From: Olivier Goulet Date: Thu, 28 Jul 2022 15:48:50 -0400 Subject: [PATCH 1/8] Add participating-organizations.js --- .../eclipsefdn.participating-organizations.js | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 js/solstice/eclipsefdn.participating-organizations.js diff --git a/js/solstice/eclipsefdn.participating-organizations.js b/js/solstice/eclipsefdn.participating-organizations.js new file mode 100644 index 0000000..d68228e --- /dev/null +++ b/js/solstice/eclipsefdn.participating-organizations.js @@ -0,0 +1,34 @@ +/*! + * Copyright (c) 2021 Eclipse Foundation, Inc. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * Contributors: + * Olivier Goulet + * + * SPDX-License-Identifier: EPL-2.0 + */ + +import $ from 'jquery'; +import path from 'path'; +import templateLoading from './templates/loading-icon.mustache'; + +const EclipseFdnParticipatingOrganizations = (async () => { + const element = document.querySelector('.eclipsefdn-participating-organizations'); + + if (!element) return; + + element.innerHTML = templateLoading(); + + const baseUrl = 'https://membership-staging.eclipse.org/api/projects/'; // set to membership.eclipse.org/api/projects + + const projectShortId = element.getAttribute('data-project-short-id'); + + if (!projectShortId) return; + + const url = path.join(baseUrl, projectShortId, '/organizations'); + + const participatingOrganizations = await getProjectsData(url); +}); \ No newline at end of file -- GitLab From 2b38d204e5dd1084940dcce44c90d06ee7f53b84 Mon Sep 17 00:00:00 2001 From: Olivier Goulet Date: Tue, 2 Aug 2022 15:44:18 -0400 Subject: [PATCH 2/8] Test participating organizations --- docs/participating-organizations.html | 321 ++++++++++++++++++ js/main.js | 2 +- .../eclipsefdn.participating-organizations.js | 30 +- js/solstice/index.js | 1 + 4 files changed, 340 insertions(+), 14 deletions(-) create mode 100644 docs/participating-organizations.html diff --git a/docs/participating-organizations.html b/docs/participating-organizations.html new file mode 100644 index 0000000..17501dd --- /dev/null +++ b/docs/participating-organizations.html @@ -0,0 +1,321 @@ + + + + + + + + + + + + + Eclipse - The Eclipse Foundation open source community website | The Eclipse Foundation + + + + + + + + + + + + + + + + + + + Skip to main content +
+ +
+
+
+
+
+ +
+
+ +
+ + +
+
+
+

Sample code used for this page:

+
 <ul class="featured-projects list-inline list" 
+            id="featured-projects"
+            data-template-id="tpl-projects-item"
+            data-url="https://projects.eclipse.org/api/projects?working_group=cloud-development-tools"></ul>
+          
+ +

Note that you will need to import eclipsefdn.projects.js as follow: + + import 'eclipsefdn-solstice-assets/js/solstice/eclipsefdn.participating-organizations.js'

+ + +
+ +
+
+
+
+ +

+ Back to the top +

+ +
+ + + + + + \ No newline at end of file diff --git a/js/main.js b/js/main.js index bf6a9ef..de54b5d 100644 --- a/js/main.js +++ b/js/main.js @@ -24,4 +24,4 @@ import './privacy' import './solstice' // Bootstrap -import './bootstrap' +import './bootstrap' \ No newline at end of file diff --git a/js/solstice/eclipsefdn.participating-organizations.js b/js/solstice/eclipsefdn.participating-organizations.js index d68228e..228bfa7 100644 --- a/js/solstice/eclipsefdn.participating-organizations.js +++ b/js/solstice/eclipsefdn.participating-organizations.js @@ -11,24 +11,28 @@ * SPDX-License-Identifier: EPL-2.0 */ -import $ from 'jquery'; -import path from 'path'; +import jQuery from 'jquery'; import templateLoading from './templates/loading-icon.mustache'; +import getProjectsData from '../api/eclipsefdn.projects'; -const EclipseFdnParticipatingOrganizations = (async () => { - const element = document.querySelector('.eclipsefdn-participating-organizations'); - - if (!element) return; +const EclipseFdnParticipatingOrganizations = (async function ($, document) { + const element = document.querySelector('.eclipsefdn-participating-organizations'); + if (!element) return; - element.innerHTML = templateLoading(); + element.innerHTML = templateLoading(); - const baseUrl = 'https://membership-staging.eclipse.org/api/projects/'; // set to membership.eclipse.org/api/projects + const baseUrl = 'https://membership-staging.eclipse.org/api/projects/'; // set to membership.eclipse.org/api/projects - const projectShortId = element.getAttribute('data-project-short-id'); + const projectShortId = element.getAttribute('data-project-short-id'); - if (!projectShortId) return; + if (!projectShortId) return; - const url = path.join(baseUrl, projectShortId, '/organizations'); + console.log("Project short id given"); + const url = `${baseUrl}/${projectShortId}/organizations`; - const participatingOrganizations = await getProjectsData(url); -}); \ No newline at end of file + const participatingOrganizations = await getProjectsData(url); + + console.log(participatingOrganizations); +})(jQuery, document); + +export default EclipseFdnParticipatingOrganizations; \ No newline at end of file diff --git a/js/solstice/index.js b/js/solstice/index.js index dc6158a..c6fa8fc 100644 --- a/js/solstice/index.js +++ b/js/solstice/index.js @@ -24,3 +24,4 @@ import './eclipsefdn.solstice-slider'; import './eclipsefdn.time-conversion'; import './eclipsefdn.wgs-list.js' import './eclipsefdn.newsroom-resources.js' +import './eclipsefdn.participating-organizations.js' -- GitLab From 824e4af8df05115792787bb7bdffd72758913248 Mon Sep 17 00:00:00 2001 From: Olivier Goulet Date: Tue, 2 Aug 2022 16:25:42 -0400 Subject: [PATCH 3/8] Add API request script for retrieving participating orgs --- js/api/eclipsefdn.project-organizations.js | 33 +++++++++++++++++++ .../eclipsefdn.participating-organizations.js | 28 +++++++++------- .../participating-organizations.mustache | 1 + 3 files changed, 51 insertions(+), 11 deletions(-) create mode 100644 js/api/eclipsefdn.project-organizations.js create mode 100644 js/solstice/templates/participating-organizations.mustache diff --git a/js/api/eclipsefdn.project-organizations.js b/js/api/eclipsefdn.project-organizations.js new file mode 100644 index 0000000..9c2fc56 --- /dev/null +++ b/js/api/eclipsefdn.project-organizations.js @@ -0,0 +1,33 @@ +import $, { type } from 'jquery'; +import { validateURL } from '../utils/utils'; +import 'isomorphic-fetch'; + +const getParticipatingOrganizations = (url) => { + if (validateURL(url)) { + return new Promise((resolve, reject) => + fetch(url) + .then((response) => { + if (response.status !== 200) { + throw `${response.status}: ${response.statusText}`; + } + response + .json() + .then((data) => { + let orgs = data; + $(orgs).each(function (key, org) { + orgs[key].version = 'none'; + }); + + orgs.sort((a, b) => a.name.localeCompare(b.name)); + resolve(orgs); + }) + .catch(reject); + }) + .catch((err) => { + reject(err); + }) + ); + } +}; + +export default getParticipatingOrganizations; diff --git a/js/solstice/eclipsefdn.participating-organizations.js b/js/solstice/eclipsefdn.participating-organizations.js index 228bfa7..2d14780 100644 --- a/js/solstice/eclipsefdn.participating-organizations.js +++ b/js/solstice/eclipsefdn.participating-organizations.js @@ -13,26 +13,32 @@ import jQuery from 'jquery'; import templateLoading from './templates/loading-icon.mustache'; -import getProjectsData from '../api/eclipsefdn.projects'; +import getParticipatingOrganizations from '../api/eclipsefdn.project-organizations'; + +const alphabeticalComparator = (a, b) => a.name.toUpperCase() > b.name.toUpperCase() ? 1 : -1; const EclipseFdnParticipatingOrganizations = (async function ($, document) { - const element = document.querySelector('.eclipsefdn-participating-organizations'); - if (!element) return; + const element = document.querySelector('.eclipsefdn-participating-organizations'); + if (!element) return; + + element.innerHTML = templateLoading(); + + const baseUrl = 'https://membership-staging.eclipse.org/api/projects/'; // set to membership.eclipse.org/api/projects - element.innerHTML = templateLoading(); + const projectShortId = element.getAttribute('data-project-short-id'); - const baseUrl = 'https://membership-staging.eclipse.org/api/projects/'; // set to membership.eclipse.org/api/projects + if (!projectShortId) return; - const projectShortId = element.getAttribute('data-project-short-id'); + console.log("Project short id given"); + const url = `${baseUrl}/${projectShortId}/organizations`; - if (!projectShortId) return; + let participatingOrganizations = await getParticipatingOrganizations(url); - console.log("Project short id given"); - const url = `${baseUrl}/${projectShortId}/organizations`; + if (!participatingOrganizations) return; - const participatingOrganizations = await getProjectsData(url); + participatingOrganizations = participatingOrganizations.sort(alphabeticalComparator); - console.log(participatingOrganizations); + console.log(participatingOrganizations); })(jQuery, document); export default EclipseFdnParticipatingOrganizations; \ No newline at end of file diff --git a/js/solstice/templates/participating-organizations.mustache b/js/solstice/templates/participating-organizations.mustache new file mode 100644 index 0000000..1e79954 --- /dev/null +++ b/js/solstice/templates/participating-organizations.mustache @@ -0,0 +1 @@ +

Testing

\ No newline at end of file -- GitLab From cebf5b4786da220e8d7e6dd859f6ee1a2d1d1009 Mon Sep 17 00:00:00 2001 From: Olivier Goulet Date: Tue, 2 Aug 2022 16:53:44 -0400 Subject: [PATCH 4/8] Add template --- js/solstice/eclipsefdn.participating-organizations.js | 7 +++++++ .../templates/participating-organizations.mustache | 8 +++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/js/solstice/eclipsefdn.participating-organizations.js b/js/solstice/eclipsefdn.participating-organizations.js index 2d14780..f4564af 100644 --- a/js/solstice/eclipsefdn.participating-organizations.js +++ b/js/solstice/eclipsefdn.participating-organizations.js @@ -14,6 +14,7 @@ import jQuery from 'jquery'; import templateLoading from './templates/loading-icon.mustache'; import getParticipatingOrganizations from '../api/eclipsefdn.project-organizations'; +import template from "./templates/participating-organizations.mustache"; const alphabeticalComparator = (a, b) => a.name.toUpperCase() > b.name.toUpperCase() ? 1 : -1; @@ -39,6 +40,12 @@ const EclipseFdnParticipatingOrganizations = (async function ($, document) { participatingOrganizations = participatingOrganizations.sort(alphabeticalComparator); console.log(participatingOrganizations); + + const data = { + items: participatingOrganizations + }; + + element.innerHTML = template(data); })(jQuery, document); export default EclipseFdnParticipatingOrganizations; \ No newline at end of file diff --git a/js/solstice/templates/participating-organizations.mustache b/js/solstice/templates/participating-organizations.mustache index 1e79954..c1dd988 100644 --- a/js/solstice/templates/participating-organizations.mustache +++ b/js/solstice/templates/participating-organizations.mustache @@ -1 +1,7 @@ -

Testing

\ No newline at end of file +
    + {{#items}} +
  • + {{ name }}'s logo +
  • + {{/items}} +
\ No newline at end of file -- GitLab From e89c9b46b07cddf66980d5c57361f67930e85385 Mon Sep 17 00:00:00 2001 From: Olivier Goulet Date: Thu, 4 Aug 2022 11:48:14 -0400 Subject: [PATCH 5/8] Update docs for participating orgs --- docs/participating-organizations.html | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/docs/participating-organizations.html b/docs/participating-organizations.html index 17501dd..dae1236 100644 --- a/docs/participating-organizations.html +++ b/docs/participating-organizations.html @@ -199,11 +199,7 @@

Sample code used for this page:

-
 <ul class="featured-projects list-inline list" 
-            id="featured-projects"
-            data-template-id="tpl-projects-item"
-            data-url="https://projects.eclipse.org/api/projects?working_group=cloud-development-tools"></ul>
-          
+
 <div data-project-short-id="iot" class="eclipsefdn-participating-organizations col-md-18 col-md-offset-3" />

Note that you will need to import eclipsefdn.projects.js as follow: -- GitLab From 55aa111d46e81af7bc39596e940f8c9008da0480 Mon Sep 17 00:00:00 2001 From: Olivier Goulet Date: Thu, 4 Aug 2022 11:53:01 -0400 Subject: [PATCH 6/8] Remove console logs --- js/solstice/eclipsefdn.participating-organizations.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/js/solstice/eclipsefdn.participating-organizations.js b/js/solstice/eclipsefdn.participating-organizations.js index f4564af..ccbd1b4 100644 --- a/js/solstice/eclipsefdn.participating-organizations.js +++ b/js/solstice/eclipsefdn.participating-organizations.js @@ -30,7 +30,6 @@ const EclipseFdnParticipatingOrganizations = (async function ($, document) { if (!projectShortId) return; - console.log("Project short id given"); const url = `${baseUrl}/${projectShortId}/organizations`; let participatingOrganizations = await getParticipatingOrganizations(url); @@ -39,8 +38,6 @@ const EclipseFdnParticipatingOrganizations = (async function ($, document) { participatingOrganizations = participatingOrganizations.sort(alphabeticalComparator); - console.log(participatingOrganizations); - const data = { items: participatingOrganizations }; -- GitLab From 6b68a5d92bd2ec6fe451c1bb11e779c0cb1037ce Mon Sep 17 00:00:00 2001 From: Olivier Goulet Date: Fri, 5 Aug 2022 14:02:02 -0400 Subject: [PATCH 7/8] Replace api staging url to prod url --- js/solstice/eclipsefdn.participating-organizations.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/solstice/eclipsefdn.participating-organizations.js b/js/solstice/eclipsefdn.participating-organizations.js index ccbd1b4..8c7c0a2 100644 --- a/js/solstice/eclipsefdn.participating-organizations.js +++ b/js/solstice/eclipsefdn.participating-organizations.js @@ -24,7 +24,7 @@ const EclipseFdnParticipatingOrganizations = (async function ($, document) { element.innerHTML = templateLoading(); - const baseUrl = 'https://membership-staging.eclipse.org/api/projects/'; // set to membership.eclipse.org/api/projects + const baseUrl = 'https://membership.eclipse.org/api/projects/'; const projectShortId = element.getAttribute('data-project-short-id'); -- GitLab From e7e1290f10ce5a38883804648345496f0b05188b Mon Sep 17 00:00:00 2001 From: Olivier Goulet Date: Mon, 8 Aug 2022 10:28:16 -0400 Subject: [PATCH 8/8] Add margins to participating orgs list items and center images --- js/solstice/templates/participating-organizations.mustache | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/solstice/templates/participating-organizations.mustache b/js/solstice/templates/participating-organizations.mustache index c1dd988..3b9b964 100644 --- a/js/solstice/templates/participating-organizations.mustache +++ b/js/solstice/templates/participating-organizations.mustache @@ -1,6 +1,6 @@ -

    +
      {{#items}} -
    • +
    • {{ name }}'s logo
    • {{/items}} -- GitLab