Skip to content

Commit

Permalink
Merge pull request #1 from opensourcepledge/cwlw/schema
Browse files Browse the repository at this point in the history
Add a schema for self-reporting
  • Loading branch information
vladh authored Aug 3, 2024
2 parents 0e5ff7d + 762b1d2 commit d3382f6
Show file tree
Hide file tree
Showing 7 changed files with 201 additions and 2 deletions.
1 change: 1 addition & 0 deletions members.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sentry,https://open.sentry.io/funding/osspledge.json
46 changes: 46 additions & 0 deletions src/content/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { z, defineCollection } from "astro:content";

/* Welcome to the schema for OSS Pledge.
*
* If you are implementing an OSS Pledge report for a member organization, and
* need to understand how to format it, you've found the source of truth. If
* you have questions or run into limitations, please open an issue:
*
* https://github.com/getsentry/osspledge.com/issues/new
*
*/

const monetaryPayment = z.object({
amount: z.number().nonnegative(),
urlDetails: z.string().url().optional(),
})

const memberProvidedData = z.object({
name: z.string(),
urlLogoWithBackground: z.string().url(),
urlLearnMore: z.string().url(),
description: z.string().optional(),
annualReports: z
.object({
dateYearEnding: z.string().date(),
averageNumberOfDevs: z.number().nonnegative(),
monetaryPayments: monetaryPayment.array().nonempty(),
monetaryValueOfTime: z.number().nonnegative(),
monetaryValueOfMaterials: z.number().nonnegative(),
})
.array()
.nonempty(),
});

export const collections = {
members: defineCollection({
type: "data",
schema: z
.object({
domain: z.string(),
urlSource: z.string().url(),
datetimeModified: z.string().datetime(),
})
.merge(memberProvidedData),
}),
};
22 changes: 22 additions & 0 deletions src/content/members/sentry.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"domain": "sentry.io",
"urlSource": "https://open.sentry.io/osspledge/data.json",
"datetimeModified": "2024-07-19T12:24:46Z",
"description": "Sentry has given to Open Source for soooooo many years.",
"name": "Sentry",
"urlLogoWithBackground": "https://fossfunders.com/logos/sentry.svg",
"urlLearnMore": "https://open.sentry.io/osspledge/",
"annualReports": [
{
"dateYearEnding": "2023-01-31",
"averageNumberOfDevs": 135,
"monetaryPayments": [
{"amount": 435000, "urlDetails": "https://thanks.dev/d/gh/getsentry/dependencies"},
{"amount": 50000, "urlDetails": "https://github.com/orgs/getsentry/sponsoring"},
{"amount": 15000, "urlDetails": "https://blog.sentry.io/we-just-gave-500-000-dollars-to-open-source-maintainers/"}
],
"monetaryValueOfTime": 100000,
"monetaryValueOfMaterials": 500000
}
]
}
1 change: 1 addition & 0 deletions src/env.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/// <reference path="../.astro/types.d.ts" />
/// <reference types="astro/client" />
3 changes: 3 additions & 0 deletions src/pages/index.astro
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
---
import { getCollection } from 'astro:content';
import Layout from "../layouts/Layout.astro";
import Prose from "../components/Prose.astro";
import Button from "../components/Button.astro";
const members = await getCollection('members');
---

<Layout title="Open Source Pledge">
Expand Down
125 changes: 125 additions & 0 deletions src/pages/members/[id].astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
---
import { getCollection } from 'astro:content';
import Layout from "../../layouts/Layout.astro";
import Prose from "../../components/Prose.astro";
export async function getStaticPaths() {
const members = await getCollection('members');
return members.map(member => ({params: {id: member.id}, props: { member }}));
}
const { member } = Astro.props;
const reports = member.data.annualReports;
function getPlatformName(url) {
let host = '';
let name = 'Other';
try {
host = new URL(url).host;
} catch (err) {
host = '';
}
switch(host) {
case 'github.com':
name = 'GitHub Sponsors';
break;
case 'thanks.dev':
name = 'Thanks.dev';
break;
}
return name;
}
---
<Layout title="OSS Pledge">
<main class="flex justify-center max-w-xl p-4">
<Prose>
<h1 class="text-app-green mt-8 mb-4 text-5xl font-bold">OSS Pledge</h1>

<a href="/">Home</a>

<h2>{member.data.name}</h2>

<img src={member.data.urlLogoWithBackground}>

<p>{member.data.description}</p>

<a href={member.data.urlLearnMore}>Learn more ...</a>

{reports.map(report => <div class="annual-report">
<h3>Year Ending {report.dateYearEnding}</h3>

<b>$3700 / dev</b>

<h4>Payments to Independent Maintainers</h4>
<table>
<tr>
<th>Platform</th>
<th>Amount ($)</th>
</tr>
{report.monetaryPayments.map(entry => <tr>
<td><a href={entry.urlDetails}>{getPlatformName(entry.urlDetails)}</a></td>
<td class="text-right">{entry.amount}</td>
</tr>)}
<tr>
<td>total</td>
<td class="text-right">500000</td>
</tr>
<tr>
<td>average number of devs</td>
<td class="text-right">{report.averageNumberOfDevs}</td>
</tr>
<tr>
<td>$ / dev</td>
<td class="text-right">3700</td>
</tr>
</table>

<h4>Other Contributions</h4>
<table>
<tr>
<th>Item</th>
<th class="text-right">Amount ($)</th>
</tr>
<tr>
<td>value of time</td>
<td class="text-right">{report.monetaryValueOfTime}</td>
</tr>
<tr>
<td>value of materials</td>
<td class="text-right">{report.monetaryValueOfMaterials}</td>
</tr>
<tr>
<td></td>
<td class="text-right">600000</td>
</tr>
<tr>
<td>payments to independent maintainers</td>
<td class="text-right">500000</td>
</tr>
<tr>
<td>total</td>
<td class="text-right">1100000</td>
</tr>
</table>
</div>)}

<small>
This information is provided directly by {member.data.name}. Open
Source Pledge does not carry out any in-depth validation of this data.
</small>

</Prose>
</main>
</Layout>

<style>
main {
margin: auto;
padding: 1rem;
width: 800px;
max-width: calc(100% - 2rem);
color: white;
font-size: 20px;
line-height: 1.6;
}
</style>
5 changes: 3 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"extends": "astro/tsconfigs/strict"
}
"extends": "astro/tsconfigs/strict",
"strictNullChecks": true,
}

0 comments on commit d3382f6

Please sign in to comment.