예제 #1
0
파일: views.py 프로젝트: taffy5366/CTFd
def static_html(template):
    try:
        return render_template('%s.html' % template)
    except TemplateNotFound:
        page = utils.get_page(template)
        if page is None:
            abort(404)
        return render_template('page.html', content=markdown(page.html))
예제 #2
0
파일: views.py 프로젝트: nus-ncl/CTFd
def static_html(template):
    page = utils.get_page(template)
    if page is None:
        abort(404)
    else:
        if page.auth_required and utils.authed() is False:
            return redirect(url_for('auth.login', next=request.path))

        return render_template('page.html', content=markdown(page.html))
예제 #3
0
def test_markdown():
    """
    Test that our markdown function renders properly
    """
    # Allow raw HTML / potentially unsafe HTML
    assert (
        markdown("<iframe src='https://example.com'></iframe>").strip()
        == "<iframe src='https://example.com'></iframe>"
    )
예제 #4
0
파일: pages.py 프로젝트: dsegna/CTFd-OSINT
def pages_detail(page_id):
    page = Pages.query.filter_by(id=page_id).first_or_404()
    page_op = request.args.get('operation')

    if request.method == 'GET' and page_op == 'preview':
        return render_template('page.html', content=markdown(page.content))

    if request.method == 'GET' and page_op == 'create':
        return render_template('admin/editor.html')

    return render_template('admin/editor.html', page=page)
예제 #5
0
파일: pages.py 프로젝트: tsg-ut/CTFd
def pages_detail(page_id):
    page = Pages.query.filter_by(id=page_id).first_or_404()
    page_op = request.args.get("operation")

    if request.method == "GET" and page_op == "preview":
        return render_template("page.html", content=markdown(page.content))

    if request.method == "GET" and page_op == "create":
        return render_template("admin/editor.html")

    return render_template("admin/editor.html", page=page)
예제 #6
0
    def custom_static_html(route):
        if route == 'index' and get_config('ctf_theme') == 'aeolus':
            return render_template('index.html')
        page = get_page(route)
        if page is None:
            abort(404)
        else:
            if page.auth_required and authed() is False:
                return redirect(url_for('auth.login', next=request.path))

            return render_template('page.html', content=markdown(page.content))
예제 #7
0
파일: views.py 프로젝트: kenz-g147/CTFd-1
def static_html(route):
    """
    Route in charge of routing users to Pages.
    :param route:
    :return:
    """
    page = get_page(route)
    if page is None:
        abort(404)
    else:
        if page.auth_required and authed() is False:
            return redirect(url_for("auth.login", next=request.full_path))

        return render_template("page.html", content=markdown(page.content))
예제 #8
0
def static_html(route):
    """
    Route in charge of routing users to Pages.
    :param route:
    :return:
    """
    page = get_page(route)
    if page is None:
        if (ctftime() or current_user.is_admin()
                or (ctf_ended() and view_after_ctf())):
            filename = safe_join(app.root_path, "static", route)
            if os.path.isfile(filename):
                return send_file(filename)
        abort(404)
    else:
        if page.auth_required and authed() is False:
            return redirect(url_for("auth.login", next=request.full_path))

        return render_template("page.html", content=markdown(page.content))
예제 #9
0
파일: views.py 프로젝트: ccns/CCNS-CTF
def static_html(route):
    """
    Route in charge of routing users to Pages.
    :param route:
    :return:
    """
    page = get_page(route)
    if page is None:
        abort(404)
    else:
        if route == 'index':
            try:
                highscore = str(get_standings()[0][3]).rjust(6, '0')
            except:
                highscore = '000000'
            return render_template('index.html', highscore=highscore)
        elif page.auth_required and authed() is False:
            return redirect(url_for('auth.login', next=request.full_path))

        return render_template("page.html", content=markdown(page.content))
예제 #10
0
파일: pages.py 프로젝트: dsegna/CTFd-OSINT
def pages_preview():
    data = request.form.to_dict()
    schema = PageSchema()
    page = schema.load(data)
    return render_template('page.html', content=markdown(page.data.content))
예제 #11
0
def build_html(html):
    html = markdown(html)
    html = sanitize_html(html)
    return html
예제 #12
0
파일: pages.py 프로젝트: KaitoRyouga/CTFd
def build_html(html):
    html = markdown(html)
    if current_app.config["HTML_SANITIZATION"] is True:
        html = sanitize_html(html)
    return html
예제 #13
0
def admin_pages_view():
    page_id = request.args.get('id')
    page_op = request.args.get('operation')

    if request.method == 'GET' and page_op == 'preview':
        page = Pages.query.filter_by(id=page_id).first_or_404()
        return render_template('page.html', content=markdown(page.html))

    if request.method == 'GET' and page_op == 'create':
        return render_template('admin/editor.html')

    if page_id and request.method == 'GET':
        page = Pages.query.filter_by(id=page_id).first()
        return render_template('admin/editor.html', page=page)

    if request.method == 'POST':
        page_form_id = request.form.get('id')
        title = request.form['title']
        html = request.form['html']
        route = request.form['route'].lstrip('/')
        auth_required = 'auth_required' in request.form

        if page_op == 'preview':
            page = Pages(title, route, html, draft=False)
            return render_template('page.html', content=markdown(page.html))

        page = Pages.query.filter_by(id=page_form_id).first()

        errors = []
        if not route:
            errors.append('Missing URL route')

        if errors:
            page = Pages(title, html, route)
            return render_template('/admin/editor.html', page=page)

        if page:
            page.title = title
            page.route = route
            page.html = html
            page.auth_required = auth_required

            if page_op == 'publish':
                page.draft = False

            db.session.commit()
            db.session.close()

            cache.clear()

            return jsonify({
                'result': 'success',
                'operation': page_op
            })

        if page_op == 'publish':
            page = Pages(title, route, html, draft=False, auth_required=auth_required)
        elif page_op == 'save':
            page = Pages(title, route, html, auth_required=auth_required)

        db.session.add(page)
        db.session.commit()
        db.session.close()

        cache.clear()

        return jsonify({
            'result': 'success',
            'operation': page_op
        })

    pages = Pages.query.all()
    return render_template('admin/pages.html', pages=pages)
예제 #14
0
def static_html(template):
    try:
        return render_template('%s.html' % template)
    except TemplateNotFound:
        page = Pages.query.filter_by(route=template).first_or_404()
        return render_template('page.html', content=markdown(page.html))
예제 #15
0
파일: pages.py 프로젝트: DevLuce/CTFd
def build_markdown(md, sanitize=False):
    html = markdown(md)
    html = format_variables(html)
    if current_app.config["HTML_SANITIZATION"] is True or sanitize is True:
        html = sanitize_html(html)
    return html
예제 #16
0
파일: views.py 프로젝트: semprix/CTFIgniter
def static_html(template):
    try:
        return render_template('%s.html' % template)
    except TemplateNotFound:
        page = Pages.query.filter_by(route=template).first_or_404()
        return render_template('page.html', content=markdown(page.html))