Skip to content
Please note that GitHub no longer supports your web browser.

We recommend upgrading to the latest Google Chrome or Firefox.

Learn more
Permalink
Browse files

fix bugs

  • Loading branch information...
tdurieux committed Sep 27, 2019
1 parent ce13716 commit 40d20a8a5a76423477a78aa8d526a7be8b78ab8b
Showing with 19 additions and 12 deletions.
  1. +5 −11 server.py
  2. +14 −1 templates/index.html
@@ -317,9 +317,10 @@ def get_content(current_file, files, path, repository_config, g_repo):
else:
file_path = current_file.path
cached_file_path = os.path.join(cache_path, file_path)
content_type = get_type_content(path, path, repository_config, g_repo, False).replace("; charset=utf-8", "")
if os.path.exists(cached_file_path):
return send_from_directory(os.path.dirname(cached_file_path), os.path.basename(cached_file_path),
mimetype=get_type_content(path, path, repository_config, g_repo, False).replace("; charset=utf-8", ""))
mimetype=content_type)
content = ''
if current_file.type != 'dir' and is_website(path, repository_config, g_repo):
if current_file.size > 1000000:
@@ -330,14 +331,7 @@ def get_content(current_file, files, path, repository_config, g_repo):
content = blob.content.decode('utf-8')
else:
content = current_file.decoded_content.decode('utf-8')
if ".html" in current_file.name \
or ".txt" in current_file.name \
or ".log" in current_file.name \
or ".java" in current_file.name \
or ".py" in current_file.name \
or ".xml" in current_file.name \
or ".json" in current_file.name \
or ".js" in current_file.name:
if "text" in content_type:
content = remove_terms(content, repository_config)
if ".md" in current_file.name:
gh = self.github
@@ -442,7 +436,7 @@ def repository(id, path):
return render_template('404.html'), 404
with open(config_path, 'r') as f:
repository_configuration = json.load(f, object_hook=json_util.object_hook)
if 'expiration_date' in repository_configuration:
if 'expiration_date' in repository_configuration and repository_configuration['expiration_date'] is not None:
if repository_configuration['expiration_date'] <= datetime.now(repository_configuration['expiration_date'].tzinfo):
if repository_configuration['expiration'] == 'redirect':
return redirect(repository_configuration['repository'])
@@ -516,7 +510,7 @@ def add_repository():
expiration = None
if 'expiration' in request.form:
expiration = request.form['expiration']
if 'expiration_date' in request.form:
if 'expiration_date' in request.form and request.form['expiration_date'] != '':
expiration_date = datetime.strptime(request.form['expiration_date'], '%Y-%m-%d')

user = session.get('user', None)
@@ -92,7 +92,9 @@ <h4 class="subtext-header mt-2 mb-4">Double-blind your repository in 5 min!</h4>
<small class="form-text text-muted">When the anonymous repository.</small>
<input class="form-control .form-control-lg" type="date" name="expiration_date" id="date" value="{% if repo.expiration_date %}{{ repo.expiration_date.date().isoformat() }}{% endif %}" />
</div>
<button type="submit" class="white_border">Submit</button>`
<button id="submit" type="submit" class="white_border">Submit</button>`

<button id="delete" class="white_border" style="color: red;">Delete</button>`
</div>
</div>
</form>
@@ -246,6 +248,17 @@ <h3 class="mb-auto text-center">2609 Anonymized Repositories</h3>
$('.main-options').show();
return false;
})
$('#delete').on('click', e => {
e.preventDefault();
if (confirm("Are you sure you want to delete the repository?")) {
$('#expiration')[0].value = 'remove';
var date = new Date();
date.setDate(date.getDate() - 1);
$('#date')[0].value = date.toISOString().split('T')[0];
$('#submit').click();
}
return false;
})
$('#edit-button').on('click', e=> {
e.preventDefault();
$('.view').removeClass('active')

0 comments on commit 40d20a8

Please sign in to comment.
You can’t perform that action at this time.