-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add dynamically calculated total amount paid to maintainers to OpenGraph image #336
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
3c1e921
Refactor memberFormatting.ts into memberData/common.ts
vladh 061ab33
Add OpenGraph image with ARR
vladh 58c8f77
workflows: run make-generated-resources on pr and deploy
vladh 16c3bd2
Simplify opengraph.svg by hand
vladh 51996ec
Update authorship information
vladh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#!/bin/sh -eu | ||
|
||
# © 2024 Functional Software, Inc. dba Sentry | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
# Generates resources that depend on dynamic content, such as the OpenGraph | ||
# image. | ||
# | ||
# USAGE: make-generated-resources | ||
# | ||
# Must be run in the repository's root directory. | ||
|
||
get_file_age_in_sec() { | ||
echo $(($(date +%s) - $(stat -c %Y -- "$1"))) | ||
} | ||
|
||
# HACK: This momentarily installs fonts into the user's font folder, then | ||
# removes them (unless they already existed). | ||
# | ||
# We would like to have imagemagick generate images using fonts that we | ||
# explicitly specify by path. This would allow us to avoid polluting default | ||
# font directories such as the user's `~/.local/share/fonts` directory. But | ||
# there doesn't seem a way to explicitly give imagemagick font paths, outside | ||
# of the `-font` option, which is not consulted when converting SVG text to | ||
# PNG. imagemagick uses fontconfig to get the list of installed fonts, but | ||
# there doesn't seem to be a way to momentarily get fontconfig to use a font, | ||
# and indeed this might not make sense. | ||
# | ||
# So, for each font file: | ||
# * put it in the user's font directory unless it's already there, | ||
# * do our imagemagick stuff, | ||
# * if the file is less than one hour old, remove it. | ||
|
||
mkdir -p ~/.local/share/fonts/ | ||
|
||
for font_path in public/fonts/*.ttf; do | ||
font_name=$(basename $font_path) | ||
installed_font_path="$HOME/.local/share/fonts/$font_name" | ||
if [ -f $installed_font_path ]; then | ||
echo "Font already exists: $installed_font_path" | ||
else | ||
echo "Installing $installed_font_path" | ||
cp $font_path $installed_font_path | ||
fi | ||
done | ||
|
||
echo 'Generating files' | ||
|
||
grand_total=$(./src/memberData/bin/getGrandTotalRaised.ts) | ||
sed -i "s/\\\$[^<]\\+/${grand_total}/" public/generated/templates/opengraph.svg | ||
|
||
echo 'Generated SVG file' | ||
cat public/generated/templates/opengraph.svg | ||
|
||
echo 'Generating PNG image' | ||
magick -verbose public/generated/templates/opengraph.svg public/generated/output/opengraph.png | ||
|
||
for font_path in public/fonts/*.ttf; do | ||
font_name=$(basename $font_path) | ||
installed_font_path="$HOME/.local/share/fonts/$font_name" | ||
installed_font_age=$(get_file_age_in_sec $installed_font_path) | ||
if [ $installed_font_age -gt 3600 ]; then | ||
echo "Font is more than an hour old, ignoring: $installed_font_path" | ||
else | ||
echo "Font is less than an hour old, deleting: $installed_font_path" | ||
rm $installed_font_path | ||
fi | ||
done |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
© 2025 Marijn Haverbeke | ||
SPDX-License-Identifier: LicenseRef-Restricted |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// © 2024 Vlad-Stefan Harbuz <vlad@vlad.website> | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import memberRoles from "./memberRoles.json" | ||
import type { Map } from './util.ts'; | ||
import type { MemberWithId } from "./schemas/members.ts"; | ||
import { getCollection } from 'astro:content'; | ||
import { sortReportsForMemberWithId } from "./memberData/common.ts"; | ||
|
||
export async function getMembers(): Promise<MemberWithId[]> { | ||
return (await getCollection('members')) | ||
.filter((member) => member.id in (memberRoles as Map)) | ||
.map(sortReportsForMemberWithId); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/env -S npx tsx | ||
|
||
// © 2024 Functional Software, Inc. dba Sentry | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// Must be run in repository root. | ||
|
||
import fs from "fs"; | ||
|
||
import memberRoles from "../../memberRoles.json"; | ||
import { sortReportsForMember, fmtCurrency } from "../common.ts"; | ||
|
||
|
||
async function main() { | ||
let grandTotal = 0; | ||
const memberSlugs = Object.keys(memberRoles); | ||
|
||
for (const slug of memberSlugs) { | ||
const localPath = `./src/content/members/${slug}.json`; | ||
|
||
let member = undefined; | ||
try { | ||
member = JSON.parse(fs.readFileSync(localPath).toString()); | ||
} catch (e) { | ||
console.error(`ERROR: could not load member data at ${localPath}`); | ||
process.exit(1); | ||
} | ||
|
||
member = sortReportsForMember(member); | ||
grandTotal += member.annualReports[0].usdAmountPaid; | ||
} | ||
|
||
console.log(fmtCurrency(grandTotal)); | ||
} | ||
|
||
|
||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2025 🙃