Skip to content

Commit

Permalink
Add opt-in for premium content.
Browse files Browse the repository at this point in the history
  • Loading branch information
jason-fox committed Jan 10, 2025
1 parent ce482e5 commit 810fb97
Show file tree
Hide file tree
Showing 88 changed files with 45 additions and 98 deletions.
3 changes: 0 additions & 3 deletions bin/downloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,6 @@ const PROMPT =
function getTextContent(item) {
const url = 'https://mlapi.qualetics.com/api/datamachine/init?id=6751b18658f9465ff86d2eef';
const input = `<p>${item.excerpt}.</p> ${item.description}`;

console.log(input)

const payload = { input, prompt: PROMPT };
return fetch(
url,
Expand Down
24 changes: 18 additions & 6 deletions bin/parsers/showcase.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ function extractSummaryInfo(input, details) {

item.Member = item.Member ? item.Member.toLowerCase() : 'false';
item.iHub = item.iHub ? item.iHub.toLowerCase() : 'false';
item.optIn = item['Opt In'] ? item['Opt In'].toLowerCase() : 'false';

if (item.Member === 'false') {
item.Member = false;
Expand All @@ -179,13 +180,20 @@ function extractSummaryInfo(input, details) {
if (item.iHub === 'true') {
item.iHub = true;
}
if (item.optIn === 'false') {
item.optIn = false;
}
if (item.optIn === 'true') {
item.optIn = true;
}

const obj = {};
obj.company = item['Organisation Name'];
obj.name = item['Product Name'];
obj.logo = item.Logo;
obj.fiwareMember = item.Member;
obj.fiwareIhub = item.iHub;
obj.optIn = item.Member && item.optIn;

if (details[category][hash]) {
obj.companyLink = '../product-details/?category=' + category + '&id=' + hash;
Expand Down Expand Up @@ -344,13 +352,17 @@ async function generateContent(optIn, products, type) {
console.log(`Generating Premium Content for ${type}`);

for (const item of _.pairs(products)) {
const filename = path.join(__dirname, `../../marketplace/texts/${item[0]}.html`);
if (hashes.includes(item[0])) {
let text = await Downloader.getTextContent(item[1]);
const text = await Downloader.getTextContent(item[1]);

const filename = path.join(__dirname, `../../marketplace/texts/${item[0]}.html`);
fs.writeFile(filename, text, function (err) {
if (err) return console.log(err);
});
} else {
fs.rmSync(filename, {
force: true,
});
}
}
console.log();
Expand Down Expand Up @@ -464,7 +476,7 @@ function parse(detailsFile, summaryFile) {
.then((summaryInfo) => {
return GEN_CONTENT
? generateContent(
_.where(summaryInfo.powered, { fiwareMember: true }),
_.where(summaryInfo.powered, { optIn: true }),
allProducts.powered,
'products'
).then(() => {
Expand All @@ -475,7 +487,7 @@ function parse(detailsFile, summaryFile) {
.then((summaryInfo) => {
return GEN_CONTENT
? generateContent(
_.where(summaryInfo.ready, { fiwareMember: true }),
_.where(summaryInfo.ready, { optIn: true }),
allProducts.ready,
'devices'
).then(() => {
Expand All @@ -486,7 +498,7 @@ function parse(detailsFile, summaryFile) {
.then((summaryInfo) => {
return GEN_CONTENT
? generateContent(
_.where(summaryInfo.services, { fiwareMember: true }),
_.where(summaryInfo.services, { optIn: true }),
allProducts.services,
'services'
).then(() => {
Expand All @@ -497,7 +509,7 @@ function parse(detailsFile, summaryFile) {
.then((summaryInfo) => {
return GEN_CONTENT
? generateContent(
_.where(summaryInfo.cities, { fiwareMember: true }),
_.where(summaryInfo.cities, { optIn: true }),
allProducts.cities,
'cities'
).then(() => {
Expand Down
1 change: 0 additions & 1 deletion marketplace/texts/addixgmbh-adifi.html

This file was deleted.

1 change: 0 additions & 1 deletion marketplace/texts/agricolussrl-agrigateways.html

This file was deleted.

This file was deleted.

Loading

0 comments on commit 810fb97

Please sign in to comment.