From ea7150ed4cea7be0354894a912b4b2cbde3f6ae2 Mon Sep 17 00:00:00 2001 From: marcofaggian Date: Tue, 11 Oct 2022 00:34:29 +0200 Subject: [PATCH 1/3] feat(microsite): added "new" ribbon to plugins Signed-off-by: marcofaggian --- microsite/pages/en/plugins.js | 22 +++++++++++++++++++++- microsite/static/css/plugins.css | 29 +++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/microsite/pages/en/plugins.js b/microsite/pages/en/plugins.js index de336444ab..3e7868cd30 100644 --- a/microsite/pages/en/plugins.js +++ b/microsite/pages/en/plugins.js @@ -16,11 +16,24 @@ const { const pluginsDirectory = require('path').join(process.cwd(), 'data/plugins'); const pluginMetadata = fs .readdirSync(pluginsDirectory) - .map(file => yaml.load(fs.readFileSync(`./data/plugins/${file}`, 'utf8'))) + .map(file => { + const fileContent = fs.readFileSync(`./data/plugins/${file}`, 'utf8'); + let metadata = yaml.load(fileContent); + + const gitIsoDate = require('child_process') + .execSync( + `git log -1 --format="%ai" --reverse ./data/plugins/${file} | cat -`, + ) + .toString(); + + return { ...metadata, date: new Date(gitIsoDate) }; + }) .sort((a, b) => a.title.toLowerCase().localeCompare(b.title.toLowerCase())); const truncate = text => text.length > 170 ? text.substr(0, 170) + '...' : text; +const newForDays = 100; + const addPluginDocsLink = '/docs/plugins/add-to-marketplace'; const defaultIconUrl = 'img/logo-gradient-on-dark.svg'; @@ -100,8 +113,15 @@ const Plugins = () => ( authorUrl, documentation, category, + date, }) => (
+ {Math.trunc((Date.now() - date) / (1000 * 60 * 60 * 24)) < + newForDays && ( +
+ NEW +
+ )}
{title} diff --git a/microsite/static/css/plugins.css b/microsite/static/css/plugins.css index b9aebfa84c..55a0c6df40 100644 --- a/microsite/static/css/plugins.css +++ b/microsite/static/css/plugins.css @@ -4,6 +4,7 @@ padding: 16px; display: flex; flex-direction: column; + position: relative; } .PluginGrid { @@ -141,3 +142,31 @@ #add-plugin-card { border: 1px solid #69ddc7; } + +/* RIBBON */ + +.ribbon { + width: 80px; + height: 80px; + overflow: hidden; + position: absolute; +} +.ribbon span { + position: absolute; + display: block; + width: 140px; + padding: 4px 0; + background-color: rgb(54, 186, 162, 0.85); + box-shadow: 0 5px 10px rgba(0, 0, 0, 0.1); + color: #fff; + text-align: center; +} +.ribbon-top-right { + top: 0; + right: 0; +} +.ribbon-top-right span { + left: -17px; + top: 11px; + transform: rotate(45deg); +} From e71398d6bf3663314bef9130a6bff229540f348d Mon Sep 17 00:00:00 2001 From: marcofaggian Date: Wed, 12 Oct 2022 11:51:03 +0200 Subject: [PATCH 2/3] fix(microsite): moved back to object mutation Signed-off-by: marcofaggian --- microsite/pages/en/plugins.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/microsite/pages/en/plugins.js b/microsite/pages/en/plugins.js index 3e7868cd30..ab83438ee8 100644 --- a/microsite/pages/en/plugins.js +++ b/microsite/pages/en/plugins.js @@ -26,7 +26,9 @@ const pluginMetadata = fs ) .toString(); - return { ...metadata, date: new Date(gitIsoDate) }; + metadata.date = new Date(gitIsoDate) + + return metadata; }) .sort((a, b) => a.title.toLowerCase().localeCompare(b.title.toLowerCase())); const truncate = text => From 13bb508c24b4897ead54e00355503c80ec6ad4e9 Mon Sep 17 00:00:00 2001 From: marcofaggian Date: Wed, 12 Oct 2022 11:59:26 +0200 Subject: [PATCH 3/3] fix(microsite): CWE-78, className Signed-off-by: marcofaggian --- microsite/pages/en/plugins.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/microsite/pages/en/plugins.js b/microsite/pages/en/plugins.js index ab83438ee8..91f4138174 100644 --- a/microsite/pages/en/plugins.js +++ b/microsite/pages/en/plugins.js @@ -21,12 +21,16 @@ const pluginMetadata = fs let metadata = yaml.load(fileContent); const gitIsoDate = require('child_process') - .execSync( - `git log -1 --format="%ai" --reverse ./data/plugins/${file} | cat -`, - ) + .execFileSync('git', [ + 'log', + '-1', + '--format="%ai"', + '--reverse', + `./data/plugins/${file}`, + ]) .toString(); - metadata.date = new Date(gitIsoDate) + metadata.date = new Date(gitIsoDate); return metadata; }) @@ -120,7 +124,7 @@ const Plugins = () => (
{Math.trunc((Date.now() - date) / (1000 * 60 * 60 * 24)) < newForDays && ( -
+
NEW
)}