Skip to content

Commit

Permalink
add a new integration option by simply redirecting to the thumbnail i…
Browse files Browse the repository at this point in the history
…mage.

this method can be used by putting the rndpic URL in the src parameter of any <img> tag.
  • Loading branch information
pmoor committed Jan 20, 2013
1 parent b4088f6 commit 864f789
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
4 changes: 4 additions & 0 deletions app.yaml
Expand Up @@ -27,6 +27,9 @@ handlers:
- url: /json/([^/]+)
script: main.app

- url: /img/([^/]+)
script: main.app

- url: /
script: root.app

Expand All @@ -48,3 +51,4 @@ skip_files:
- ^(.*/)?.*/RCS/.*
- ^(.*/)?\..*
- ^google_appengine$
- ^rndpic\.iml$
29 changes: 29 additions & 0 deletions img_handler.py
@@ -0,0 +1,29 @@
# rndpic - an App Engine app to display random pictures from Picasa Web.
# Copyright (C) 2013 Patrick Moor <patrick@moor.ws>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import webapp2

class ImgHandler(webapp2.RequestHandler):

def get(self, user_name):
size = self.request.get("size", "200u")
album_id = int(self.request.get("album_id", 0))
picture = webapp2.get_app().registry["picker"].Pick(
user_name, size, album_id)
if picture:
self.redirect(picture.GetThumbnailUrl().encode())
else:
self.response.set_status(204)
6 changes: 4 additions & 2 deletions main.py
Expand Up @@ -20,17 +20,19 @@
from album_repository import AlbumRepository
from picker import RandomPicturePicker

from user_handler import UserHandler
from img_handler import ImgHandler
from json_handler import JsonHandler
from user_handler import UserHandler


repository = AlbumRepository(FeedRepository())
picker = RandomPicturePicker(repository)

app = webapp2.WSGIApplication(
[
(r'/user/([^/]+)', UserHandler),
(r'/img/([^/]+)', ImgHandler),
(r'/json/([^/]+)', JsonHandler),
(r'/user/([^/]+)', UserHandler),
],
debug=False)
app.registry["picker"] = picker

0 comments on commit 864f789

Please sign in to comment.