Skip to content

Commit

Permalink
Add license to app listing (#26)
Browse files Browse the repository at this point in the history
* Add license to app listing

Adds a small license icon and name at the bottom left of each AppBlock.
This primarily relies on GitHub's license detection mechanism, but can
be overwritten in the application entries if GitHub fails to detect the
right one.

* Add manual license entry in Golioth's apps

GitHub's license detection fails in two of Golioth's apps, but based on
the content, it's meant to be Apache 2.0.
  • Loading branch information
trond-snekvik authored Nov 8, 2023
1 parent d6347e5 commit 392f21d
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 6 deletions.
2 changes: 2 additions & 0 deletions index/golioth.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@
"title": "CAN / OBD-II Asset Tracker Reference Design",
"description": "This Reference Design requires external hardware on top of an nRF9160-DK (see [https://projects.golioth.io/reference-designs/can-asset-tracker/guide-nrf9160-dk/](https://projects.golioth.io/reference-designs/can-asset-tracker/guide-nrf9160-dk/), but includes all code required to pass messages received on a CAN bus back to the Cloud, as well as regular GPS readings. Over-the-air updates are built in.",
"kind": "template",
"license": "Apache 2.0",
"tags": ["dfu","lte"]
},
{
"name": "reference-design-air-quality",
"title": "Air Quality Monitor Reference Design",
"description": "This Reference Design requires external hardware on top of an nRF9160-DK (see [https://projects.golioth.io/reference-designs/air-quality-monitor/guide-nrf9160-dk](https://projects.golioth.io/reference-designs/air-quality-monitor/guide-nrf9160-dk/), but includes all code required to monitor readings from connected air quality sensors and pass back to the Cloud. Includes remote procedure call to clean sensor, and Over-the-air updates are built in.",
"kind": "template",
"license": "Apache 2.0",
"tags": ["dfu","lte"]
}
]
Expand Down
4 changes: 4 additions & 0 deletions resources/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@
]
},
"description": "An array of tags describing the application."
},
"license": {
"type": "string",
"description": "The name of the application license, e.g. \"Apache 2.0\". Inferred from the repo if missing."
}
},
"additionalProperties": false,
Expand Down
2 changes: 1 addition & 1 deletion scripts/generate-index-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ async function fetchRepoData(
isTemplate: repoData.is_template ?? false,
kind: app.kind,
lastUpdate: repoData.updated_at,
license: repoData.license?.spdx_id ?? undefined,
license: app.license ?? repoData.license?.name ?? undefined,
watchers: repoData.watchers_count,
releases: releases.data.map((release) => ({
date: release.created_at,
Expand Down
21 changes: 16 additions & 5 deletions site/src/app/AppBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
CommandLineIcon,
ArrowTopRightOnSquareIcon,
CheckBadgeIcon,
ScaleIcon,
} from '@heroicons/react/20/solid';

import { NormalisedApp } from '../schema';
Expand Down Expand Up @@ -82,7 +83,9 @@ function AppBlock({ app, setShowingAppId }: Props): JSX.Element {
<TagList app={app} />
</div>

<Markdown disallowedElements={["img"]} className="description">{app.description}</Markdown>
<Markdown disallowedElements={['img']} className="description">
{app.description}
</Markdown>

<div className="flex flex-wrap items-center gap-2">
<VSCodeButton app={app} />
Expand All @@ -94,10 +97,18 @@ function AppBlock({ app, setShowingAppId }: Props): JSX.Element {
Instructions <CommandLineIcon width={20} height={20} />
</button>
</div>

<p className="float-right text-xs font-thin italic text-gray-600">
Last updated {formatRelative(new Date(app.lastUpdate), new Date())}
</p>
<div className="flex justify-between gap-4 text-xs text-gray-600">
<span className="flex gap-1">
{app.license && (
<>
<ScaleIcon className={smallIconClass} /> {app.license}
</>
)}
</span>
<span className="float-right font-thin italic">
Last updated {formatRelative(new Date(app.lastUpdate), new Date())}
</span>
</div>
</li>
);
}
Expand Down
5 changes: 5 additions & 0 deletions site/src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ export const appMetadataSchema = {
items: appTagSchema,
description: 'An array of tags describing the application.',
},
license: {
type: 'string',
description:
'The name of the application license, e.g. "Apache 2.0". Inferred from the repo if missing.',
},
},
additionalProperties: false,
required: ['name', 'kind', 'tags'],
Expand Down

0 comments on commit 392f21d

Please sign in to comment.