Skip to content
Snippets Groups Projects
Commit dd778457 authored by Eric Poirier's avatar Eric Poirier
Browse files

Use projects.js from hugo theme


Signed-off-by: default avatarEric Poirier <eric.poirier@eclipse-foundation.org>
parent 8b1028f2
No related branches found
No related tags found
No related merge requests found
......@@ -9,13 +9,24 @@ container: "container-fluid"
main_content_class: "col-sm-18 col-sm-offset-3"
---
{{< grid/div class="row featured-section featured-section-prefix text-center featured-content-white-bg" isMarkdown="false" >}}
{{< grid/div class="container" isMarkdown="false" >}}
{{< grid/div class="row" isMarkdown="false" >}}
{{< grid/div class="col-md-14 col-md-offset-5 col-sm-18 col-sm-offset-3" isMarkdown="false" >}}
<p class="small">PROJECTS</p>
<p class="powered-by-description">The Eclipse Cloud DevTools Working Group serves to
advance, promote, and drive community participation in a
broad portfolio of Eclipse projects.</p>
<p><a class="btn btn-primary" href="https://projects.eclipse.org/projects/ecd">Learn More</a></p>
{{</ grid/div >}}
{{</ grid/div >}}
{{</ grid/div >}}
{{</ grid/div >}}
{{< page/projects
{{< eclipsefdn_projects
templateId="tpl-projects-item"
url="https://projects.eclipse.org/api/projects?working_group=cloud-development-tools"
classes="margin-top-30"
display_title="false"
display_search="true"
display_categories="true"
categories="featured-projects-categories.json"
categories="/js/featured-projects-categories.json"
>}}
......@@ -13,7 +13,7 @@
import 'eclipsefdn-solstice-assets'
import './src/userprofile'
import './src/projects'
import 'eclipsefdn-solstice-assets/js/solstice/eclipsefdn.projects'
import './src/eclipseApi'
import './src/parallax'
import './adopters-alternate.js'
......
/*!
* 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:
* Eric Poirier <eric.poirier@eclipse-foundation.org>
*
* SPDX-License-Identifier: EPL-2.0
*/
import $ from 'jquery';
import Mustache from 'mustache';
import template from '../templates/tpl-projects-item.mustache';
import "numeral";
import List from 'list.js';
export const processJSON = (json, options) => {
function fileExists(url) {
if(url){
let req = new XMLHttpRequest();
req.open('GET', url, false);
req.send();
return req.status == 200;
} else {
return false;
}
}
// Initiate the projects array
let projects = json;
// Filter by project ID
if (options.projectIds !== undefined && options.projectIds !== "") {
const acceptedProjectIds = options.projectIds.split(",");
projects = [];
$(json).each(function(key, element){
if (acceptedProjectIds.includes(element.project_id)) {
projects.push(element);
}
});
}
$(projects).each(function(key, project){
// Populate the Tags array
const project_tags = projects[key].tags;
if (project_tags.length !== 0) {
tags[projects[key].project_id] = project_tags;
}
let category = getCategory(projects[key].project_id);
projects[key].category = category.toString().split(',').join(', ');
projects[key].version = 'none';
if (project.releases[0]) {
projects[key].version = project.releases[0].name;
}
if (options.templateId !== "tpl-projects-item") {
$(project.project_leads).each(function(project_lead_key, project_lead){
projects[key].project_lead_image = '/images/ecdtools/home/silhouette.jpg';
projects[key].project_lead_full_name = project_lead.full_name;
if (fileExists('/images/ecdtools/projects/'+ project_lead.username +'.png')) {
projects[key].project_lead_image = '/images/ecdtools/projects/'+ project_lead.username +'.png';
}
return false;
});
}
});
return projects;
};
(function ($, document) {
$('.featured-projects').each(function (index, element) {
const options = {
id: '',
templateId: '',
projectIds: '',
url: '',
...$(element).data(),
};
// fetching the users
function fetchProjects() {
return fetch(options.url)
.then(response => response.json())
}
let results = [];
Promise.allSettled([fetchProjects()])
.then(function (responses) {
responses.forEach((el) => {
// skip rejected promises
if (el.status === 'fulfilled') {
const projects = processJSON(el.value, options);
if (projects.length > 0) {
results = projects;
}
}
});
const data = {
items: results,
};
// Render component
let html = '';
if (options.templateId !== '' && document.getElementById(options.templateId)) {
const theme = document.getElementById(options.templateId).innerHTML;
html = Mustache.render(theme, data);
} else {
html = template(data);
}
element.innerHTML += html;
const values = {
valueNames: [
'name',
'category'
],
};
let list = new List('projects-list', values);
// Filters
let categories = projectsCategories();
$.each( categories, function( key, projects ) {
$.each( projects, function( key, value ) {
let duplicate = $('.eclipsefdn-project-list-filters').find("button:contains('"+ value +"')");
if (duplicate.length > 0) {
return;
}
let button = document.createElement('button');
button.innerHTML = value;
button.className = 'btn btn-filter-project';
button.setAttribute('data-toggle','button');
$('.eclipsefdn-project-list-filters').append(button);
});
});
$('.btn-filter-project').on('click', function (elem) {
$('.btn-filter-project').not(this).each(function(){
$(this).removeClass('active');
});
setTimeout(function () {
list.filter(computeFilterFunction);
}, 10);
});
})
.catch(err => console.log(err));
});
})(jQuery, document);
let tags = {};
let projectsCategories = function() {
let elem = document.getElementById('projects-categories');
if (elem !== null){
let categoriesUrl = elem.getAttribute('data-categories');
let json = require('./' + categoriesUrl);
if (json) {
return json;
}
}
return tags;
}
let getCategory = function(project_id) {
const categories = projectsCategories();
let category = "Other Tools";
if (typeof categories[project_id] !== "undefined") {
category = categories[project_id];
}
return category;
}
let computeFilterFunction = function (item) {
let filter = [];
$('.btn-filter-project').each(function (index, elem) {
if ($(elem).hasClass('active')) {
filter.push($(elem).text());
}
});
if (filter.length == 0) {
return true;
}
let found = false;
for (let i = 0; i < filter.length; i++) {
const element = filter[i];
if (typeof item.values().category !== "undefined" && item.values().category.indexOf(element) !== -1) {
found = true;
continue;
}
found = false;
break;
}
return found;
};
......@@ -18,7 +18,7 @@
{{ $classes := .Get "classes" }}
{{ $categories := .Get "categories" | default "" }}
<section id="wg-projects" class="container featured-section featured-section-projects" data-filter-wg="{{ $.Site.Params.projects_working_group }}">
<section id="wg-projects" class="container featured-section featured-section-projects featured-section-projects-home" data-filter-wg="{{ $.Site.Params.projects_working_group }}">
<div class="row">
<div id="projects-list" class="col-md-18 col-md-offset-3">
<h2 id="projects" class="brand-primary text-center heading-underline">Featured Projects</h2>
......
......@@ -32,10 +32,12 @@
</div>
<section id="wg-projects" class="container featured-section featured-section-projects" data-filter-wg="{{ $.Site.Params.projects_working_group }}">
<div class="row">
<div id="projects-list" class="col-md-18 col-md-offset-3">
<div id="projects-list" class="col-md-14 col-md-offset-5">
<input aria-label="Search for a project" type="text" class="form-control search center-block" placeholder="Start typing to filter projects…">
<p class="margin-bottom-0 margin-top-20 text-center">Filter by categories:</p>
<div id="projects-categories" class="eclipsefdn-project-list-filters text-center" data-categories="{{ $categories }}"></div>
{{ if ne $categories "" }}
<p class="margin-bottom-0 margin-top-20 text-center">Filter by categories:</p>
<div id="projects-categories" class="eclipsefdn-project-list-filters text-center" data-categories="{{ $categories }}"></div>
{{ end }}
<ul class="featured-projects list-inline list {{ $classes }}"
id="{{ $id }}"
data-project-ids="{{ $projectIds }}"
......
......@@ -117,7 +117,7 @@
}
}
.featured-section-projects {
.featured-section-projects-home {
background-color:#f9fafa;
.logo {
max-height: 65px;
......
......@@ -14,56 +14,3 @@
.header-projects-bg-img {
background-image:@featured-jumbotron-projects-bg-img;
}
.featured-projects-item {
background-color:@white;
box-shadow: 5px 5px 5px rgba(0,0,0,0.3);
padding: 20px;
margin-bottom: 30px;
hr{
border-top: 1px solid @brand-primary;
}
.downloadUrl {
color:@brand-primary;
&:hover {
color:darken(@brand-primary, 15%);
}
}
}
.featured-projects-item-category {
background-color:@brand-primary;
min-width:200px;
color:@white;
text-transform: uppercase;
text-align:center;
padding:2px;
float: right;
position: relative;
right: -20px;
font-size: 11px;
}
.featured-projects-item-heading {
font-weight:bold;
margin-bottom: 0;
}
.featured-projects-item-img {
margin-bottom: 40px;
max-width: 130px;
margin-top: 20px;
max-height: 40px;
}
.featured-projects-item-content {
padding-top:30px;
}
.eclipsefdn-project-list-filters .btn {
margin: 10px 10px 0 0;
&.active:focus, &:focus {
outline: none;
color: #333;
}
}
\ No newline at end of file
......@@ -18,11 +18,9 @@
"hot": "NODE_ENV=development webpack-dev-server --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
"production": "NODE_ENV=production webpack --progress --config=node_modules/laravel-mix/setup/webpack.config.js",
"install": "NODE_ENV=production npm run production",
"postinstall": "npm run fetch_projects && npm run yaml2json_projects",
"fetch_projects": "node node_modules/eclipsefdn-hugo-solstice-theme/bin/projects/index.js -l data -u https://projects.eclipse.org/api/projects?working_group=cloud-development-tools",
"yaml2json_projects": "node node_modules/js-yaml/bin/js-yaml.js -c data/eclipsefdn_projects.yaml | node node_modules/json-minify/index.js > static/js/projects.json",
"postinstall": "cp data/featured-projects-categories.json static/js",
"disallow_robots_txt": "echo \"User-agent: *\r\nDisallow: /\" > layouts/robots.txt",
"build_netlify": "NODE_ENV=production npm run disallow_robots_txt && npm run production && npm run fetch_projects && npm run yaml2json_projects"
"build_netlify": "NODE_ENV=production npm run disallow_robots_txt && npm run production && cp data/featured-projects-categories.json static/js"
},
"dependencies": {
"eclipsefdn-hugo-solstice-theme": "0.0.148",
......
......@@ -1508,12 +1508,21 @@ async@^2.6.2:
lodash "^4.17.14"
autoprefixer@^10.4.0:
<<<<<<< HEAD
version "10.4.7"
resolved "https://registry.yarnpkg.com/autoprefixer/-/autoprefixer-10.4.7.tgz#1db8d195f41a52ca5069b7593be167618edbbedf"
integrity sha512-ypHju4Y2Oav95SipEcCcI5J7CGPuvz8oat7sUtYj3ClK44bldfvtvcxK6IEK++7rqB7YchDGzweZIBG+SD0ZAA==
dependencies:
browserslist "^4.20.3"
caniuse-lite "^1.0.30001335"
=======
version "10.4.6"
resolved "https://registry.yarnpkg.com/autoprefixer/-/autoprefixer-10.4.6.tgz#ce6eba3aea7c03adf0f6a907bd594fd170b3f0b6"
integrity sha512-Rvzel0AZO9tJNm3ydySK80PpkWoEZTGC5bHUh/xbrP8qJCy08NFBwNGPcozy3d3SDIM0b2kNxw2K7jAIYFF01A==
dependencies:
browserslist "^4.20.3"
caniuse-lite "^1.0.30001334"
>>>>>>> f6c2bc4 (Use projects.js from hugo theme)
fraction.js "^4.2.0"
normalize-range "^0.1.2"
picocolors "^1.0.0"
......@@ -1805,7 +1814,11 @@ caniuse-api@^3.0.0:
lodash.memoize "^4.1.2"
lodash.uniq "^4.5.0"
<<<<<<< HEAD
caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001332, caniuse-lite@^1.0.30001335:
=======
caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001332, caniuse-lite@^1.0.30001334:
>>>>>>> f6c2bc4 (Use projects.js from hugo theme)
version "1.0.30001335"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001335.tgz#899254a0b70579e5a957c32dced79f0727c61f2a"
integrity sha512-ddP1Tgm7z2iIxu6QTtbZUv6HJxSaV/PZeSrWFZtbY4JZ69tOeNhBCl3HyRQgeNZKE5AOn1kpV7fhljigy0Ty3w==
......@@ -2074,17 +2087,29 @@ copy-anything@^2.0.1:
is-what "^3.14.1"
core-js-compat@^3.21.0, core-js-compat@^3.22.1:
<<<<<<< HEAD
version "3.22.4"
resolved "https://registry.yarnpkg.com/core-js-compat/-/core-js-compat-3.22.4.tgz#d700f451e50f1d7672dcad0ac85d910e6691e579"
integrity sha512-dIWcsszDezkFZrfm1cnB4f/J85gyhiCpxbgBdohWCDtSVuAaChTSpPV7ldOQf/Xds2U5xCIJZOK82G4ZPAIswA==
=======
version "3.22.3"
resolved "https://registry.yarnpkg.com/core-js-compat/-/core-js-compat-3.22.3.tgz#9b10d786052d042bc97ee8df9c0d1fb6a49c2005"
integrity sha512-wliMbvPI2idgFWpFe7UEyHMvu6HWgW8WA+HnDRtgzoSDYvXFMpoGX1H3tPDDXrcfUSyXafCLDd7hOeMQHEZxGw==
>>>>>>> f6c2bc4 (Use projects.js from hugo theme)
dependencies:
browserslist "^4.20.3"
semver "7.0.0"
core-js@^3.1.3, core-js@^3.15.2:
<<<<<<< HEAD
version "3.22.4"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.22.4.tgz#f4b3f108d45736935aa028444a69397e40d8c531"
integrity sha512-1uLykR+iOfYja+6Jn/57743gc9n73EWiOnSJJ4ba3B4fOEYDBv25MagmEZBxTp5cWq4b/KPx/l77zgsp28ju4w==
=======
version "3.22.3"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.22.3.tgz#498c41d997654cb00e81c7a54b44f0ab21ab01d5"
integrity sha512-1t+2a/d2lppW1gkLXx3pKPVGbBdxXAkqztvWb1EJ8oF8O2gIGiytzflNiFEehYwVK/t2ryUsGBoOFFvNx95mbg==
>>>>>>> f6c2bc4 (Use projects.js from hugo theme)
core-util-is@~1.0.0:
version "1.0.3"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment