4
4
5
5
import 'dart:convert' ;
6
6
7
+ import 'package:meta/meta.dart' ;
7
8
import 'package:pana/models.dart' show SuggestionCode;
8
9
9
10
import 'package:pub_dartlang_org/shared/platform.dart' show KnownPlatforms;
@@ -12,26 +13,50 @@ import '../shared/urls.dart' as urls;
12
13
13
14
class PlatformDict {
14
15
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;
16
21
final String landingPageTitle;
17
22
final String landingBlurb;
18
23
final String landingUrl;
19
24
final String listingUrl;
20
25
final String tagTitle;
21
26
22
27
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;
33
53
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' ,
35
60
landingPageTitle: _landingPageTitle (platform),
36
61
landingBlurb: _landingBlurb (platform),
37
62
landingUrl: platform == null ? '/' : '/$platform ' ,
@@ -55,6 +80,7 @@ final _dictionaries = <String, PlatformDict>{
55
80
KnownPlatforms .flutter: new PlatformDict .forPlatform (
56
81
KnownPlatforms .flutter,
57
82
tagTitle: 'Compatible with the Flutter platform.' ,
83
+ onlyPlatformPackagesUrl: '/packages?q=dependency%3Aflutter' ,
58
84
),
59
85
KnownPlatforms .web: new PlatformDict .forPlatform (
60
86
KnownPlatforms .web,
@@ -63,6 +89,15 @@ final _dictionaries = <String, PlatformDict>{
63
89
KnownPlatforms .other: new PlatformDict (
64
90
name: KnownPlatforms .other,
65
91
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 ,
66
101
),
67
102
};
68
103
@@ -149,9 +184,6 @@ final String defaultPageDescriptionEscaped = htmlEscape.convert(
149
184
'Pub is the package manager for the Dart programming language, containing reusable '
150
185
'libraries & packages for Flutter, AngularDart, and general Dart programs.' );
151
186
152
- String flutterSpecificPackagesHtml =
153
- '<a href="/packages?q=dependency%3Aflutter">Flutter-specific packages...</a>' ;
154
-
155
187
final _suggestionHelpMessages = < String , String > {
156
188
SuggestionCode .analysisOptionsRenameRequired: 'Read more about the setup of '
157
189
'<a href="https://www.dartlang.org/guides/language/analysis-options#the-analysis-options-file">'
0 commit comments