forked from rDrama/rDrama
1
0
Fork 0

use permalinks for instant visit marker

master
Aevann 2024-01-14 17:53:41 +02:00
parent 23bfbc5de0
commit 5455ec6a7d
3 changed files with 68 additions and 63 deletions

View File

@ -47,7 +47,9 @@ if (fake_textarea) {
if (screen_width < 768) {
const post_ids = localStorage.getItem("post_ids").split(', ');
const current_index = post_ids.indexOf(pid)
const permalink = document.getElementById("permalink").value
const current_index = post_ids.indexOf(`'${permalink}'`)
if (current_index > -1) {
const id_after = post_ids[current_index+1]
const id_before = post_ids[current_index-1]
@ -75,10 +77,10 @@ if (screen_width < 768) {
if (!getSelection().toString() && (f > 0.04 || f < -0.04) && (fy < 0.02 && fy > -0.02)) {
if (id_before && f > 0.2) {
location.href = `/post/${id_before}`
location.href = id_before.slice(1, -1)
}
if (id_after && f < -0.2) {
location.href = `/post/${id_after}`
location.href = id_after.slice(1, -1)
}
}
}
@ -125,3 +127,4 @@ if (screen_width < 768) {
_C.addEventListener('mouseup', move, false);
_C.addEventListener('touchend', move, false);
}
}

View File

@ -80,7 +80,7 @@ def front_all(v, hole=None):
if v and v.client: return {"data": [x.json for x in posts], "total": total}
result = render_template("home.html", v=v, listing=posts, total=total, sort=sort, t=t, page=page, hole=hole, home=True, pins=pins, size=size, post_ids=ids)
result = render_template("home.html", v=v, listing=posts, total=total, sort=sort, t=t, page=page, hole=hole, home=True, pins=pins, size=size, post_ids=[p.permalink for p in posts])
if not v:
cache.set(f'frontpage_{sort}_{t}_{page}_{hole}_{pins}', result, timeout=900)

View File

@ -347,6 +347,8 @@
<input hidden class="twoattrs" value="{{p.id}},{{p.comment_count}}">
<script defer src="{{'js/new_comments.js' | asset}}"></script>
<input hidden id="permalink" value="{{p.permalink}}">
<script defer src="{{'js/post.js' | asset}}"></script>
{% if fart and not (v and v.has_badge(128)) %}