Fix dates on gardening page
This commit is contained in:
parent
6c6096b873
commit
384a8667ef
4 changed files with 30 additions and 23 deletions
21
src/_includes/helpers/git.js
Normal file
21
src/_includes/helpers/git.js
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
import { promisify } from 'node:util'
|
||||||
|
import { exec as _exec } from 'node:child_process'
|
||||||
|
const exec = promisify(_exec)
|
||||||
|
|
||||||
|
const commitFromLog = message => {
|
||||||
|
if (message === '') return {}
|
||||||
|
|
||||||
|
const [ commit, author, date, _, msg ] = message.split('\n')
|
||||||
|
|
||||||
|
return {
|
||||||
|
hash: commit.replace(/^commit /, ''),
|
||||||
|
author: author.replace(/^Author:\s*/, ''),
|
||||||
|
date: new Date(date.replace(/^Date:\s*/, '')),
|
||||||
|
message: msg.trim()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const latestCommitFor = async file => {
|
||||||
|
const { stdout } = await exec(`git log -n 1 --pretty=medium --date=iso -- ${file}`)
|
||||||
|
return commitFromLog(stdout)
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
import { env } from 'node:process'
|
import { env } from 'node:process'
|
||||||
import eleventyFetch from '@11ty/eleventy-fetch'
|
import eleventyFetch from '@11ty/eleventy-fetch'
|
||||||
|
|
||||||
|
import { latestCommitFor } from '../_includes/helpers/git.js'
|
||||||
|
|
||||||
const { MB_DATA_URL, LB_DATA_URL, OSM_DATA_URL } = env
|
const { MB_DATA_URL, LB_DATA_URL, OSM_DATA_URL } = env
|
||||||
|
|
||||||
const osmChangeSets = async (baseUrl) => {
|
const osmChangeSets = async (baseUrl) => {
|
||||||
|
|
@ -50,5 +52,8 @@ export default async (_) => {
|
||||||
listenBrainz,
|
listenBrainz,
|
||||||
musicBrainz,
|
musicBrainz,
|
||||||
openStreetMap,
|
openStreetMap,
|
||||||
|
eleventyComputed: {
|
||||||
|
commit: async data => await latestCommitFor(data.page.inputPath)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,12 @@
|
||||||
---
|
---
|
||||||
|
date: Git created
|
||||||
title: Gardening the commons
|
title: Gardening the commons
|
||||||
---
|
---
|
||||||
# Gardening the commons
|
# Gardening the commons
|
||||||
|
|
||||||
This page holds information about open data platforms that I participate in. Text that is marked `like this` will update whenever this site is rebuilt.
|
This page holds information about open data platforms that I participate in. Text that is marked `like this` will update whenever this site is rebuilt.
|
||||||
|
|
||||||
I have submitted `{{ musicBrainz.edits.total }}` edits to [MusicBrainz](https://musicbrainz.org/), adding `{{ musicBrainz.addedEntities.coverArt }}` pieces of cover art, `{{ musicBrainz.addedEntities.release }}` releases and `{{ musicBrainz.addedEntities.artist }}` artists which now exist in the database. Music is something deeply personal for me and it feels good to know that work I put into furthering information about the music I like is available in the public domain. Oftentimes these submissions are directly related to the artists and songs I listen to, of which I tracked `{{ listenBrainz.total }}` on [ListenBrainz](https://listenbrainz.org/). My listening history goes back to `{{ listenBrainz.firstYear }}`, and I have even created a Markov-Chain based playlist generation tool by exporting it to SQLite. Maybe I'll write about that some time.
|
I have submitted `{{ musicBrainz.edits.total }}` edits to [MusicBrainz](https://musicbrainz.org/), adding `{{ musicBrainz.addedEntities.coverArt }}` pieces of cover art, `{{ musicBrainz.addedEntities.release }}` releases and `{{ musicBrainz.addedEntities.artist }}` artists to the database. Music is something deeply personal for me and it feels good to know that work I put into furthering information about the music I like is available in the public domain. Oftentimes these submissions are directly related to the artists and songs I listen to, of which I tracked `{{ listenBrainz.total }}` on [ListenBrainz](https://listenbrainz.org/). My listening history goes back to `{{ listenBrainz.firstYear }}`, and I have even created a Markov-Chain based playlist generation tool by exporting it to SQLite. Maybe I'll write about that some time.
|
||||||
|
|
||||||
[OpenStreetMap](https://www.openstreetmap.org/) is one other place I regularly submit data to. I use different apps to navigate using OpenStreetMap data and to find my way around when I'm somewhere I don't know well. I have added `{{ openStreetMap.changesets.length }}` changes, many of which were locations of benches or water fountains — things I found useful when being outside. For this I mostly use [OsmAnd](https://osmand.net/) (`{{ openStreetMap.stats.doneInOsmand }}` times). It's an Android application that has very many toggles and switches for a map application. I have also completed `{{ openStreetMap.stats.doneInStreetComplete }}` quests in [StreetComplete](https://streetcomplete.app/), which prompts you with tasks to complete map data around you. It's very fun. Common topics are questions around accessibility, lighting conditions, public transit or more generally outside amenities.
|
[OpenStreetMap](https://www.openstreetmap.org/) is one other place I regularly submit data to. I use different apps to navigate using OpenStreetMap data and to find my way around when I'm somewhere I don't know well. I have added `{{ openStreetMap.changesets.length }}` changes, many of which were locations of benches or water fountains — things I found useful when being outside. For this I mostly use [OsmAnd](https://osmand.net/) (`{{ openStreetMap.stats.doneInOsmand }}` times). It's an Android application that has very many toggles and switches for a map application. I have also completed `{{ openStreetMap.stats.doneInStreetComplete }}` quests in [StreetComplete](https://streetcomplete.app/), which prompts you with tasks to complete map data around you. It's very fun. Common topics are questions around accessibility, lighting conditions, public transit or more generally outside amenities.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,31 +1,11 @@
|
||||||
import { promisify } from 'node:util'
|
import { latestCommitFor } from '../_includes/helpers/git.js'
|
||||||
import { exec as _exec } from 'node:child_process'
|
|
||||||
const exec = promisify(_exec)
|
|
||||||
|
|
||||||
const commitFromLog = message => {
|
|
||||||
if (message === '') return {}
|
|
||||||
|
|
||||||
const [ commit, author, date, _, msg ] = message.split('\n')
|
|
||||||
|
|
||||||
return {
|
|
||||||
hash: commit.replace(/^commit /, ''),
|
|
||||||
author: author.replace(/^Author:\s*/, ''),
|
|
||||||
date: new Date(date.replace(/^Date:\s*/, '')),
|
|
||||||
message: msg.trim()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const lastCommitFor = async file => {
|
|
||||||
const { stdout } = await exec(`git log -n 1 --pretty=medium --date=iso -- ${file}`)
|
|
||||||
return commitFromLog(stdout)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default async (_) => {
|
export default async (_) => {
|
||||||
return {
|
return {
|
||||||
tags: "posts",
|
tags: "posts",
|
||||||
layout: "posts.njk",
|
layout: "posts.njk",
|
||||||
eleventyComputed: {
|
eleventyComputed: {
|
||||||
commit: async data => await lastCommitFor(data.page.inputPath)
|
commit: async data => await latestCommitFor(data.page.inputPath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue