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.tag) link.push("tag", env.tag);
|
||||||
if(env.user) link.push("user", env.user, env.type ?? 'f0cks');
|
if(env.user) link.push("user", env.user, env.type ?? 'f0cks');
|
||||||
if(env.mime.length > 2) link.push(env.mime);
|
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) {
|
parseTag(tag) {
|
||||||
if(!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++)
|
for(let i = Math.max(1, act_page - 3); i <= Math.min(act_page + 3, pages); i++)
|
||||||
cheat.push(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 = {
|
data = {
|
||||||
success: true,
|
success: true,
|
||||||
|
@ -172,11 +172,10 @@ export default {
|
||||||
prev: (act_page > 1) ? act_page - 1 : null,
|
prev: (act_page > 1) ? act_page - 1 : null,
|
||||||
next: (act_page < pages) ? act_page + 1 : null,
|
next: (act_page < pages) ? act_page + 1 : null,
|
||||||
page: act_page,
|
page: act_page,
|
||||||
cheat: cheat,
|
cheat: cheat
|
||||||
uff: false
|
|
||||||
},
|
},
|
||||||
link: link,
|
link,
|
||||||
tmp: tmp
|
tmp
|
||||||
};
|
};
|
||||||
return data;
|
return data;
|
||||||
},
|
},
|
||||||
|
@ -279,7 +278,7 @@ export default {
|
||||||
|
|
||||||
const tags = await lib.getTags(itemid);
|
const tags = await lib.getTags(itemid);
|
||||||
const cheat = [...new Set(items.slice(Math.max(0, item - 3), item + 4).map(i => i.id))];
|
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`
|
const favorites = await db`
|
||||||
select "user".user, "user_options".avatar
|
select "user".user, "user_options".avatar
|
||||||
from "favorites"
|
from "favorites"
|
||||||
|
@ -327,12 +326,11 @@ export default {
|
||||||
next: items[item + 1]?.id,
|
next: items[item + 1]?.id,
|
||||||
prev: items[item - 1]?.id,
|
prev: items[item - 1]?.id,
|
||||||
page: actitem.id,
|
page: actitem.id,
|
||||||
cheat: cheat,
|
cheat: cheat
|
||||||
uff: true
|
|
||||||
},
|
},
|
||||||
phrase: cfg.websrv.phrases[~~(Math.random() * cfg.websrv.phrases.length)],
|
phrase: cfg.websrv.phrases[~~(Math.random() * cfg.websrv.phrases.length)],
|
||||||
link: link,
|
link,
|
||||||
tmp: tmp
|
tmp
|
||||||
};
|
};
|
||||||
return data;
|
return data;
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
@include(snippets/header)
|
@include(snippets/header)
|
||||||
<div class="index-container">
|
<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.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">
|
<div id="posts">
|
||||||
@each(items as item)
|
@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
|
@endeach
|
||||||
</div>
|
</div>
|
||||||
<div id="footbar">
|
<div id="footbar">
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<div class="next-post">
|
<div class="next-post">
|
||||||
@if(pagination.prev)
|
@if(pagination.prev)
|
||||||
<div class="arrow-next">
|
<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>
|
</div>
|
||||||
@else
|
@else
|
||||||
<div class="arrow-next">
|
<div class="arrow-next">
|
||||||
|
@ -34,7 +34,7 @@
|
||||||
<div class="previous-post">
|
<div class="previous-post">
|
||||||
@if(pagination.next)
|
@if(pagination.next)
|
||||||
<div class="arrow-prev">
|
<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>
|
</div>
|
||||||
@else
|
@else
|
||||||
<div class="arrow-prev">
|
<div class="arrow-prev">
|
||||||
|
|
|
@ -64,17 +64,17 @@
|
||||||
<div class="pagination-wrapper">
|
<div class="pagination-wrapper">
|
||||||
@if(typeof pagination !== "undefined")
|
@if(typeof pagination !== "undefined")
|
||||||
<nav class="pagination">
|
<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.main }}{{ link.path }}{{ 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.prev }}" class="page-item-2 btn prev@if(!pagination.prev) disabled@endif">‹</a>
|
||||||
@each(pagination.cheat as i)
|
@each(pagination.cheat as i)
|
||||||
@if(i == pagination.page)
|
@if(i == pagination.page)
|
||||||
<span class="btn disabled">{{ i }}</span>
|
<span class="btn disabled">{{ i }}</span>
|
||||||
@else
|
@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
|
@endif
|
||||||
@endeach
|
@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.main }}{{ link.path }}{{ 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.end }}" class="page-item-4 btn start@if(!pagination.next) disabled@endif">»</a>
|
||||||
</nav>
|
</nav>
|
||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user