Esempio n. 1
0
File: web.py Progetto: imgtl/imgtl
def show_thumbnail(url):
    upload = get_upload(current_user, url)
    if isinstance(upload, int):
        abort(upload)
    obj = upload.object
    r = make_response()
    r.headers['Cache-Control'] = 'public'
    r.headers['Content-Type'] = ''
    r.headers['Content-Disposition'] = 'inline; filename="%s"' % upload.title.encode('utf8')
    r.headers['X-Accel-Redirect'] = imgtl.lib.get_spath('/x/thumb', obj.code)
    return r
Esempio n. 2
0
def show_thumbnail(url):
    upload = get_upload(current_user, url)
    if isinstance(upload, int):
        abort(upload)
    obj = upload.object
    r = make_response()
    r.headers['Cache-Control'] = 'public'
    r.headers['Content-Type'] = ''
    r.headers[
        'Content-Disposition'] = 'inline; filename="%s"' % upload.title.encode(
            'utf8')
    r.headers['X-Accel-Redirect'] = imgtl.lib.get_spath('/x/thumb', obj.code)
    return r
Esempio n. 3
0
File: web.py Progetto: imgtl/imgtl
def show_only_image(url, ext):
    upload = get_upload(current_user, url)
    if isinstance(upload, int):
        abort(upload)
    obj = upload.object
    if isinstance(obj, Image):
        if obj.ext != ext:
            abort(404)
        r = make_response()
        r.headers['Cache-Control'] = 'public'
        r.headers['Content-Type'] = ''
        r.headers['Content-Disposition'] = 'inline; filename="%s"' % upload.title.encode('utf8')
        r.headers['X-Accel-Redirect'] = imgtl.lib.get_spath('/x', obj.code)
        return r
Esempio n. 4
0
def show_only_image(url, ext):
    upload = get_upload(current_user, url)
    if isinstance(upload, int):
        abort(upload)
    obj = upload.object
    if isinstance(obj, Image):
        if obj.ext != ext:
            abort(404)
        r = make_response()
        r.headers['Cache-Control'] = 'public'
        r.headers['Content-Type'] = ''
        r.headers[
            'Content-Disposition'] = 'inline; filename="%s"' % upload.title.encode(
                'utf8')
        r.headers['X-Accel-Redirect'] = imgtl.lib.get_spath('/x', obj.code)
        return r
Esempio n. 5
0
File: web.py Progetto: imgtl/imgtl
def show(url):
    if request.method == 'DELETE':
        res = do_delete_image(current_user, url)
        if res == 'success':
            flash(i18n('deletesuccess'), 'success')
        return jsonify({'res': res})
    elif request.method == 'PUT':
        res = do_update_image(current_user, url, request.form.get('nsfw') == 'true', request.form.get('anonymous') == 'true', request.form.get('private') == 'true')
        return jsonify({'res': res})
    elif request.method == 'GET':
        upload = get_upload(current_user, url)
        if isinstance(upload, int):
            abort(upload)
        obj = upload.object
        if isinstance(obj, Image):
            return render_imgtl_template('show/image.html', upload=upload)
Esempio n. 6
0
def show(url):
    if request.method == 'DELETE':
        res = do_delete_image(current_user, url)
        if res == 'success':
            flash(i18n('deletesuccess'), 'success')
        return jsonify({'res': res})
    elif request.method == 'PUT':
        res = do_update_image(current_user, url,
                              request.form.get('nsfw') == 'true',
                              request.form.get('anonymous') == 'true',
                              request.form.get('private') == 'true')
        return jsonify({'res': res})
    elif request.method == 'GET':
        upload = get_upload(current_user, url)
        if isinstance(upload, int):
            abort(upload)
        obj = upload.object
        if isinstance(obj, Image):
            return render_imgtl_template('show/image.html', upload=upload)
Esempio n. 7
0
 def get(self, url):
     upload = get_upload(None, url)
     if not upload or upload.deleted:
         return error('nosuchupload'), 404
     user = {
         'name': upload.user.name,
         'profile_image_url': upload.user.profile_image_url
     } if upload.user else None
     return success({
         'type': upload.object.__tablename__,
         'url': {
             'page': BASE_URL % upload.url,
             'direct': upload.direct_url
         },
         'title': upload.title,
         'desc': upload.desc,
         'upload_at': upload.time.strftime('%s'),
         'user': user,
         'view_count': upload.view_count,
         'properties': upload.object.prop
     })
Esempio n. 8
0
File: api.py Progetto: imgtl/imgtl
 def get(self, url):
     upload = get_upload(None, url)
     if not upload or upload.deleted:
         return error('nosuchupload'), 404
     user = {'name': upload.user.name, 'profile_image_url': upload.user.profile_image_url} if upload.user else None
     return success({'type': upload.object.__tablename__, 'url': {'page': BASE_URL % upload.url, 'direct': upload.direct_url}, 'title': upload.title, 'desc': upload.desc, 'upload_at': upload.time.strftime('%s'), 'user': user, 'view_count': upload.view_count, 'properties': upload.object.prop})