Skip to content

Commit

Permalink
Merge pull request #35 from artlung/http-sites-fix
Browse files Browse the repository at this point in the history
HTTP Only sites (no SSL) Fix
  • Loading branch information
artlung authored May 30, 2024
2 parents afbc2af + 1c080e2 commit a634394
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
6 changes: 3 additions & 3 deletions feed.xml
Original file line number Diff line number Diff line change
Expand Up @@ -652,9 +652,9 @@
<item>
<title><![CDATA[thisvictorianlife.com]]></title>
<description><![CDATA[Blog about Victorian era]]></description>
<link>https://thisvictorianlife.com</link>
<guid isPermaLink="true">https://thisvictorianlife.com</guid>
<pubDate>Thu, 30 May 2024 00:00:00 GMT</pubDate>
<link>http://thisvictorianlife.com</link>
<guid isPermaLink="true">http://thisvictorianlife.com</guid>
<pubDate>Thu, 30 May 2024 00:00:01 GMT</pubDate>
</item>
</channel>
</rss>
7 changes: 5 additions & 2 deletions generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const fs = require('fs');

const sites = require('./sites.json');
const dates = require('./dates.json');
const httpSites = require('./http-sites.json');
const today = new Date().toISOString().split('T')[0];
const numberOfSites = sites.blogs.length;
const maxNumberOfDates = numberOfSites * 2;
Expand Down Expand Up @@ -73,10 +74,11 @@ sites.blogs.forEach(site => {
// log whether the site has a description
const hasDescriptionKey = sites.descriptions.hasOwnProperty(site);
const hasDescription = sites.descriptions[site] && sites.descriptions[site].length > 0;
const protocol = httpSites.sites.includes(site) ? 'http://' : 'https://';

if (!hasDescriptionKey) {
console.log(`Fetching description for ${site}.`);
fetch(`https://${site}`)
fetch(`${protocol}${site}`)
.then(res => res.text())
.then(html => {
const $ = cheerio.load(html);
Expand Down Expand Up @@ -105,10 +107,11 @@ Object.keys(dates.dates).forEach(date => {
const site = dates.dates[date];
const sites = require('./sites.json');
const description = sites.descriptions[site] || '';
const protocol = httpSites.sites.include(site) ? 'http://' : 'https://';
feed.item({
title: site,
description: description,
url: `https://${site}`,
url: `${protocol}${site}`,
date: date
});
});
Expand Down
5 changes: 5 additions & 0 deletions http-sites.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"sites": [
"thisvictorianlife.com"
]
}

0 comments on commit a634394

Please sign in to comment.