mirror of
https://github.com/aljazceru/CTFd.git
synced 2025-12-18 06:24:23 +01:00
Plugins can register global javascript files (#373)
* Give CTFd plugins the ability to register javascript files * Pass hiding of .alert to specific object in challenge template
This commit is contained in:
@@ -68,7 +68,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row notification-row">
|
<div class="row notification-row">
|
||||||
<div id="result-notification" class="alert alert-dismissable text-center" role="alert">
|
<div id="result-notification" class="alert alert-dismissable text-center" role="alert" style="display: none;">
|
||||||
<strong id="result-message"></strong>
|
<strong id="result-message"></strong>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -74,5 +74,9 @@
|
|||||||
<script src="{{ request.script_root }}/themes/{{ ctf_theme() }}/static/js/vendor/bootstrap.min.js"></script>
|
<script src="{{ request.script_root }}/themes/{{ ctf_theme() }}/static/js/vendor/bootstrap.min.js"></script>
|
||||||
{% block scripts %}
|
{% block scripts %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
{% for script in get_registered_scripts() %}
|
||||||
|
<script src="{% if script.startswith('http')%}{{ request.script_root }}{% endif %}{{ script }}"></script>
|
||||||
|
{% endfor %}
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
<style>
|
<style>
|
||||||
.hide-text { text-overflow: ellipsis; overflow: hidden; }
|
.hide-text { text-overflow: ellipsis; overflow: hidden; }
|
||||||
.dialog-inner {padding-bottom: 30px;}
|
.dialog-inner {padding-bottom: 30px;}
|
||||||
.alert {display: none}
|
|
||||||
.category-header {text-align: center}
|
.category-header {text-align: center}
|
||||||
.challenge-wrapper {padding: 5px;}
|
.challenge-wrapper {padding: 5px;}
|
||||||
.challenge-button {width: 100%; height:100px;}
|
.challenge-button {width: 100%; height:100px;}
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ from CTFd.models import db, WrongKeys, Pages, Config, Tracking, Teams, Files, ip
|
|||||||
cache = Cache()
|
cache = Cache()
|
||||||
migrate = Migrate()
|
migrate = Migrate()
|
||||||
markdown = mistune.Markdown()
|
markdown = mistune.Markdown()
|
||||||
|
plugin_scripts = []
|
||||||
|
|
||||||
|
|
||||||
def init_logs(app):
|
def init_logs(app):
|
||||||
@@ -106,6 +107,7 @@ def init_utils(app):
|
|||||||
app.jinja_env.globals.update(ctf_name=ctf_name)
|
app.jinja_env.globals.update(ctf_name=ctf_name)
|
||||||
app.jinja_env.globals.update(ctf_theme=ctf_theme)
|
app.jinja_env.globals.update(ctf_theme=ctf_theme)
|
||||||
app.jinja_env.globals.update(get_configurable_plugins=get_configurable_plugins)
|
app.jinja_env.globals.update(get_configurable_plugins=get_configurable_plugins)
|
||||||
|
app.jinja_env.globals.update(get_registered_scripts=get_registered_scripts)
|
||||||
app.jinja_env.globals.update(get_config=get_config)
|
app.jinja_env.globals.update(get_config=get_config)
|
||||||
app.jinja_env.globals.update(hide_scores=hide_scores)
|
app.jinja_env.globals.update(hide_scores=hide_scores)
|
||||||
|
|
||||||
@@ -176,6 +178,10 @@ def override_template(template, html):
|
|||||||
app.jinja_loader.overriden_templates[template] = html
|
app.jinja_loader.overriden_templates[template] = html
|
||||||
|
|
||||||
|
|
||||||
|
def register_plugin_script(url):
|
||||||
|
plugin_scripts.append(url)
|
||||||
|
|
||||||
|
|
||||||
def pages():
|
def pages():
|
||||||
pages = Pages.query.filter(Pages.route != "index").all()
|
pages = Pages.query.filter(Pages.route != "index").all()
|
||||||
return pages
|
return pages
|
||||||
@@ -349,6 +355,10 @@ def get_configurable_plugins():
|
|||||||
if os.path.isfile(os.path.join(dir, name, 'config.html'))]
|
if os.path.isfile(os.path.join(dir, name, 'config.html'))]
|
||||||
|
|
||||||
|
|
||||||
|
def get_registered_scripts():
|
||||||
|
return plugin_scripts
|
||||||
|
|
||||||
|
|
||||||
def upload_file(file, chalid):
|
def upload_file(file, chalid):
|
||||||
filename = secure_filename(file.filename)
|
filename = secure_filename(file.filename)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user