mirror of
https://github.com/aljazceru/CTFd.git
synced 2025-12-17 22:14:25 +01:00
Finalize 2.0.0 (#751)
* Fix Font-Awesome running offline and use minified Font-Awesome * Rename chal-* classes/ids to challenge-* * Fix admins changing their password
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
{% if solves == None %}
|
||||
{% else %}
|
||||
<li class="nav-item">
|
||||
<a class="nav-link chal-solves" href="#solves">
|
||||
<a class="nav-link challenge-solves" href="#solves">
|
||||
{{ solves }} {% if solves > 1 %}Solves{% else %}Solves{% endif %}
|
||||
</a>
|
||||
</li>
|
||||
@@ -20,15 +20,15 @@
|
||||
<div role="tabpanel">
|
||||
<div class="tab-content">
|
||||
<div role="tabpanel" class="tab-pane fade show active" id="challenge">
|
||||
<h2 class='chal-name text-center pt-3'>{{ name }}</h2>
|
||||
<h3 class="chal-value text-center">{{ value }}</h3>
|
||||
<div class="chal-tags text-center">
|
||||
<h2 class='challenge-name text-center pt-3'>{{ name }}</h2>
|
||||
<h3 class="challenge-value text-center">{{ value }}</h3>
|
||||
<div class="challenge-tags text-center">
|
||||
{% for tag in tags %}
|
||||
<span class='badge badge-info chal-tag'>{{ tag }}</span>
|
||||
<span class='badge badge-info challenge-tag'>{{ tag }}</span>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<span class="chal-desc">{{ description | safe }}</span>
|
||||
<div class="chal-hints hint-row row">
|
||||
<span class="challenge-desc">{{ description | safe }}</span>
|
||||
<div class="challenge-hints hint-row row">
|
||||
{% for hint in hints %}
|
||||
<div class='col-md-12 hint-button-wrapper text-center mb-3'>
|
||||
<a class="btn btn-info btn-hint btn-block" href="javascript:;"
|
||||
@@ -52,7 +52,7 @@
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div class="row chal-files text-center pb-3">
|
||||
<div class="row challenge-files text-center pb-3">
|
||||
{% for file in files %}
|
||||
<div class='col-md-4 col-sm-4 col-xs-12 file-button-wrapper d-block'>
|
||||
<a class='btn btn-info btn-file mb-1 d-inline-block px-2 w-100 text-truncate'
|
||||
@@ -68,9 +68,8 @@
|
||||
|
||||
<div class="row submit-row">
|
||||
<div class="col-md-9 form-group">
|
||||
<input class="form-control" type="text" name="answer" id="answer-input"
|
||||
placeholder="Flag"/>
|
||||
<input id="chal-id" type="hidden" value="{{ id }}">
|
||||
<input class="form-control" type="text" name="answer" id="submission-input" placeholder="Flag"/>
|
||||
<input id="challenge-id" type="hidden" value="{{ id }}">
|
||||
</div>
|
||||
<div class="col-md-3 form-group key-submit">
|
||||
<button type="submit" id="submit-key" tabindex="5"
|
||||
@@ -99,7 +98,7 @@
|
||||
</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="chal-solves-names">
|
||||
<tbody id="challenge-solves-names">
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
@@ -19,8 +19,8 @@ window.challenge.postRender = function () {
|
||||
|
||||
|
||||
window.challenge.submit = function (cb, preview) {
|
||||
var challenge_id = parseInt($('#chal-id').val());
|
||||
var submission = $('#answer-input').val();
|
||||
var challenge_id = parseInt($('#challenge-id').val());
|
||||
var submission = $('#submission-input').val();
|
||||
var url = "/api/v1/challenges/attempt";
|
||||
|
||||
if (preview) {
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
{% if solves == None %}
|
||||
{% else %}
|
||||
<li class="nav-item">
|
||||
<a class="nav-link chal-solves" href="#solves">
|
||||
<a class="nav-link challenge-solves" href="#solves">
|
||||
{{ solves }} {% if solves > 1 %}Solves{% else %}Solves{% endif %}
|
||||
</a>
|
||||
</li>
|
||||
@@ -20,15 +20,15 @@
|
||||
<div role="tabpanel">
|
||||
<div class="tab-content">
|
||||
<div role="tabpanel" class="tab-pane fade show active" id="challenge">
|
||||
<h2 class='chal-name text-center pt-3'>{{ name }}</h2>
|
||||
<h3 class="chal-value text-center">{{ value }}</h3>
|
||||
<div class="chal-tags text-center">
|
||||
<h2 class='challenge-name text-center pt-3'>{{ name }}</h2>
|
||||
<h3 class="challenge-value text-center">{{ value }}</h3>
|
||||
<div class="challenge-tags text-center">
|
||||
{% for tag in tags %}
|
||||
<span class='badge badge-info chal-tag'>{{ tag }}</span>
|
||||
<span class='badge badge-info challenge-tag'>{{ tag }}</span>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<span class="chal-desc">{{ description | safe }}</span>
|
||||
<div class="chal-hints hint-row row">
|
||||
<span class="challenge-desc">{{ description | safe }}</span>
|
||||
<div class="challenge-hints hint-row row">
|
||||
{% for hint in hints %}
|
||||
<div class='col-md-12 hint-button-wrapper text-center mb-3'>
|
||||
<a class="btn btn-info btn-hint btn-block" href="javascript:;"
|
||||
@@ -52,7 +52,7 @@
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div class="row chal-files text-center pb-3">
|
||||
<div class="row challenge-files text-center pb-3">
|
||||
{% for file in files %}
|
||||
<div class='col-md-4 col-sm-4 col-xs-12 file-button-wrapper d-block'>
|
||||
<a class='btn btn-info btn-file mb-1 d-inline-block px-2 w-100 text-truncate'
|
||||
@@ -68,9 +68,9 @@
|
||||
|
||||
<div class="row submit-row">
|
||||
<div class="col-md-9 form-group">
|
||||
<input class="form-control" type="text" name="answer" id="answer-input"
|
||||
<input class="form-control" type="text" name="answer" id="submission-input"
|
||||
placeholder="Flag"/>
|
||||
<input id="chal-id" type="hidden" value="{{ id }}">
|
||||
<input id="challenge-id" type="hidden" value="{{ id }}">
|
||||
</div>
|
||||
<div class="col-md-3 form-group key-submit">
|
||||
<button type="submit" id="submit-key" tabindex="5"
|
||||
@@ -99,7 +99,7 @@
|
||||
</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="chal-solves-names">
|
||||
<tbody id="challenge-solves-names">
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
@@ -19,8 +19,8 @@ window.challenge.postRender = function () {
|
||||
|
||||
|
||||
window.challenge.submit = function (cb, preview) {
|
||||
var challenge_id = parseInt($('#chal-id').val());
|
||||
var submission = $('#answer-input').val();
|
||||
var challenge_id = parseInt($('#challenge-id').val());
|
||||
var submission = $('#submission-input').val();
|
||||
var url = "/api/v1/challenges/attempt";
|
||||
|
||||
if (preview) {
|
||||
|
||||
@@ -105,10 +105,9 @@ class UserSchema(ma.ModelSchema):
|
||||
user_id = data.get('id')
|
||||
|
||||
if is_admin():
|
||||
if user_id:
|
||||
if password:
|
||||
data['password'] = hash_password(data['password'])
|
||||
return data
|
||||
if password:
|
||||
data['password'] = hash_password(data['password'])
|
||||
return data
|
||||
else:
|
||||
if password and (confirm is None):
|
||||
raise ValidationError('Please confirm your current password', field_names=['confirm'])
|
||||
|
||||
@@ -3918,3 +3918,18 @@ readers do not read off random characters that represent icons */
|
||||
overflow: visible;
|
||||
position: static;
|
||||
width: auto; }
|
||||
|
||||
.fab {
|
||||
font-family: 'Font Awesome 5 Brands', 'Font Awesome 5 Brands Offline';
|
||||
}
|
||||
|
||||
.far {
|
||||
font-family: 'Font Awesome 5 Free', 'Font Awesome 5 Free Offline';
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.fa,
|
||||
.fas {
|
||||
font-family: 'Font Awesome 5 Free', 'Font Awesome 5 Free Offline';
|
||||
font-weight: 900;
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -3,7 +3,7 @@ function renderSubmissionResponse(response, cb) {
|
||||
|
||||
var result_message = $('#result-message');
|
||||
var result_notification = $('#result-notification');
|
||||
var answer_input = $("#answer-input");
|
||||
var answer_input = $("#submission-input");
|
||||
result_notification.removeClass();
|
||||
result_message.text(result.message);
|
||||
|
||||
@@ -25,7 +25,7 @@ function renderSubmissionResponse(response, cb) {
|
||||
result_notification.addClass('alert alert-success alert-dismissable text-center');
|
||||
result_notification.slideDown();
|
||||
|
||||
$('.chal-solves').text((parseInt($('.chal-solves').text().split(" ")[0]) + 1 + " Solves"));
|
||||
$('.challenge-solves').text((parseInt($('.challenge-solves').text().split(" ")[0]) + 1 + " Solves"));
|
||||
|
||||
answer_input.val("");
|
||||
answer_input.removeClass("wrong");
|
||||
@@ -81,8 +81,8 @@ $(document).ready(function () {
|
||||
|
||||
$('#challenge-window').append(template.render(challenge_data));
|
||||
|
||||
$('.chal-solves').click(function (e) {
|
||||
getsolves($('#chal-id').val())
|
||||
$('.challenge-solves').click(function (e) {
|
||||
getsolves($('#challenge-id').val())
|
||||
});
|
||||
$('.nav-tabs a').click(function (e) {
|
||||
e.preventDefault();
|
||||
@@ -91,8 +91,8 @@ $(document).ready(function () {
|
||||
|
||||
// Handle modal toggling
|
||||
$('#challenge-window').on('hide.bs.modal', function (event) {
|
||||
$("#answer-input").removeClass("wrong");
|
||||
$("#answer-input").removeClass("correct");
|
||||
$("#submission-input").removeClass("wrong");
|
||||
$("#submission-input").removeClass("correct");
|
||||
$("#incorrect-key").slideUp();
|
||||
$("#correct-key").slideUp();
|
||||
$("#already-solved").slideUp();
|
||||
@@ -109,7 +109,7 @@ $(document).ready(function () {
|
||||
// Preview passed as true
|
||||
});
|
||||
|
||||
$("#answer-input").keyup(function (event) {
|
||||
$("#submission-input").keyup(function (event) {
|
||||
if (event.keyCode == 13) {
|
||||
$("#submit-key").click();
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<link rel="icon" href="{{ url_for('views.themes', theme='core', path='img/favicon.ico') }}" type="image/x-icon">
|
||||
<link rel="stylesheet" href="{{ url_for('views.themes', theme='admin', path='css/vendor/bootstrap.min.css') }}">
|
||||
<link rel="stylesheet" href="{{ url_for('views.themes', theme='admin', path='css/vendor/font-awesome/fontawesome-fonts.css') }}" type='text/css'>
|
||||
<link rel="stylesheet" href="{{ url_for('views.themes', theme='admin', path='css/vendor/font-awesome/fontawesome-all.css') }}" type='text/css'>
|
||||
<link rel="stylesheet" href="{{ url_for('views.themes', theme='admin', path='css/vendor/font-awesome/fontawesome-all.min.css') }}" type='text/css'>
|
||||
<link rel="stylesheet" href='{{ url_for('views.themes', theme='admin', path='css/vendor/font.css') }}'>
|
||||
<link rel="stylesheet" href="{{ url_for('views.themes', theme='admin', path='css/jumbotron.css') }}">
|
||||
<link rel="stylesheet" href="{{ url_for('views.themes', theme='admin', path='css/sticky-footer.css') }}">
|
||||
|
||||
@@ -3918,3 +3918,18 @@ readers do not read off random characters that represent icons */
|
||||
overflow: visible;
|
||||
position: static;
|
||||
width: auto; }
|
||||
|
||||
.fab {
|
||||
font-family: 'Font Awesome 5 Brands', 'Font Awesome 5 Brands Offline';
|
||||
}
|
||||
|
||||
.far {
|
||||
font-family: 'Font Awesome 5 Free', 'Font Awesome 5 Free Offline';
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.fa,
|
||||
.fas {
|
||||
font-family: 'Font Awesome 5 Free', 'Font Awesome 5 Free Offline';
|
||||
font-weight: 900;
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -35,7 +35,7 @@ function updateChalWindow(obj) {
|
||||
|
||||
$.getScript(script_root + obj.script, function () {
|
||||
$.get(script_root + obj.template, function (template_data) {
|
||||
$('#chal-window').empty();
|
||||
$('#challenge-window').empty();
|
||||
var template = nunjucks.compile(template_data);
|
||||
window.challenge.data = challenge_data;
|
||||
window.challenge.preRender();
|
||||
@@ -43,10 +43,10 @@ function updateChalWindow(obj) {
|
||||
challenge_data['description'] = window.challenge.render(challenge_data['description']);
|
||||
challenge_data['script_root'] = script_root;
|
||||
|
||||
$('#chal-window').append(template.render(challenge_data));
|
||||
$('#challenge-window').append(template.render(challenge_data));
|
||||
|
||||
$('.chal-solves').click(function (e) {
|
||||
getsolves($('#chal-id').val())
|
||||
$('.challenge-solves').click(function (e) {
|
||||
getsolves($('#challenge-id').val())
|
||||
});
|
||||
$('.nav-tabs a').click(function (e) {
|
||||
e.preventDefault();
|
||||
@@ -54,9 +54,9 @@ function updateChalWindow(obj) {
|
||||
});
|
||||
|
||||
// Handle modal toggling
|
||||
$('#chal-window').on('hide.bs.modal', function (event) {
|
||||
$("#answer-input").removeClass("wrong");
|
||||
$("#answer-input").removeClass("correct");
|
||||
$('#challenge-window').on('hide.bs.modal', function (event) {
|
||||
$("#submission-input").removeClass("wrong");
|
||||
$("#submission-input").removeClass("correct");
|
||||
$("#incorrect-key").slideUp();
|
||||
$("#correct-key").slideUp();
|
||||
$("#already-solved").slideUp();
|
||||
@@ -73,7 +73,7 @@ function updateChalWindow(obj) {
|
||||
});
|
||||
});
|
||||
|
||||
$("#answer-input").keyup(function (event) {
|
||||
$("#submission-input").keyup(function (event) {
|
||||
if (event.keyCode == 13) {
|
||||
$("#submit-key").click();
|
||||
}
|
||||
@@ -96,13 +96,13 @@ function updateChalWindow(obj) {
|
||||
window.challenge.postRender();
|
||||
|
||||
window.location.replace(window.location.href.split('#')[0] + '#' + obj.name);
|
||||
$('#chal-window').modal();
|
||||
$('#challenge-window').modal();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
$("#answer-input").keyup(function (event) {
|
||||
$("#submission-input").keyup(function (event) {
|
||||
if (event.keyCode == 13) {
|
||||
$("#submit-key").click();
|
||||
}
|
||||
@@ -114,7 +114,7 @@ function renderSubmissionResponse(response, cb) {
|
||||
|
||||
var result_message = $('#result-message');
|
||||
var result_notification = $('#result-notification');
|
||||
var answer_input = $("#answer-input");
|
||||
var answer_input = $("#submission-input");
|
||||
result_notification.removeClass();
|
||||
result_message.text(result.message);
|
||||
|
||||
@@ -136,7 +136,7 @@ function renderSubmissionResponse(response, cb) {
|
||||
result_notification.addClass('alert alert-success alert-dismissable text-center');
|
||||
result_notification.slideDown();
|
||||
|
||||
$('.chal-solves').text((parseInt($('.chal-solves').text().split(" ")[0]) + 1 + " Solves"));
|
||||
$('.challenge-solves').text((parseInt($('.challenge-solves').text().split(" ")[0]) + 1 + " Solves"));
|
||||
|
||||
answer_input.val("");
|
||||
answer_input.removeClass("wrong");
|
||||
@@ -207,10 +207,10 @@ function load_user_solves(cb) {
|
||||
function getsolves(id) {
|
||||
$.get(script_root + '/api/v1/challenges/' + id + '/solves', function (response) {
|
||||
var data = response.data;
|
||||
$('.chal-solves').text(
|
||||
$('.challenge-solves').text(
|
||||
(parseInt(data.length) + " Solves")
|
||||
);
|
||||
var box = $('#chal-solves-names');
|
||||
var box = $('#challenge-solves-names');
|
||||
box.empty();
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var id = data[i].account_id;
|
||||
@@ -292,16 +292,16 @@ function loadchals(cb) {
|
||||
|
||||
|
||||
$('#submit-key').click(function (e) {
|
||||
submitkey($('#chal-id').val(), $('#answer-input').val(), $('#nonce').val())
|
||||
submitkey($('#challenge-id').val(), $('#submission-input').val(), $('#nonce').val())
|
||||
});
|
||||
|
||||
$('.chal-solves').click(function (e) {
|
||||
getsolves($('#chal-id').val())
|
||||
$('.challenge-solves').click(function (e) {
|
||||
getsolves($('#challenge-id').val())
|
||||
});
|
||||
|
||||
$('#chal-window').on('hide.bs.modal', function (event) {
|
||||
$("#answer-input").removeClass("wrong");
|
||||
$("#answer-input").removeClass("correct");
|
||||
$('#challenge-window').on('hide.bs.modal', function (event) {
|
||||
$("#submission-input").removeClass("wrong");
|
||||
$("#submission-input").removeClass("correct");
|
||||
$("#incorrect-key").slideUp();
|
||||
$("#correct-key").slideUp();
|
||||
$("#already-solved").slideUp();
|
||||
@@ -335,7 +335,7 @@ $('.nav-tabs a').click(function (e) {
|
||||
$(this).tab('show')
|
||||
});
|
||||
|
||||
$('#chal-window').on('hidden.bs.modal', function () {
|
||||
$('#challenge-window').on('hidden.bs.modal', function () {
|
||||
$('.nav-tabs a:first').tab('show');
|
||||
history.replaceState('', document.title, window.location.pathname);
|
||||
});
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
type="image/x-icon">
|
||||
<link rel="stylesheet" href="{{ url_for('views.themes', theme=get_ctf_theme(), path='css/vendor/bootstrap.min.css') }}">
|
||||
<link rel="stylesheet" href="{{ url_for('views.themes', theme=get_ctf_theme(), path='css/vendor/font-awesome/fontawesome-fonts.css') }}" type='text/css'>
|
||||
<link rel="stylesheet" href="{{ url_for('views.themes', theme=get_ctf_theme(), path='css/vendor/font-awesome/fontawesome-all.css') }}" type='text/css'>
|
||||
<link rel="stylesheet" href="{{ url_for('views.themes', theme=get_ctf_theme(), path='css/vendor/font-awesome/fontawesome-all.min.css') }}" type='text/css'>
|
||||
<link href='{{ url_for('views.themes', theme=get_ctf_theme(), path='css/vendor/font.css') }}' rel='stylesheet' type='text/css'>
|
||||
<link rel="stylesheet" href="{{ url_for('views.themes', theme=get_ctf_theme(), path='css/jumbotron.css') }}">
|
||||
<link rel="stylesheet" href="{{ url_for('views.themes', theme=get_ctf_theme(), path='css/sticky-footer.css') }}">
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
|
||||
<input id="nonce" type="hidden" name="nonce" value="{{ nonce }}">
|
||||
|
||||
<div class="modal fade" id="chal-window" tabindex="-1" role="dialog">
|
||||
<div class="modal fade" id="challenge-window" tabindex="-1" role="dialog">
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user