diff --git a/app/app.py b/app/app.py index dd6b9b8..b9a7f64 100755 --- a/app/app.py +++ b/app/app.py @@ -175,7 +175,7 @@ def front_page(): hidden = ? AND saved = ? ORDER BY - score desc + created_utc asc LIMIT ? """ binds = [False, False, config.posts_per_page_load] @@ -217,7 +217,7 @@ def other_page(): count <= ? ) ORDER BY - score desc + created_utc asc LIMIT ? """ binds = [False, False, False, config.other_posts_cutoff, config.posts_per_page_load] @@ -264,7 +264,7 @@ def get_subreddit(subreddit): hidden = ? AND saved = ? ORDER BY - score desc + created_utc asc LIMIT ? """ binds = [subreddit, False, False, config.posts_per_page_load] diff --git a/app/config.py b/app/config.py index 5572aac..dc228a0 100644 --- a/app/config.py +++ b/app/config.py @@ -4,7 +4,7 @@ max_age_seconds = max_age_days * 24 * 60 * 60 other_posts_cutoff = 4 #subreddits with this many unread posts or fewer are merged to /r/other # Webpage configuration -posts_per_page_load = 25 +posts_per_page_load = 10 db_dir = "/reddit/db" media_dir = "/reddit/media" diff --git a/app/templates/index.html b/app/templates/index.html index f8e8cee..b37ec6c 100755 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -1,188 +1,222 @@ + - - - Reddit, but better - + + .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.saved { + background-color: var(--saved) + } + + .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; + } + + -
- -
-

{{ title }}

- {% for post in posts %} -
-

{{ post.title }}

+
+ +
+

{{ title }}

+ {% for post in posts %} +
+

{{ post.title }}

{% if post.subreddit %}
@@ -196,219 +230,230 @@
{% endif %}
- {% if post.media_html|length > 0 %} -
- {% for media in post.media_html %} - {{ media|safe }} - {% endfor %} - {% if post.media_html|length > 1 %} - - - {% endif %} -
- {% endif %} - {% if post.body %} -
- {{ post.body }} -
- {% endif %} - - - - - -
- {% endfor %} -
-
- + window.addEventListener('load', (event) => { + checkHeight() + }); + + window.addEventListener('resize', (event) => { + checkHeight() + }); + + // audio/video sync code + function pauseVideo(element) { + div = element.closest('.post'); + video = div.querySelector('video:first-of-type'); + if (video) { + video.pause(); + pauseAudio(video); + } + } + + function findAudio(video) { + div = video.closest('.post'); + return div.querySelector('audio:first-of-type'); + } + + function playAudio(video) { + audio = findAudio(video); + if (audio) { + audio.play(); + audio.currentTime = video.currentTime; + } + } + function pauseAudio(video) { + audio = findAudio(video); + if (audio) { + audio.pause(); + audio.currentTime = video.currentTime; + } + } + function seekAudio(video) { + audio = findAudio(video); + if (audio) { + audio.currentTime = video.currentTime; + } + } + + function checkPostCount() { + posts = document.querySelectorAll('.post').length; + if (posts == 0) { + setTimeout(() => {window.location.href = window.location.href;}, 1000); + } + } + - + + \ No newline at end of file