reddit/app/templates/admin.html

229 lines
6.7 KiB
HTML
Executable File

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Reddit, but better</title>
<style>
:root {
--dark: #2c2c2c;
--darker: #171717;
--light: #bfbfbf;
--confirm: #970000;
}
html {
height: 100%;
}
body {
background-color: var(--darker);
color: var(--light);
min-height: 100%;
margin: 0; /* Removes default browser margin */
}
img, video {
max-width: 100%;
width: auto;
height: auto;
}
div.post {
background-color: var(--dark);
border: 2px solid var(--light);
border-radius: 15px;
padding: 10px;
margin-bottom: 20px;
}
.sidebar {
outline: 2px solid var(--light);
position: sticky;
top: 0;
left: 0;
background-color: var(--dark);
display: flex;
flex-wrap: nowrap;
z-index: 1000;
}
.content {
display: flex;
flex-grow: 1; /* Takes up remaining space */
flex-direction: column;
}
/* desktop */
@media (min-aspect-ratio: 1) {
img, video {
max-height: 80vh;
}
div.post {
width: 70vw;
}
.container {
display: flex;
flex-direction: row;
}
.sidebar {
width: fit-content;
height: 100vh;
flex-direction: column;
overflow-y: auto;
padding: 5px;
margin-right: 20px;
}
}
/* phone */
@media (max-aspect-ratio: 1) {
img, video {
max-height: 100vh;
}
div.post {
width: calc(100vw - 50px);
margin-top: 10px;
}
.container {
display: flex;
flex-direction: column;
}
.sidebar {
width: 100vw;
height: 50px;
flex-direction: row;
overflow-x: auto;
align-items: center;
padding-top: 5px;
padding-bottom: 5px;
margin-bottom: 10px;
}
.content {
align-items: center;
}
}
.sidebar a {
display: block;
color: var(--light);
text-decoration: none;
white-space: nowrap;
margin: 5px;
padding: 5px;
}
.sidebar a:hover {
background-color: var(--darker);
color: var(--light);
}
.invert {
filter: invert(1);
transition: filter 0.3s;
}
.button-wrapper {
display: flex;
width: 100%;
gap: 10px;
margin-top: 10px;
}
.button-wrapper.gallery {
gap: 5px;
}
.button-wrapper button {
flex: 1;
padding: 10px;
cursor: pointer;
background-color: var(--darker);
color: var(--light);
border: 2px solid var(--light);
border-radius: 10px;
font-size: 1.25rem;
font-weight: bold;
}
.button-wrapper button.confirm {
background-color: var(--confirm)
}
.button-wrapper button.gallery {
padding: 5px;
background-color: var(--darker);
border-radius: 5px;
border: none;
cursor: none;
}
.button-wrapper button.gallery.selected {
background-color: var(--light);
}
.text-content {
overflow: hidden;
transition: max-height 0.3s ease-out; /* Smooth transition */
max-height: 20vh;
position: relative;
}
.text-content::after {
content: "";
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 30px;
background: linear-gradient(to bottom, rgba(255,255,255,0), var(--dark));
}
.text-content.expanded {
max-height: 1000vh;
}
.text-content.expanded::after {
display: none;
}
</style>
</head>
<body>
<div class="container">
<div class="sidebar">
{% for subreddit in post_subreddits %}
<a href="{{ subreddit }}">{{ subreddit }}</a>
{% endfor %}
</div>
<div class="content">
<h1>Admin Panel</h1>
<div class="post">
<h3>Subreddits</h3>
<table>
<tr>
<th>Subreddit</th>
<th>Minimum Score</th>
<th>Fetch by</th>
<th>Fetch max</th>
<th>Update</th>
</tr>
{% for subreddit in sub_subreddits %}
<tr>
<td>/r/{{ subreddit[0] }}</td>
<td>{{ subreddit[1] }}</td>
<td>{{ subreddit[2] }}</td>
<td>{{ subreddit[3] }}</td>
<td><button onclick='deleteSubreddit("{{ subreddit[0] }}")'>Delete</button></td>
</tr>
{% endfor %}
<tr></tr>
<tr></tr>
<tr>
<form method="post">
<td>/r/<input name="name" type="text"></td>
<td><input name="score" type="text" value="100"></td>
<td>
<select name="by">
<option value="day">Day</option>
<option value="week">Week</option>
</select>
</td>
<td><input name="max" type="text" value="100"></td>
<td><button type="submit">Add</button></td>
</form>
</tr>
</table>
</div>
</div>
</div>
<script>
function deleteSubreddit(name) {
fetch('/admin?name='+name, {
method: 'DELETE'
}).then(() => {
window.location.href = window.location.href;
});
}
</script>
</body>
</html>