Skip to content

Commit 65dde03

Browse files
authored
New wording: Flutter-compatible and Flutter-only (#1536)
* Change Flutter-specific to Flutter-only. * Refactor plaform-related consts. * Explicit morePlatformPackagesLabel field in dict. * Update Flutter-compatible/only labels. * Update search placeholder label. * web-compatible labels without web-only url.
1 parent 3248e90 commit 65dde03

File tree

5 files changed

+62
-30
lines changed

5 files changed

+62
-30
lines changed

app/lib/frontend/template_consts.dart

Lines changed: 47 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import 'dart:convert';
66

7+
import 'package:meta/meta.dart';
78
import 'package:pana/models.dart' show SuggestionCode;
89

910
import 'package:pub_dartlang_org/shared/platform.dart' show KnownPlatforms;
@@ -12,26 +13,50 @@ import '../shared/urls.dart' as urls;
1213

1314
class PlatformDict {
1415
final String name;
15-
final String pageTitle;
16+
final String topPlatformPackages;
17+
final String morePlatformPackagesLabel;
18+
final String onlyPlatformPackagesLabel;
19+
final String onlyPlatformPackagesUrl;
20+
final String searchPlatformPackagesLabel;
1621
final String landingPageTitle;
1722
final String landingBlurb;
1823
final String landingUrl;
1924
final String listingUrl;
2025
final String tagTitle;
2126

2227
PlatformDict({
23-
this.name,
24-
String pageTitle,
25-
this.landingPageTitle,
26-
this.landingBlurb,
27-
this.landingUrl,
28-
this.listingUrl,
29-
this.tagTitle,
30-
}) : this.pageTitle = pageTitle ?? 'Top $name packages';
31-
32-
factory PlatformDict.forPlatform(String platform, {String tagTitle}) {
28+
@required this.name,
29+
@required this.topPlatformPackages,
30+
@required this.morePlatformPackagesLabel,
31+
@required this.onlyPlatformPackagesLabel,
32+
@required this.onlyPlatformPackagesUrl,
33+
@required this.searchPlatformPackagesLabel,
34+
@required this.landingPageTitle,
35+
@required this.landingBlurb,
36+
@required this.landingUrl,
37+
@required this.listingUrl,
38+
@required this.tagTitle,
39+
});
40+
41+
factory PlatformDict.forPlatform(
42+
String platform, {
43+
String tagTitle,
44+
String onlyPlatformPackagesUrl,
45+
}) {
46+
final formattedPlatform = _formattedPlatformName(platform);
47+
final hasOnly = onlyPlatformPackagesUrl != null;
48+
final hasCompatible = hasOnly || platform == KnownPlatforms.web;
49+
final platformCompatible =
50+
hasCompatible ? '$formattedPlatform-compatible' : formattedPlatform;
51+
final platformOnly =
52+
hasOnly ? '$formattedPlatform-only' : formattedPlatform;
3353
return new PlatformDict(
34-
name: _formattedPlatformName(platform),
54+
name: formattedPlatform,
55+
topPlatformPackages: 'Top $platformCompatible packages',
56+
morePlatformPackagesLabel: 'More $platformCompatible packages...',
57+
onlyPlatformPackagesLabel: hasOnly ? '$platformOnly packages...' : null,
58+
onlyPlatformPackagesUrl: onlyPlatformPackagesUrl,
59+
searchPlatformPackagesLabel: 'Search $platformCompatible packages',
3560
landingPageTitle: _landingPageTitle(platform),
3661
landingBlurb: _landingBlurb(platform),
3762
landingUrl: platform == null ? '/' : '/$platform',
@@ -55,6 +80,7 @@ final _dictionaries = <String, PlatformDict>{
5580
KnownPlatforms.flutter: new PlatformDict.forPlatform(
5681
KnownPlatforms.flutter,
5782
tagTitle: 'Compatible with the Flutter platform.',
83+
onlyPlatformPackagesUrl: '/packages?q=dependency%3Aflutter',
5884
),
5985
KnownPlatforms.web: new PlatformDict.forPlatform(
6086
KnownPlatforms.web,
@@ -63,6 +89,15 @@ final _dictionaries = <String, PlatformDict>{
6389
KnownPlatforms.other: new PlatformDict(
6490
name: KnownPlatforms.other,
6591
tagTitle: 'Compatible with other platforms (terminal, server, etc.).',
92+
listingUrl: null, // no listing for platform tag
93+
topPlatformPackages: null, // no landing page
94+
morePlatformPackagesLabel: null, // no search filter for it
95+
onlyPlatformPackagesLabel: null, // no search filter for it
96+
onlyPlatformPackagesUrl: null, // no search filter for it
97+
searchPlatformPackagesLabel: null, // no search filter for it
98+
landingUrl: null,
99+
landingPageTitle: null,
100+
landingBlurb: null,
66101
),
67102
};
68103

@@ -149,9 +184,6 @@ final String defaultPageDescriptionEscaped = htmlEscape.convert(
149184
'Pub is the package manager for the Dart programming language, containing reusable '
150185
'libraries & packages for Flutter, AngularDart, and general Dart programs.');
151186

152-
String flutterSpecificPackagesHtml =
153-
'<a href="/packages?q=dependency%3Aflutter">Flutter-specific packages...</a>';
154-
155187
final _suggestionHelpMessages = <String, String>{
156188
SuggestionCode.analysisOptionsRenameRequired: 'Read more about the setup of '
157189
'<a href="https://www.dartlang.org/guides/language/analysis-options#the-analysis-options-file">'

app/lib/frontend/templates.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ class TemplateService {
159159
'ranking_tooltip_html': sortDict.tooltip,
160160
'is_search': isSearch,
161161
'unsupported_qualifier': unsupportedQualifier,
162-
'title': platformDict.pageTitle,
162+
'title': platformDict.topPlatformPackages,
163163
'packages': packagesJson,
164164
'has_packages': packages.isNotEmpty,
165165
'pagination': renderPagination(links),
@@ -168,7 +168,7 @@ class TemplateService {
168168
};
169169
final content = _renderTemplate('pkg/index', values);
170170

171-
String pageTitle = platformDict.pageTitle;
171+
String pageTitle = platformDict.topPlatformPackages;
172172
if (isSearch) {
173173
pageTitle = 'Search results for ${searchQuery.query}.';
174174
} else {
@@ -647,16 +647,16 @@ class TemplateService {
647647
) {
648648
final platformDict = getPlatformDict(platform);
649649
final packagesUrl = urls.searchUrl(platform: platform);
650-
final morePackages = 'More ${platformDict.name} packages...';
651650
final links = <String>[
652-
'<a href="$packagesUrl">${_htmlEscaper.convert(morePackages)}</a>'
651+
'<a href="$packagesUrl">${_htmlEscaper.convert(platformDict.morePlatformPackagesLabel)}</a>'
653652
];
654-
if (platform == KnownPlatforms.flutter) {
655-
links.add(flutterSpecificPackagesHtml);
653+
if (platformDict.onlyPlatformPackagesUrl != null) {
654+
links.add('<a href="${platformDict.onlyPlatformPackagesUrl}">'
655+
'${_htmlEscaper.convert(platformDict.onlyPlatformPackagesLabel)}</a>');
656656
}
657657
final values = {
658658
'more_links_html': links.join(' '),
659-
'top_header': platformDict.pageTitle,
659+
'top_header': platformDict.topPlatformPackages,
660660
'ranking_tooltip_html': getSortDict('top').tooltip,
661661
'top_html': topHtml,
662662
};
@@ -725,7 +725,7 @@ class TemplateService {
725725
'title': htmlEscape.convert(title),
726726
'search_platform': platform,
727727
'search_query': escapedSearchQuery,
728-
'search_query_placeholder': 'Search ${platformDict.name} packages',
728+
'search_query_placeholder': platformDict.searchPlatformPackagesLabel,
729729
'search_sort_param': searchSort,
730730
'platform_tabs_html': platformTabs,
731731
'api_search_enabled': searchQuery?.isApiEnabled ?? true,

app/test/frontend/golden/flutter_landing_page.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ <h1 class="_visuallyhidden">Dart pub</h1>
6666
<h2 class="_visuallyhidden">Dart package manager</h2>
6767
<img class="logo" src="/static/img/flutter-packages.png" alt="Flutter packages" />
6868
<form class="search-bar" action="/flutter/packages">
69-
<input class="input" name="q" placeholder="Search Flutter packages" autocomplete="on" autofocus />
69+
<input class="input" name="q" placeholder="Search Flutter-compatible packages" autocomplete="on" autofocus />
7070
<button class="icon"></button>
7171
</form>
7272
<div class="list-filters">
@@ -83,7 +83,7 @@ <h2 class="_visuallyhidden">Dart package manager</h2>
8383
<div class="home-lists-container">
8484
<div class="landing-page-title-block">
8585
<div class="tooltip-base hoverable">
86-
<h2 class="center landing-page-title tooltip-dotted">Top Flutter packages</h2>
86+
<h2 class="center landing-page-title tooltip-dotted">Top Flutter-compatible packages</h2>
8787
<div class="tooltip-content">
8888
Packages are sorted by the overall score. More information on <a href="/help#ranking">ranking</a>.
8989
</div>
@@ -102,7 +102,7 @@ <h3 class="title"><a href="/packages/foobar_pkg">foobar_pkg</a></h3>
102102
</ul>
103103

104104
<div class="more">
105-
<a href="/flutter/packages">More Flutter packages...</a> <a href="/packages?q=dependency%3Aflutter">Flutter-specific packages...</a>
105+
<a href="/flutter/packages">More Flutter-compatible packages...</a> <a href="/packages?q=dependency%3Aflutter">Flutter-only packages...</a>
106106
</div>
107107
</div>
108108

app/test/frontend/golden/pkg_show_page_flutter_plugin.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ <h1 class="_visuallyhidden">Dart pub</h1>
6262
<div class="_banner-bg">
6363
<main class="package-banner">
6464
<form class="search-bar" action="/flutter/packages">
65-
<input class="input" name="q" placeholder="Search Flutter packages" autocomplete="on" autofocus />
65+
<input class="input" name="q" placeholder="Search Flutter-compatible packages" autocomplete="on" autofocus />
6666
<button class="icon"></button>
6767
</form>
6868
</main>

app/test/frontend/golden/web_landing_page.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ <h1 class="_visuallyhidden">Dart pub</h1>
6666
<h2 class="_visuallyhidden">Dart package manager</h2>
6767
<img class="logo" src="/static/img/dart-packages.png" alt="Dart packages" />
6868
<form class="search-bar" action="/web/packages">
69-
<input class="input" name="q" placeholder="Search web packages" autocomplete="on" autofocus />
69+
<input class="input" name="q" placeholder="Search web-compatible packages" autocomplete="on" autofocus />
7070
<button class="icon"></button>
7171
</form>
7272
<div class="list-filters">
@@ -83,7 +83,7 @@ <h2 class="_visuallyhidden">Dart package manager</h2>
8383
<div class="home-lists-container">
8484
<div class="landing-page-title-block">
8585
<div class="tooltip-base hoverable">
86-
<h2 class="center landing-page-title tooltip-dotted">Top web packages</h2>
86+
<h2 class="center landing-page-title tooltip-dotted">Top web-compatible packages</h2>
8787
<div class="tooltip-content">
8888
Packages are sorted by the overall score. More information on <a href="/help#ranking">ranking</a>.
8989
</div>
@@ -102,7 +102,7 @@ <h3 class="title"><a href="/packages/foobar_pkg">foobar_pkg</a></h3>
102102
</ul>
103103

104104
<div class="more">
105-
<a href="/web/packages">More web packages...</a>
105+
<a href="/web/packages">More web-compatible packages...</a>
106106
</div>
107107
</div>
108108

0 commit comments

Comments
 (0)