Start working on bloggers page.

We've hit the anonymous GitHub API rate limit though, so we'll have to continue later. We'll merge this branch once we're done.
pull/1/head
Starbeamrainbowlabs 2022-08-14 15:55:13 +01:00
parent 82e733a789
commit 0bddc9535e
No known key found for this signature in database
GPG Key ID: 1BE5172E637709C2
5 changed files with 158 additions and 0 deletions

44
src/bloggers.11tydata.js Normal file
View File

@ -0,0 +1,44 @@
"use strict";
const path = require("path");
const fs = require("fs");
const fetch_json = require("./lib/fetch_json.js");
async function fetch_info(blogger) {
if(typeof blogger.github_username !== "string") return;
const github_userdata = (await fetch_json(`https://api.github.com/users/${blogger.github_username}`)).body;
if(typeof github_userdata.message === "string") {
console.error(github_userdata.message);
}
console.log(`GITHUB_USERDATA`, github_userdata)
blogger.bio = github_userdata.bio;
blogger.url_blog = github_userdata.blog;
blogger.url_github = github_userdata.html_url;
blogger.url_twitter = github_userdata.twitter_username === null ? null : `https://twitter.com/@${github_userdata.twitter_username.replace(/^@/, "")}`;
blogger.url_avatar = github_userdata.avatar_url;
if(typeof blogger.url_blog !== "string" || blogger.url_blog.length == 0)
blogger.url_blog = null;
}
module.exports = async function() {
const feeds_data = JSON.parse(await fs.promises.readFile(path.resolve(__dirname, "../feeds.json"), "utf-8"));
await Promise.all(feeds_data.map(fetch_info));
return {
layout: "main.njk",
title: "Bloggers",
tags: "navigable",
date: "2001-01-01",
bloggers: feeds_data
}
}

25
src/bloggers.html Normal file
View File

@ -0,0 +1,25 @@
<p>Check out these cool people who are featured here on hullblogs.com!</p>
<section>
{% for blogger in bloggers %}
<div class="blogger">
<img src="{% asset blogger.url_avatar }}" class="blogger-avatar large-icon" alt="{{ blogger.author_name | htmlentities }}" aria-hidden="hidden" />
<span class="blogger-name">{{ blogger.author_name | htmlentities }}</span>
<span class="blogger-icons">
{% if blogger.url_blog %}<a href="{{ blogger.url_blog | htmlentities }}">
<img src="{% asset 'images/post.svg' %}" alt="{{ blogger.author_name | htmlentities }}'s blog" />
</a>{% endif %}
<a href="{{ blogger.url_feed | htmlentities }}">
<img src="{% asset 'images/rss.svg' %}" alt="{{ blogger.author_name | htmlentities }}'s blog feed">
</a>
<a href="{{ blogger.url_github }}">
<img src="{% asset 'images/github.svg' %}" alt="{{ blogger.author_name | htmlentities }}'s GitHub account">
</a>
{% if blogger.url_twitter %}<a href="{{ blogger.url_twitter }}">
<img src="{% asset 'images/twitter.svg' %}" alt="{{ blogger.author_name | htmlentities }}'s GitHub account">
</a>{% endif %}
</span>
<span class="blogger-bio">{{ blogger.bio | htmlentities }}</span>
</div>
{% endfor %}
</section>

1
src/images/rss.svg Normal file
View File

