liquid_feedback_frontend
annotate app/main/member_image/show.lua @ 1072:ba51e72830e6
Added OpenLDAP license to LICENSE file
| author | bsw | 
|---|---|
| date | Fri Jul 18 23:12:14 2014 +0200 (2014-07-18) | 
| parents | f52f918b38b8 | 
| children | 904f6807f7fa | 
| rev | line source | 
|---|---|
| bsw/jbe@4 | 1 local image_type = param.get("image_type") | 
| bsw/jbe@4 | 2 local record = MemberImage:by_pk(param.get_id(), image_type, true) | 
| bsw/jbe@4 | 3 | 
| poelzi@148 | 4 print('Cache-Control: max-age=300'); -- let the client cache the image for 5 minutes | 
| poelzi@148 | 5 | 
| bsw/jbe@4 | 6 if record == nil then | 
| bsw@729 | 7 local default_file = ({ avatar = "avatar.jpg", photo = nil })[image_type] | 
| bsw/jbe@4 | 8 if default_file then | 
| bsw/jbe@4 | 9 print('Location: ' .. encode.url{ static = default_file } .. '\n\n') | 
| bsw/jbe@4 | 10 else | 
| bsw/jbe@4 | 11 print('Location: ' .. encode.url{ static = 'icons/16/lightning.png' } .. '\n\n') | 
| bsw/jbe@4 | 12 end | 
| bsw/jbe@4 | 13 exit() | 
| bsw/jbe@4 | 14 end | 
| bsw/jbe@4 | 15 | 
| bsw/jbe@52 | 16 assert(record.content_type, "No content-type set for image.") | 
| bsw/jbe@52 | 17 | 
| bsw/jbe@52 | 18 slot.set_layout(nil, record.content_type) | 
| bsw/jbe@4 | 19 | 
| bsw/jbe@4 | 20 if record then | 
| bsw/jbe@52 | 21 slot.put_into("data", record.data) | 
| bsw/jbe@4 | 22 end |