| 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 #!/usr/bin/env python | 5 #!/usr/bin/env python |
| 6 # | 6 # |
| 7 import re, base64, logging, pickle, httplib2, time, urlparse, urllib2, urllib, S
tringIO, gzip, zipfile | 7 import re, base64, logging, pickle, httplib2, time, urlparse, urllib2, urllib, S
tringIO, gzip, zipfile |
| 8 | 8 |
| 9 from google.appengine.ext import webapp, db | 9 from google.appengine.ext import webapp, db |
| 10 | 10 |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 | 272 |
| 273 # Add the articles. | 273 # Add the articles. |
| 274 collectFeed(feed, data) | 274 collectFeed(feed, data) |
| 275 | 275 |
| 276 else: | 276 else: |
| 277 logging.error('Could not find section %s to add the feed to' % | 277 logging.error('Could not find section %s to add the feed to' % |
| 278 sectionTitle) | 278 sectionTitle) |
| 279 | 279 |
| 280 self.redirect('/') | 280 self.redirect('/') |
| 281 | 281 |
| 282 # TODO(jimhug): Batch these up and request them more agressively. | 282 # TODO(jimhug): Batch these up and request them more aggressively. |
| 283 class DataHandler(webapp.RequestHandler): | 283 class DataHandler(webapp.RequestHandler): |
| 284 def get(self, name): | 284 def get(self, name): |
| 285 if name.endswith('.jpg'): | 285 if name.endswith('.jpg'): |
| 286 # Must be a thumbnail | 286 # Must be a thumbnail |
| 287 key = urllib2.unquote(name[:-len('.jpg')]) | 287 key = urllib2.unquote(name[:-len('.jpg')]) |
| 288 article = Article.get_by_key_name(key) | 288 article = Article.get_by_key_name(key) |
| 289 self.response.headers['Content-Type'] = 'image/jpeg' | 289 self.response.headers['Content-Type'] = 'image/jpeg' |
| 290 # cache images for 10 hours | 290 # cache images for 10 hours |
| 291 self.response.headers['Cache-Control'] = 'public,max-age=36000' | 291 self.response.headers['Cache-Control'] = 'public,max-age=36000' |
| 292 article.ensureThumbnail() | 292 article.ensureThumbnail() |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 730 ('/oauth2callback', OAuthHandler), | 730 ('/oauth2callback', OAuthHandler), |
| 731 | 731 |
| 732 ('/', TopHandler), | 732 ('/', TopHandler), |
| 733 ('/(.*)', MainHandler), | 733 ('/(.*)', MainHandler), |
| 734 ], | 734 ], |
| 735 debug=True) | 735 debug=True) |
| 736 webapp.util.run_wsgi_app(application) | 736 webapp.util.run_wsgi_app(application) |
| 737 | 737 |
| 738 if __name__ == '__main__': | 738 if __name__ == '__main__': |
| 739 main() | 739 main() |
| OLD | NEW |