Skip to content

Commit 7065813

Browse files
authored
Render funding links with the same verification logic as the other pubspec links. (#8473)
1 parent 3acb30b commit 7065813

File tree

4 files changed

+17
-22
lines changed

4 files changed

+17
-22
lines changed

app/lib/fake/backend/fake_pana_runner.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,10 @@ Future<Summary> fakePanaSummary({
8585
issueTrackerUrl: issueTrackerUrl,
8686
documentationUrl: documentationUrl,
8787
repository: repository,
88-
// TODO: add funding URLs
89-
fundingUrls: null,
88+
fundingUrls: pubspec.funding
89+
.map((e) => e.toString())
90+
.where((url) => fakeUrlCheck('funding', url) != null)
91+
.toList(),
9092
contributingUrl: contributingUrl,
9193
licenses: [License(path: '', spdxIdentifier: licenseSpdx)]);
9294
return Summary(

app/lib/frontend/templates/package.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,10 @@ d.Node renderPkgInfoBox(PackagePageData data) {
8585
addLink(dartdocsUrl, 'API reference', documentation: true);
8686
}
8787

88-
// TODO: display only verified links
89-
final fundingLinks = data.version.pubspec!.funding.map((uri) {
88+
final fundingLinks = packageLinks.fundingUris.map((uri) {
9089
return InfoBoxLink(uri.toString(), uri.host, rel: 'ugc');
9190
}).toList();
91+
9292
return packageInfoBoxNode(
9393
data: data,
9494
metaLinks: metaLinks,

app/lib/package/models.dart

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,21 +1056,27 @@ class PackageLinks {
10561056
/// The link to `CONTRIBUTING.md` in the git repository (when the repository is verified).
10571057
final String? contributingUrl;
10581058

1059+
/// The `funding` URLs from `pubspec.yaml`.
1060+
final List<Uri> fundingUris;
1061+
10591062
PackageLinks._({
10601063
this.homepageUrl,
10611064
String? documentationUrl,
10621065
this.repositoryUrl,
10631066
this.issueTrackerUrl,
10641067
this.contributingUrl,
1065-
}) : documentationUrl = urls.hideUserProvidedDocUrl(documentationUrl)
1068+
List<Uri>? fundingUris,
1069+
}) : documentationUrl = urls.hideUserProvidedDocUrl(documentationUrl)
10661070
? null
1067-
: documentationUrl;
1071+
: documentationUrl,
1072+
fundingUris = fundingUris ?? <Uri>[];
10681073

10691074
factory PackageLinks.infer({
10701075
String? homepageUrl,
10711076
String? documentationUrl,
10721077
String? repositoryUrl,
10731078
String? issueTrackerUrl,
1079+
List<Uri>? fundingUris,
10741080
}) {
10751081
repositoryUrl ??= urls.inferRepositoryUrl(homepageUrl);
10761082
issueTrackerUrl ??= urls.inferIssueTrackerUrl(repositoryUrl);
@@ -1079,6 +1085,7 @@ class PackageLinks {
10791085
documentationUrl: documentationUrl,
10801086
repositoryUrl: repositoryUrl,
10811087
issueTrackerUrl: issueTrackerUrl,
1088+
fundingUris: fundingUris,
10821089
);
10831090
}
10841091
}
@@ -1133,6 +1140,7 @@ class PackagePageData {
11331140
issueTrackerUrl: result.issueTrackerUrl,
11341141
documentationUrl: result.documentationUrl,
11351142
contributingUrl: result.contributingUrl,
1143+
fundingUris: result.fundingUrls?.map(Uri.parse).toList(),
11361144
);
11371145
}
11381146

@@ -1143,6 +1151,7 @@ class PackagePageData {
11431151
documentationUrl: pubspec.documentation,
11441152
repositoryUrl: pubspec.repository,
11451153
issueTrackerUrl: pubspec.issueTracker,
1154+
fundingUris: pubspec.funding,
11461155
);
11471156
}();
11481157

app/test/frontend/golden/pkg_show_page_publisher.html

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -264,14 +264,6 @@ <h3 class="title">Documentation</h3>
264264
<a class="link" href="/documentation/neon/latest/">API reference</a>
265265
<br/>
266266
</p>
267-
<h3 class="title">Funding</h3>
268-
<p>
269-
Consider supporting this project:
270-
<br/>
271-
<br/>
272-
<a class="link" href="https://example.com/funding/neon" rel="ugc">example.com</a>
273-
<br/>
274-
</p>
275267
<h3 class="title">License</h3>
276268
<p>
277269
<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"/>
@@ -344,14 +336,6 @@ <h3 class="title">Documentation</h3>
344336
<a class="link" href="/documentation/neon/latest/">API reference</a>
345337
<br/>
346338
</p>
347-
<h3 class="title">Funding</h3>
348-
<p>
349-
Consider supporting this project:
350-
<br/>
351-
<br/>
352-
<a class="link" href="https://example.com/funding/neon" rel="ugc">example.com</a>
353-
<br/>
354-
</p>
355339
<h3 class="title">License</h3>
356340
<p>
357341
<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"/>

0 commit comments

Comments
 (0)