2024-09-10 16:00:43 +02:00
<!DOCTYPE html>
< html lang = "en" >
< head >
< meta charset = "UTF-8" >
< meta name = "viewport" content = "width=device-width, initial-scale=1.0" >
< title > {{ username }}'s Dashboard< / title >
< style >
body {
font-family: Arial, sans-serif;
line-height: 1.6;
margin: 0;
padding: 20px;
background-color: #1a1a1a;
color: #f0f0f0;
display: flex;
justify-content: center;
}
.container {
max-width: 800px;
width: 100%;
}
h2, h3 {
color: #4CAF50;
text-align: center;
}
nav {
margin-bottom: 20px;
text-align: center;
}
nav a, .btn {
display: inline-block;
background-color: #4CAF50;
color: white;
padding: 8px 12px;
text-decoration: none;
border-radius: 4px;
margin: 0 5px;
border: none;
cursor: pointer;
font-size: 14px;
}
nav a:hover, .btn:hover {
background-color: #45a049;
}
form {
margin-bottom: 20px;
text-align: center;
}
input[type="text"], input[type="file"] {
padding: 8px;
margin-right: 10px;
border-radius: 4px;
border: 1px solid #4CAF50;
background-color: #333;
color: #f0f0f0;
}
.file-list {
list-style-type: none;
padding: 0;
}
.file-item {
background-color: #2a2a2a;
padding: 10px;
border-radius: 5px;
margin-bottom: 5px;
display: flex;
align-items: center;
justify-content: space-between;
}
.file-icon {
margin-right: 10px;
}
.file-name {
flex-grow: 1;
}
.file-actions {
display: flex;
gap: 5px;
}
.folder {
font-weight: bold;
}
2024-09-10 19:41:49 +02:00
.upload-list {
margin-top: 20px;
}
.upload-item {
margin-bottom: 10px;
}
.tabs {
display: flex;
justify-content: center;
margin-bottom: 20px;
}
.tab {
background-color: #333;
color: #f0f0f0;
padding: 10px 20px;
cursor: pointer;
border: none;
}
.tab.active {
background-color: #4CAF50;
}
.tab-content {
display: none;
}
.tab-content.active {
display: block;
}
2024-09-11 19:29:29 +02:00
.modal {
display: none;
position: fixed;
z-index: 1000;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: rgba(0,0,0,0.5);
}
.modal-content {
background-color: #2a2a2a;
margin: 15% auto;
padding: 20px;
border-radius: 8px;
width: 300px;
box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}
.modal-input {
width: 100%;
padding: 8px;
margin: 10px 0;
border-radius: 4px;
border: 1px solid #4CAF50;
background-color: #333;
color: #f0f0f0;
}
.modal-buttons {
display: flex;
justify-content: flex-end;
gap: 10px;
margin-top: 15px;
}
.action-buttons {
display: flex;
justify-content: center;
gap: 10px;
margin: 20px 0;
}
.file-list {
border-radius: 8px;
overflow: hidden;
}
.file-item {
border-radius: 0;
margin-bottom: 0;
border-bottom: 1px solid #3a3a3a;
}
.file-item:last-child {
border-bottom: none;
}
.file-actions .btn {
padding: 4px 8px;
font-size: 12px;
}
2024-09-10 16:00:43 +02:00
< / style >
< / head >
< body >
< div class = "container" >
< h2 > {{ username }}'s Dashboard< / h2 >
< nav >
< a href = "{{ url_for('index') }}" > Home< / a >
< a href = "{{ url_for('logout') }}" > Logout< / a >
< / nav >
2024-09-10 19:41:49 +02:00
< div style = "text-align: center; margin-top: 10px;" >
< a href = "{{ url_for('serve_user_page', username=username) }}" class = "btn" > Visit my site< / a >
< / div >
2024-09-10 16:00:43 +02:00
2024-09-10 19:41:49 +02:00
< div class = "tabs" >
< button class = "tab active" onclick = "openTab(event, 'filesAndFolders')" > Files and Folders< / button >
< button class = "tab" onclick = "openTab(event, 'myUploads')" > My Uploads< / button >
< button class = "tab" onclick = "openTab(event, 'shareXConfig')" > ShareX Config< / button >
< / div >
2024-09-10 16:00:43 +02:00
2024-09-10 19:41:49 +02:00
< div id = "filesAndFolders" class = "tab-content active" >
< form id = "toggleIndexForm" style = "text-align: center;" >
< label >
< input type = "checkbox" id = "ignoreIndexCheckbox" { % if ignore_index % } checked { % endif % } >
Ignore index.html and always show file listing
< / label >
< / form >
2024-09-10 16:00:43 +02:00
2024-09-10 19:41:49 +02:00
{% if index_exists and not ignore_index %}
< p style = "text-align: center;" > An index.html file exists in this folder. When viewing publicly, this file will be displayed instead of the file listing.< / p >
{% endif %}
2024-09-10 16:00:43 +02:00
2024-09-10 19:41:49 +02:00
< h3 > Upload File< / h3 >
< form action = "{{ url_for('upload_user_file', username=username) }}" method = "post" enctype = "multipart/form-data" >
< input type = "hidden" name = "subpath" value = "{{ current_path }}" >
< input type = "file" name = "file" required >
< input type = "submit" value = "Upload" class = "btn" >
< / form >
2024-09-10 16:00:43 +02:00
2024-09-11 19:29:29 +02:00
< div class = "action-buttons" >
< button onclick = "showModal('createFolder')" class = "btn" > Create Folder< / button >
< button onclick = "showModal('createFile')" class = "btn" > Create File< / button >
< / div >
2024-09-10 16:00:43 +02:00
2024-09-10 19:41:49 +02:00
< h3 > Files and Folders< / h3 >
< p style = "text-align: center;" > Current folder: {{ current_folder or 'Root' }}< / p >
< ul class = "file-list" >
{% if parent_folder is not none %}
< li class = "file-item folder" >
< span class = "file-icon" > 📁< / span >
< span class = "file-name" >
< a href = "{{ url_for('user_files', username=username, subpath=parent_folder) }}" > ..< / a >
< / span >
< / li >
{% endif %}
{% for item in items %}
< li class = "file-item {% if item.type == 'folder' %}folder{% endif %}" >
< span class = "file-icon" > {% if item.type == 'folder' %}📁{% else %}📄{% endif %}< / span >
< span class = "file-name" >
{% if item.type == 'folder' %}
< a href = "{{ url_for('user_files', username=username, subpath=item.path) }}" > {{ item.name }}< / a >
{% else %}
{{ item.name }}
{% endif %}
< / span >
< div class = "file-actions" >
2024-09-11 19:29:29 +02:00
< button onclick = "showModal('rename', '{{ item.name }}', '{{ item.type }}')" class = "btn" > Rename< / button >
< button onclick = "showModal('move', '{{ item.name }}', '{{ item.type }}')" class = "btn" > Move< / button >
< button onclick = "showModal('copy', '{{ item.name }}', '{{ item.type }}')" class = "btn" > Copy< / button >
2024-09-10 19:41:49 +02:00
< button onclick = "deleteItem('{{ item.name }}', '{{ item.type }}')" class = "btn" > Delete< / button >
{% if item.type == 'file' %}
< a href = "{{ url_for('edit_file', username=username, filename=item.path) }}" class = "btn" > Edit< / a >
{% endif %}
< / div >
< / li >
{% endfor %}
< / ul >
< / div >
< div id = "myUploads" class = "tab-content" >
< h3 > Your Uploads< / h3 >
< div class = "upload-list" >
{% for upload in uploads %}
< div class = "upload-item" >
{% if upload.type == 'pastebin' %}
Pastebin:
{% elif upload.type == 'file' %}
File:
{% elif upload.type == 'url' %}
Shortened URL:
{% endif %}
< a href = "{{ url_for('redirect_vanity', vanity=upload.vanity) }}" target = "_blank" >
{% if upload.type == 'file' %}
{{ upload.data }}
{% else %}
{{ upload.vanity }}
{% endif %}
< / a >
(Created: {{ upload.created_at }})
< a href = "{{ url_for('content_info', vanity=upload.vanity) }}" class = "btn" > Info< / a >
{% if upload.type == 'url' %}
< button onclick = "editUrl('{{ upload.vanity }}', '{{ upload.data }}')" class = "btn" > Edit< / button >
{% else %}
< a href = "{{ url_for('edit_content', vanity=upload.vanity) }}" class = "btn" > Edit< / a >
{% endif %}
< button onclick = "deleteUpload('{{ upload.vanity }}')" class = "btn" > Delete< / button >
< / div >
{% endfor %}
< / div >
< / div >
< div id = "shareXConfig" class = "tab-content" >
< h3 > ShareX Configuration< / h3 >
< p > Click the button below to download your ShareX configuration file:< / p >
< a href = "{{ url_for('generate_sharex_config') }}" class = "btn" download = "aCloud_ShareX.sxcu" > Download ShareX Config< / a >
< / div >
2024-09-10 16:00:43 +02:00
< / div >
2024-09-11 19:29:29 +02:00
< div id = "customModal" class = "modal" >
< div class = "modal-content" >
< h3 id = "modalTitle" > < / h3 >
< input type = "text" id = "modalInput" class = "modal-input" >
< div class = "modal-buttons" >
< button onclick = "closeModal()" class = "btn" style = "background-color: #888;" > Cancel< / button >
< button onclick = "handleModalAction()" class = "btn" style = "background-color: #4CAF50;" > Confirm< / button >
< / div >
< / div >
< / div >
< div id = "folderNavigationModal" class = "modal" >
< div class = "modal-content" style = "width: 80%; max-width: 600px;" >
< h3 id = "folderNavigationTitle" > < / h3 >
< div id = "currentPath" style = "margin-bottom: 10px;" > < / div >
< div id = "folderList" style = "max-height: 300px; overflow-y: auto; margin-bottom: 10px;" > < / div >
< div style = "display: flex; justify-content: space-between; align-items: center;" >
< button onclick = "showNewFolderInput()" class = "btn" style = "background-color: #4CAF50;" > New Folder< / button >
< / div >
< div id = "newFolderInputContainer" style = "display: none; margin-top: 10px;" >
< input type = "text" id = "newFolderInput" placeholder = "Enter new folder name" style = "width: 70%;" >
< button onclick = "createNewFolder()" class = "btn" style = "background-color: #4CAF50;" > Create< / button >
< / div >
< div class = "modal-buttons" >
< button onclick = "closeFolderNavigation()" class = "btn" style = "background-color: #888;" > Cancel< / button >
< button onclick = "confirmFolderNavigation()" class = "btn" style = "background-color: #4CAF50;" > OK< / button >
< / div >
< / div >
< / div >
2024-09-10 16:00:43 +02:00
< script >
2024-09-10 19:41:49 +02:00
function openTab(evt, tabName) {
var i, tabcontent, tablinks;
tabcontent = document.getElementsByClassName("tab-content");
for (i = 0; i < tabcontent.length ; i + + ) {
tabcontent[i].style.display = "none";
}
tablinks = document.getElementsByClassName("tab");
for (i = 0; i < tablinks.length ; i + + ) {
tablinks[i].className = tablinks[i].className.replace(" active", "");
}
document.getElementById(tabName).style.display = "block";
evt.currentTarget.className += " active";
}
2024-09-10 16:00:43 +02:00
function deleteItem(name, type) {
if (confirm(`Are you sure you want to delete this ${type}?`)) {
const form = document.createElement('form');
form.method = 'POST';
form.action = "{{ url_for('delete_user_file', username=username, filename='') }}" + name;
document.body.appendChild(form);
form.submit();
}
}
2024-09-10 19:41:49 +02:00
function deleteUpload(vanity) {
if (confirm('Are you sure you want to delete this upload?')) {
fetch("{{ url_for('delete_content', vanity='') }}" + vanity, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({})
})
.then(response => response.json())
.then(data => {
if (data.success) {
location.reload();
} else {
alert('Error deleting upload: ' + data.error);
}
})
.catch(error => {
console.error('Error:', error);
alert('An error occurred while deleting the upload');
});
}
}
2024-09-11 19:29:29 +02:00
function showModal(action, name = '', type = '') {
if (action === 'move' || action === 'copy') {
showFolderNavigation(action, name, type);
} else {
const modal = document.getElementById('customModal');
const title = document.getElementById('modalTitle');
const input = document.getElementById('modalInput');
switch (action) {
case 'createFolder':
title.textContent = 'Create New Folder';
input.placeholder = 'Enter folder name';
break;
case 'createFile':
title.textContent = 'Create New File';
input.placeholder = 'Enter file name (with or without extension)';
break;
case 'rename':
title.textContent = `Rename ${type}`;
input.value = name;
break;
}
modal.style.display = 'block';
input.focus();
window.currentAction = { action, name, type };
2024-09-10 16:00:43 +02:00
}
}
2024-09-11 19:29:29 +02:00
function closeModal() {
const modal = document.getElementById('customModal');
modal.style.display = 'none';
2024-09-10 16:00:43 +02:00
}
2024-09-11 19:29:29 +02:00
function handleModalAction() {
const input = document.getElementById('modalInput');
const value = input.value.trim();
if (!value) {
alert('Please enter a valid value');
return;
}
switch (window.currentAction.action) {
case 'createFolder':
createFolder(value);
break;
case 'createFile':
createFile(value);
break;
case 'rename':
renameItem(window.currentAction.name, window.currentAction.type, value);
break;
2024-09-10 16:00:43 +02:00
}
2024-09-11 19:29:29 +02:00
closeModal();
}
function createFolder(name) {
const form = document.createElement('form');
form.method = 'POST';
form.action = "{{ url_for('create_folder', username=username) }}";
const input = document.createElement('input');
input.type = 'hidden';
input.name = 'folder_name';
input.value = name;
form.appendChild(input);
document.body.appendChild(form);
form.submit();
}
function createFile(name) {
const form = document.createElement('form');
form.method = 'POST';
form.action = "{{ url_for('create_new_file', username=username) }}";
const input = document.createElement('input');
input.type = 'hidden';
input.name = 'file_name';
input.value = name;
form.appendChild(input);
document.body.appendChild(form);
form.submit();
}
function renameItem(oldName, type, newName) {
const form = document.createElement('form');
form.method = 'POST';
form.action = "{{ url_for('rename_user_file', username=username, subpath=current_path) }}";
const oldInput = document.createElement('input');
oldInput.type = 'hidden';
oldInput.name = 'old_filename';
oldInput.value = oldName;
const newInput = document.createElement('input');
newInput.type = 'hidden';
newInput.name = 'new_filename';
newInput.value = newName;
form.appendChild(oldInput);
form.appendChild(newInput);
document.body.appendChild(form);
form.submit();
2024-09-10 16:00:43 +02:00
}
2024-09-10 19:41:49 +02:00
function editUrl(vanity, currentUrl) {
const newUrl = prompt("Enter the new URL:", currentUrl);
if (newUrl & & newUrl !== currentUrl) {
fetch('/edit/content/' + vanity, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ content: newUrl }),
})
.then(response => response.json())
.then(data => {
if (data.success) {
alert('URL updated successfully');
location.reload();
} else {
alert('Error updating URL: ' + data.error);
}
})
.catch(error => {
console.error('Error:', error);
alert('An error occurred while updating the URL');
});
}
}
document.getElementById('ignoreIndexCheckbox').addEventListener('change', function() {
fetch("{{ url_for('toggle_index', username=username) }}", {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Requested-With': 'XMLHttpRequest'
},
body: JSON.stringify({})
})
.then(response => response.json())
.then(data => {
if (data.success) {
// Update the checkbox state based on the server response
this.checked = data.ignore_index;
// Reload the page to reflect the changes
location.reload();
} else {
alert('Error toggling index.html ignore setting: ' + data.error);
// Revert the checkbox state if there was an error
this.checked = !this.checked;
}
})
.catch(error => {
console.error('Error:', error);
alert('An error occurred while toggling the index.html ignore setting');
// Revert the checkbox state if there was an error
this.checked = !this.checked;
});
});
2024-09-11 19:29:29 +02:00
let currentFolderPath = '';
let actionType = '';
let itemToMove = '';
function showFolderNavigation(action, itemName, itemType) {
actionType = action;
itemToMove = itemName;
currentFolderPath = '{{ current_path }}';
const modal = document.getElementById('folderNavigationModal');
const title = document.getElementById('folderNavigationTitle');
title.textContent = `${action} ${itemType}: ${itemName}`;
modal.style.display = 'block';
updateFolderNavigation();
}
function updateFolderNavigation() {
const currentPathElement = document.getElementById('currentPath');
currentPathElement.textContent = `Current path: ${currentFolderPath || '/'}`;
const folderList = document.getElementById('folderList');
folderList.innerHTML = '';
if (currentFolderPath) {
const parentFolder = document.createElement('div');
parentFolder.innerHTML = '< span style = "margin-right: 5px;" > 📁< / span > ..';
parentFolder.style.cursor = 'pointer';
parentFolder.onclick = () => {
currentFolderPath = currentFolderPath.split('/').slice(0, -1).join('/');
updateFolderNavigation();
};
folderList.appendChild(parentFolder);
}
// Fetch and display folders and files
fetch(`{{ url_for('get_folders_and_files', username=username) }}?path=${currentFolderPath}`)
.then(response => response.json())
.then(data => {
data.folders.forEach(folder => {
const folderElement = document.createElement('div');
folderElement.innerHTML = `< span style = "margin-right: 5px;" > 📁< / span > ${folder}`;
folderElement.style.cursor = 'pointer';
folderElement.onclick = () => {
currentFolderPath = currentFolderPath ? `${currentFolderPath}/${folder}` : folder;
updateFolderNavigation();
};
folderList.appendChild(folderElement);
});
data.files.forEach(file => {
const fileElement = document.createElement('div');
fileElement.innerHTML = `< span style = "margin-right: 5px;" > 📄< / span > ${file}`;
folderList.appendChild(fileElement);
});
});
}
function showNewFolderInput() {
document.getElementById('newFolderInputContainer').style.display = 'block';
document.getElementById('newFolderInput').focus();
}
function createNewFolder() {
const newFolderName = document.getElementById('newFolderInput').value.trim();
if (newFolderName) {
fetch("{{ url_for('create_folder', username=username) }}", {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
folder_name: newFolderName,
subpath: currentFolderPath
}),
})
.then(response => response.json())
.then(data => {
if (data.success) {
document.getElementById('newFolderInput').value = '';
document.getElementById('newFolderInputContainer').style.display = 'none';
updateFolderNavigation();
} else {
alert('Error creating folder: ' + data.error);
}
})
.catch(error => {
console.error('Error:', error);
alert('An error occurred while creating the folder');
});
}
}
function closeFolderNavigation() {
document.getElementById('folderNavigationModal').style.display = 'none';
}
function confirmFolderNavigation() {
if (actionType === 'move') {
moveItem(itemToMove, 'file', currentFolderPath);
} else if (actionType === 'copy') {
copyItem(itemToMove, 'file', currentFolderPath);
}
closeFolderNavigation();
}
function moveItem(name, type, destination) {
const form = document.createElement('form');
form.method = 'POST';
form.action = "{{ url_for('move_item', username=username, subpath=current_path) }}";
const nameInput = document.createElement('input');
nameInput.type = 'hidden';
nameInput.name = 'item_name';
nameInput.value = name;
const typeInput = document.createElement('input');
typeInput.type = 'hidden';
typeInput.name = 'item_type';
typeInput.value = type;
const destInput = document.createElement('input');
destInput.type = 'hidden';
destInput.name = 'destination_folder';
destInput.value = destination;
form.appendChild(nameInput);
form.appendChild(typeInput);
form.appendChild(destInput);
document.body.appendChild(form);
form.submit();
}
function copyItem(name, type, destination) {
const form = document.createElement('form');
form.method = 'POST';
form.action = "{{ url_for('copy_item', username=username, subpath=current_path) }}";
const nameInput = document.createElement('input');
nameInput.type = 'hidden';
nameInput.name = 'item_name';
nameInput.value = name;
const typeInput = document.createElement('input');
typeInput.type = 'hidden';
typeInput.name = 'item_type';
typeInput.value = type;
const destInput = document.createElement('input');
destInput.type = 'hidden';
destInput.name = 'destination_folder';
destInput.value = destination;
form.appendChild(nameInput);
form.appendChild(typeInput);
form.appendChild(destInput);
document.body.appendChild(form);
form.submit();
}
2024-09-10 16:00:43 +02:00
< / script >
< / body >
< / html >