Skip to content

Separate homepage and repository for a package #904

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/lib/frontend/model_properties.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ class Pubspec {
return _asString(_json['homepage']);
}

String get repository {
_load();
return _asString(_json['repository']);
}

String get description {
_load();
return _asString(_json['description']);
Expand Down
12 changes: 12 additions & 0 deletions app/lib/frontend/models.dart
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,22 @@ class PackageVersion extends db.ExpandoModel {
String get documentationNice => niceUrl(documentation);

String get homepage {
if (pubspec.repository == null && isRepositoryUrl(pubspec.homepage)) {
return null;
}
return pubspec.homepage;
}

String get homepageNice => niceUrl(homepage);

String get repository {
if (pubspec.repository == null && isRepositoryUrl(pubspec.homepage)) {
return pubspec.homepage;
}
return pubspec.repository;
}

String get repositoryNice => niceUrl(repository);
}

@db.Kind(name: 'PrivateKey', idType: db.IdType.String)
Expand Down
10 changes: 6 additions & 4 deletions app/lib/frontend/templates.dart
Original file line number Diff line number Diff line change
Expand Up @@ -265,23 +265,23 @@ class TemplateService {
if (selectedVersion.readme != null) {
readmeFilename = selectedVersion.readme.filename;
renderedReadme =
_renderFile(selectedVersion.readme, selectedVersion.homepage);
_renderFile(selectedVersion.readme, selectedVersion.repository);
}

String changelogFilename;
String renderedChangelog;
if (selectedVersion.changelog != null) {
changelogFilename = selectedVersion.changelog.filename;
renderedChangelog =
_renderFile(selectedVersion.changelog, selectedVersion.homepage);
_renderFile(selectedVersion.changelog, selectedVersion.repository);
}

String exampleFilename;
String renderedExample;
if (selectedVersion.example != null) {
exampleFilename = selectedVersion.example.filename;
renderedExample =
_renderFile(selectedVersion.example, selectedVersion.homepage);
_renderFile(selectedVersion.example, selectedVersion.repository);
if (renderedExample != null) {
renderedExample = '<p style="font-family: monospace">'
'<b>${_htmlEscaper.convert(exampleFilename)}</b>'
Expand Down Expand Up @@ -346,6 +346,8 @@ class TemplateService {
_getAuthorsHtml(selectedVersion.pubspec.getAllAuthors()),
'homepage': selectedVersion.homepage,
'nice_homepage': selectedVersion.homepageNice,
'repository': selectedVersion.repository,
'nice_repository': selectedVersion.repositoryNice,
'documentation': selectedVersion.documentation,
'nice_documentation': selectedVersion.documentationNice,
// TODO: make this 'Uploaders' if Package.uploaders is > 1?!
Expand All @@ -354,7 +356,7 @@ class TemplateService {
'short_created': selectedVersion.shortCreated,
'install_html': _renderInstall(isFlutterPackage, analysis?.platforms),
'license_html':
_renderLicenses(selectedVersion.homepage, analysis?.licenses),
_renderLicenses(selectedVersion.repository, analysis?.licenses),
'score_box_html': _renderScoreBox(extract?.overallScore,
isOutdated: extract?.isOutdated,
isNewPackage: package.isNewPackage()),
Expand Down
6 changes: 6 additions & 0 deletions app/lib/shared/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -358,3 +358,9 @@ class StringInternPool {
}
}
}

bool isRepositoryUrl(String url) {
if (url == null) return false;
return url.startsWith('https://github.com/') ||
url.startsWith('https://gitlab.com/');
}
1 change: 1 addition & 0 deletions app/test/frontend/golden/pkg_show_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ <h3 class="title">Author</h3>
<h3 class="title">Homepage</h3>
<a class="link" href="http:&#x2F;&#x2F;hans.juergen.com">hans.juergen.com</a>


<h3 class="title">Documentation</h3>
<a class="link" href="http:&#x2F;&#x2F;www.dartdocs.org&#x2F;documentation&#x2F;foobar_pkg&#x2F;0.1.1&#x2F;">www.dartdocs.org&#x2F;documentation&#x2F;foobar_pkg&#x2F;0.1.1&#x2F;</a>

Expand Down
1 change: 1 addition & 0 deletions app/test/frontend/golden/pkg_show_page_flutter_plugin.html
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ <h3 class="title">Author</h3>
<h3 class="title">Homepage</h3>
<a class="link" href="http:&#x2F;&#x2F;hans.juergen.com">hans.juergen.com</a>


<h3 class="title">Documentation</h3>
<a class="link" href="http:&#x2F;&#x2F;www.dartdocs.org&#x2F;documentation&#x2F;foobar_pkg&#x2F;0.1.1&#x2F;">www.dartdocs.org&#x2F;documentation&#x2F;foobar_pkg&#x2F;0.1.1&#x2F;</a>

Expand Down
1 change: 1 addition & 0 deletions app/test/frontend/golden/pkg_show_page_outdated.html
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ <h3 class="title">Author</h3>
<h3 class="title">Homepage</h3>
<a class="link" href="http:&#x2F;&#x2F;hans.juergen.com">hans.juergen.com</a>


<h3 class="title">Documentation</h3>
<a class="link" href="http:&#x2F;&#x2F;www.dartdocs.org&#x2F;documentation&#x2F;foobar_pkg&#x2F;0.1.1&#x2F;">www.dartdocs.org&#x2F;documentation&#x2F;foobar_pkg&#x2F;0.1.1&#x2F;</a>

Expand Down
1 change: 1 addition & 0 deletions app/test/frontend/golden/pkg_show_version_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ <h3 class="title">Author</h3>
<h3 class="title">Homepage</h3>
<a class="link" href="http:&#x2F;&#x2F;hans.juergen.com">hans.juergen.com</a>


<h3 class="title">Documentation</h3>
<a class="link" href="http:&#x2F;&#x2F;www.dartdocs.org&#x2F;documentation&#x2F;foobar_pkg&#x2F;0.1.1&#x2F;">www.dartdocs.org&#x2F;documentation&#x2F;foobar_pkg&#x2F;0.1.1&#x2F;</a>

Expand Down
5 changes: 5 additions & 0 deletions app/views/pkg/show.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ import 'package:{{package}}/{{library}}';
<a class="link" href="{{package.homepage}}">{{package.nice_homepage}}</a>
{{/package.homepage}}

{{#package.repository}}
<h3 class="title">Repository</h3>
<a class="link" href="{{package.repository}}">{{package.nice_repository}}</a>
{{/package.repository}}

{{#package.documentation}}
<h3 class="title">Documentation</h3>
<a class="link" href="{{package.documentation}}">{{package.nice_documentation}}</a>
Expand Down