Skip to content

Commit 22abaa8

Browse files
committed
21.0 beta
[general] - replace snowstorm with snow-fall - append scripts to head instead of body - new npm run scripts - update kuma css - remove unused assets - minor tweaks and fixes [changelog] - new changelog page - new changelog building tools (ruby!) [this] - minor changes [quizzes] - minor corrections [index] - emojify and add content to the about section
1 parent 39bf243 commit 22abaa8

22 files changed

Lines changed: 1076 additions & 64 deletions

.eleventy.js

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,17 +82,63 @@ module.exports = function (eleventyConfig) {
8282
});
8383

8484
eleventyConfig.addShortcode("keywords", function() {
85-
return `<meta name="keywords" content="${require('./package.json').keywords.join(', ')}">`;
85+
let json = require('./package.json');
86+
if (!json.keywords) {
87+
console.log('keywords not found in package.json');
88+
return '';
89+
}
90+
return `<meta name="keywords" content="${json.keywords.join(', ')}">`;
8691
});
8792

8893
eleventyConfig.addShortcode("version", function() {
8994
let json = require('./package.json');
9095
let version = json.version;
9196
let channel = json.channel && json.channel !== 'RTW' ? ` (${json.channel})` : '';
92-
let versionString = `${version}${channel}`;
93-
return `<a id="version-tag" href="https://github.com/miermontoto/mier.info/commit/${json.channel === "RTW" ? 'main' : 'beta'}" target="_blank">${versionString}</a>`;
97+
return `<a id="version-tag" href="/changelog/" target="_blank">${version}${channel}</a>`;
9498
});
9599

