From 7065813f62e884c628f82d39f6e697ade6d686f4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Istv=C3=A1n=20So=C3=B3s?=
Date: Thu, 16 Jan 2025 18:05:03 +0100
Subject: [PATCH] Render funding links with the same verification logic as the
other pubspec links. (#8473)
---
app/lib/fake/backend/fake_pana_runner.dart | 6 ++++--
app/lib/frontend/templates/package.dart | 4 ++--
app/lib/package/models.dart | 13 +++++++++++--
.../frontend/golden/pkg_show_page_publisher.html | 16 ----------------
4 files changed, 17 insertions(+), 22 deletions(-)
diff --git a/app/lib/fake/backend/fake_pana_runner.dart b/app/lib/fake/backend/fake_pana_runner.dart
index 1162ab9c41..5edd4daea6 100644
--- a/app/lib/fake/backend/fake_pana_runner.dart
+++ b/app/lib/fake/backend/fake_pana_runner.dart
@@ -85,8 +85,10 @@ Future 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(
diff --git a/app/lib/frontend/templates/package.dart b/app/lib/frontend/templates/package.dart
index 817d66ed1d..7c574b7547 100644
--- a/app/lib/frontend/templates/package.dart
+++ b/app/lib/frontend/templates/package.dart
@@ -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,
diff --git a/app/lib/package/models.dart b/app/lib/package/models.dart
index f1c9db752d..11157e0a37 100644
--- a/app/lib/package/models.dart
+++ b/app/lib/package/models.dart
@@ -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 fundingUris;
+
PackageLinks._({
this.homepageUrl,
String? documentationUrl,
this.repositoryUrl,
this.issueTrackerUrl,
this.contributingUrl,
- }) : documentationUrl = urls.hideUserProvidedDocUrl(documentationUrl)
+ List? fundingUris,
+ }) : documentationUrl = urls.hideUserProvidedDocUrl(documentationUrl)
? null
- : documentationUrl;
+ : documentationUrl,
+ fundingUris = fundingUris ?? [];
factory PackageLinks.infer({
String? homepageUrl,
String? documentationUrl,
String? repositoryUrl,
String? issueTrackerUrl,
+ List? fundingUris,
}) {
repositoryUrl ??= urls.inferRepositoryUrl(homepageUrl);
issueTrackerUrl ??= urls.inferIssueTrackerUrl(repositoryUrl);
@@ -1079,6 +1085,7 @@ class PackageLinks {
documentationUrl: documentationUrl,
repositoryUrl: repositoryUrl,
issueTrackerUrl: issueTrackerUrl,
+ fundingUris: fundingUris,
);
}
}
@@ -1133,6 +1140,7 @@ class PackagePageData {
issueTrackerUrl: result.issueTrackerUrl,
documentationUrl: result.documentationUrl,
contributingUrl: result.contributingUrl,
+ fundingUris: result.fundingUrls?.map(Uri.parse).toList(),
);
}
@@ -1143,6 +1151,7 @@ class PackagePageData {
documentationUrl: pubspec.documentation,
repositoryUrl: pubspec.repository,
issueTrackerUrl: pubspec.issueTracker,
+ fundingUris: pubspec.funding,
);
}();
diff --git a/app/test/frontend/golden/pkg_show_page_publisher.html b/app/test/frontend/golden/pkg_show_page_publisher.html
index b4d8db7cae..a7863a02d3 100644
--- a/app/test/frontend/golden/pkg_show_page_publisher.html
+++ b/app/test/frontend/golden/pkg_show_page_publisher.html
@@ -264,14 +264,6 @@ Documentation
API reference
- Funding
-
- Consider supporting this project:
-
-
- example.com
-
-
License
@@ -344,14 +336,6 @@
Documentation
API reference
- Funding
-
- Consider supporting this project:
-
-
- example.com
-
-
License