Skip to content

Commit

Permalink
Fixing subdirectory deployment (CTFd#401)
Browse files Browse the repository at this point in the history
* Fixing subdirectory deploy linking incorrectly (Closes CTFd#400)
* Fix some admin panel CSS
  • Loading branch information
ColdHeat authored Oct 6, 2017
1 parent 608d4f4 commit 4862a3c
Show file tree
Hide file tree
Showing 11 changed files with 109 additions and 111 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<div class="chal-files file-row row text-center">
{{#each files}}
<div class='col-md-3 file-button-wrapper'>
<a class='file-button' href='/files/{{this}}'>
<a class='file-button' href='files/{{this}}'>
<label class='challenge-wrapper file-wrapper hide-text'>
{{splitSlash this}}
</label>
Expand Down
2 changes: 1 addition & 1 deletion CTFd/themes/admin/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
</div>
</div>

<div class="container">
<div class="container main-container">
{% block content %}
{% endblock %}
</div>
Expand Down
1 change: 0 additions & 1 deletion CTFd/themes/admin/templates/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

{% block content %}
<div class="row">
<br>
<h1>Config</h1>
<form method="POST">
<div class="col-md-2 col-md-offset-2">
Expand Down
1 change: 0 additions & 1 deletion CTFd/themes/admin/templates/correct_keys.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
{% block content %}

<div class="row">
<br>
<h1>Correct Key Submissions</h1>
<div id="confirm" class="modal fade" tabindex="-1">
<div class="modal-dialog">
Expand Down
4 changes: 4 additions & 0 deletions CTFd/themes/admin/templates/editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ <h3>Content: </h3>
</div>
</form>
</div>

<br>
<br> <!-- Don't compete with footer for bottom of page -->
<br>
{% endblock %}

{% block scripts %}
Expand Down
2 changes: 1 addition & 1 deletion CTFd/themes/admin/templates/pages.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

{% block content %}
<div class="row">
<br>
<h1>Pages</h1>
<div id="confirm" class="modal fade" tabindex="-1" data-width="760">
<div class="modal-dialog">
<div class="modal-content">
Expand Down
1 change: 0 additions & 1 deletion CTFd/themes/admin/templates/scoreboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

{% block content %}
<div class="row">
<br>
<h1>Scoreboard</h1>
<table id="scoreboard" class="table table-striped">
<thead>
Expand Down
1 change: 0 additions & 1 deletion CTFd/themes/admin/templates/statistics.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
{% block content %}

<div class="row" style="text-align:center">
<br>
<h1>Statistics</h1>

<h3><b>{{ team_count }}</b> teams registered</h3>
Expand Down
1 change: 0 additions & 1 deletion CTFd/themes/admin/templates/teams.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

{% block content %}
<div class="row">
<br>
<h1>Teams</h1>
<div id="confirm" class="modal fade" tabindex="-1">
<div class="modal-dialog">
Expand Down
203 changes: 101 additions & 102 deletions CTFd/themes/admin/templates/wrong_keys.html
Original file line number Diff line number Diff line change
@@ -1,118 +1,117 @@
{% extends "admin/base.html" %}

{% block stylesheets %}
<style>
.btn-primary {
background-color: #337ab7;
}
<style>
.btn-primary {
background-color: #337ab7;
}

.btn-danger {
background-color: #d9534f;
}
</style>
.btn-danger {
background-color: #d9534f;
}
</style>
{% endblock %}

{% block content %}

<div class="row">
<br>
<h1>Incorrect Key Submissions</h1>
<div id="confirm" class="modal fade" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header text-center">
<h3>Delete Key</h3>
</div>
<div class="modal-body">
<form method="POST" action="">
<input id="nonce" type="hidden" name="nonce" value="{{ nonce }}">
<div class="small-6 small-centered text-center columns">
<p>Are you sure you want to delete incorrect key submission for team: <strong
id="confirm-team-name"></strong> in challenge: <strong
id="confirm-chal-name"></strong>?</p>
<a onclick="$('#confirm').modal('hide')" class="btn btn-primary">No</a>
<button class="btn btn-danger" id="delete-solve" type="button">Yes</button>
</div>
</form>
</div>
</div>
</div>
</div>
<table id="teamsboard" class="table table-striped">
<thead>
<tr>
<td class="text-center"><b>Team</b>
</td>
<td class="text-center"><b>Challenge</b>
</td>
<td class="text-center"><b>Date</b>
</td>
<td class="text-center"><b>Submitted Key</b>
</td>
<td class="text-center"><b>Delete</b>
</td>
</tr>
</thead>
<tbody>
{% for wrong_key in wrong_keys %}
<tr>
<td class="text-center team" id="{{ wrong_key.teamid }}"><a href="{{ request.script_root }}/admin/team/{{ wrong_key.teamid }}">{{ wrong_key.team_name }}</a>
<td class="text-center chal" id="{{ wrong_key.chalid }}">{{ wrong_key.chal_name }}</td>
<td class="text-center solve-time"><script>document.write( moment({{ wrong_key.date|unix_time_millis }}).local().format('MMMM Do, h:mm:ss A'))</script></td>
<td class="text-center flag" id="{{ wrong_key.id }}">{{ wrong_key.flag }}</td>
<td class="text-center"><i class="fa fa-times"></i></td>
</tr>
{% endfor %}
</tbody>
</table>
{% if pages > 1 %}
<div class="text-center">Page
<br>
{% if curr_page != 1 %}<a href="{{ request.script_root }}/admin/wrong_keys/{{ curr_page-1 }}">&lt;&lt;&lt;</a>{% endif %}
{% for page in range(1, pages + 1) %}
{% if curr_page != page %}
<a href="{{ request.script_root }}/admin/wrong_keys/{{ page }}">{{ page }}</a>
{% else %}
<b>{{ page }}</b>
{% endif %}
{% endfor %}
{% if curr_page != pages %}<a href="{{ request.script_root }}/admin/wrong_keys/{{ curr_page+1 }}">&gt;&gt;&gt;</a>{% endif %}
<a href="{{ request.script_root }}">
</div>
{% endif %}
<h1>Incorrect Key Submissions</h1>
<div id="confirm" class="modal fade" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header text-center">
<h3>Delete Key</h3>
</div>
<div class="modal-body">
<form method="POST" action="">
<input id="nonce" type="hidden" name="nonce" value="{{ nonce }}">
<div class="small-6 small-centered text-center columns">
<p>Are you sure you want to delete incorrect key submission for team: <strong
id="confirm-team-name"></strong> in challenge: <strong
id="confirm-chal-name"></strong>?</p>
<a onclick="$('#confirm').modal('hide')" class="btn btn-primary">No</a>
<button class="btn btn-danger" id="delete-solve" type="button">Yes</button>
</div>
</form>
</div>
</div>
</div>
</div>
<table id="teamsboard" class="table table-striped">
<thead>
<tr>
<td class="text-center"><b>Team</b>
</td>
<td class="text-center"><b>Challenge</b>
</td>
<td class="text-center"><b>Date</b>
</td>
<td class="text-center"><b>Submitted Key</b>
</td>
<td class="text-center"><b>Delete</b>
</td>
</tr>
</thead>
<tbody>
{% for wrong_key in wrong_keys %}
<tr>
<td class="text-center team" id="{{ wrong_key.teamid }}"><a href="{{ request.script_root }}/admin/team/{{ wrong_key.teamid }}">{{ wrong_key.team_name }}</a>
<td class="text-center chal" id="{{ wrong_key.chalid }}">{{ wrong_key.chal_name }}</td>
<td class="text-center solve-time"><script>document.write( moment({{ wrong_key.date|unix_time_millis }}).local().format('MMMM Do, h:mm:ss A'))</script></td>
<td class="text-center flag" id="{{ wrong_key.id }}">{{ wrong_key.flag }}</td>
<td class="text-center"><i class="fa fa-times"></i></td>
</tr>
{% endfor %}
</tbody>
</table>
{% if pages > 1 %}
<div class="text-center">Page
<br>
{% if curr_page != 1 %}<a href="{{ request.script_root }}/admin/wrong_keys/{{ curr_page-1 }}">&lt;&lt;&lt;</a>{% endif %}
{% for page in range(1, pages + 1) %}
{% if curr_page != page %}
<a href="{{ request.script_root }}/admin/wrong_keys/{{ page }}">{{ page }}</a>
{% else %}
<b>{{ page }}</b>
{% endif %}
{% endfor %}
{% if curr_page != pages %}<a href="{{ request.script_root }}/admin/wrong_keys/{{ curr_page+1 }}">&gt;&gt;&gt;</a>{% endif %}
<a href="{{ request.script_root }}">
</div>
{% endif %}
</div>
{% endblock %}

{% block scripts %}
<script src="{{ request.script_root }}/themes/admin/static/js/utils.js"></script>
<script>
$('#delete-solve').click(function (e) {
e.preventDefault();
var solve = $('#confirm input[name="solve"]').val();
$.post($('#confirm form').attr('action'), $('#confirm form').serialize(), function (data) {
var data = $.parseJSON(JSON.stringify(data));
if (data == "1") {
location.reload()
}
})
});
<script src="{{ request.script_root }}/themes/admin/static/js/utils.js"></script>
<script>
$('#delete-solve').click(function (e) {
e.preventDefault();
var solve = $('#confirm input[name="solve"]').val();
$.post($('#confirm form').attr('action'), $('#confirm form').serialize(), function (data) {
var data = $.parseJSON(JSON.stringify(data));
if (data == "1") {
location.reload()
}
})
});

function load_confirm_modal(key_id, team_name, chal_name) {
var modal = $('#confirm')
modal.find('#confirm-team-name').text(team_name);
modal.find('#confirm-chal-name').text(chal_name);
$('#confirm form').attr('action', '{{ request.script_root }}/admin/wrong_keys/' + key_id + '/delete');
$('#confirm').modal('show');
}
function load_confirm_modal(key_id, team_name, chal_name) {
var modal = $('#confirm')
modal.find('#confirm-team-name').text(team_name);
modal.find('#confirm-chal-name').text(chal_name);
$('#confirm form').attr('action', '{{ request.script_root }}/admin/wrong_keys/' + key_id + '/delete');
$('#confirm').modal('show');
}

$('.fa-times').click(function () {
var elem = $(this).parent().parent();
var chal = elem.find('.chal').attr('id');
var chal_name = elem.find('.chal').text().trim();
var team = elem.find('.team').attr('id');
var team_name = elem.find('.team').text().trim();
var key_id = elem.find('.flag').attr('id');
load_confirm_modal(key_id, team_name, chal_name);
});
</script>
$('.fa-times').click(function () {
var elem = $(this).parent().parent();
var chal = elem.find('.chal').attr('id');
var chal_name = elem.find('.chal').text().trim();
var team = elem.find('.team').attr('id');
var team_name = elem.find('.team').text().trim();
var key_id = elem.find('.flag').attr('id');
load_confirm_modal(key_id, team_name, chal_name);
});
</script>
{% endblock %}
2 changes: 1 addition & 1 deletion CTFd/themes/original/static/js/chalboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ function getsolves(id){
var id = teams[i].id;
var name = teams[i].name;
var date = moment(teams[i].date).local().format('LLL');
box.append('<tr><td><a href="/team/{0}">{1}</td><td>{2}</td></tr>'.format(id, htmlentities(name), date));
box.append('<tr><td><a href="team/{0}">{1}</td><td>{2}</td></tr>'.format(id, htmlentities(name), date));
};
});
}
Expand Down

0 comments on commit 4862a3c

Please sign in to comment.