100+
// function to get the changelog from the github commit history
101+
eleventyConfig.addShortcode("changelog", function(data) {
102+
let content = '<div id="changelog">'
103+
104+
// if the current version isn't in the changelog, add it manually to the data array
105+
let currentJson = require('./package.json')
106+
let currentVersion = currentJson.version.split('.')
107+
let currentChannel = currentJson.channel ? ` ${currentJson.channel}` : ''
108+
if (!data.find(d => d.version.major == currentVersion[1] && d.version.minor == currentVersion[2])) {
109+
data.push({
110+
"version": {
111+
"major": currentVersion[1],
112+
"minor": currentVersion[2]
113+
},
114+
"title": `${currentVersion[1]}.${currentVersion[2]}${currentChannel}`,
115+
"date": "ongoing",
116+
"message": "<span class='warning'>unreported changes: please run <code>npm run changelog</code></span>",
117+
"hash": null
118+
})
119+
}
120+
121+
// sort commits by version
122+
data.sort((a, b) => {
123+
return a.version.major > b.version.major ? -1 : 1;
124+
})
125+
126+
let prevMajor = null
127+
data.forEach((d) => {
128+
if (prevMajor != d.version.major) {
129+
if (prevMajor) content += '<hr>'
130+
content += `<h1>v${d.version.major}</h1>`
131+
}
132+
prevMajor = d.version.major
133+
content += `<div class="entry hoverborder">
134+
<span class="title">${d.title}</span>`
135+
if (d.message) content += `<br><span class="message">${d.message.replace(/\n/g, '<br>')}</span>`
136+
content += `<a class="date" href="https://github.com/miermontoto/mier.info/commit/${d.hash}" target="_blank">${d.date}</a></div>`
137+
})
138+
content += '</div>'
139+
return content
140+
})
141+
96142
eleventyConfig.addShortcode("breadcrumbs", function(navPages) {
97143
if (!this.page.url) return ''; // if permalink is false in frontmatter, don't show breadcrumbs
98144

@@ -140,7 +186,7 @@ module.exports = function (eleventyConfig) {
140186

141187
eleventyConfig.addShortcode("quizButtons", function(json) {
142188
let blocks = getBlocksFromJson(json);
143-
if (blocks.length == 0 || blocks.length == 1) return '';
189+
if (blocks.length <= 1) return '';
144190

145191
let template = `<div id="block-selection"> <h3>preguntas.</h3> <ul>`;
146192
blocks.forEach(b => {

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
*.md linguist-detectable
22
package*.json linguist-generated
33
assets/** linguist-generated
4+
src/content/data/changelog.json linguist-generated

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ _site
44
target
55
firebase-debug.log
66
**.report.html
7+
.vscode

assets/files/kuma.css

Lines changed: 10 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/files/mods_1.zip

-22.8 KB
Binary file not shown.

build-changelog.rb

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
class Commit
2+
attr_accessor :message, :date, :version, :title, :hash, :author, :body
3+
4+
def to_json(*a)
5+
{
6+
"title" => title,
7+
"message" => message,
8+
"date" => date,
9+
"hash" => hash,
10+
"version" => version
11+
}.to_json(*a)
12+
end
13+
end
14+
15+
16+
class Version
17+
# versions are in the form XX.y (major.minor)
18+
# they can also have a channel (alpha, beta, rc) and a channel number (optional)
19+
# examples: 18.1, 18.0 RC1, 19.0 alpha 2, 20.1 beta2
20+
# if no channel is mentioned, it's assumed to be RTW
21+
attr_accessor :major, :minor, :channel, :channel_number
22+
23+
def to_json(*a)
24+
{
25+
"major" => major,
26+
"minor" => minor,
27+
"channel" => channel,
28+
"channel_number" => channel_number
29+
}.to_json(*a)
30+
end
31+
end
32+
33+
require 'json'
34+
require 'time'
35+
36+
start = Time.now
37+
38+
delim = "¿¿¡¡"
39+
raw = `git log --pretty=format:"%B||%ad||%H||%an#{delim}" --date=short`
40+
commits = []
41+
raw.split(delim).each do |line|
42+
commit = Commit.new
43+
commit.body, commit.date, commit.hash, commit.author = line.split("||")
44+
commit.author.strip!
45+
46+
# filter out commits
47+
next unless commit.author == "miermontoto" # discard commits from other authors
48+
next if commit.body !~ /^\d{1,2}\.\d{1,2}(.*)/ # discard commits that don't have a version number (XX.y)
49+
50+
# process version
51+
commit.version = Version.new
52+
commit.version.major, commit.version.minor = commit.body.match(/^(\d{1,2})\.(\d{1,2})(.*)/).captures
53+
channel_matches = commit.body.match(/(alpha|beta|RC)( ?\d?)/)
54+
if channel_matches then
55+
channel_matches = channel_matches.captures.compact
56+
commit.version.channel = channel_matches.first
57+
commit.version.channel_number = channel_matches.last if channel_matches.length > 1
58+
end
59+
60+
# process commit message
61+
commit.body = commit.body.split("\n").drop(1).join("\n") unless commits.length == 0 # remove first line (version)
62+
split = commit.body.split("\n")
63+
if split.length > 1 then
64+
commit.title = split.first
65+
commit.message = split.drop(1).join("\n")
66+
else
67+
commit.title = commit.body
68+
end
69+
commit.title.strip!
70+
71+
# sanitize HTML content
72+
commit.title = commit.title.gsub(/</, "&lt;").gsub(/>/, "&gt;")
73+
commit.message = commit.message.gsub(/</, "&lt;").gsub(/>/, "&gt;") unless commit.message.nil?
74+
75+
# process markdown code as HTML
76+
commit.title = commit.title.gsub(/`(.*)`/, "<code>\\1</code>")
77+
commit.message = commit.message.gsub(/`(.*)`/, "<code>\\1</code>") unless commit.message.nil?
78+
79+
commits << commit
80+
end
81+
82+
# output json to file
83+
File.open("src/content/data/changelog.json", "w") do |f|
84+
f.write(JSON.pretty_generate(commits))
85+
end
86+
87+
puts "changelog!: processed and outputed changelog in #{Time.now - start} seconds"

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/content/about.njk

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
{% import "src/static/macros.njk" as macros %}
22

33
<ul>
4-
<li>spanish computer engineering undergraduate.</li>
5-
<li>currently studying at EPI Gijón (University of Oviedo).</li>
6-
<li>interested in all things tech and music.</li>
7-
<li>i like climbing, cycling and playing bass.</li>
4+
<li>🇪🇸 spanish computer engineering undergraduate.</li>
5+
<li>🎓 currently studying at EPI Gijón (University of Oviedo).</li>
6+
<li>📟 interested in all things 💻 tech and 🎵 music.</li>
7+
<li>🤸‍♂️ i like 🧗 climbing, 🚲 cycling and playing 🎸 bass.</li>
88
<li>{{ macros.renderIcon('ruby') }} ruby, {{ macros.renderIcon('python') }} python, {{ macros.renderIcon('java') }} java and a little bit of everything else (c/c++/c#, shell, web, sql, ...)</li>
9-
<li>i take <a href="https://github.com/miermontoto/notes">notes</a> in {{ macros.renderIcon('markdown') }} markdown using {{ macros.renderIcon('obsidian') }} <a href="https://obsidian.md">obsidian</a>.
9+
<li>📒 i take <a href="https://github.com/miermontoto/notes">notes</a> in {{ macros.renderIcon('markdown') }} markdown using {{ macros.renderIcon('obsidian') }} <a href="https://obsidian.md">obsidian</a>.
10+
<li>🌐 <a href="/this/">this webpage</a> was hand built by me using {{ macros.renderIcon('eleventy') }} <a href="https://11ty.dev" target="_blank">eleventy</a>.</li>
1011
</ul>

src/content/changelog.njk

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
layout: project.njk
3+
title: changelog
4+
permalink: /changelog/
5+
eleventyNavigation:
6+
key: changelog
7+
---
8+
9+
{% addStyle "changelog" %}
10+
{% changelog changelog %}

0 commit comments

Comments
 (0)