Skip to content

Commit 6475951

Browse files
committed
Updating Demos
1 parent 475922a commit 6475951

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+115
-8057
lines changed

demos/emoji.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010

1111
<body class="demo-emoji">
1212
<div class="header">
13-
<h1>GitHub Emoji</h1>
14-
<div class="btn btn-primary" id="view-source">View the Source</div>
13+
<h1 class="inline-block">GitHub Emoji</h1>
14+
&nbsp;&nbsp;
15+
<div class="btn" id="view-source">View the Source</div>
1516
<p></p>
1617
</div>
1718

demos/index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
<meta charset="utf-8">
77
<meta name="viewport" content="width=device-width, initial-scale=1.0">
88
<title>GitHub for Dart - Demos</title>
9+
<link rel="stylesheet/less" type="text/css" href="styles/main.less" />
10+
<script src="https://cdnjs.cloudflare.com/ajax/libs/less.js/1.7.4/less.min.js"></script>
911
</head>
1012

1113
<body>

demos/oauth2.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
<meta charset="utf-8">
77
<meta name="viewport" content="width=device-width, initial-scale=1.0">
88
<title>GitHub OAuth2 Demo</title>
9+
<link rel="stylesheet/less" type="text/css" href="styles/main.less" />
10+
<script src="https://cdnjs.cloudflare.com/ajax/libs/less.js/1.7.4/less.min.js"></script>
911
</head>
1012

1113
<body>

demos/packages/path/path.dart

Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ library path;
4949
import 'src/context.dart';
5050
import 'src/style.dart';
5151

52-
export 'src/context.dart' hide createInternal;
52+
export 'src/context.dart';
5353
export 'src/path_exception.dart';
5454
export 'src/style.dart';
5555

@@ -62,17 +62,27 @@ final windows = new Context(style: Style.windows);
6262
/// A default context for manipulating URLs.
6363
final url = new Context(style: Style.url);
6464

65-
/// The system path context.
65+
/// The result of [Uri.base] last time the current working directory was
66+
/// calculated.
6667
///
67-
/// This differs from a context created with [new Context] in that its
68-
/// [Context.current] is always the current working directory, rather than being
69-
/// set once when the context is created.
70-
final Context context = createInternal();
68+
/// This is used to invalidate [_cachedContext] when the working directory has
69+
/// changed since the last time a function was called.
70+
Uri _lastBaseUri;
71+
72+
/// An internal context for the current OS so we can provide a straight
73+
/// functional interface and not require users to create one.
74+
Context get _context {
75+
if (_cachedContext != null && Uri.base == _lastBaseUri) return _cachedContext;
76+
_lastBaseUri = Uri.base;
77+
_cachedContext = new Context();
78+
return _cachedContext;
79+
}
80+
Context _cachedContext;
7181

7282
/// Returns the [Style] of the current context.
7383
///
7484
/// This is the style that all top-level path functions will use.
75-
Style get style => context.style;
85+
Style get style => _context.style;
7686

