* Fixes running CTFd under a folder
This commit is contained in:
Kevin Chung
2017-03-02 20:28:17 -05:00
parent fdb2c34d88
commit 3022a7a01a
7 changed files with 7 additions and 6 deletions

View File

@@ -20,7 +20,6 @@ def admin_key_types():
@admin_keys.route('/admin/keys/<int:keyid>', methods=['POST', 'GET'])
@admins_only
def admin_keys_view(keyid):
print repr(keyid)
if request.method == 'GET':
if keyid:
saved_key = Keys.query.filter_by(id=keyid).first_or_404()

View File

@@ -26,6 +26,7 @@ function load_edit_key_modal(key_id, key_type_name) {
$.get(script_root + '/admin/keys/' + key_id, function(key_data){
$('#edit-keys').empty();
var template = Handlebars.compile(template_data);
key_data['script_root'] = script_root;
$('#edit-keys').append(template(key_data));
$('#key-id').val(key_id);
$('#submit-keys').click(function (e) {
@@ -92,7 +93,7 @@ function loadkeys(chal){
$('#current-keys').empty();
$.get(script_root + "/static/admin/js/templates/admin-keys-table.hbs", function(data){
var template = Handlebars.compile(data);
var wrapper = {keys: keys};
var wrapper = {keys: keys, script_root: script_root};
$('#current-keys').append(template(wrapper));
});
});

View File

@@ -1,5 +1,5 @@
<div class="col-md-6 col-md-offset-3">
<form method="POST" action="{{ request.script_root }}/admin/chal/new" enctype="multipart/form-data">
<form method="POST" action="{{ script_root }}/admin/chal/new" enctype="multipart/form-data">
<div class="form-group">
<label for="name">Name</label>
<input type="text" class="form-control" name="name" placeholder="Enter challenge name">

View File

@@ -4,7 +4,7 @@
<h3>Regex Key</h3>
</div>
<div class="modal-body">
<form method="POST" action="{{ request.script_root }}/admin/key/{{id}}" style="text-align:center">
<form method="POST" action="{{ script_root }}/admin/key/{{id}}" style="text-align:center">
<input type="text" id="key-data" class="form-control" name="key" value="{{key}}" placeholder="Enter regex key data">
<input type="hidden" id="key-type" value="1">
<input type="hidden" id="key-id">

View File

@@ -4,7 +4,7 @@
<h3>Static Key</h3>
</div>
<div class="modal-body">
<form method="POST" action="{{ request.script_root }}/admin/key/{{id}}" style="text-align:center">
<form method="POST" action="{{ script_root }}/admin/key/{{id}}" style="text-align:center">
<input type="text" id="key-data" class="form-control" name="key" value="{{key}}" placeholder="Enter static key data">
<input type="hidden" id="key-type" value="0">
<input type="hidden" id="key-id">

View File

@@ -28,6 +28,7 @@ function updateChalWindow(obj) {
$('#chal-window').empty();
templates[obj.type] = template_data;
var template_data = templates[obj.type];
template_data['script_root'] = script_root;
var template = Handlebars.compile(template_data);
var solves = obj.solves == 1 ? " Solve" : " Solves";
solves = obj.solves + solves;

View File

@@ -38,7 +38,7 @@
function load_chal_template(chal_type_name){
$.get(script_root + '/static/admin/js/templates/challenges/'+ chal_type_name +'/' + chal_type_name + '-challenge-create.hbs', function(template_data){
var template = Handlebars.compile(template_data);
$("#create-chal-entry-div").html(template({'nonce':nonce}));
$("#create-chal-entry-div").html(template({'nonce':nonce, 'script_root':script_root}));
$.getScript(script_root + '/static/admin/js/templates/challenges/'+chal_type_name+'/'+chal_type_name+'-challenge-create.js', function(){
console.log('loaded');
});