diff --git a/src/inc/lib.mjs b/src/inc/lib.mjs index bee99a6..d320541 100644 --- a/src/inc/lib.mjs +++ b/src/inc/lib.mjs @@ -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; + } }; diff --git a/src/inc/routes/index.mjs b/src/inc/routes/index.mjs index 3be1caa..324f32f 100644 --- a/src/inc/routes/index.mjs +++ b/src/inc/routes/index.mjs @@ -11,7 +11,7 @@ const auth = async (req, res, next) => { export default (router, tpl) => { router.get(/\/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(); diff --git a/views/about.html b/views/about.html index 9d4ab94..6910eab 100644 --- a/views/about.html +++ b/views/about.html @@ -1,7 +1,7 @@ @include(snippets/header)
- +

thanks to our turkish fellow lol@n0xy/#f0ck for this gif <3

f0ck Contact
@@ -34,7 +34,7 @@
  • admin@f0ck.me
  • Compatibility
    - +

    f0ck is developed and tested for Firefox and Chromium in their latest versions

    If you encounter bugs please report them so we can fix them.

    Microsoft Edgy is not actively supported, but if it werks, great! Same for anything apple related.

    Tinfoil f0ckers listen!
    diff --git a/views/error.html b/views/error.html index 3fd5f7b..b6799d4 100644 --- a/views/error.html +++ b/views/error.html @@ -2,7 +2,7 @@
    {{ message }} - f0ck?! + f0ck?!
    @include(snippets/footer) diff --git a/views/user.html b/views/user.html index 10c2601..e11ed08 100644 --- a/views/user.html +++ b/views/user.html @@ -3,24 +3,24 @@

    f0cks:

    @if('items' in f0cks) -show all f0cks -
    +
    @each(f0cks.items as item)

    @endeach
    +show all f0cks @else no f0cks given @endif

    favs:

    @if('items' in favs) -show all favs -
    +
    @each(favs.items as item)

    @endeach
    +show all favs @else no favorites @endif