Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(275)

Side by Side Diff: client/lib/item.dart

Issue 695593003: Look for the file name with a hyphen rather than a colon (Closed) Base URL: https://github.com/dart-lang/dartdoc-viewer.git@master
Patch Set: Previous version was on out of date base Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library category_item; 5 library category_item;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:convert'; 8 import 'dart:convert';
9 import 'dart:html' show ProgressEvent; 9 import 'dart:html' show ProgressEvent;
10 10
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 /** 403 /**
404 * An [Item] that is lazily loaded. 404 * An [Item] that is lazily loaded.
405 */ 405 */
406 abstract class LazyItem extends Item { 406 abstract class LazyItem extends Item {
407 bool isLoaded = false; 407 bool isLoaded = false;
408 final String previewComment; 408 final String previewComment;
409 409
410 LazyItem(String qualifiedName, String name, this.previewComment, 410 LazyItem(String qualifiedName, String name, this.previewComment,
411 [String comment]) : super(name, qualifiedName, comment); 411 [String comment]) : super(name, qualifiedName, comment);
412 412
413 /// The name of the file/url path we'll use to retrieve this item's data.
414 String get fileName => qualifiedName.replaceFirst(":", "-");
415
413 /// Loads this [Item]'s data and populates all fields. 416 /// Loads this [Item]'s data and populates all fields.
414 Future load() { 417 Future load() {
415 if (isLoaded) return new Future.value(this); 418 if (isLoaded) return new Future.value(this);
416 var location = '$docsPath$qualifiedName.json'; 419 var location = '$docsPath$fileName.json';
417 var data = retrieveFileContents(location); 420 var data = retrieveFileContents(location);
418 return data.then((response) { 421 return data.then((response) {
419 loadValues(JSON.decode(response)); 422 loadValues(JSON.decode(response));
420 buildHierarchy(this, this); 423 buildHierarchy(this, this);
421 return new Future.value(this); 424 return new Future.value(this);
422 }).catchError(_loadError); 425 }).catchError(_loadError);
423 } 426 }
424 427
425 /// Fallback function -- if we fail to load the specific version of a file, 428 /// Fallback function -- if we fail to load the specific version of a file,
426 /// revert to asking for an unversioned one. 429 /// revert to asking for an unversioned one.
(...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after
1104 } 1107 }
1105 1108
1106 1109
1107 bool _boolFor(String key, Map input) { 1110 bool _boolFor(String key, Map input) {
1108 var value = input[key]; 1111 var value = input[key];
1109 if (value == true || value == 'true') return true; 1112 if (value == true || value == 'true') return true;
1110 if (value == null || value == false || value == 'false') return false; 1113 if (value == null || value == false || value == 'false') return false;
1111 throw new FormatException("Invalid format, expected boolean key: $key" 1114 throw new FormatException("Invalid format, expected boolean key: $key"
1112 " value: $value"); 1115 " value: $value");
1113 } 1116 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698