Skip to content
Snippets Groups Projects
Commit 41e05917 authored by Zhou Fang's avatar Zhou Fang
Browse files

Merge branch 'zhoufang/master/infra508' into 'master'

Updated resource code based on new EFSA

See merge request eclipsefdn/it/websites/iot.eclipse.org!701
parents 59a4b5b1 54abb605
No related branches found
No related tags found
No related merge requests found
...@@ -15,8 +15,8 @@ layout: "single" ...@@ -15,8 +15,8 @@ layout: "single"
{{< youtube "videoseries?list=PLy7t4z5SYNaRorMpk1txiehpkyeI0JLn-">}} {{< youtube "videoseries?list=PLy7t4z5SYNaRorMpk1txiehpkyeI0JLn-">}}
{{</ grid/div >}} {{</ grid/div >}}
<!-- Items inside all-resources will be generated by resources.js using template iot-resources.mustache --> {{< newsroom/resources wg="eclipse_iot" title="Surveys, Case Studies, White Papers, Market Reports" type="survey_report, case_study, white_paper, market_report" template="image-with-title" limit="3" class="col-md-8" viewMorePath="iot-surveys, case-studies, white-papers, market-reports" >}}
{{< grid/div id="all-resources" >}}{{</ grid/div >}}
{{< grid/div class="resources" isMarkdown="false" >}} {{< grid/div class="resources" isMarkdown="false" >}}
{{< newsroom/news {{< newsroom/news
......
...@@ -7,4 +7,4 @@ weight: 3 ...@@ -7,4 +7,4 @@ weight: 3
layout: "single" layout: "single"
--- ---
{{< page-api-resources type="case_study" >}} {{< newsroom/resources wg="eclipse_iot" type="case_study" template="image-with-title" class="col-md-8" >}}
...@@ -8,4 +8,4 @@ weight: 2 ...@@ -8,4 +8,4 @@ weight: 2
Explore the results of the influential annual IoT Developer Surveys on key IoT industry technologies, trends, and opportunities. Explore the results of the influential annual IoT Developer Surveys on key IoT industry technologies, trends, and opportunities.
{{< page-api-resources type="survey_report" >}} {{< newsroom/resources wg="eclipse_iot" type="survey_report" template="image-with-title" class="col-md-8" >}}
\ No newline at end of file
...@@ -6,4 +6,4 @@ weight: 5 ...@@ -6,4 +6,4 @@ weight: 5
layout: "single" layout: "single"
--- ---
{{< page-api-resources type="market_report" >}} {{< newsroom/resources wg="eclipse_iot" type="market_report" template="image-with-title" class="col-md-8" >}}
...@@ -8,4 +8,4 @@ weight: 4 ...@@ -8,4 +8,4 @@ weight: 4
layout: "single" layout: "single"
--- ---
{{< page-api-resources type="white_paper" >}} {{< newsroom/resources wg="eclipse_iot" type="white_paper" template="image-with-title" class="col-md-8" >}}
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
import 'eclipsefdn-solstice-assets' import 'eclipsefdn-solstice-assets'
import './src/home-members' import './src/home-members'
import 'eclipsefdn-solstice-assets/js/solstice/eclipsefdn.projects' import 'eclipsefdn-solstice-assets/js/solstice/eclipsefdn.projects'
import './src/resources'
(function($, document) { (function($, document) {
$('.media-video').matchHeight(); $('.media-video').matchHeight();
......
export let resourcesData = [
{
title: 'Surveys',
resource_type: 'survey_report',
path: 'iot-surveys',
isFetching: true,
data: [],
},
{
title: 'Case Studies',
resource_type: 'case_study',
path: 'case-studies',
isFetching: true,
data: [],
},
{
title: 'White Papers',
resource_type: 'white_paper',
path: 'white-papers',
isFetching: true,
data: [],
},
{
title: 'Market Reports',
resource_type: 'market_report',
path: 'market-reports',
isFetching: true,
data: [],
},
];
import { resourcesData } from './resources-data';
import template from '../templates/iot-resources.mustache';
import templateForOneType from '../templates/iot-one-type-resources.mustache';
const formatDate = function () {
let theDate = new Date(this.date).toDateString();
theDate = theDate.slice(0, 3) + ',' + theDate.slice(3);
return theDate;
};
const displayDataOnPage = () => {
document.getElementById('all-resources').innerHTML = template({
sections: resourcesData,
formatDate: formatDate,
});
};
const displayDataOnPageForOneType = (data) => {
document.getElementById('one-type-resources').innerHTML = templateForOneType({
items: data,
formatDate: formatDate,
});
};
if (document.getElementById('all-resources')) {
// Set loading spinner
displayDataOnPage();
const fetchPreviewData = () => {
resourcesData.forEach((section) => {
fetch(
`https://newsroom.eclipse.org/api/resources?pagesize=3&parameters[publish_to]=eclipse_iot&parameters[resource_type][]=${section.resource_type}`
)
.then((res) => res.json())
.then((data) => {
section.data = data.resources;
section.isFetching = false;
displayDataOnPage();
})
.catch((err) => console.log(err));
});
};
fetchPreviewData();
}
const oneTypeResElement = document.getElementById('one-type-resources');
if (oneTypeResElement) {
const fetchWithPagination = async () => {
let i = 1;
let data = [];
const getData = async () => {
let response = await fetch(
`https://newsroom.eclipse.org/api/resources?pagesize=60&parameters[publish_to]=eclipse_iot&parameters[resource_type][]=${oneTypeResElement.getAttribute(
'data-res-type'
)}`
);
if (response.ok) {
let newData = await response.json();
data = [...data, ...newData.resources];
if (response.headers.get('link')?.includes('rel="next"')) {
i++;
await getData();
}
}
};
await getData();
displayDataOnPageForOneType(data);
};
fetchWithPagination();
}
{{#items}}
<div class="col-md-8">
<div class="resources-summary">
{{#landing_link}}
<a class="resources-summary-img" href="{{landing_link}}">
<img src="{{image}}" alt="{{title}}">
</a>
<h4 class="resources-summary-heading"><a href="{{landing_link}}">{{title}}</a></h4>
{{/landing_link}}
{{^landing_link}}
{{#direct_link}}
<a class="resources-summary-img" href="{{direct_link}}">
<img src="{{image}}" alt="{{title}}">
</a>
<h4 class="resources-summary-heading"><a href="{{direct_link}}">{{title}}</a></h4>
{{/direct_link}}
{{^direct_link}}
<img src="{{image}}" alt="{{title}}">
<h4 class="resources-summary-heading">{{title}}</h4>
{{/direct_link}}
{{/landing_link}}
{{#date}}
<p class="resources-summary-date">{{formatDate}}</p>
{{/date}}
<p style="margin-top: 1em;">
{{#landing_link}}
<a href="{{landing_link}}"><i class="fa fa-file-text-o" aria-hidden="true"></i> <span class="sr-only">HTML Link</span></a>
{{/landing_link}}
{{^landing_link}}
{{#direct_link}}
<a href="{{direct_link}}"><i class="fa fa-file-pdf-o" aria-hidden="true"></i> <span class="sr-only">PDF Link</span></a>
{{/direct_link}}
{{/landing_link}}
</p>
</div>
</div>
{{/items}}
\ No newline at end of file
{{#sections}}
<h2>{{title}}</h2>
<div class="resources">
<div class="row">
{{#.}}
{{#isFetching}}
<i class="fa fa-spinner fa-pulse fa-2x fa-fw margin-left-20"></i>
<span class="sr-only">Loading...</span>
{{/isFetching}}
{{#data}}
<div class="col-md-8 matchheight-item">
<div class="resources-summary">
{{#landing_link}}
<a class="resources-summary-img" href="{{landing_link}}">
<img src="{{image}}" alt="{{title}}">
</a>
<h4 class="resources-summary-heading"><a href="{{landing_link}}">{{title}}</a></h4>
{{/landing_link}}
{{^landing_link}}
{{#direct_link}}
<a class="resources-summary-img" href="{{direct_link}}">
<img src="{{image}}" alt="{{title}}">
</a>
<h4 class="resources-summary-heading"><a href="{{direct_link}}">{{title}}</a></h4>
{{/direct_link}}
{{^direct_link}}
<img src="{{image}}" alt="{{title}}">
<h4 class="resources-summary-heading">{{title}}</h4>
{{/direct_link}}
{{/landing_link}}
{{#date}}
<p class="resources-summary-date">{{formatDate}}</p>
{{/date}}
<p style="margin-top: 1em;">
{{#landing_link}}
<a href="{{landing_link}}"><i class="fa fa-file-text-o" aria-hidden="true"></i> <span class="sr-only">HTML Link</span></a>
{{/landing_link}}
{{^landing_link}}
{{#direct_link}}
<a href="{{direct_link}}"><i class="fa fa-file-pdf-o" aria-hidden="true"></i> <span class="sr-only">PDF Link</span></a>
{{/direct_link}}
{{/landing_link}}
</p>
</div>
</div>
{{/data}}
{{/.}}
</div>
<p class="text-right resources-more"><a href="{{path}}">View More</a></p>
</div>
{{/sections}}
<!--
Copyright (c) 2022 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:
Zhou Fang <zhou.fang@eclipse-foundation.org>
SPDX-License-Identifier: EPL-2.0
-->
{{ $type := .Get "type" }}
<div class="resources each-resource" id="one-type-resources" data-res-type="{{$type}}" style="border-bottom:none;">
<i class="fa fa-spinner fa-pulse fa-2x fa-fw margin-left-20"></i>
<span class="sr-only">Loading...</span>
</div>
\ No newline at end of file
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
"build_netlify": "NODE_ENV=production npm run production" "build_netlify": "NODE_ENV=production npm run production"
}, },
"dependencies": { "dependencies": {
"eclipsefdn-hugo-solstice-theme": "0.0.154", "eclipsefdn-hugo-solstice-theme": "0.0.156",
"list.js": "^1.2.0" "list.js": "^1.2.0"
}, },
"prettier": { "prettier": {
......
This diff is collapsed.
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