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

View File

@ -1,7 +1,7 @@
@include(snippets/header) @include(snippets/header)
<div class="about"> <div class="about">
<div> <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> <p>thanks to our turkish fellow lol@n0xy/#f0ck for this gif &lt;3</p>
</div> </div>
<h5>f0ck Contact</h5> <h5>f0ck Contact</h5>
@ -34,7 +34,7 @@
<li>admin@f0ck.me</li> <li>admin@f0ck.me</li>
</ul> </ul>
<h5>Compatibility</h5> <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>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> <p>Microsoft Edgy is not actively supported, but if it werks, great! Same for anything apple related.</p>
<h5>Tinfoil f0ckers listen!</h5> <h5>Tinfoil f0ckers listen!</h5>

View File

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

View File

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