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))
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))
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>" )
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)
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)
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))
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))
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))
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))
def pages_preview(): data = request.form.to_dict() schema = PageSchema() page = schema.load(data) return render_template('page.html', content=markdown(page.data.content))
def build_html(html): html = markdown(html) html = sanitize_html(html) return html
def build_html(html): html = markdown(html) if current_app.config["HTML_SANITIZATION"] is True: html = sanitize_html(html) return html
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)
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))
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