static_images_DATA = \
src/static/img/default-avatar.jpg \
src/static/img/ipfire-tux.png \
+ src/static/img/iuse-not-found.png \
src/static/img/lightningwirelabs-logo.svg
static_imagesdir = $(staticdir)/img
# i-use.ipfire.org
self.add_handlers(r"i-use(\.dev)?\.ipfire\.org", [
- (r"/profile/([a-f0-9]{40})/([0-9]+).png", iuse.Image),
+ (r"/profile/([a-f0-9]{40})/([0-9]+).png", iuse.ImageHandler),
])
# boot.ipfire.org
#!/usr/bin/python
-import datetime
import logging
-import os
-import random
import tornado.web
from . import base
-class Image(base.BaseHandler):
+class ImageHandler(base.BaseHandler):
def write_error(self, status_code, **kwargs):
"""
Select a random image from the errors directory
"""
self.set_expires(3600)
- self.set_header("Content-Type", "image/png")
-
- template_path = self.application.settings.get("template_path", "")
- template_path = os.path.join(template_path, "i-use", "errors")
-
- images = os.listdir(template_path)
- if images:
- image = random.choice(images)
- image = os.path.join(template_path, image)
-
- imgdata = None
- with open(image, "rb") as f:
- imgdata = f.read()
-
- self.finish(imgdata)
+ # Redirect to static image
+ self.redirect(self.static_url("img/iuse-not-found.png"))
def get(self, profile_id, image_id):
- image = None
-
when = self.get_argument_date("when", None)
- logging.info("Rendering new image for profile: %s" % profile_id)
-
profile = self.fireinfo.get_profile_with_data(profile_id, when=when)
if not profile:
raise tornado.web.HTTPError(404, "Profile '%s' was not found." % profile_id)
+ logging.info("Rendering new image for profile: %s" % profile_id)
+
image_cls = self.iuse.get_imagetype(image_id)
if not image_cls:
raise tornado.web.HTTPError(404, "Image class is unknown: %s" % image_id)