From dc96a2578a79c6f4adc0c228f9b8e8cd5894533f Mon Sep 17 00:00:00 2001 From: Flummi Date: Tue, 17 May 2022 09:40:43 +0000 Subject: [PATCH 01/24] misc bugfixes --- debug/adduser.mjs | 5 +---- src/index.mjs | 4 +++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/debug/adduser.mjs b/debug/adduser.mjs index 271dedb..8991d16 100644 --- a/debug/adduser.mjs +++ b/debug/adduser.mjs @@ -2,13 +2,10 @@ import db from '../src/inc/sql.mjs'; import lib from '../src/inc/lib.mjs'; import readline from 'node:readline/promises'; -import stream from 'stream'; - -const _args = process.argv[2]; const rl = readline.createInterface({ input: process.stdin, output: process.stdout }); -const newuser = _args?.length ? _args : await rl.question('username: '); +const newuser = process.argv[2]?.length ? process.argv[2] : await rl.question('username: '); const password = await rl.question('password: '); const level = +(await rl.question('level (0-100): ')); diff --git a/src/index.mjs b/src/index.mjs index 48a8e36..5a7ba5d 100644 --- a/src/index.mjs +++ b/src/index.mjs @@ -61,7 +61,7 @@ import flummpress from "flummpress"; req.session = false; if(req.url.pathname.match(/^\/(s|b|t|ca)\//)) return; - req.theme = req.cookies.theme ?? 'f0ck'; + req.theme = req.cookies.theme || 'f0ck'; if(req.cookies.session) { const user = await db` @@ -95,6 +95,8 @@ import flummpress from "flummpress"; where id = ${+user[0].sess_id} `; + req.session.theme = req.cookies.theme; + // update userprofile await db` insert into "user_options" ${ From 29acafe9185d6ff0480d24298d52110eb7823be8 Mon Sep 17 00:00:00 2001 From: Flummi Date: Tue, 17 May 2022 10:03:11 +0000 Subject: [PATCH 02/24] ability to color iconset from css --- public/s/css/f0ck.css | 8 ++++++++ public/s/img/iconset.svg | 6 +++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/public/s/css/f0ck.css b/public/s/css/f0ck.css index 0e9d156..b29a250 100644 --- a/public/s/css/f0ck.css +++ b/public/s/css/f0ck.css @@ -2316,3 +2316,11 @@ table img { visibility: visible; } } + +/* icons */ +.iconset#a_delete { + stroke: var(--accent); +} +.iconset#a_favo { + fill: var(--accent); +} diff --git a/public/s/img/iconset.svg b/public/s/img/iconset.svg index 498573d..cafc7df 100644 --- a/public/s/img/iconset.svg +++ b/public/s/img/iconset.svg @@ -3,8 +3,8 @@ - - - + + + From ba821b81fa54482e02dc35991502b293369ebec4 Mon Sep 17 00:00:00 2001 From: Flummi Date: Tue, 17 May 2022 10:59:17 +0000 Subject: [PATCH 03/24] removed hardcoded link --- views/settings.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/settings.html b/views/settings.html index d4ca5b7..b336fe7 100644 --- a/views/settings.html +++ b/views/settings.html @@ -1,6 +1,6 @@ @include(snippets/header)

Settings

-@if(session.avatar)@endif +@if(session.avatar)@endif

Account

From f57a8b4320ab9f5b3c37e3910c9d084390c61158 Mon Sep 17 00:00:00 2001 From: Flummi Date: Tue, 17 May 2022 14:57:32 +0000 Subject: [PATCH 04/24] userprofiles test --- src/inc/routeinc/f0cklib.mjs | 2 +- src/inc/routes/index.mjs | 49 +++++++++++++++++++++++++++++++++++- views/user.html | 28 +++++++++++++++++++++ 3 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 views/user.html diff --git a/src/inc/routeinc/f0cklib.mjs b/src/inc/routeinc/f0cklib.mjs index 3c26ac9..836ecfb 100644 --- a/src/inc/routeinc/f0cklib.mjs +++ b/src/inc/routeinc/f0cklib.mjs @@ -65,7 +65,7 @@ export default { and "user".user ilike ${user} group by "items".id `; - total = total[0].total; + total = total[0]?.total ?? 0; } } diff --git a/src/inc/routes/index.mjs b/src/inc/routes/index.mjs index 6309dad..3be1caa 100644 --- a/src/inc/routes/index.mjs +++ b/src/inc/routes/index.mjs @@ -10,6 +10,53 @@ const auth = async (req, res, next) => { }; export default (router, tpl) => { + router.get(/\/user\/(?.*)/, async (req, res) => { + const user = req.params.user; + + const query = await db` + select "user".user, user_options.* + from user_options + left join "user" on "user".id = user_options.user_id + where "user".user ilike ${user} + limit 1 + `; + + if(!query.length) { + return res.reply({ + code: 404, + body: tpl.render('error', { + message: 'this user does not exists', + tmp: null + }, req) + }); + } + + const f0cks = await f0cklib.getf0cks({ + user: user, + mode: req.session.mode, + fav: false + }); + const favs = await f0cklib.getf0cks({ + user: user, + mode: req.session.mode, + fav: true + }); + + if('items' in f0cks) + f0cks.items = f0cks.items.slice(0, 50); + if('items' in favs) + favs.items = favs.items.slice(0, 50); + + const data = { + user: query[0], + f0cks, + favs, + tmp: null + }; + + return res.reply({ body: tpl.render('user', data, req) }); + }); + router.get(/^\/?(?:\/tag\/(?.+?))?(?:\/user\/(?.+?)\/(?f0cks|favs))?(?:\/(?image|audio|video))?(?:\/p\/(?\d+))?(?:\/(?\d+))?$/, async (req, res) => { const mode = req.params.itemid ? 'item' : 'index'; const data = await (req.params.itemid ? f0cklib.getf0ck : f0cklib.getf0cks)({ @@ -44,7 +91,7 @@ export default (router, tpl) => { const mode = +req.url.split[1]; let referertmp = req.headers.referer; let referer = ""; - + if(referertmp?.match(/f0ck\.me/)) referer = referertmp.split("/").slice(3).join("/"); diff --git a/views/user.html b/views/user.html new file mode 100644 index 0000000..10c2601 --- /dev/null +++ b/views/user.html @@ -0,0 +1,28 @@ +@include(snippets/header) +

{{ user.user }}

+ +

f0cks:

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

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

favs:

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

+ @endeach +
+@else + no favorites +@endif + +@include(snippets/footer) \ No newline at end of file From 97ef14716014d2d39f44b51dda5cf02bdfc22179 Mon Sep 17 00:00:00 2001 From: Flummi Date: Wed, 18 May 2022 03:43:17 +0000 Subject: [PATCH 05/24] misc bugfixes --- src/inc/lib.mjs | 10 ++++++++++ src/inc/routes/index.mjs | 20 ++++++++++---------- views/about.html | 4 ++-- views/error.html | 2 +- views/user.html | 8 ++++---- 5 files changed, 27 insertions(+), 17 deletions(-) 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 From 44ca53a05083d8d4244b9e8a1e4b9a5a989ef6c9 Mon Sep 17 00:00:00 2001 From: schrumpel Date: Wed, 18 May 2022 13:37:24 +0200 Subject: [PATCH 06/24] adding new f0ck style, various css changes --- public/s/css/f0ck.css | 152 +++++++++++++++++++++++++++++++++++------- views/item.html | 12 +++- 2 files changed, 137 insertions(+), 27 deletions(-) diff --git a/public/s/css/f0ck.css b/public/s/css/f0ck.css index b29a250..2f3e975 100644 --- a/public/s/css/f0ck.css +++ b/public/s/css/f0ck.css @@ -255,6 +255,26 @@ html[theme="paper"] { --scroller-bg: #424242; } +html[theme="paper"] ._204863 { + color: white; +} + +html[theme="paper"] svg.iconset { + background: black; +} + +html[theme="paper"] svg.iconset:hover { + background: rgb(31, 30, 30); +} + +html[theme="paper"] .iconset#a_favo { + fill: var(--white); +} + +html[theme="paper"] .iconset#a_delete { + stroke: var(--white); +} + html[theme="paper"] .pagination > a, .pagination > span { border-radius: 3px; border: 1px solid var(--black); @@ -523,6 +543,18 @@ html[theme="iced"] { --tooltip-bg: #0a3f53; } +html[theme="iced"] ._204863 { + background: -webkit-linear-gradient(left, #102c5e, #111d37); +} + +html[theme="iced"] svg.iconset { + background: #111d37; +} + +html[theme="iced"] svg.iconset:hover { + background: #1b2f5a; +} + html[theme="iced"] .pagination > a, .pagination > span { border-radius: 3px; border: 1px solid var(--black); @@ -605,20 +637,6 @@ html[theme="f0ck95"] .metadata { color: var(--black); } -html[theme="f0ck95"] ._204863 { - content: " "; - background: -webkit-linear-gradient(left,#08216b,#a5cef7); - text-align: left; - width: 100%; - color: white; - height: 20px; - display: block; - border-left: inset 2px silver; - border-top: inset 2px silver; - border-right: outset 2px silver; - border-bottom: outset 2px silver; -} - html[theme="f0ck95"] .container { padding-top: 10px; } @@ -722,6 +740,60 @@ html[theme="f0ck95"] .badge-danger { border-radius: 0; } +html[theme="f0ck95"] ._204863 { + content: " "; + background: -webkit-linear-gradient(left,#08216b,#a5cef7); + text-align: left; + width: 100%; + color: white; + height: auto; + display: flex; + border-left: inset 2px silver; + border-top: inset 2px silver; + border-right: outset 2px silver; + border-bottom: outset 2px silver; + justify-content: space-between; + line-height: 1.7; +} + +html[theme="f0ck95"] .iconset#a_delete { + stroke: var(--black); +} + +html[theme="f0ck95"] .iconset#a_favo { + fill: var(--black); +} + +html[theme="f0ck95"] .gapD { + height: 16px; + background: #08f; + width: max-content; + display: flex; +} + +html[theme="f0ck95"] svg.iconset { + display: inline-block; + height: 18px; + cursor: pointer; + width: 21px; + background: silver; + margin: 1px; + padding: 1px; + border: 1px outset silver; + position: relative; + right: 2px; +} + +html[theme="f0ck95"] .gapRight { + display: flex; + align-items: center; +} + +html[theme="f0ck95"] .populateME { + position: relative; + left: 5px; +} + /* f0ck95dARK */ html[theme='f0ck95d'] { --accent: #fff; @@ -761,16 +833,18 @@ html[theme='f0ck95d'] { html[theme="f0ck95d"] ._204863 { content: " "; - background: -webkit-linear-gradient(left,#08216b,#a5cef7); + background: -webkit-linear-gradient(left,#0e111a,#073c71); text-align: left; width: 100%; color: white; - height: 20px; - display: block; - border-left: inset 1px silver; - border-top: inset 1px silver; - border-right: outset 1px silver; - border-bottom: outset 1px silver; + height: auto; + display: flex; + border-left: inset 2px silver; + border-top: inset 2px silver; + border-right: outset 2px silver; + border-bottom: outset 2px silver; + justify-content: space-between; + line-height: 1.7; } html[theme="f0ck95d"] .embed-responsive-16by9::before { @@ -1462,8 +1536,28 @@ span.placeholder { margin-left: auto; z-index: 1; position: relative; + padding-top: 5px; } +.gapRight { + display: flex; + align-items: center; +} + +._204863 { + content: " "; + background: -webkit-linear-gradient(left,#131313,#4f4a4f); + text-align: left; + width: 100%; + color: var(--accent); + height: auto; + display: flex; + justify-content: space-between; + line-height: 1.7; + border: 1px solid black; +} + + .index-container { width: 100%; padding: 5px; @@ -2192,10 +2286,20 @@ table.table tbody tr:nth-of-type(odd) { /* buttons */ svg.iconset { display: inline-block; - height: 14px; - width: 14px; - vertical-align: sub; + height: 18px; + width: 21px; cursor: pointer; + background: #312c2c; + margin: 1px; + padding: 1px; + border: 1px outset #221d1d; + position: relative; + right: 2px; +} + +svg.iconset:hover { + background: #7b7b77; + transition: .2s ease; } /* favorites */ diff --git a/views/item.html b/views/item.html index 3b3c691..c72df52 100644 --- a/views/item.html +++ b/views/item.html @@ -1,6 +1,14 @@ @include(snippets/header)
    - +
    +
    + f0ck - {{ item.id }} +
    +
    + + +
    +