Skip to content

Commit

Permalink
Always display pubspec URLs (optionally updated from verified URLs). (d…
Browse files Browse the repository at this point in the history
  • Loading branch information
isoos authored Feb 13, 2024
1 parent 93e65bb commit 0a0169e
Show file tree
Hide file tree
Showing 28 changed files with 311 additions and 48 deletions.
39 changes: 21 additions & 18 deletions app/lib/package/models.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1080,30 +1080,33 @@ class PackagePageData {
bool get isLatestStable => version.version == package.latestVersion;

late final packageLinks = () {
// Trying to use verfied URLs
final result = scoreCard.panaReport?.result;
if (result != null) {
final baseUrl = urls.inferBaseUrl(
homepageUrl: result.homepageUrl,
repositoryUrl: result.repositoryUrl,
);
return PackageLinks._(
baseUrl,
homepageUrl: result.homepageUrl,
repositoryUrl: result.repositoryUrl,
issueTrackerUrl: result.issueTrackerUrl,
documentationUrl: result.documentationUrl,
contributingUrl: result.contributingUrl,
);
}
// Falling back to use URLs from pubspec.yaml.
// start with the URLs from pubspec.yaml
final pubspec = version.pubspec!;
return PackageLinks.infer(
final inferred = PackageLinks.infer(
homepageUrl: pubspec.homepage,
documentationUrl: pubspec.documentation,
repositoryUrl: pubspec.repository,
issueTrackerUrl: pubspec.issueTracker,
);

// Use verified URLs when they are available.
final result = scoreCard.panaReport?.result;
if (result == null) {
return inferred;
}

final baseUrl = urls.inferBaseUrl(
homepageUrl: result.homepageUrl ?? inferred.homepageUrl,
repositoryUrl: result.repositoryUrl ?? inferred.repositoryUrl,
);
return PackageLinks._(
baseUrl,
homepageUrl: result.homepageUrl ?? inferred.homepageUrl,
repositoryUrl: result.repositoryUrl ?? inferred.repositoryUrl,
issueTrackerUrl: result.issueTrackerUrl ?? inferred.issueTrackerUrl,
documentationUrl: result.documentationUrl ?? inferred.documentationUrl,
contributingUrl: result.contributingUrl ?? inferred.contributingUrl,
);
}();

/// The verified repository (or homepage).
Expand Down
4 changes: 4 additions & 0 deletions app/test/frontend/golden/pkg_activity_log_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,8 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
<br/>
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/blob/master/CONTRIBUTING.md" rel="ugc">Contributing</a>
<br/>
</p>
Expand Down Expand Up @@ -462,6 +464,8 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
<br/>
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/blob/master/CONTRIBUTING.md" rel="ugc">Contributing</a>
<br/>
</p>
Expand Down
4 changes: 4 additions & 0 deletions app/test/frontend/golden/pkg_admin_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,8 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
<br/>
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/blob/master/CONTRIBUTING.md" rel="ugc">Contributing</a>
<br/>
</p>
Expand Down Expand Up @@ -665,6 +667,8 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
<br/>
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/blob/master/CONTRIBUTING.md" rel="ugc">Contributing</a>
<br/>
</p>
Expand Down
4 changes: 4 additions & 0 deletions app/test/frontend/golden/pkg_changelog_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,8 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
<br/>
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/blob/master/CONTRIBUTING.md" rel="ugc">Contributing</a>
<br/>
</p>
Expand Down Expand Up @@ -333,6 +335,8 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
<br/>
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/blob/master/CONTRIBUTING.md" rel="ugc">Contributing</a>
<br/>
</p>
Expand Down
4 changes: 4 additions & 0 deletions app/test/frontend/golden/pkg_example_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,8 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
<br/>
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/blob/master/CONTRIBUTING.md" rel="ugc">Contributing</a>
<br/>
</p>
Expand Down Expand Up @@ -330,6 +332,8 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
<br/>
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/blob/master/CONTRIBUTING.md" rel="ugc">Contributing</a>
<br/>
</p>
Expand Down
4 changes: 4 additions & 0 deletions app/test/frontend/golden/pkg_install_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,8 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
<br/>
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/blob/master/CONTRIBUTING.md" rel="ugc">Contributing</a>
<br/>
</p>
Expand Down Expand Up @@ -356,6 +358,8 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
<br/>
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/blob/master/CONTRIBUTING.md" rel="ugc">Contributing</a>
<br/>
</p>
Expand Down
4 changes: 4 additions & 0 deletions app/test/frontend/golden/pkg_score_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,8 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
<br/>
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/blob/master/CONTRIBUTING.md" rel="ugc">Contributing</a>
<br/>
</p>
Expand Down Expand Up @@ -418,6 +420,8 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
<br/>
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/blob/master/CONTRIBUTING.md" rel="ugc">Contributing</a>
<br/>
</p>
Expand Down
4 changes: 4 additions & 0 deletions app/test/frontend/golden/pkg_show_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,8 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
<br/>
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/blob/master/CONTRIBUTING.md" rel="ugc">Contributing</a>
<br/>
</p>
Expand Down Expand Up @@ -333,6 +335,8 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
<br/>
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/blob/master/CONTRIBUTING.md" rel="ugc">Contributing</a>
<br/>
</p>
Expand Down
8 changes: 8 additions & 0 deletions app/test/frontend/golden/pkg_show_page_discontinued.html
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,12 @@ <h3 class="title">Publisher</h3>
<h3 class="title pkg-infobox-metadata">Metadata</h3>
<p>pkg is awesome</p>
<p>
<a class="link" href="https://pkg.example.dev/" rel="ugc">Homepage</a>
<br/>
<a class="link" href="https://github.com/example/pkg" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/pkg/issues" rel="ugc">View/report issues</a>
<br/>
<a class="link" href="https://github.com/example/pkg/blob/main/CONTRIBUTING.md" rel="ugc">Contributing</a>
<br/>
</p>
Expand Down Expand Up @@ -320,8 +324,12 @@ <h3 class="title">Publisher</h3>
<h3 class="title pkg-infobox-metadata">Metadata</h3>
<p>pkg is awesome</p>
<p>
<a class="link" href="https://pkg.example.dev/" rel="ugc">Homepage</a>
<br/>
<a class="link" href="https://github.com/example/pkg" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/pkg/issues" rel="ugc">View/report issues</a>
<br/>
<a class="link" href="https://github.com/example/pkg/blob/main/CONTRIBUTING.md" rel="ugc">Contributing</a>
<br/>
</p>
Expand Down
4 changes: 4 additions & 0 deletions app/test/frontend/golden/pkg_show_page_flutter_plugin.html
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
<br/>
<a class="link" href="https://github.com/example/flutter_titanium" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/flutter_titanium/issues" rel="ugc">View/report issues</a>
<br/>
<a class="link" href="https://github.com/example/flutter_titanium/blob/master/CONTRIBUTING.md" rel="ugc">Contributing</a>
<br/>
</p>
Expand Down Expand Up @@ -326,6 +328,8 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
<br/>
<a class="link" href="https://github.com/example/flutter_titanium" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/flutter_titanium/issues" rel="ugc">View/report issues</a>
<br/>
<a class="link" href="https://github.com/example/flutter_titanium/blob/master/CONTRIBUTING.md" rel="ugc">Contributing</a>
<br/>
</p>
Expand Down
4 changes: 4 additions & 0 deletions app/test/frontend/golden/pkg_show_page_publisher.html
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,8 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
<br/>
<a class="link" href="https://github.com/example/neon" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/neon/issues" rel="ugc">View/report issues</a>
<br/>
<a class="link" href="https://github.com/example/neon/blob/master/CONTRIBUTING.md" rel="ugc">Contributing</a>
<br/>
</p>
Expand Down Expand Up @@ -327,6 +329,8 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
<br/>
<a class="link" href="https://github.com/example/neon" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/neon/issues" rel="ugc">View/report issues</a>
<br/>
<a class="link" href="https://github.com/example/neon/blob/master/CONTRIBUTING.md" rel="ugc">Contributing</a>
<br/>
</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,12 @@ <h3 class="title">Publisher</h3>
<h3 class="title pkg-infobox-metadata">Metadata</h3>
<p>pkg is awesome</p>
<p>
<a class="link" href="https://pkg.example.dev/" rel="ugc">Homepage</a>
<br/>
<a class="link" href="https://github.com/example/pkg" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/pkg/issues" rel="ugc">View/report issues</a>
<br/>
<a class="link" href="https://github.com/example/pkg/blob/main/CONTRIBUTING.md" rel="ugc">Contributing</a>
<br/>
</p>
Expand Down Expand Up @@ -311,8 +315,12 @@ <h3 class="title">Publisher</h3>
<h3 class="title pkg-infobox-metadata">Metadata</h3>
<p>pkg is awesome</p>
<p>
<a class="link" href="https://pkg.example.dev/" rel="ugc">Homepage</a>
<br/>
<a class="link" href="https://github.com/example/pkg" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/pkg/issues" rel="ugc">View/report issues</a>
<br/>
<a class="link" href="https://github.com/example/pkg/blob/main/CONTRIBUTING.md" rel="ugc">Contributing</a>
<br/>
</p>
Expand Down
4 changes: 4 additions & 0 deletions app/test/frontend/golden/pkg_show_version_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,8 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
<br/>
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/blob/master/CONTRIBUTING.md" rel="ugc">Contributing</a>
<br/>
</p>
Expand Down Expand Up @@ -327,6 +329,8 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
<br/>
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/blob/master/CONTRIBUTING.md" rel="ugc">Contributing</a>
<br/>
</p>
Expand Down
4 changes: 4 additions & 0 deletions app/test/frontend/golden/pkg_versions_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,8 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
<br/>
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/blob/master/CONTRIBUTING.md" rel="ugc">Contributing</a>
<br/>
</p>
Expand Down Expand Up @@ -436,6 +438,8 @@ <h3 class="title pkg-infobox-metadata">Metadata</h3>
<br/>
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/blob/master/CONTRIBUTING.md" rel="ugc">Contributing</a>
<br/>
</p>
Expand Down
18 changes: 16 additions & 2 deletions app/test/task/testdata/goldens/packages/oxygen.html
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,14 @@ <h3 class="title">Publisher</h3>
</p>
<h3 class="title pkg-infobox-metadata">Metadata</h3>
<p>oxygen is awesome</p>
<p></p>
<p>
<a class="link" href="https://oxygen.example.dev/" rel="ugc">Homepage</a>
<br/>
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
<br/>
</p>
<h3 class="title">Topics</h3>
<p>
<a href="/packages?q=topic%3Achemical-element" rel="nofollow">#chemical-element</a>
Expand Down Expand Up @@ -319,7 +326,14 @@ <h3 class="title">Publisher</h3>
</p>
<h3 class="title pkg-infobox-metadata">Metadata</h3>
<p>oxygen is awesome</p>
<p></p>
<p>
<a class="link" href="https://oxygen.example.dev/" rel="ugc">Homepage</a>
<br/>
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
<br/>
</p>
<h3 class="title">Topics</h3>
<p>
<a href="/packages?q=topic%3Achemical-element" rel="nofollow">#chemical-element</a>
Expand Down
18 changes: 16 additions & 2 deletions app/test/task/testdata/goldens/packages/oxygen/changelog.html
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,14 @@ <h3 class="title">Publisher</h3>
</p>
<h3 class="title pkg-infobox-metadata">Metadata</h3>
<p>oxygen is awesome</p>
<p></p>
<p>
<a class="link" href="https://oxygen.example.dev/" rel="ugc">Homepage</a>
<br/>
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
<br/>
</p>
<h3 class="title">Topics</h3>
<p>
<a href="/packages?q=topic%3Achemical-element" rel="nofollow">#chemical-element</a>
Expand Down Expand Up @@ -325,7 +332,14 @@ <h3 class="title">Publisher</h3>
</p>
<h3 class="title pkg-infobox-metadata">Metadata</h3>
<p>oxygen is awesome</p>
<p></p>
<p>
<a class="link" href="https://oxygen.example.dev/" rel="ugc">Homepage</a>
<br/>
<a class="link" href="https://github.com/example/oxygen" rel="ugc">Repository (GitHub)</a>
<br/>
<a class="link" href="https://github.com/example/oxygen/issues" rel="ugc">View/report issues</a>
<br/>
</p>
<h3 class="title">Topics</h3>
<p>
<a href="/packages?q=topic%3Achemical-element" rel="nofollow">#chemical-element</a>
Expand Down
Loading

0 comments on commit 0a0169e

Please sign in to comment.