fucking pagination
This commit is contained in:
parent
7b2ad52fe0
commit
2162f1565c
@ -64,8 +64,17 @@ export default new class {
|
||||
if(env.tag) link.push("tag", env.tag);
|
||||
if(env.user) link.push("user", env.user, env.type ?? 'f0cks');
|
||||
if(env.mime.length > 2) link.push(env.mime);
|
||||
if(env.page) link.push("p", env.page);
|
||||
return link.join("/");
|
||||
|
||||
let tmp = link.length === 0 ? '/' : link.join('/');
|
||||
if(!tmp.endsWith('/'))
|
||||
tmp = tmp + '/';
|
||||
if(!tmp.startsWith('/'))
|
||||
tmp = '/' + tmp;
|
||||
|
||||
return {
|
||||
main: tmp,
|
||||
path: env.path ? env.path : ''
|
||||
};
|
||||
};
|
||||
parseTag(tag) {
|
||||
if(!tag)
|
||||
|
@ -161,7 +161,7 @@ export default {
|
||||
for(let i = Math.max(1, act_page - 3); i <= Math.min(act_page + 3, pages); i++)
|
||||
cheat.push(i);
|
||||
|
||||
const link = lib.genLink({ user, tag, mime, type: o.fav ? 'favs' : 'f0cks' });
|
||||
const link = lib.genLink({ user, tag, mime, type: o.fav ? 'favs' : 'f0cks', path: 'p/' });
|
||||
|
||||
data = {
|
||||
success: true,
|
||||
@ -172,11 +172,10 @@ export default {
|
||||
prev: (act_page > 1) ? act_page - 1 : null,
|
||||
next: (act_page < pages) ? act_page + 1 : null,
|
||||
page: act_page,
|
||||
cheat: cheat,
|
||||
uff: false
|
||||
cheat: cheat
|
||||
},
|
||||
link: link,
|
||||
tmp: tmp
|
||||
link,
|
||||
tmp
|
||||
};
|
||||
return data;
|
||||
},
|
||||
@ -279,7 +278,7 @@ export default {
|
||||
|
||||
const tags = await lib.getTags(itemid);
|
||||
const cheat = [...new Set(items.slice(Math.max(0, item - 3), item + 4).map(i => i.id))];
|
||||
const link = lib.genLink({ user, tag, mime, type: o.fav ? 'favs' : 'f0cks' });
|
||||
const link = lib.genLink({ user, tag, mime, type: o.fav ? 'favs' : 'f0cks', path: '' });
|
||||
const favorites = await db`
|
||||
select "user".user, "user_options".avatar
|
||||
from "favorites"
|
||||
@ -327,12 +326,11 @@ export default {
|
||||
next: items[item + 1]?.id,
|
||||
prev: items[item - 1]?.id,
|
||||
page: actitem.id,
|
||||
cheat: cheat,
|
||||
uff: true
|
||||
cheat: cheat
|
||||
},
|
||||
phrase: cfg.websrv.phrases[~~(Math.random() * cfg.websrv.phrases.length)],
|
||||
link: link,
|
||||
tmp: tmp
|
||||
link,
|
||||
tmp
|
||||
};
|
||||
return data;
|
||||
},
|
||||
|
@ -1,10 +1,10 @@
|
||||
@include(snippets/header)
|
||||
<div class="index-container">
|
||||
@if(tmp.user)<h2>user: {!! tmp.user.toLowerCase() !!}@if(tmp.mime) ({{ tmp.mime }}s)@else (all)@endif</h2>@endif
|
||||
@if(tmp.tag)<h2>tag: @if(session)<a href="/admin/test?tag={!! tmp.tag.toLowerCase() !!}" target="_blank">{!! tmp.tag.toLowerCase() !!}</a>@else{!! tmp.tag.toLowerCase() !!}@endif@if(tmp.mime) ({{ tmp.mime }}s)@else (all)@endif</h2>@endif
|
||||
@if(tmp.tag)<h2>tag: @if(session)<a href="/search?tag={!! tmp.tag.toLowerCase() !!}" target="_blank">{!! tmp.tag.toLowerCase() !!}</a>@else{!! tmp.tag.toLowerCase() !!}@endif@if(tmp.mime) ({{ tmp.mime }}s)@else (all)@endif</h2>@endif
|
||||
<div id="posts">
|
||||
@each(items as item)
|
||||
<a href="/{{ link }}@if(link.length != 0)/@endif{{ item.id }}" data-mime="{{ item.mime }}" data-mode="{{ item.tag_id ? ['','sfw','nsfw'][item.tag_id] : 'null' }}" style="background-image: url('/t/{{ item.id }}.webp')"><p></p></a>
|
||||
<a href="{{ link.main }}{{ item.id }}" data-mime="{{ item.mime }}" data-mode="{{ item.tag_id ? ['','sfw','nsfw'][item.tag_id] : 'null' }}" style="background-image: url('/t/{{ item.id }}.webp')"><p></p></a>
|
||||
@endeach
|
||||
</div>
|
||||
<div id="footbar">
|
||||
|
@ -4,7 +4,7 @@
|
||||
<div class="next-post">
|
||||
@if(pagination.prev)
|
||||
<div class="arrow-next">
|
||||
<a id="next" href="/{{ link }}@if(link.length != 0)/@endif{{ pagination.prev }}"></a>
|
||||
<a id="next" href="{{ link.main }}{{ pagination.prev }}"></a>
|
||||
</div>
|
||||
@else
|
||||
<div class="arrow-next">
|
||||
@ -34,7 +34,7 @@
|
||||
<div class="previous-post">
|
||||
@if(pagination.next)
|
||||
<div class="arrow-prev">
|
||||
<a id="prev" href="/{{ link }}@if(link.length != 0)/@endif{{ pagination.next }}"></a>
|
||||
<a id="prev" href="{{ link.main }}{{ pagination.next }}"></a>
|
||||
</div>
|
||||
@else
|
||||
<div class="arrow-prev">
|
||||
|
@ -64,17 +64,17 @@
|
||||
<div class="pagination-wrapper">
|
||||
@if(typeof pagination !== "undefined")
|
||||
<nav class="pagination">
|
||||
<a href="/{{ link }}@if(link.length != 0)/@endif@if(!pagination.uff)p/@endif{{ pagination.start }}" class="page-item-1 btn start@if(!pagination.prev) disabled@endif">«</a>
|
||||
<a href="/{{ link }}@if(link.length != 0)/@endif@if(!pagination.uff)p/@endif{{ pagination.prev }}" class="page-item-2 btn prev@if(!pagination.prev) disabled@endif">‹</a>
|
||||
<a href="{{ link.main }}{{ link.path }}{{ pagination.start }}" class="page-item-1 btn start@if(!pagination.prev) disabled@endif">«</a>
|
||||
<a href="{{ link.main }}{{ link.path }}{{ pagination.prev }}" class="page-item-2 btn prev@if(!pagination.prev) disabled@endif">‹</a>
|
||||
@each(pagination.cheat as i)
|
||||
@if(i == pagination.page)
|
||||
<span class="btn disabled">{{ i }}</span>
|
||||
@else
|
||||
<a href="/{{ link }}@if(link.length != 0)/@endif@if(!pagination.uff)p/@endif{{ i }}" class="pagination-int-item btn">{{ i }}</a>
|
||||
<a href="{{ link.main }}{{ link.path }}{{ i }}" class="pagination-int-item btn">{{ i }}</a>
|
||||
@endif
|
||||
@endeach
|
||||
<a href="/{{ link }}@if(link.length != 0)/@endif@if(!pagination.uff)p/@endif{{ pagination.next }}" class="page-item-3 btn next@if(!pagination.next) disabled@endif">›</a>
|
||||
<a href="/{{ link }}@if(link.length != 0)/@endif@if(!pagination.uff)p/@endif{{ pagination.end }}" class="page-item-4 btn start@if(!pagination.next) disabled@endif">»</a>
|
||||
<a href="{{ link.main }}{{ link.path }}{{ pagination.next }}" class="page-item-3 btn next@if(!pagination.next) disabled@endif">›</a>
|
||||
<a href="{{ link.main }}{{ link.path }}{{ pagination.end }}" class="page-item-4 btn start@if(!pagination.next) disabled@endif">»</a>
|
||||
</nav>
|
||||
@endif
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user