@ -0,0 +1 @@
<svg width="56.677mm" height="56.716mm" version="1.1" viewBox="0 0 56.677 56.716" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><defs><radialGradient id="a" cx="223.38" cy="481.42" r="109" gradientTransform="matrix(.0041709 -.51511 .26457 .0021391 -24.373 290.79)" gradientUnits="userSpaceOnUse"><stop stop-color="#f5821f" offset="0"/><stop stop-color="#ff7f2a" offset="1"/></radialGradient><linearGradient id="b" x1="173.42" x2="292.82" y1="320.56" y2="442.68" gradientUnits="userSpaceOnUse"><stop stop-color="#fff" offset="0"/><stop stop-color="#e6e6e6" offset="1"/></linearGradient></defs><g transform="translate(-76.115 -120.14)"><path d="m80.574 120.46c-2.3774-0.21589-4.3761 1.8239-4.1817 4.1817 0.01886 16.095-0.05802 32.193 0.03772 48.285-0.02106 2.6076 2.6557 3.9354 4.9625 3.6199 15.901-0.0489 31.811 0.0969 47.706-0.0713 2.6471-0.1086 3.6686-2.9281 3.3812-5.1992-0.0491-15.812 0.0971-31.633-0.0713-47.44-0.10724-2.6473-2.9329-3.6732-5.1992-3.3812-15.545 3e-3 -31.09-6e-3 -46.635 5e-3z" fill="url(#a)" stroke="#fdfdfd" stroke-width=".52911"/><rect x="78.45" y="122.32" width="51.969" height="51.885" rx="4" ry="4" fill="#fff" fill-opacity=".25703" style="paint-order:stroke fill markers"/><path transform="matrix(.26458 0 0 .26458 44.828 49.38)" d="m155.14 300.98c-0.37005 0-0.74023 1e-3 -1.1094 4e-3v22.287c0.3697-3e-3 0.73894-6e-3 1.1094-6e-3 66.046 0 119.59 50.313 119.59 112.38 0 4.2734-0.25389 8.4897-0.74805 12.639h23.85c0.41182-4.1608 0.625-8.3765 0.625-12.639 0-74.373-64.163-134.67-143.32-134.67zm0 44.92c-0.37039 0-0.73966 3e-3 -1.1094 8e-3v22.285c0.36931-5e-3 0.73918-8e-3 1.1094-8e-3 39.646 0 71.789 30.203 71.789 67.467 0 4.3208-0.42994 8.5449-1.2558 12.639h24.039c0.61996-4.1291 0.94336-8.3481 0.94336-12.639v-2e-3c0-49.565-42.76-89.75-95.516-89.75zm17.533 51.637c-11.358 0-20.566 9.2071-20.566 20.566 0 11.358 9.208 20.566 20.566 20.566 11.359 0 20.566-9.2081 20.566-20.566 0-11.359-9.2071-20.566-20.566-20.566z" fill="url(#b)" stroke="#cfcfcf" stroke-opacity=".90909" stroke-width="1.9998"/><path d="m131.52 142.75v-18.238c0-1.7006-1.3913-3.0919-3.092-3.0919h-47.984c-1.7006 0-3.0919 1.3913-3.0919 3.0919v19.163c7.4391 1.557 15.99 2.444 25.088 2.444 10.773 0 20.78-1.2422 29.08-3.3693z" fill-opacity="0" stroke-width=".26458"/></g></svg>

After

Width:  |  Height:  |  Size: 2.2 KiB

65
src/images/twitter.svg Normal file
View File

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="64.665543"
height="52.551762"
id="svg2"
version="1.1"
inkscape:version="0.92.3 (2405546, 2018-03-11)"
sodipodi:docname="twitter.svg">
<defs
id="defs4" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="3.7200571"
inkscape:cx="44.306277"
inkscape:cy="50.181135"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:window-width="1825"
inkscape:window-height="1047"
inkscape:window-x="95"
inkscape:window-y="33"
inkscape:window-maximized="1"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-282.32001,-483.13396)">
<path
style="fill:#2aa9e0;stroke-width:0.37704381"
inkscape:connector-curvature="0"
id="path5"
d="m 346.98555,489.35475 c -2.37903,1.05534 -4.93621,1.76827 -7.61949,2.08901 2.73889,-1.64185 4.84277,-4.24172 5.83311,-7.33982 -2.56365,1.5206 -5.40277,2.62443 -8.42489,3.21936 -2.41977,-2.57853 -5.86772,-4.18934 -9.68361,-4.18934 -7.32657,0 -13.26703,5.93982 -13.26703,13.26638 0,1.03982 0.11737,2.05247 0.3437,3.02343 -11.02606,-0.55322 -20.80149,-5.83507 -27.34496,-13.86163 -1.14198,1.95936 -1.79639,4.23815 -1.79639,6.66957 0,4.60287 2.34217,8.66351 5.90198,11.04254 -2.17469,-0.0689 -4.22036,-0.66572 -6.009,-1.65931 -0.002,0.0553 -0.002,0.1109 -0.002,0.16684 0,6.42771 4.57312,11.78942 10.64226,13.00901 -1.11321,0.30328 -2.28527,0.46527 -3.49516,0.46527 -0.85486,0 -1.6858,-0.0834 -2.49606,-0.23797 1.68841,5.27053 6.58776,9.10615 12.39339,9.21285 -4.54046,3.55852 -10.26073,5.67954 -16.47668,5.67954 -1.07086,0 -2.12683,-0.063 -3.16471,-0.1856 5.87128,3.76449 12.84476,5.96084 20.33686,5.96084 24.40237,0 37.747,-20.21529 37.747,-37.74732 0,-0.57519 -0.0129,-1.14716 -0.0385,-1.71653 2.59178,-1.87012 4.84083,-4.20648 6.61946,-6.86712 z" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.8 KiB

23
src/lib/fetch_json.js Normal file
View File

@ -0,0 +1,23 @@
const fs = require("fs");
const path = require("path");
const os = require("os");
const phin = require("phin");
async function fetch_json(url) {
let package = JSON.parse(await fs.promises.readFile(
path.join(path.dirname(path.dirname(__dirname)), "package.json"), "utf8"
));
return (await phin({
url,
headers: {
"user-agent": `HullBlogsStaticBuilder/${package.version} (Node.js/${process.version}; ${os.platform()} ${os.arch()}) eleventy/${package.dependencies["@11ty/eleventy"].replace(/\^/, "")}`
},
followRedirects: true,
parse: "json"
}));
}
module.exports = fetch_json;