diff --git a/app/lib/fake/backend/fake_pana_runner.dart b/app/lib/fake/backend/fake_pana_runner.dart index 1162ab9c4..5edd4daea 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 817d66ed1..7c574b754 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 f1c9db752..11157e0a3 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 b4d8db7ca..a7863a02d 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