Compare commits
No commits in common. "875041fa71ce71614e45c5bb668bfecdbe837974" and "ec4a034581e6ec86eca60a27ae47c6c12a086b16" have entirely different histories.
875041fa71
...
ec4a034581
25
saddle.py
25
saddle.py
|
@ -41,12 +41,6 @@ async def index(request):
|
|||
files.append(handle_filefield(filefield, rand_name=rand_name))
|
||||
if data.get('url'):
|
||||
files.append(handle_url(data.get('url'), rand_name=rand_name))
|
||||
if data.get('text'):
|
||||
files.append(handle_text(
|
||||
data.get('text'),
|
||||
data.get('text_filename', ''),
|
||||
rand_name=rand_name)
|
||||
)
|
||||
|
||||
if data.get('delete_this'):
|
||||
delete_num = data.get('delete_num', '')
|
||||
|
@ -140,25 +134,6 @@ def handle_url(url, rand_name=True):
|
|||
return tup
|
||||
|
||||
|
||||
def handle_text(text, filename, rand_name=True):
|
||||
"""Handles a posted text field."""
|
||||
filename = safe_filename(filename)
|
||||
if not filename:
|
||||
rand_name = True
|
||||
prefix = get_rand_chars()
|
||||
if rand_name:
|
||||
filename = prefix + os.path.splitext(filename)[1]
|
||||
else:
|
||||
filename = prefix + '_' + filename
|
||||
filename = filename + '.txt'
|
||||
|
||||
with open(os.path.join(config.upload_dir, filename), 'w') as file:
|
||||
file.write(text)
|
||||
|
||||
tup = (prefix, filename)
|
||||
return tup
|
||||
|
||||
|
||||
def safe_filename(filename=''):
|
||||
"""Sanitizes the given filename."""
|
||||
safe_char = string.ascii_letters + string.digits + '._ '
|
||||
|
|
|
@ -82,7 +82,6 @@ section {
|
|||
color: black;
|
||||
border: 1px solid darkgray;
|
||||
border-bottom: none;
|
||||
box-shadow: 0 1px 0 gainsboro;
|
||||
}
|
||||
|
||||
.tabWindow {
|
||||
|
|
|
@ -11,12 +11,3 @@ function switchFileTab(span, window_id) {
|
|||
let tab_window = document.querySelector('#' + window_id);
|
||||
tab_window.classList.add('tabWindowSelected');
|
||||
}
|
||||
|
||||
function disable_text_filename(checkbox) {
|
||||
let input = document.querySelector('#text_filename');
|
||||
if (checkbox.checked) {
|
||||
input.disabled = true;
|
||||
} else {
|
||||
input.disabled = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,4 @@
|
|||
<object id="logo" title="Saddle Logo" data="/static/saddle.svg"></object>
|
||||
<h1>Saddle</h1>
|
||||
</div>
|
||||
<nav>
|
||||
<span><a href="{{ url('index') }}">Home</a></span>
|
||||
<span><a href="{{ url('gallery', user_id=request.cookies.get('userid')) }}">Gallery</a></span>
|
||||
</nav>
|
||||
<nav><span><a href="./gallery/{{ request.cookies.get('userid') }}">Gallery</a></span></nav>
|
||||
|
|
|
@ -27,12 +27,10 @@
|
|||
<input type="url" name="url" placeholder="URL"><br>
|
||||
</div>
|
||||
<div id="textTabWindow" class="tabWindow">
|
||||
<label for="text_filename">Filename:</label>
|
||||
<input type="text" name="text_filename" id="text_filename" required disabled><br>
|
||||
<textarea name="text"></textarea>
|
||||
Imagine actually using this feature.
|
||||
</div>
|
||||
</div>
|
||||
<input type="checkbox" name="rand_name" id="rand_name" onchange="disable_text_filename(this)" checked>
|
||||
<input type="checkbox" name="rand_name" id="rand_name" checked>
|
||||
<label for="rand_name">Generate random filename.</label><br>
|
||||
<input type="hidden" name="response_type" value="html">
|
||||
<input type="checkbox" name="delete_this" id="delete_this">
|
||||
|
|
Loading…
Reference in New Issue
Block a user