Skip to content

Commit

Permalink
remove open-source page, redirect to github instead
Browse files Browse the repository at this point in the history
  • Loading branch information
bobheadxi committed Feb 13, 2022
1 parent f57ee6c commit 3065788
Showing 1 changed file with 8 additions and 114 deletions.
122 changes: 8 additions & 114 deletions open-source/index.html
Original file line number Diff line number Diff line change
@@ -1,114 +1,8 @@
---
layout: page
title: Open Source
---
<hr />
<h1>🚀</h1>
<h1 style="font-weight:500;margin-top:-0.5rem;margin-bottom:-0.2rem;text-align:center;">open source</h1>

<div class="page-intro">

<p align="center">
The open source community has been a huge part of my learning, so I do my best to give back where I can through contributions and making my code available for everyone.
Check out my <a href="https://github.com/bobheadxi">GitHub</a> to see what I've been working on!
</p>

<!-- Based on https://observablehq.com/@bumbeishvili/trying-out-rough -->
<figure>
<div id="canvas-container" height="150px" style="max-width: 30rem; margin: auto;">
<!-- Populated by `drawChart()` -->
<canvas id="canvas"></canvas>
</div>

<figcaption>Generated chart of my recent
<a href="https://github.com/bobheadxi" target="_blank">GitHub activity</a>! Check out
<a href="/rough-github-chart" target="_blank">this blog post</a> to see how it works.
</figcaption>
</figure>

</div>

<script>
/**
* Fetch contributions history and populate `<canvas>`.
*/
function drawChart() {
/**
* The github-contributions API used here is a third party service that is intended to
* back https://github.com/sallar/github-contributions-chart, and thus requires a CORS
* proxy.
*
* In the past, proxies have stopped working/get taken down/etc so make it easier to
* track and change here.
*/
const proxyURL = 'https://cors.bridged.cc';
const contributionsURL = 'https://github-contributions.now.sh/api/v1/bobheadxi';

return fetch(`${proxyURL}/${contributionsURL}`)
.then((resp) => resp.json())
.then((data) => {
const maxWidth = document.getElementById('canvas-container').clientWidth;
const maxHeight = 150;
const canvas = document.getElementById('canvas');
canvas.width = `${maxWidth}`;
canvas.height = `${maxHeight}`;

const barWidth = 8;
const barGap = barWidth / 4;
const days = Math.floor(maxWidth / (barWidth + barGap));

let firstNonZero = 0;
for (let i = 0; i < data.contributions.length; i++) {
if (data.contributions[i].count > 0) {
firstNonZero = i;
break;
}
}
const counts = data.contributions
.slice(firstNonZero, firstNonZero+days)
.map(c => c.count)
.reverse();

const max = d3.max(counts);
const heightFlex = maxHeight / (max + 4);
console.log('chart parameters generated',
{ days, max, heightFlex, data: counts });

const rc = rough.canvas(canvas);
counts.forEach((d, i) => {
const barHeight = heightFlex * d;
const dim = {
x: i * (barWidth + barGap) + 1,
y: maxHeight - barHeight - 1,
w: barWidth,
h: barHeight,
};
rc.rectangle(dim.x, dim.y, dim.w, dim.h, { fill: '#5A85F3' });
});
console.log('charts drawn!');
})
.catch((err) => console.error(`/open-source chart error`, { err }));
}

/**
* Trigger a render whenever the page is loaded or resized.
*/
window.onload = drawChart;
window.onresize = drawChart;
</script>

<section class="post-list">
{% for post in site.open-source reversed %}
<div class="item">
<a class="url" href="{% if post.externalLink %}{{ post.externalLink }}{% else %}{{ site.url }}{{ post.url }}{% endif %}">
{% if post.star %}
<img class="image" src="{{ post.image }}" width="100%" style="margin-top:16px"/>
{% endif %}
<h3 class="title">{{ post.title }}</h3>
<p> {{ post.description }} </p>
{% include post-tags.html %}
</a>
{% if post.star %}<br />{% endif %}
</div>
{% endfor %}
</section>
<html>
<head>
<meta http-equiv="Refresh" content="0; url=https://github.com/bobheadxi">
</head>
<body>
Redirecting to GitHub...
</body>
</html>

0 comments on commit 3065788

Please sign in to comment.