mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-07-12 08:16:33 +02:00
fix bugs
This commit is contained in:
@@ -317,9 +317,10 @@ class Anonymous_Github:
|
|||||||
else:
|
else:
|
||||||
file_path = current_file.path
|
file_path = current_file.path
|
||||||
cached_file_path = os.path.join(cache_path, 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):
|
if os.path.exists(cached_file_path):
|
||||||
return send_from_directory(os.path.dirname(cached_file_path), os.path.basename(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 = ''
|
content = ''
|
||||||
if current_file.type != 'dir' and is_website(path, repository_config, g_repo):
|
if current_file.type != 'dir' and is_website(path, repository_config, g_repo):
|
||||||
if current_file.size > 1000000:
|
if current_file.size > 1000000:
|
||||||
@@ -330,14 +331,7 @@ class Anonymous_Github:
|
|||||||
content = blob.content.decode('utf-8')
|
content = blob.content.decode('utf-8')
|
||||||
else:
|
else:
|
||||||
content = current_file.decoded_content.decode('utf-8')
|
content = current_file.decoded_content.decode('utf-8')
|
||||||
if ".html" in current_file.name \
|
if "text" in content_type:
|
||||||
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:
|
|
||||||
content = remove_terms(content, repository_config)
|
content = remove_terms(content, repository_config)
|
||||||
if ".md" in current_file.name:
|
if ".md" in current_file.name:
|
||||||
gh = self.github
|
gh = self.github
|
||||||
@@ -442,7 +436,7 @@ class Anonymous_Github:
|
|||||||
return render_template('404.html'), 404
|
return render_template('404.html'), 404
|
||||||
with open(config_path, 'r') as f:
|
with open(config_path, 'r') as f:
|
||||||
repository_configuration = json.load(f, object_hook=json_util.object_hook)
|
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_date'] <= datetime.now(repository_configuration['expiration_date'].tzinfo):
|
||||||
if repository_configuration['expiration'] == 'redirect':
|
if repository_configuration['expiration'] == 'redirect':
|
||||||
return redirect(repository_configuration['repository'])
|
return redirect(repository_configuration['repository'])
|
||||||
@@ -516,7 +510,7 @@ class Anonymous_Github:
|
|||||||
expiration = None
|
expiration = None
|
||||||
if 'expiration' in request.form:
|
if 'expiration' in request.form:
|
||||||
expiration = request.form['expiration']
|
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')
|
expiration_date = datetime.strptime(request.form['expiration_date'], '%Y-%m-%d')
|
||||||
|
|
||||||
user = session.get('user', None)
|
user = session.get('user', None)
|
||||||
|
|||||||
+14
-1
@@ -92,7 +92,9 @@
|
|||||||
<small class="form-text text-muted">When the anonymous repository.</small>
|
<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 %}" />
|
<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>
|
</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>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
@@ -246,6 +248,17 @@
|
|||||||
$('.main-options').show();
|
$('.main-options').show();
|
||||||
return false;
|
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=> {
|
$('#edit-button').on('click', e=> {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
$('.view').removeClass('active')
|
$('.view').removeClass('active')
|
||||||
|
|||||||
Reference in New Issue
Block a user