misc bugfixes

This commit is contained in:
Flummi 2022-05-18 03:43:17 +00:00
parent f57a8b4320
commit 97ef147160
5 changed files with 27 additions and 17 deletions

View File

@ -185,5 +185,15 @@ export default new class {
};
};
async getDefaultAvatar() {
return (await db`
select column_default as avatar
from "information_schema"."columns"
where
TABLE_SCHEMA='public' and
TABLE_NAME='user_options' and
COLUMN_NAME = 'avatar'
`)[0].avatar;
}
};

View File

@ -11,7 +11,7 @@ const auth = async (req, res, next) => {
export default (router, tpl) => {
router.get(/\/user\/(?<user>.*)/, async (req, res) => {
const user = req.params.user;
const user = decodeURIComponent(req.params.user);
const query = await db`
select "user".user, user_options.*
@ -118,15 +118,15 @@ export default (router, tpl) => {
router.get(/^\/ranking$/, async (req, res) => {
try {
const list = await db`
select
"user".user,
coalesce("user_options".avatar, 47319) as avatar,
count(distinct(tag_id, item_id)) as count
from "tags_assign"
left join "user" on "user".id = "tags_assign".user_id
left join "user_options" on "user_options".user_id = "user".id
group by "user".user, "user_options".avatar
order by count desc
select
"user".user,
coalesce("user_options".avatar, ${await lib.getDefaultAvatar()}) as avatar,
count(distinct(tag_id, item_id)) as count
from "tags_assign"
left join "user" on "user".id = "tags_assign".user_id
left join "user_options" on "user_options".user_id = "user".id
group by "user".user, "user_options".avatar
order by count desc
`;
const stats = await lib.countf0cks();

View File

@ -1,7 +1,7 @@
@include(snippets/header)
<div class="about">
<div>
<a href="/48908"><img src="/s/img/loool.webp" /></a>
<a href="//f0ck.me/48908"><img src="//f0ck.me/s/img/loool.webp" /></a>
<p>thanks to our turkish fellow lol@n0xy/#f0ck for this gif &lt;3</p>
</div>
<h5>f0ck Contact</h5>
@ -34,7 +34,7 @@
<li>admin@f0ck.me</li>
</ul>
<h5>Compatibility</h5>
<!--<p>f0ck is developed and tested for Firefox and Chromium in their latest versions</p>-->
<p>f0ck is developed and tested for Firefox and Chromium in their latest versions</p>
<p>If you encounter bugs please report them so we can fix them.</p>
<p>Microsoft Edgy is not actively supported, but if it werks, great! Same for anything apple related.</p>
<h5>Tinfoil f0ckers listen!</h5>

View File

@ -2,7 +2,7 @@
<div class="container">
<div class="err">
<span>{{ message }}</span>
<img src="https://f0ck.me/s/img/favicon.gif" alt="f0ck?!">
<img src="/s/img/favicon.gif" alt="f0ck?!">
</div>
</div>
@include(snippets/footer)

View File

@ -3,24 +3,24 @@
<h2>f0cks:</h2>
@if('items' in f0cks)
<a href="{{ f0cks.link.main }}">show all f0cks</a>
<div id="posts">
<div class="posts">
@each(f0cks.items as item)
<a href="{{ f0cks.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>
<a href="{{ f0cks.link.main }}">show all f0cks</a>
@else
no f0cks given
@endif
<h2>favs:</h2>
@if('items' in favs)
<a href="{{ favs.link.main }}">show all favs</a>
<div id="posts">
<div class="posts">
@each(favs.items as item)
<a href="{{ favs.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>
<a href="{{ favs.link.main }}">show all favs</a>
@else
no favorites
@endif