OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 /** The top-level collection of all sections for a user. */ | 5 /** The top-level collection of all sections for a user. */ |
6 // TODO(jimhug): This is known as UserData in the server model. | 6 // TODO(jimhug): This is known as UserData in the server model. |
7 class Sections implements Collection<Section> { | 7 class Sections implements Collection<Section> { |
8 final List<Section> _sections; | 8 final List<Section> _sections; |
9 | 9 |
10 Sections(this._sections); | 10 Sections(this._sections); |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 // By default images from the real server are cached. | 211 // By default images from the real server are cached. |
212 // Bump the version flag if you change the thumbnail size, and you want to | 212 // Bump the version flag if you change the thumbnail size, and you want to |
213 // get the new images. Our server ignores the query params but it gets | 213 // get the new images. Our server ignores the query params but it gets |
214 // around appengine server side caching and the client side cache. | 214 // around appengine server side caching and the client side cache. |
215 return 'data/$dataUri.jpg'; | 215 return 'data/$dataUri.jpg'; |
216 } | 216 } |
217 | 217 |
218 // TODO(jimhug): need to return a lazy Observable<String> and also | 218 // TODO(jimhug): need to return a lazy Observable<String> and also |
219 // add support for preloading. | 219 // add support for preloading. |
220 void _ensureLoaded() { | 220 void _ensureLoaded() { |
221 if (_htmlBody !== null) return; | 221 if (_htmlBody != null) return; |
222 | 222 |
223 var name = '$dataUri.html'; | 223 var name = '$dataUri.html'; |
224 if (Sections.runningFromFile) { | 224 if (Sections.runningFromFile) { |
225 _htmlBody = CannedData.data[name]; | 225 _htmlBody = CannedData.data[name]; |
226 } else { | 226 } else { |
227 // TODO(jimhug): Remove this truly evil synchronoush xhr. | 227 // TODO(jimhug): Remove this truly evil synchronoush xhr. |
228 final req = new HttpRequest(); | 228 final req = new HttpRequest(); |
229 req.open('GET', 'data/$name', false); | 229 req.open('GET', 'data/$name', false); |
230 req.send(); | 230 req.send(); |
231 _htmlBody = req.responseText; | 231 _htmlBody = req.responseText; |
232 } | 232 } |
233 } | 233 } |
234 | 234 |
235 static Article decodeHeader(Feed source, Decoder decoder) { | 235 static Article decodeHeader(Feed source, Decoder decoder) { |
236 final id = decoder.readString(); | 236 final id = decoder.readString(); |
237 final title = decoder.readString(); | 237 final title = decoder.readString(); |
238 final srcUrl = decoder.readString(); | 238 final srcUrl = decoder.readString(); |
239 final hasThumbnail = decoder.readBool(); | 239 final hasThumbnail = decoder.readBool(); |
240 final author = decoder.readString(); | 240 final author = decoder.readString(); |
241 final dateInSeconds = decoder.readInt(); | 241 final dateInSeconds = decoder.readInt(); |
242 final snippet = decoder.readString(); | 242 final snippet = decoder.readString(); |
243 final date = | 243 final date = |
244 new Date.fromMillisecondsSinceEpoch(dateInSeconds*1000, isUtc: true); | 244 new Date.fromMillisecondsSinceEpoch(dateInSeconds*1000, isUtc: true); |
245 return new Article(source, id, date, title, author, srcUrl, hasThumbnail, | 245 return new Article(source, id, date, title, author, srcUrl, hasThumbnail, |
246 snippet); | 246 snippet); |
247 } | 247 } |
248 } | 248 } |
OLD | NEW |