Skip to content

Commit

Permalink
Render funding links with the same verification logic as the other pu…
Browse files Browse the repository at this point in the history
…bspec links. (#8473)
  • Loading branch information
isoos authored Jan 16, 2025
1 parent 3acb30b commit 7065813
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 22 deletions.
6 changes: 4 additions & 2 deletions app/lib/fake/backend/fake_pana_runner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,10 @@ Future<Summary> fakePanaSummary({
issueTrackerUrl: issueTrackerUrl,
documentationUrl: documentationUrl,
repository: repository,
// TODO: add funding URLs
fundingUrls: null,
fundingUrls: pubspec.funding
.map((e) => e.toString())
.where((url) => fakeUrlCheck('funding', url) != null)
.toList(),
contributingUrl: contributingUrl,
licenses: [License(path: '', spdxIdentifier: licenseSpdx)]);
return Summary(
Expand Down
4 changes: 2 additions & 2 deletions app/lib/frontend/templates/package.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ d.Node renderPkgInfoBox(PackagePageData data) {
addLink(dartdocsUrl, 'API reference', documentation: true);
}

// TODO: display only verified links
final fundingLinks = data.version.pubspec!.funding.map((uri) {
final fundingLinks = packageLinks.fundingUris.map((uri) {
return InfoBoxLink(uri.toString(), uri.host, rel: 'ugc');
}).toList();

return packageInfoBoxNode(
data: data,
metaLinks: metaLinks,
Expand Down
13 changes: 11 additions & 2 deletions app/lib/package/models.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1056,21 +1056,27 @@ class PackageLinks {
/// The link to `CONTRIBUTING.md` in the git repository (when the repository is verified).
final String? contributingUrl;

/// The `funding` URLs from `pubspec.yaml`.
final List<Uri> fundingUris;

PackageLinks._({
this.homepageUrl,
String? documentationUrl,
this.repositoryUrl,
this.issueTrackerUrl,
this.contributingUrl,
}) : documentationUrl = urls.hideUserProvidedDocUrl(documentationUrl)
List<Uri>? fundingUris,
}) : documentationUrl = urls.hideUserProvidedDocUrl(documentationUrl)
? null
: documentationUrl;
: documentationUrl,
fundingUris = fundingUris ?? <Uri>[];

factory PackageLinks.infer({
String? homepageUrl,
String? documentationUrl,
String? repositoryUrl,
String? issueTrackerUrl,
List<Uri>? fundingUris,
}) {
repositoryUrl ??= urls.inferRepositoryUrl(homepageUrl);
issueTrackerUrl ??= urls.inferIssueTrackerUrl(repositoryUrl);
Expand All @@ -1079,6 +1085,7 @@ class PackageLinks {
documentationUrl: documentationUrl,
repositoryUrl: repositoryUrl,
issueTrackerUrl: issueTrackerUrl,
fundingUris: fundingUris,
);
}
}
Expand Down Expand Up @@ -1133,6 +1140,7 @@ class PackagePageData {
issueTrackerUrl: result.issueTrackerUrl,
documentationUrl: result.documentationUrl,
contributingUrl: result.contributingUrl,
fundingUris: result.fundingUrls?.map(Uri.parse).toList(),
);
}

Expand All @@ -1143,6 +1151,7 @@ class PackagePageData {
documentationUrl: pubspec.documentation,
repositoryUrl: pubspec.repository,
issueTrackerUrl: pubspec.issueTracker,
fundingUris: pubspec.funding,
);
}();

Expand Down
16 changes: 0 additions & 16 deletions app/test/frontend/golden/pkg_show_page_publisher.html
Original file line number Diff line number Diff line change
Expand Up @@ -264,14 +264,6 @@ <h3 class="title">Documentation</h3>
<a class="link" href="/documentation/neon/latest/">API reference</a>
<br/>
</p>
<h3 class="title">Funding</h3>
<p>
Consider supporting this project:
<br/>
<br/>
<a class="link" href="https://example.com/funding/neon" rel="ugc">example.com</a>
<br/>
</p>
<h3 class="title">License</h3>
<p>
<img class="inline-icon-img filter-invert-on-dark" src="/static/hash-%%etag%%/img/material-icon-balance.svg" alt="" width="14" height="14" role="presentation"/>
Expand Down Expand Up @@ -344,14 +336,6 @@ <h3 class="title">Documentation</h3>
<a class="link" href="/documentation/neon/latest/">API reference</a>
<br/>
</p>
<h3 class="title">Funding</h3>
<p>
Consider supporting this project:
<br/>
<br/>
<a class="link" href="https://example.com/funding/neon" rel="ugc">example.com</a>
<br/>
</p>
<h3 class="title">License</h3>
<p>
<img class="inline-icon-img filter-invert-on-dark" src="/static/hash-%%etag%%/img/material-icon-balance.svg" alt="" width="14" height="14" role="presentation"/>
Expand Down

0 comments on commit 7065813

Please sign in to comment.