Example #1
0
def webnail(item_name):
    item_name = encode(item_name)
    c = get_class_for_item(item_name)
    if c:
        item = c(item_name, flask.request.args)
        if item.user_may_view():
            item.create_webnail()
            webnail_item_path = item.webnail_item_path()
            if os.path.exists(webnail_item_path):
                return flask.send_file(webnail_item_path)
    flask.abort(404)
Example #2
0
def item(item_name):
    item_name = encode(item_name)
    if flask.request.args.get('search_request', None) is None:
        c = get_class_for_item(item_name)
    else:
        c = get_class_for_item(item_name, force_uncached=True, force_list=True)
    if c:
        item = c(item_name, flask.request.args)
        #
        # Edit/ Add a tag if posted
        #
        if flask.request.method == 'POST' and flask.request.form.get('tag_submit') == '1':
            # TODO: Right management for tagging
            tag_id = flask.request.form.get('tag_id', None)
            action = flask.request.form.get('action')
            if action == 'Submit Tag':       # EDIT/ ADD
                x1 = int(flask.request.form.get('x1'))
                x2 = int(flask.request.form.get('x2'))
                y1 = int(flask.request.form.get('y1'))
                y2 = int(flask.request.form.get('y2'))
                tag_text = flask.request.form.get('tag_text')
                item.add_tag_wn_x1y1x2y2(x1, y1, x2, y2, tag_text, tag_id)
            elif action == 'Delete Tag':     # DELETE
                item.delete_tag(tag_id)
        #
        # Create Page
        #
        inp = collector(title=item.name(), url_prefix=url_prefix, url_extention=url_extention(item_name), this=item, pygal_user=pygal_user, lang=lang)
        rv = flask.render_template('header.html', input=inp)
        if item.user_may_view():
            if item.exists():
                if item.user_may_view() or type(item) is itemlist:
                    rv += flask.render_template(item.template(), input=inp)
                else:
                    rv += lang.permission_denied
        rv += flask.render_template('footer.html', input=inp)
        return rv
    flask.abort(404)
Example #3
0
def info(item_name):
    item_name = encode(item_name)
    if flask.request.args.get('q', None) is None:
        c = get_class_for_item(item_name)
    else:
        c = get_class_for_item(item_name, force_uncached=True, force_list=True)
    if c:
        item = c(item_name, flask.request.args)
        inp = collector(title='Info: %s' % item.name(), url_prefix=url_prefix, url_extention=url_extention(item_name), this=item, pygal_user=pygal_user, lang=lang)
        rv = flask.render_template('header.html', input=inp)
        if item.exists():
            if item.user_may_view():
                rv += flask.render_template('info.html', input=inp)
            else:
                rv += lang.permission_denied
        rv += flask.render_template('footer.html', input=inp)
        return rv
    flask.abort(404)