7787
/// Gets the path to the current working directory.
7888
///
@@ -92,15 +102,15 @@ String get current {
92102

93103
/// Gets the path separator for the current platform. This is `\` on Windows
94104
/// and `/` on other platforms (including the browser).
95-
String get separator => context.separator;
105+
String get separator => _context.separator;
96106

97107
/// Creates a new path by appending the given path parts to [current].
98108
/// Equivalent to [join()] with [current] as the first argument. Example:
99109
///
100110
/// path.absolute('path', 'to/foo'); // -> '/your/current/dir/path/to/foo'
101111
String absolute(String part1, [String part2, String part3, String part4,
102112
String part5, String part6, String part7]) =>
103-
context.absolute(part1, part2, part3, part4, part5, part6, part7);
113+
_context.absolute(part1, part2, part3, part4, part5, part6, part7);
104114

105115
/// Gets the part of [path] after the last separator.
106116
///
@@ -110,7 +120,7 @@ String absolute(String part1, [String part2, String part3, String part4,
110120
/// Trailing separators are ignored.
111121
///
112122
/// path.basename('path/to/'); // -> 'to'
113-
String basename(String path) => context.basename(path);
123+
String basename(String path) => _context.basename(path);
114124

115125
/// Gets the part of [path] after the last separator, and without any trailing
116126
/// file extension.
@@ -121,7 +131,7 @@ String basename(String path) => context.basename(path);
121131
///
122132
/// path.basenameWithoutExtension('path/to/foo.dart/'); // -> 'foo'
123133
String basenameWithoutExtension(String path) =>
124-
context.basenameWithoutExtension(path);
134+
_context.basenameWithoutExtension(path);
125135

126136
/// Gets the part of [path] before the last separator.
127137
///
@@ -142,7 +152,7 @@ String basenameWithoutExtension(String path) =>
142152
///
143153
/// path.dirname('foo'); // -> '.'
144154
/// path.dirname(''); // -> '.'
145-
String dirname(String path) => context.dirname(path);
155+
String dirname(String path) => _context.dirname(path);
146156

147157
/// Gets the file extension of [path]: the portion of [basename] from the last
148158
/// `.` to the end (including the `.` itself).
@@ -157,7 +167,7 @@ String dirname(String path) => context.dirname(path);
157167
///
158168
/// path.extension('~/.bashrc'); // -> ''
159169
/// path.extension('~/.notes.txt'); // -> '.txt'
160-
String extension(String path) => context.extension(path);
170+
String extension(String path) => _context.extension(path);
161171

162172
// TODO(nweiz): add a UNC example for Windows once issue 7323 is fixed.
163173
/// Returns the root of [path], if it's absolute, or the empty string if it's
@@ -175,7 +185,7 @@ String extension(String path) => context.extension(path);
175185
/// path.rootPrefix('path/to/foo'); // -> ''
176186
/// path.rootPrefix('http://dartlang.org/path/to/foo');
177187
/// // -> 'http://dartlang.org'
178-
String rootPrefix(String path) => context.rootPrefix(path);
188+
String rootPrefix(String path) => _context.rootPrefix(path);
179189

180190
/// Returns `true` if [path] is an absolute path and `false` if it is a
181191
/// relative path.
@@ -189,13 +199,13 @@ String rootPrefix(String path) => context.rootPrefix(path);
189199
/// relative to the root of the current URL. Since root-relative paths are still
190200
/// absolute in every other sense, [isAbsolute] will return true for them. They
191201
/// can be detected using [isRootRelative].
192-
bool isAbsolute(String path) => context.isAbsolute(path);
202+
bool isAbsolute(String path) => _context.isAbsolute(path);
193203

194204
/// Returns `true` if [path] is a relative path and `false` if it is absolute.
195205
/// On POSIX systems, absolute paths start with a `/` (forward slash). On
196206
/// Windows, an absolute path starts with `\\`, or a drive letter followed by
197207
/// `:/` or `:\`.
198-
bool isRelative(String path) => context.isRelative(path);
208+
bool isRelative(String path) => _context.isRelative(path);
199209

200210
/// Returns `true` if [path] is a root-relative path and `false` if it's not.
201211
///
@@ -205,7 +215,7 @@ bool isRelative(String path) => context.isRelative(path);
205215
/// can be detected using [isRootRelative].
206216
///
207217
/// No POSIX and Windows paths are root-relative.
208-
bool isRootRelative(String path) => context.isRootRelative(path);
218+
bool isRootRelative(String path) => _context.isRootRelative(path);
209219

210220
/// Joins the given path parts into a single path using the current platform's
211221
/// [separator]. Example:
@@ -222,7 +232,7 @@ bool isRootRelative(String path) => context.isRootRelative(path);
222232
/// path.join('path', '/to', 'foo'); // -> '/to/foo'
223233
String join(String part1, [String part2, String part3, String part4,
224234
String part5, String part6, String part7, String part8]) =>
225-
context.join(part1, part2, part3, part4, part5, part6, part7, part8);
235+
_context.join(part1, part2, part3, part4, part5, part6, part7, part8);
226236

227237
/// Joins the given path parts into a single path using the current platform's
228238
/// [separator]. Example:
@@ -239,7 +249,7 @@ String join(String part1, [String part2, String part3, String part4,
239249
/// path.joinAll(['path', '/to', 'foo']); // -> '/to/foo'
240250
///
241251
/// For a fixed number of parts, [join] is usually terser.
242-
String joinAll(Iterable<String> parts) => context.joinAll(parts);
252+
String joinAll(Iterable<String> parts) => _context.joinAll(parts);
243253

244254
// TODO(nweiz): add a UNC example for Windows once issue 7323 is fixed.
245255
/// Splits [path] into its components using the current platform's [separator].
@@ -262,13 +272,13 @@ String joinAll(Iterable<String> parts) => context.joinAll(parts);
262272
/// // Browser
263273
/// path.split('http://dartlang.org/path/to/foo');
264274
/// // -> ['http://dartlang.org', 'path', 'to', 'foo']
265-
List<String> split(String path) => context.split(path);
275+
List<String> split(String path) => _context.split(path);
266276

267277
/// Normalizes [path], simplifying it by handling `..`, and `.`, and
268278
/// removing redundant path separators whenever possible.
269279
///
270280
/// path.normalize('path/./to/..//file.text'); // -> 'path/file.txt'
271-
String normalize(String path) => context.normalize(path);
281+
String normalize(String path) => _context.normalize(path);
272282

273283
/// Attempts to convert [path] to an equivalent relative path from the current
274284
/// directory.
@@ -298,19 +308,19 @@ String normalize(String path) => context.normalize(path);
298308
/// path.relative('http://dartlang.org', from: 'http://pub.dartlang.org');
299309
/// // -> 'http://dartlang.org'
300310
String relative(String path, {String from}) =>
301-
context.relative(path, from: from);
311+
_context.relative(path, from: from);
302312

303313
/// Returns `true` if [child] is a path beneath `parent`, and `false` otherwise.
304314
///
305315
/// path.isWithin('/root/path', '/root/path/a'); // -> true
306316
/// path.isWithin('/root/path', '/root/other'); // -> false
307317
/// path.isWithin('/root/path', '/root/path') // -> false
308-
bool isWithin(String parent, String child) => context.isWithin(parent, child);
318+
bool isWithin(String parent, String child) => _context.isWithin(parent, child);
309319

310320
/// Removes a trailing extension from the last part of [path].
311321
///
312322
/// withoutExtension('path/to/foo.dart'); // -> 'path/to/foo'
313-
String withoutExtension(String path) => context.withoutExtension(path);
323+
String withoutExtension(String path) => _context.withoutExtension(path);
314324

315325
/// Returns the path represented by [uri], which may be a [String] or a [Uri].
316326
///
@@ -332,7 +342,7 @@ String withoutExtension(String path) => context.withoutExtension(path);
332342
/// If [uri] is relative, a relative path will be returned.
333343
///
334344
/// path.fromUri('path/to/foo'); // -> 'path/to/foo'
335-
String fromUri(uri) => context.fromUri(uri);
345+
String fromUri(uri) => _context.fromUri(uri);
336346

337347
/// Returns the URI that represents [path].
338348
///
@@ -355,7 +365,7 @@ String fromUri(uri) => context.fromUri(uri);
355365
///
356366
/// path.toUri('path/to/foo')
357367
/// // -> Uri.parse('path/to/foo')
358-
Uri toUri(String path) => context.toUri(path);
368+
Uri toUri(String path) => _context.toUri(path);
359369

360370
/// Returns a terse, human-readable representation of [uri].
361371
///
@@ -378,4 +388,4 @@ Uri toUri(String path) => context.toUri(path);
378388
/// path.prettyUri('http://dartlang.org/root/path/a/b.dart');
379389
/// // -> r'a/b.dart'
380390
/// path.prettyUri('file:///root/path'); // -> 'file:///root/path'
381-
String prettyUri(uri) => context.prettyUri(uri);
391+
String prettyUri(uri) => _context.prettyUri(uri);

demos/packages/path/src/context.dart

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ import 'parsed_path.dart';
1010
import 'path_exception.dart';
1111
import '../path.dart' as p;
1212

13-
Context createInternal() => new Context._internal();
14-
1513
/// An instantiable class for manipulating paths. Unlike the top-level
1614
/// functions, this lets you explicitly select what platform the paths will use.
1715
class Context {
@@ -43,20 +41,13 @@ class Context {
4341
return new Context._(style, current);
4442
}
4543

46-
/// Create a [Context] to be used internally within path.
47-
Context._internal() : style = Style.platform, _current = null;
48-
49-
Context._(this.style, this._current);
44+
Context._(this.style, this.current);
5045

5146
/// The style of path that this context works with.
5247
final InternalStyle style;
5348

54-
/// The current directory given when Context was created. If null, current
55-
/// directory is evaluated from 'p.current'.
56-
final String _current;
57-
58-
/// The current directory that relative paths are relative to.
59-
String get current => _current != null ? _current : p.current;
49+
/// The current directory that relative paths will be relative to.
50+
final String current;
6051

6152
/// Gets the path separator for the context's [style]. On Mac and Linux,
6253
/// this is `/`. On Windows, it's `\`.

demos/packages/stack_trace/src/chain.dart

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,7 @@ class Chain implements StackTrace {
9090
/// [15105]: https://code.google.com/p/dart/issues/detail?id=15105
9191
static capture(callback(), {ChainHandler onError}) {
9292
var spec = new StackZoneSpecification(onError);
93-
return runZoned(() {
94-
try {
95-
return callback();
96-
} catch (error, stackTrace) {
97-
// TODO(nweiz): Don't special-case this when issue 19566 is fixed.
98-
return Zone.current.handleUncaughtError(error, stackTrace);
99-
}
100-
}, zoneSpecification: spec.toSpec(), zoneValues: {
93+
return runZoned(callback, zoneSpecification: spec.toSpec(), zoneValues: {
10194
#stack_trace.stack_zone.spec: spec
10295
});
10396
}

demos/packages/stack_trace/src/frame.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,15 @@ final _friendlyFrame = new RegExp(
4747

4848
final _initialDot = new RegExp(r"^\.");
4949

50+
/// "dart:" libraries that are incorrectly reported without a "dart:" prefix.
51+
///
52+
/// See issue 11901. All these libraries should be in "dart:io".
53+
final _ioLibraries = new Set.from([
54+
new Uri(path: 'timer_impl.dart'),
55+
new Uri(path: 'http_impl.dart'),
56+
new Uri(path: 'http_parser.dart')
57+
]);
58+
5059
/// A single stack frame. Each frame points to a precise location in Dart code.
5160
class Frame {
5261
/// The URI of the file in which the code is located.
@@ -126,6 +135,7 @@ class Frame {
126135
// always be found. The column is optional.
127136
var member = match[1].replaceAll("<anonymous closure>", "<fn>");
128137
var uri = Uri.parse(match[2]);
138+
if (_ioLibraries.contains(uri)) uri = Uri.parse('dart:io/${uri.path}');
129139
var line = int.parse(match[3]);
130140
var column = null;
131141
var columnMatch = match[4];

demos/packages/unittest/src/test_case.dart

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,7 @@ class TestCase {
9999
_startTime = new DateTime.now();
100100
_runningTime = null;
101101
++_callbackFunctionsOutstanding;
102-
var testReturn = _testFunction();
103-
// If _testFunction() returned a future, we want to wait for it like we
104-
// would a callback, so if a failure occurs while waiting, we can abort.
105-
if (testReturn is Future) {
106-
++_callbackFunctionsOutstanding;
107-
testReturn.catchError(_errorHandler('Test'))
108-
.whenComplete(_markCallbackComplete);
109-
}
102+
return _testFunction();
110103
}).catchError(_errorHandler('Test')).then((_) {
111104
_markCallbackComplete();
112105
if (result == null) {

demos/releases.html

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,13 @@
44
<head>
55
<title>GitHub Releases</title>
66

7-
<style>
8-
.line {
9-
border-top: 1px;
10-
border-style: solid;
11-
}
12-
.box {
13-
border: 2px solid;
14-
}
15-
.repo {
16-
display: inline-block;
17-
margin-top: 5px;
18-
margin-left: 5px;
19-
width: 256px;
20-
margin-bottom: 5px;
21-
}
22-
.info {}
23-
</style>
7+
8+
<link rel="stylesheet/less" type="text/css" href="styles/main.less" />
9+
<script src="https://cdnjs.cloudflare.com/ajax/libs/less.js/1.7.4/less.min.js"></script>
2410
</head>
2511

2612
<body>
27-
<div class="header">
13+
<div class="demo-releases header">
2814
<h1>GitHub Releases</h1>
2915
<button id="view-source">View the Source</button>
3016
<p></p>

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy