Compare commits
1 Commits
master
...
chat-overh
| Author | SHA1 | Date | |
|---|---|---|---|
| f803ec27a5 |
@@ -1,9 +1,9 @@
|
||||
POSTGRES_USER=f0ckm
|
||||
POSTGRES_DB=f0ckm
|
||||
POSTGRES_PASSWORD=f0ckm
|
||||
# --- Nginx & Tor Profiles (Optional) ---
|
||||
# Set to 'f0ckm-nginx' for Nginx, 'tor' for Tor hidden service, or 'f0ckm-nginx,tor' for both
|
||||
# COMPOSE_PROFILES=tor
|
||||
# --- Nginx & Let's Encrypt Configuration (Optional) ---
|
||||
# Set to 'f0ckm-nginx' to enable the Nginx & Let's Encrypt proxy stack
|
||||
# COMPOSE_PROFILES=f0ckm-nginx
|
||||
#
|
||||
# VIRTUAL_HOST=yourdomain.com
|
||||
# LETSENCRYPT_HOST=yourdomain.com
|
||||
|
||||
20
README.md
20
README.md
@@ -78,23 +78,3 @@ now visit http://localhost:1337 in your browser, you can develop without needing
|
||||
## NGINX
|
||||
|
||||
uncomment in .env # COMPOSE_PROFILES=f0ckm-nginx to enable nginx proxy with automatic lets encrypt.
|
||||
|
||||
## Tor Hidden Service (.onion)
|
||||
|
||||
Tor is bundled in `docker-compose.yml` and preconfigured as long as COMPOSE_PROFILES=f0ckm-tor is set with a hidden service pointing to the application (`f0ckm:1337`).
|
||||
|
||||
When running `docker compose up -d`, Tor automatically generates a `.onion` address for your node. You can find your onion address by running:
|
||||
|
||||
```bash
|
||||
cat ./f0ckm-data/tor/f0ckm_hs/hostname
|
||||
```
|
||||
|
||||
### Automatic Onion-Location Header
|
||||
|
||||
To advertise your `.onion` address to Tor Browser users visiting your clearnet site, add your `.onion` address to `config.json`:
|
||||
|
||||
```json
|
||||
"main": {
|
||||
"onion": "http://yourgeneratedaddress.onion"
|
||||
}
|
||||
```
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
# Tor configuration for f0ckm
|
||||
|
||||
# Enable SOCKS proxy for internal container & external connections
|
||||
SocksPort 0.0.0.0:9050
|
||||
|
||||
# Tor Hidden Service (v3 Onion Service) configuration
|
||||
# Tor will automatically generate private keys and hostnames in /var/lib/tor/f0ckm_hs/
|
||||
HiddenServiceDir /var/lib/tor/f0ckm_hs/
|
||||
HiddenServicePort 80 f0ckm:1337
|
||||
@@ -5,7 +5,6 @@
|
||||
"domain": "example.com",
|
||||
"regex": "example\\.com"
|
||||
},
|
||||
"onion": "http://your-onion-address.onion",
|
||||
"socks": "socks5://127.0.0.1:9050",
|
||||
"mail": "admin@example.com",
|
||||
"maxfilesize": 104857600,
|
||||
@@ -62,7 +61,6 @@
|
||||
"show_koepfe": false,
|
||||
"hide_sidebar_default": true,
|
||||
"koepfe": [],
|
||||
"enable_tor_hs": true,
|
||||
"enable_global_chat": true,
|
||||
"enable_danmaku": true,
|
||||
"private_messages": true,
|
||||
@@ -134,8 +132,6 @@
|
||||
"open_registration_require_mail_andor_token": false,
|
||||
"private_society": false,
|
||||
"private_society_gate": "cloudflare",
|
||||
"private_society_gate_location": "Frankfurt",
|
||||
"private_society_gate_template": "_gate_template",
|
||||
"public_nsfw": false,
|
||||
"paths": {
|
||||
"images": "/b",
|
||||
|
||||
@@ -49,14 +49,9 @@ services:
|
||||
tor:
|
||||
image: dockurr/tor
|
||||
container_name: tor
|
||||
profiles:
|
||||
- tor
|
||||
ports:
|
||||
- "9050:9050"
|
||||
- "8118:8118"
|
||||
volumes:
|
||||
- ./config/tor:/etc/tor:ro
|
||||
- ./f0ckm-data/tor:/var/lib/tor:Z
|
||||
networks:
|
||||
- f0ckm-net
|
||||
restart: always
|
||||
|
||||
@@ -1237,7 +1237,7 @@ html[theme='95'] .item-main-content .metadata {
|
||||
|
||||
.notif-count {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
top: 0px;
|
||||
right: -5px;
|
||||
background: var(--badge-nsfw);
|
||||
color: white;
|
||||
@@ -1650,10 +1650,6 @@ body.layout-modern .global-sidebar-right {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
body.sidebar-right-hidden #sidebar-drag-zone {
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
/* Always show the handle on touch devices (no hover state available) */
|
||||
@media (pointer: coarse) {
|
||||
#sidebar-drag-zone {
|
||||
@@ -1988,7 +1984,7 @@ body.sidebar-right-hidden #sidebar-drag-zone {
|
||||
right: 0;
|
||||
width: 100%;
|
||||
height: 20px;
|
||||
background: linear-gradient(to bottom, transparent, var(--bg));
|
||||
background: linear-gradient(to bottom, transparent, rgba(28, 27, 27, 0.8));
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
@@ -3878,7 +3874,7 @@ html[theme="f0ck95d"] ._204863 {
|
||||
line-height: 1.7;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 0px 5px;
|
||||
padding: 2px 4px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
@@ -3897,6 +3893,8 @@ html[theme="f0ck95d"] ._204863 .location::before {
|
||||
background-size: contain;
|
||||
background-repeat: no-repeat;
|
||||
background-position: center;
|
||||
image-rendering: pixelated;
|
||||
image-rendering: crisp-edges;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
@@ -4625,17 +4623,16 @@ span.placeholder {
|
||||
transition: right 0.3s ease-in-out;
|
||||
}
|
||||
|
||||
/* Sidebar hidden — reclaim the full width */
|
||||
body.sidebar-right-hidden .pagination-container-fluid {
|
||||
right: 0;
|
||||
}
|
||||
|
||||
/* Modern layout: wider sidebar needs wider offset */
|
||||
body.layout-modern .pagination-container-fluid {
|
||||
right: 400px;
|
||||
}
|
||||
|
||||
/* Sidebar hidden — reclaim the full width */
|
||||
body.sidebar-right-hidden .pagination-container-fluid,
|
||||
body.layout-modern.sidebar-right-hidden .pagination-container-fluid {
|
||||
right: 0;
|
||||
}
|
||||
|
||||
.bottom-pagination.fixed-pagination {
|
||||
margin: 10px auto;
|
||||
pointer-events: auto;
|
||||
@@ -4644,6 +4641,7 @@ body.layout-modern.sidebar-right-hidden .pagination-container-fluid {
|
||||
-webkit-backdrop-filter: blur(12px);
|
||||
border: 1px solid rgba(255, 255, 255, 0.08);
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
|
||||
padding: 2px;
|
||||
max-width: fit-content;
|
||||
}
|
||||
@@ -10034,6 +10032,7 @@ html[theme="orange"] .image-brand {
|
||||
.pagewrapper:has(.index-layout-wrapper),
|
||||
.pagewrapper:has(.item-layout-container),
|
||||
.pagewrapper:has(.meme-layout-wrapper),
|
||||
.pagewrapper:has(.chat-page),
|
||||
body.private-gate-active .pagewrapper {
|
||||
padding-right: 0 !important;
|
||||
}
|
||||
@@ -10178,7 +10177,7 @@ ol {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 20px;
|
||||
padding: 0 5px;
|
||||
padding: 0 15px;
|
||||
flex-shrink: 0;
|
||||
margin-left: auto;
|
||||
}
|
||||
@@ -14706,6 +14705,7 @@ body.layout-modern .xd-score-wrapper {
|
||||
z-index: 950;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: flex-end;
|
||||
align-items: flex-end;
|
||||
pointer-events: none;
|
||||
font-family: var(--font, monospace);
|
||||
@@ -14790,8 +14790,9 @@ body.scroller-active #gchat-reopen-bubble {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 300px;
|
||||
height: 40dvh;
|
||||
max-height: calc(100dvh - var(--navbar-h, 50px));
|
||||
height: 400px;
|
||||
max-height: calc(100dvh - var(--navbar-h, 50px) - 15px);
|
||||
min-height: 180px;
|
||||
background: var(--bg, #1a1a1a);
|
||||
border: 1px solid var(--nav-border-color, rgba(255, 255, 255, 0.08));
|
||||
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.65);
|
||||
@@ -14976,22 +14977,12 @@ body.scroller-active #gchat-reopen-bubble {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
#gchat-topic {
|
||||
padding: 5px 10px;
|
||||
font-size: 0.78em;
|
||||
font-weight: 600;
|
||||
color: var(--bg, #111);
|
||||
background: var(--accent, #f2ef0b);
|
||||
border-bottom: 1px solid rgba(0, 0, 0, 0.15);
|
||||
word-break: break-word;
|
||||
white-space: pre-wrap;
|
||||
flex-shrink: 0;
|
||||
opacity: 0.95;
|
||||
}
|
||||
|
||||
#gchat-messages {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
flex: 1 1 0%;
|
||||
min-height: 0;
|
||||
overflow-y: auto !important;
|
||||
overflow-x: hidden;
|
||||
padding: 8px;
|
||||
display: flex;
|
||||
@@ -15098,7 +15089,9 @@ body.scroller-active #gchat-reopen-bubble {
|
||||
|
||||
/* Emoji images inside chat bubbles */
|
||||
.gchat-bubble .emoji {
|
||||
height: 10.4em;
|
||||
height: 1.4em;
|
||||
max-height: 28px;
|
||||
width: auto;
|
||||
vertical-align: middle;
|
||||
display: inline-block;
|
||||
}
|
||||
@@ -15206,33 +15199,15 @@ body.scroller-active #gchat-reopen-bubble {
|
||||
transform: scale(0.92);
|
||||
}
|
||||
|
||||
/* Emoji picker grid (above input area, inside panel) */
|
||||
#gchat-emoji-picker {
|
||||
display: none;
|
||||
grid-template-columns: repeat(6, 1fr);
|
||||
gap: 4px;
|
||||
padding: 8px;
|
||||
overflow-y: auto;
|
||||
max-height: 140px;
|
||||
flex-direction: column;
|
||||
max-height: 220px;
|
||||
background: var(--nav-bg, #111);
|
||||
border-top: 1px solid var(--nav-border-color, rgba(255, 255, 255, 0.08));
|
||||
scrollbar-width: thin;
|
||||
}
|
||||
|
||||
#gchat-emoji-picker img {
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
object-fit: contain;
|
||||
cursor: pointer;
|
||||
border-radius: 4px;
|
||||
padding: 2px;
|
||||
transition: background 0.1s;
|
||||
}
|
||||
|
||||
#gchat-emoji-picker img:hover {
|
||||
background: rgba(255, 255, 255, 0.12);
|
||||
}
|
||||
|
||||
/* :emoji inline autocomplete — portaled to body */
|
||||
#gchat-emoji-ac {
|
||||
position: fixed;
|
||||
@@ -15745,14 +15720,319 @@ body.scroller-active #gchat-reopen-bubble {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.gchat-item-card-meta {
|
||||
font-size: 0.7rem;
|
||||
opacity: 0.5;
|
||||
/* ── Dedicated /chat Page ── */
|
||||
html:has(.chat-page),
|
||||
body:has(.chat-page) {
|
||||
height: 100% !important;
|
||||
overflow: hidden !important;
|
||||
}
|
||||
|
||||
body:has(.chat-page) .pagewrapper {
|
||||
height: calc(100dvh - var(--navbar-h, 60px)) !important;
|
||||
min-height: 0 !important;
|
||||
max-width: 100% !important;
|
||||
width: 100% !important;
|
||||
padding: 0 !important;
|
||||
margin: 0 !important;
|
||||
overflow: hidden !important;
|
||||
display: flex !important;
|
||||
flex-direction: column !important;
|
||||
transition: padding-right 0.3s ease-in-out !important;
|
||||
}
|
||||
|
||||
@media (min-width: 1000px) {
|
||||
body:has(.chat-page):not(.sidebar-right-hidden) .pagewrapper {
|
||||
padding-right: 300px !important;
|
||||
}
|
||||
}
|
||||
|
||||
body:has(.chat-page) footer,
|
||||
body:has(.chat-page) .footer {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.chat-page {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
max-width: 100%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.site-chat-container {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: relative;
|
||||
border-radius: 0;
|
||||
overflow: hidden;
|
||||
border: none;
|
||||
background: var(--bg, #1a1a1a);
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.gchat-page-panel {
|
||||
position: relative !important;
|
||||
inset: auto !important;
|
||||
width: 100% !important;
|
||||
height: 100% !important;
|
||||
max-width: 100% !important;
|
||||
min-width: 0 !important;
|
||||
border: none !important;
|
||||
border-radius: 0 !important;
|
||||
box-shadow: none !important;
|
||||
display: flex !important;
|
||||
flex-direction: column !important;
|
||||
transform: none !important;
|
||||
}
|
||||
|
||||
.gchat-page-panel #gchat-resize-h,
|
||||
.gchat-page-panel #gchat-resize-w,
|
||||
.gchat-page-panel #gchat-resize-e,
|
||||
.gchat-page-panel .gchat-header-btns {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
/* Flex layout containers for chat body */
|
||||
.gchat-body-wrap {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
#gchat-panel:not(.gchat-page-panel) .gchat-body-wrap {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.gchat-page-panel .gchat-body-wrap {
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.gchat-main-area {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.gchat-page-panel #gchat-messages {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
padding: 14px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.gchat-page-panel .gchat-msg {
|
||||
max-width: 100% !important;
|
||||
}
|
||||
|
||||
/* Right-side user list in page mode */
|
||||
.gchat-page-panel #gchat-online {
|
||||
width: 250px;
|
||||
min-width: 200px;
|
||||
max-width: 300px;
|
||||
border-left: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
|
||||
background: rgba(0, 0, 0, 0.25);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.gchat-page-panel .gchat-online-header {
|
||||
padding: 12px 14px 4px 14px;
|
||||
font-size: 0.92rem;
|
||||
font-weight: 700;
|
||||
color: var(--accent, #f2ef0b);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.gchat-page-panel .gchat-online-subhead {
|
||||
padding: 2px 14px 10px 14px;
|
||||
font-size: 0.75rem;
|
||||
opacity: 0.6;
|
||||
border-bottom: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
|
||||
}
|
||||
|
||||
.gchat-page-panel .gchat-online-list {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
overflow-y: auto;
|
||||
padding: 8px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.gchat-page-panel .gchat-online-user-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 6px 10px;
|
||||
border-radius: 6px;
|
||||
text-decoration: none;
|
||||
color: var(--fg, #e0e0e0);
|
||||
transition: background 0.15s ease;
|
||||
}
|
||||
|
||||
.gchat-page-panel .gchat-online-user-item:hover {
|
||||
background: rgba(255, 255, 255, 0.08);
|
||||
}
|
||||
|
||||
.gchat-page-panel .gchat-online-user-avatar {
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
border-radius: 50%;
|
||||
object-fit: cover;
|
||||
flex-shrink: 0;
|
||||
border: 1px solid rgba(255, 255, 255, 0.15);
|
||||
}
|
||||
|
||||
.gchat-page-panel .gchat-online-user-avatar.guest-avatar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: rgba(255, 255, 255, 0.08);
|
||||
font-size: 0.8rem;
|
||||
color: #aaa;
|
||||
}
|
||||
|
||||
.gchat-page-panel .gchat-online-user-name {
|
||||
font-size: 0.88rem;
|
||||
font-weight: 500;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.gchat-page-panel .gchat-body-wrap {
|
||||
flex-direction: column !important;
|
||||
flex: 1 !important;
|
||||
min-height: 0 !important;
|
||||
height: 100% !important;
|
||||
overflow: hidden !important;
|
||||
}
|
||||
|
||||
.gchat-page-panel #gchat-online {
|
||||
width: 100% !important;
|
||||
max-width: 100% !important;
|
||||
height: 40px !important;
|
||||
min-height: 40px !important;
|
||||
max-height: 40px !important;
|
||||
border-left: none !important;
|
||||
border-bottom: 1px solid var(--border-color, rgba(255, 255, 255, 0.12)) !important;
|
||||
order: -1 !important;
|
||||
flex-shrink: 0 !important;
|
||||
display: flex !important;
|
||||
flex-direction: row !important;
|
||||
align-items: center !important;
|
||||
padding: 0 10px !important;
|
||||
overflow: hidden !important;
|
||||
background: rgba(0, 0, 0, 0.3) !important;
|
||||
}
|
||||
|
||||
.gchat-page-panel .gchat-online-header {
|
||||
padding: 0 !important;
|
||||
font-size: 0.8rem !important;
|
||||
white-space: nowrap !important;
|
||||
flex-shrink: 0 !important;
|
||||
gap: 4px !important;
|
||||
}
|
||||
|
||||
.gchat-page-panel .gchat-online-header span {
|
||||
font-size: 0.78rem !important;
|
||||
}
|
||||
|
||||
.gchat-page-panel .gchat-online-subhead {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.gchat-page-panel .gchat-online-list {
|
||||
flex: 1 !important;
|
||||
min-width: 0 !important;
|
||||
display: flex !important;
|
||||
flex-direction: row !important;
|
||||
flex-wrap: nowrap !important;
|
||||
overflow-x: auto !important;
|
||||
overflow-y: hidden !important;
|
||||
gap: 6px !important;
|
||||
padding: 0 4px !important;
|
||||
align-items: center !important;
|
||||
scrollbar-width: none !important;
|
||||
-webkit-overflow-scrolling: touch !important;
|
||||
touch-action: pan-x !important;
|
||||
}
|
||||
|
||||
.gchat-page-panel .gchat-online-list::-webkit-scrollbar {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.gchat-page-panel .gchat-online-user-item {
|
||||
flex-shrink: 0 !important;
|
||||
padding: 2px 8px !important;
|
||||
gap: 6px !important;
|
||||
border-radius: 12px !important;
|
||||
background: rgba(255, 255, 255, 0.08) !important;
|
||||
height: 28px !important;
|
||||
align-items: center !important;
|
||||
}
|
||||
|
||||
.gchat-page-panel .gchat-online-user-avatar {
|
||||
width: 20px !important;
|
||||
height: 20px !important;
|
||||
}
|
||||
|
||||
.gchat-page-panel .gchat-online-user-name {
|
||||
font-size: 0.75rem !important;
|
||||
max-width: 110px !important;
|
||||
}
|
||||
|
||||
.gchat-page-panel .gchat-main-area {
|
||||
flex: 1 !important;
|
||||
min-height: 0 !important;
|
||||
height: auto !important;
|
||||
display: flex !important;
|
||||
flex-direction: column !important;
|
||||
overflow: hidden !important;
|
||||
}
|
||||
|
||||
.gchat-page-panel #gchat-messages {
|
||||
flex: 1 !important;
|
||||
min-height: 0 !important;
|
||||
overflow-y: auto !important;
|
||||
padding: 10px !important;
|
||||
-webkit-overflow-scrolling: touch !important;
|
||||
}
|
||||
|
||||
.gchat-page-panel .gchat-msg {
|
||||
max-width: 92% !important;
|
||||
}
|
||||
|
||||
.gchat-page-panel #gchat-input-area {
|
||||
flex-shrink: 0 !important;
|
||||
background: var(--nav-bg, #0d0d0d) !important;
|
||||
padding-bottom: env(safe-area-inset-bottom, 0px) !important;
|
||||
}
|
||||
}
|
||||
|
||||
/* =============================================
|
||||
SETTINGS PAGE – MOBILE OVERFLOW FIXES
|
||||
Prevents long i18n strings (Deutsch / Zange)
|
||||
@@ -16135,21 +16415,12 @@ body.scroller-active #gchat-reopen-bubble {
|
||||
color: #ccc;
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.05);
|
||||
font-size: 0.9em;
|
||||
word-break: break-word;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.info-table td a {
|
||||
color: var(--accent, #9f0);
|
||||
text-decoration: none;
|
||||
font-weight: 600;
|
||||
word-break: break-all;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
#info-modal .modal-content .info-table td a {
|
||||
word-break: break-all;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.info-table td a:hover {
|
||||
|
||||
@@ -1160,13 +1160,17 @@ class CommentSystem {
|
||||
const author = openerEl.dataset.display || openerEl.dataset.username || 'System';
|
||||
const contentEl = body.querySelector('.comment-content');
|
||||
if (contentEl) {
|
||||
const LINE_MAX = 200;
|
||||
let rawText = (contentEl.dataset.raw || '').trim();
|
||||
if (rawText.includes('>') || rawText.includes('<') || rawText.includes('&')) {
|
||||
const txt = document.createElement('textarea');
|
||||
txt.innerHTML = rawText;
|
||||
rawText = txt.value;
|
||||
}
|
||||
const lines = rawText.split('\n');
|
||||
// Preserve all lines but cap any single line exceeding LINE_MAX chars
|
||||
const lines = rawText.split('\n').map(line =>
|
||||
line.length > LINE_MAX ? line.substring(0, LINE_MAX) + '\u2026' : line
|
||||
);
|
||||
const quote = `>>${id} \n>${author}\n${lines.map(line => `>${line}`).join('\n')}\n`;
|
||||
|
||||
if (isNew) {
|
||||
@@ -1621,25 +1625,17 @@ class CommentSystem {
|
||||
syncLevel(roots, list, false);
|
||||
}
|
||||
|
||||
// Maximum characters & lines to fully render in the item view per comment
|
||||
static get ITEM_VIEW_MAX_CHARS() { return 500; }
|
||||
static get ITEM_VIEW_MAX_LINES() { return 6; }
|
||||
// Maximum characters to fully render in the item view per comment
|
||||
static get ITEM_VIEW_MAX_CHARS() { return 2000; }
|
||||
|
||||
renderCommentContent(content, commentId = null, bypassTruncation = false) {
|
||||
if (!content) return '';
|
||||
|
||||
// Truncate long comments before any processing
|
||||
// Truncate extremely long comments before any processing
|
||||
let truncated = false;
|
||||
if (!bypassTruncation) {
|
||||
const lines = content.split('\n');
|
||||
if (lines.length > CommentSystem.ITEM_VIEW_MAX_LINES) {
|
||||
content = lines.slice(0, CommentSystem.ITEM_VIEW_MAX_LINES).join('\n');
|
||||
truncated = true;
|
||||
}
|
||||
if (content.length > CommentSystem.ITEM_VIEW_MAX_CHARS) {
|
||||
content = content.substring(0, CommentSystem.ITEM_VIEW_MAX_CHARS);
|
||||
truncated = true;
|
||||
}
|
||||
if (!bypassTruncation && content.length > CommentSystem.ITEM_VIEW_MAX_CHARS) {
|
||||
content = content.substring(0, CommentSystem.ITEM_VIEW_MAX_CHARS) + '\u2026';
|
||||
truncated = true;
|
||||
}
|
||||
|
||||
if (typeof marked === 'undefined') {
|
||||
@@ -1788,11 +1784,10 @@ class CommentSystem {
|
||||
if (trimmed.startsWith('>') && !trimmed.match(/^>>\d+/)) {
|
||||
const quoteContent = line.substring(line.indexOf('>') + 1);
|
||||
const quoteEmojis = window.f0ckSession?.quote_emojis === true;
|
||||
const escapedQuote = quoteContent.replace(/>/g, '>');
|
||||
const renderedContent = quoteEmojis
|
||||
? escapedQuote.replace(/:([a-z0-9_]+):/g, (m, n) => this.renderEmoji(m, n))
|
||||
: escapedQuote;
|
||||
return `<span class="greentext">>${renderedContent}</span>`;
|
||||
? quoteContent.replace(/:([a-z0-9_]+):/g, (m, n) => this.renderEmoji(m, n))
|
||||
: quoteContent;
|
||||
return `<span class="greentext">>${renderedContent.replace(/>/g, '>')}</span>`;
|
||||
}
|
||||
|
||||
// 2. Per-line limit to prevent marked.parse recursion on single giant lines
|
||||
@@ -3608,9 +3603,9 @@ class CommentSystem {
|
||||
// element whenever the raw content exceeds ITEM_VIEW_MAX_CHARS. Called after every
|
||||
// optimistic DOM insert to guarantee the button regardless of rendering path.
|
||||
_ensureTruncationButton(commentEl, rawContent) {
|
||||
if (!rawContent) return;
|
||||
const lineCount = rawContent.split('\n').length;
|
||||
if (rawContent.length <= CommentSystem.ITEM_VIEW_MAX_CHARS && lineCount <= CommentSystem.ITEM_VIEW_MAX_LINES) {
|
||||
console.log('[ensureBtn] called, rawContent.length:', rawContent?.length, 'threshold:', CommentSystem.ITEM_VIEW_MAX_CHARS);
|
||||
if (!rawContent || rawContent.length <= CommentSystem.ITEM_VIEW_MAX_CHARS) {
|
||||
console.log('[ensureBtn] below threshold, skipping');
|
||||
return;
|
||||
}
|
||||
const contentEl = commentEl.querySelector('.comment-content');
|
||||
|
||||
@@ -2438,7 +2438,7 @@ window.cancelAnimFrame = (function () {
|
||||
const isAdmin = !!pathname.match(/^\/admin/);
|
||||
const isMod = !!pathname.match(/^\/mod/);
|
||||
const isSettings = pathname.match(/\/settings\/?(?:$|\?)/);
|
||||
const isStatic = pathname.match(/\/(about|rules|terms|upload|subscriptions|stats|docs|discord|ranking|meme|memes)($|\/|\?)/);
|
||||
const isStatic = pathname.match(/\/(about|rules|terms|upload|subscriptions|stats|docs|discord|ranking|meme|memes|chat)($|\/|\?)/);
|
||||
const isUpload = pathname.match(/\/upload\/?(?:$|\?)/);
|
||||
const parts = pathname.split('/').filter(Boolean);
|
||||
const isItem = !pathname.match(/\/p\//) && (
|
||||
@@ -2446,8 +2446,9 @@ window.cancelAnimFrame = (function () {
|
||||
(parts.length >= 3 && (parts[0] === 'tag' || parts[0] === 'user' || parts[0] === 'h') && /^\d+$/.test(parts[parts.length - 1]))
|
||||
);
|
||||
const isMessages = !!pathname.match(/^\/messages(\/|$)/);
|
||||
const isChat = !!pathname.match(/^\/chat(\/|$)/);
|
||||
const isAbyss = !!pathname.match(/^\/abyss(\/|$|\?|#)/) || pathname === '/abyss';
|
||||
const isGrid = !isProfile && !isUserHall && !isUserHalls && !isHall && !isHalls && !isTags && !isComments && !isNotifs && !isItem && !isAdmin && !isMod && !isSettings && !isStatic && !isUpload && !isMessages && !isAbyss;
|
||||
const isGrid = !isProfile && !isUserHall && !isUserHalls && !isHall && !isHalls && !isTags && !isComments && !isNotifs && !isItem && !isAdmin && !isMod && !isSettings && !isStatic && !isUpload && !isMessages && !isChat && !isAbyss;
|
||||
|
||||
if (isItem) {
|
||||
isNavigating = false;
|
||||
@@ -4079,7 +4080,7 @@ window.cancelAnimFrame = (function () {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isSpecialLink && (pathname === '/' || pathname.startsWith('/halls') || pathname.startsWith('/h/') || pathname.startsWith('/notifications') || pathname.startsWith('/tag') || pathname.startsWith('/user/') || pathname.match(/^\/(image|video|audio)/) || pathname.match(/\/p\/\d+/) || pathname.match(/^\/\d+/) || pathname.match(/^\/(about|rules|terms|upload|subscriptions|stats|docs|settings|admin|mod|ranking|messages|meme|memes)/) || pathname.startsWith('/abyss'))) {
|
||||
if (!isSpecialLink && (pathname === '/' || pathname.startsWith('/halls') || pathname.startsWith('/h/') || pathname.startsWith('/notifications') || pathname.startsWith('/tag') || pathname.startsWith('/user/') || pathname.match(/^\/(image|video|audio)/) || pathname.match(/\/p\/\d+/) || pathname.match(/^\/\d+/) || pathname.match(/^\/(about|rules|terms|upload|subscriptions|stats|docs|settings|admin|mod|ranking|messages|meme|memes|chat)/) || pathname.startsWith('/abyss'))) {
|
||||
e.preventDefault();
|
||||
e.stopImmediatePropagation();
|
||||
|
||||
@@ -4533,7 +4534,7 @@ window.cancelAnimFrame = (function () {
|
||||
(parts.length >= 3 && parts[0] === 'tag' && /^\d+$/.test(parts[parts.length - 1])) ||
|
||||
(parts.length >= 3 && parts[0] === 'user' && /^\d+$/.test(parts[parts.length - 1]))
|
||||
);
|
||||
const isSpecial = p.startsWith('/notifications') || p.startsWith('/tags') || p.startsWith('/user/') || p.startsWith('/subscriptions') || p.startsWith('/ranking');
|
||||
const isSpecial = p.startsWith('/notifications') || p.startsWith('/tags') || p.startsWith('/user/') || p.startsWith('/subscriptions') || p.startsWith('/ranking') || p.startsWith('/chat');
|
||||
const isGridLike = url.match(/\/p\/\d+/) || url.match(/[?&]page=\d+/) || p === '/';
|
||||
|
||||
window.f0ckDebug("[popstate] Navigation to:", url, { isItem, isSpecial, isGridLike });
|
||||
@@ -7567,48 +7568,29 @@ class NotificationSystem {
|
||||
|
||||
// Helper: apply a display name change to all relevant DOM nodes
|
||||
this.applyDisplayNameUpdate = (display_name, user) => {
|
||||
const isSelf = !user || (window.f0ckSession?.user && user.toLowerCase() === window.f0ckSession.user.toLowerCase());
|
||||
|
||||
// Capture old value before overwriting — needed for thumb matching below
|
||||
const oldDisplayName = isSelf ? (window.f0ckSession?.display_name || null) : null;
|
||||
if (isSelf && window.f0ckSession) {
|
||||
window.f0ckSession.display_name = display_name || null;
|
||||
}
|
||||
const oldDisplayName = window.f0ckSession?.display_name || null;
|
||||
if (window.f0ckSession) window.f0ckSession.display_name = display_name || null;
|
||||
|
||||
const userName = user || window.f0ckSession?.user;
|
||||
|
||||
// Update navbar display name only if this update is for the logged-in user
|
||||
if (isSelf) {
|
||||
document.querySelectorAll('#nav-display-name').forEach(nameSpan => {
|
||||
for (let i = nameSpan.childNodes.length - 1; i >= 0; i--) {
|
||||
let node = nameSpan.childNodes[i];
|
||||
if (node.nodeType === Node.TEXT_NODE && node.nodeValue.trim().length > 0) {
|
||||
const match = node.nodeValue.match(new RegExp('^(\\s*)(.*)'));
|
||||
node.nodeValue = (match ? match[1] : '') + (display_name || userName || '');
|
||||
break;
|
||||
}
|
||||
// Update ALL nav-display-name instances (handles the profile page having a duplicate ID)
|
||||
document.querySelectorAll('#nav-display-name').forEach(nameSpan => {
|
||||
// preserve the badges (Admin, Mod)
|
||||
for (let i = nameSpan.childNodes.length - 1; i >= 0; i--) {
|
||||
let node = nameSpan.childNodes[i];
|
||||
if (node.nodeType === Node.TEXT_NODE && node.nodeValue.trim().length > 0) {
|
||||
// Match and preserve any non-breaking spaces at the start (from admin/mod badges)
|
||||
const match = node.nodeValue.match(new RegExp('^(\\s*)(.*)'));
|
||||
node.nodeValue = (match ? match[1] : '') + (display_name || userName || '');
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Update profile header display name if currently viewing this user's profile
|
||||
const profileBox = document.getElementById('live-profile-preview-box');
|
||||
if (profileBox && profileBox.dataset.bannerUser && userName && profileBox.dataset.bannerUser.toLowerCase() === userName.toLowerCase()) {
|
||||
const profileNameSpan = document.getElementById('profile-display-name');
|
||||
if (profileNameSpan) {
|
||||
for (let i = profileNameSpan.childNodes.length - 1; i >= 0; i--) {
|
||||
let node = profileNameSpan.childNodes[i];
|
||||
if (node.nodeType === Node.TEXT_NODE && node.nodeValue.trim().length > 0) {
|
||||
const match = node.nodeValue.match(new RegExp('^(\\s*)(.*)'));
|
||||
node.nodeValue = (match ? match[1] : '') + (display_name || userName || '');
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
const bracket = document.getElementById('username-bracket');
|
||||
if (bracket) {
|
||||
const bracket = document.getElementById('username-bracket');
|
||||
if (bracket) {
|
||||
bracket.style.display = display_name ? 'inline' : 'none';
|
||||
}
|
||||
}
|
||||
|
||||
if (userName) {
|
||||
@@ -7635,7 +7617,6 @@ class NotificationSystem {
|
||||
|
||||
// Helper: apply a username color change to relevant DOM nodes
|
||||
this.applyUsernameColorUpdate = (username_color, user) => {
|
||||
const isSelf = !user || (window.f0ckSession?.user && user.toLowerCase() === window.f0ckSession.user.toLowerCase());
|
||||
const userName = user || window.f0ckSession?.user;
|
||||
if (!userName) return;
|
||||
|
||||
@@ -7682,21 +7663,22 @@ class NotificationSystem {
|
||||
}
|
||||
});
|
||||
|
||||
// Profile header display name color (if currently viewing this user's profile)
|
||||
const profileBox = document.getElementById('live-profile-preview-box');
|
||||
if (profileBox && profileBox.dataset.bannerUser && profileBox.dataset.bannerUser.toLowerCase() === userName.toLowerCase()) {
|
||||
const profileNameSpan = document.getElementById('profile-display-name');
|
||||
if (profileNameSpan) {
|
||||
// Special case for settings page preview block
|
||||
if (window.f0ckSession && userName === window.f0ckSession.user) {
|
||||
const previewBlock = document.getElementById('live-profile-preview-box');
|
||||
if (previewBlock) {
|
||||
if (username_color) {
|
||||
profileNameSpan.style.color = username_color;
|
||||
previewBlock.style.setProperty('--author-accent', username_color);
|
||||
previewBlock.style.setProperty('--author-border', username_color);
|
||||
} else {
|
||||
profileNameSpan.style.removeProperty('color');
|
||||
previewBlock.style.setProperty('--author-accent', 'var(--accent)');
|
||||
previewBlock.style.setProperty('--author-border', 'var(--accent)');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Navbar display name color (only for current user)
|
||||
if (isSelf) {
|
||||
// Handle the nav-display-name span elements (profile header and top navbar)
|
||||
if (window.f0ckSession && userName === window.f0ckSession.user) {
|
||||
document.querySelectorAll('#nav-display-name').forEach(el => {
|
||||
if (username_color) {
|
||||
el.style.color = username_color;
|
||||
@@ -7709,21 +7691,14 @@ class NotificationSystem {
|
||||
|
||||
// Helper: apply an avatar update to relevant DOM nodes
|
||||
this.applyAvatarUpdate = (avatar_file, user) => {
|
||||
const isSelf = !user || (window.f0ckSession?.user && user.toLowerCase() === window.f0ckSession.user.toLowerCase());
|
||||
const userName = user || window.f0ckSession?.user;
|
||||
if (!userName) return;
|
||||
|
||||
const newSrc = avatar_file ? `/a/${avatar_file}?t=${Date.now()}` : '/a/default.png';
|
||||
|
||||
// Update Nav Avatar only for current user
|
||||
if (isSelf) {
|
||||
document.querySelectorAll('.nav-avatar-img').forEach(img => img.src = newSrc);
|
||||
}
|
||||
|
||||
// Update profile header avatar if currently viewing this user's profile
|
||||
const profileBox = document.getElementById('live-profile-preview-box');
|
||||
if (profileBox && profileBox.dataset.bannerUser && profileBox.dataset.bannerUser.toLowerCase() === userName.toLowerCase()) {
|
||||
document.querySelectorAll('.profile_head_avatar img').forEach(img => img.src = newSrc);
|
||||
// Update Nav Avatar & profile header Avatar (only for current user)
|
||||
if (window.f0ckSession && userName === window.f0ckSession.user) {
|
||||
document.querySelectorAll('.nav-avatar-img, .profile_head_avatar img').forEach(img => img.src = newSrc);
|
||||
}
|
||||
|
||||
// Update globally (comments, sidebar, polls, rank, infoboxes, favs)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -153,6 +153,12 @@
|
||||
const renderCommentContent = (content, commentId = null, itemId = null) => {
|
||||
if (!content) return '';
|
||||
|
||||
// Truncate extremely long comments before any processing to keep the sidebar
|
||||
// fast and the DOM lean, regardless of markdown / regex complexity.
|
||||
if (content.length > SIDEBAR_CONTENT_TRUNCATE) {
|
||||
content = content.substring(0, SIDEBAR_CONTENT_TRUNCATE) + '\u2026';
|
||||
}
|
||||
|
||||
if (typeof marked === 'undefined') {
|
||||
return escapeHtml(content)
|
||||
.replace(/:([a-z0-9_]+):/g, (m, n) => renderEmoji(m, n));
|
||||
@@ -262,11 +268,10 @@
|
||||
// Manual greentext handling — apply emoji if the user preference allows it
|
||||
const quoteContent = line.substring(line.indexOf('>') + 1);
|
||||
const quoteEmojis = window.f0ckSession?.quote_emojis === true;
|
||||
const escapedQuote = quoteContent.replace(/>/g, '>');
|
||||
const rendered = quoteEmojis
|
||||
? escapedQuote.replace(/:([a-z0-9_]+):/g, (m, n) => renderEmoji(m, n))
|
||||
: escapedQuote;
|
||||
return `<span class="greentext">>${rendered}</span>`;
|
||||
? quoteContent.replace(/:([a-z0-9_]+):/g, (m, n) => renderEmoji(m, n))
|
||||
: quoteContent;
|
||||
return `<span class="greentext">>${rendered.replace(/>/g, '>')}</span>`;
|
||||
}
|
||||
|
||||
// Per-line limit to prevent marked.parse recursion on single giant lines
|
||||
|
||||
@@ -306,12 +306,7 @@ if (!window.UserCommentSystem) {
|
||||
const trimmed = line.trimStart();
|
||||
if (trimmed.startsWith('>') && !trimmed.match(/^>>\d+/)) {
|
||||
const quoteContent = line.substring(line.indexOf('>') + 1);
|
||||
const quoteEmojis = window.f0ckSession?.quote_emojis === true;
|
||||
const escapedQuote = quoteContent.replace(/>/g, '>');
|
||||
const rendered = quoteEmojis
|
||||
? escapedQuote.replace(/:([a-z0-9_]+):/g, (m, n) => this.renderEmoji(m, n))
|
||||
: escapedQuote;
|
||||
return `<span class="greentext">>${rendered}</span>`;
|
||||
return `<span class="greentext">>${quoteContent.replace(/>/g, '>')}</span>`;
|
||||
}
|
||||
|
||||
// Per-line limit
|
||||
|
||||
@@ -460,15 +460,4 @@ export default new class {
|
||||
console.error(`[ERROR REF ${errId}] ${context}:`, err);
|
||||
return `Internal Error. Reference: ${errId}`;
|
||||
}
|
||||
|
||||
isOnionRequest(req) {
|
||||
if (!req || !req.headers) return false;
|
||||
const rawHost = req.headers['x-forwarded-host'] || req.headers['host'] || req.headers['x-forwarded-server'] || '';
|
||||
if (!rawHost) return false;
|
||||
const hostStr = Array.isArray(rawHost) ? rawHost[0] : String(rawHost);
|
||||
const firstHost = hostStr.split(',')[0].trim();
|
||||
const hostNoPort = firstHost.split(':')[0].trim().toLowerCase();
|
||||
return hostNoPort.endsWith('.onion');
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
"meme": "Meme",
|
||||
"halls": "Hallen",
|
||||
"tags": "Tags",
|
||||
"chat": "Chat",
|
||||
"search": "Suchen",
|
||||
"random": "Zufall",
|
||||
"profile": "Profil",
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
"meme": "Meme",
|
||||
"halls": "Halls",
|
||||
"tags": "Tags",
|
||||
"chat": "Chat",
|
||||
"search": "Search",
|
||||
"random": "Random",
|
||||
"profile": "Profile",
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
"meme": "meme",
|
||||
"halls": "Hallen",
|
||||
"tags": "Tags",
|
||||
"chat": "Chat",
|
||||
"search": "Zoeken",
|
||||
"random": "Willekeurig",
|
||||
"profile": "profiel",
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
"meme": "Memen",
|
||||
"halls": "Hallen",
|
||||
"tags": "Etiketten",
|
||||
"chat": "Geschwafel",
|
||||
"search": "Suche",
|
||||
"random": "Zufall",
|
||||
"profile": "Profil",
|
||||
|
||||
@@ -1428,8 +1428,8 @@ export default (router, tpl) => {
|
||||
const userId = newUser[0].id;
|
||||
|
||||
await db`
|
||||
INSERT INTO user_options (user_id, mode, theme, fullscreen, avatar, avatar_file, use_new_layout, disable_autoplay, disable_swiping, use_alternative_infobox)
|
||||
VALUES (${userId}, 3, 'amoled', 0, NULL, 'default.png', ${getDefaultLayout() === 'modern'}, ${cfg.websrv.enable_autoplay === false}, ${cfg.websrv.enable_swiping === false}, ${cfg.websrv.user_alternative_infobox !== false})
|
||||
INSERT INTO user_options (user_id, mode, theme, fullscreen, avatar, avatar_file, use_new_layout, disable_autoplay, disable_swiping)
|
||||
VALUES (${userId}, 3, 'amoled', 0, NULL, 'default.png', ${getDefaultLayout() === 'modern'}, ${cfg.websrv.enable_autoplay === false}, ${cfg.websrv.enable_swiping === false})
|
||||
`;
|
||||
|
||||
await audit.log(req.session.id, 'admin_create_user', 'user', userId, {
|
||||
|
||||
@@ -47,6 +47,25 @@ function buildBgHostRegex() {
|
||||
|
||||
export default (router, tpl) => {
|
||||
|
||||
// GET /chat — Dedicated site chat page
|
||||
router.get('/chat', async (req, res) => {
|
||||
if (!cfg.websrv.enable_global_chat) {
|
||||
return res.reply({ code: 404, body: 'Not found' });
|
||||
}
|
||||
if (!req.session) {
|
||||
return res.redirect('/login');
|
||||
}
|
||||
if (req.session.banned) {
|
||||
return res.reply({ code: 403, body: 'Access denied: You are banned' });
|
||||
}
|
||||
return res.html(tpl.render('chat', {
|
||||
session: req.session,
|
||||
hidePagination: true,
|
||||
link: { main: '/chat', path: '/chat' },
|
||||
domain: cfg.main.url.domain
|
||||
}, req));
|
||||
});
|
||||
|
||||
// GET /api/chat — fetch recent messages
|
||||
router.get('/api/chat', async (req, res) => {
|
||||
if (!cfg.websrv.enable_global_chat) {
|
||||
|
||||
@@ -48,7 +48,7 @@ export default (router, tpl) => {
|
||||
return res.writeHead(200, { 'Content-Type': 'application/json' }).end(JSON.stringify({ success: false, msg: errorMsg }));
|
||||
}
|
||||
return res.reply({
|
||||
body: tpl.render("register", { theme: req.cookies?.theme ?? (cfg.websrv.theme || "f0ck"), error: errorMsg, registration_open: getRegistrationOpen() }, req)
|
||||
body: tpl.render("register", { theme: req.cookies.theme ?? (cfg.websrv.theme || "f0ck"), error: errorMsg, registration_open: getRegistrationOpen() })
|
||||
});
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ export default (router, tpl) => {
|
||||
return res.writeHead(200, { 'Content-Type': 'application/json' }).end(JSON.stringify({ success: false, msg }));
|
||||
}
|
||||
return res.reply({
|
||||
body: tpl.render("register", { theme: req.cookies?.theme ?? (cfg.websrv.theme || "f0ck"), error: msg, registration_open: getRegistrationOpen() }, req)
|
||||
body: tpl.render("register", { theme: req.cookies.theme ?? (cfg.websrv.theme || "f0ck"), error: msg, registration_open: getRegistrationOpen() })
|
||||
});
|
||||
};
|
||||
|
||||
@@ -67,7 +67,7 @@ export default (router, tpl) => {
|
||||
return res.writeHead(200, { 'Content-Type': 'application/json' }).end(JSON.stringify({ success: true, msg }));
|
||||
}
|
||||
return res.reply({
|
||||
body: tpl.render("register", { theme: req.cookies?.theme ?? (cfg.websrv.theme || "f0ck"), success: msg, registration_open: getRegistrationOpen() }, req)
|
||||
body: tpl.render("register", { theme: req.cookies.theme ?? (cfg.websrv.theme || "f0ck"), success: msg, registration_open: getRegistrationOpen() })
|
||||
});
|
||||
};
|
||||
|
||||
@@ -88,9 +88,8 @@ export default (router, tpl) => {
|
||||
return renderError("Passwords do not match.");
|
||||
}
|
||||
|
||||
// reCAPTCHA verification (bypassed for .onion requests as Google reCAPTCHA cannot validate .onion domains)
|
||||
const isOnion = lib.isOnionRequest(req);
|
||||
if (!isOnion && cfg.recaptcha?.enabled && cfg.recaptcha?.secret_key) {
|
||||
// reCAPTCHA verification
|
||||
if (cfg.recaptcha?.enabled && cfg.recaptcha?.secret_key) {
|
||||
const rcToken = req.post['g-recaptcha-response'];
|
||||
if (!rcToken) return renderError("Please complete the reCAPTCHA.");
|
||||
try {
|
||||
@@ -168,8 +167,8 @@ export default (router, tpl) => {
|
||||
const avatarFile = 'default.png';
|
||||
|
||||
await db`
|
||||
insert into user_options (user_id, mode, theme, fullscreen, avatar, avatar_file, use_new_layout, disable_autoplay, disable_swiping, use_alternative_infobox)
|
||||
values (${userId}, 3, 'amoled', 0, ${avatarId}, ${avatarFile}, ${getDefaultLayout() === 'modern'}, ${cfg.websrv.enable_autoplay === false}, ${cfg.websrv.enable_swiping === false}, ${cfg.websrv.user_alternative_infobox !== false})
|
||||
insert into user_options (user_id, mode, theme, fullscreen, avatar, avatar_file, use_new_layout, disable_autoplay, disable_swiping)
|
||||
values (${userId}, 3, 'amoled', 0, ${avatarId}, ${avatarFile}, ${getDefaultLayout() === 'modern'}, ${cfg.websrv.enable_autoplay === false}, ${cfg.websrv.enable_swiping === false})
|
||||
`;
|
||||
} catch (err) {
|
||||
console.error(`[REGISTER] DB Error during user creation:`, err);
|
||||
|
||||
147
src/index.mjs
147
src/index.mjs
@@ -49,7 +49,7 @@ const gateOptions = {
|
||||
},
|
||||
cloudflare_status: {
|
||||
status: 'ok',
|
||||
location: cfg.websrv.private_society_gate_location || 'Frankfurt',
|
||||
location: 'Frankfurt',
|
||||
name: 'Cloudflare',
|
||||
status_text: 'Working',
|
||||
},
|
||||
@@ -79,13 +79,11 @@ const nginx502Fallback = `<html>
|
||||
</html>`;
|
||||
|
||||
// Login + Register modal injected before </body>
|
||||
// Dynamic function so reCAPTCHA can be bypassed for .onion requests
|
||||
// This string is built at startup so it can reference cfg.recaptcha values.
|
||||
const _rcEnabled = !!(cfg.recaptcha && cfg.recaptcha.enabled && cfg.recaptcha.site_key);
|
||||
const _rcSiteKey = (cfg.recaptcha && cfg.recaptcha.site_key) || '';
|
||||
|
||||
function getGateLoginInjection(req) {
|
||||
const rcEnabled = _rcEnabled && !lib.isOnionRequest(req);
|
||||
return `
|
||||
const gateLoginInjection = `
|
||||
<div id="hot-corner" style="position:fixed;bottom:0;left:0;width:20px;height:20px;z-index:9999;"></div>
|
||||
|
||||
<div id="gate-modal" style="display:none;position:fixed;inset:0;background:rgba(0,0,0,0.45);z-index:10000;align-items:center;justify-content:center;">
|
||||
@@ -125,7 +123,7 @@ function getGateLoginInjection(req) {
|
||||
<input type="text" name="token" placeholder="Invite token" autocomplete="off"
|
||||
style="background:white;color:black;border:1px solid #bbb;padding:7px 10px;width:100%;box-sizing:border-box;font-size:14px;font-family:inherit;" />
|
||||
<input type="text" name="email_confirm_field" style="display:none !important;" tabindex="-1" autocomplete="off" />
|
||||
${rcEnabled ? '<div id="gate-recaptcha" style="margin:4px 0;transform-origin:left top;"></div>' : ''}
|
||||
${_rcEnabled ? '<div id="gate-recaptcha" style="margin:4px 0;transform-origin:left top;"></div>' : ''}
|
||||
<button type="submit" id="gate-register-btn" style="background:#0051c3;color:white;border:none;padding:9px;font-weight:600;font-size:14px;cursor:pointer;font-family:inherit;"
|
||||
onmouseover="this.style.background='#003681'" onmouseout="if(!this.disabled)this.style.background='#0051c3'">Create account</button>
|
||||
<p style="text-align:center;font-size:0.85em;margin:6px 0 0;color:#555;">
|
||||
@@ -266,9 +264,8 @@ function getGateLoginInjection(req) {
|
||||
if (_sb.length > 12) _sb = _sb.slice(-12);
|
||||
});
|
||||
</script>
|
||||
${rcEnabled ? '<script src="https://www.google.com/recaptcha/api.js?onload=onRecaptchaGateReady&render=explicit" async defer><\/script>' : ''}
|
||||
${_rcEnabled ? '<script src="https://www.google.com/recaptcha/api.js?onload=onRecaptchaGateReady&render=explicit" async defer><\/script>' : ''}
|
||||
`;
|
||||
}
|
||||
|
||||
|
||||
// Text injected into the "What can I do?" section
|
||||
@@ -285,40 +282,11 @@ try {
|
||||
}
|
||||
|
||||
// Called on every gated request — produces a fresh page with unique Ray ID + timestamp
|
||||
// Accepts an optional request object to inject the visitor's real IP into the footer reveal and dynamic host into page text/title.
|
||||
// Accepts an optional request object to inject the visitor's real IP into the footer reveal.
|
||||
function buildGatePage(req) {
|
||||
if (!_cfRender) return nginx502Fallback;
|
||||
|
||||
let reqHost = null;
|
||||
if (req && req.headers) {
|
||||
const rawHost = req.headers['x-forwarded-host'] || req.headers['host'];
|
||||
if (rawHost) {
|
||||
const firstHost = rawHost.split(',')[0].trim();
|
||||
let extracted = '';
|
||||
if (firstHost.startsWith('[')) {
|
||||
const closeBracket = firstHost.indexOf(']');
|
||||
extracted = closeBracket !== -1 ? firstHost.substring(1, closeBracket) : firstHost;
|
||||
} else {
|
||||
extracted = firstHost.split(':')[0].trim();
|
||||
}
|
||||
const isLocalHost = ['localhost', '127.0.0.1', '::1', 'f0ckm', '0.0.0.0', 'localhost.localdomain'].includes(extracted.toLowerCase());
|
||||
if (extracted && !isLocalHost) {
|
||||
reqHost = extracted;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!reqHost) reqHost = cfg.main.url.domain;
|
||||
|
||||
const currentGateOptions = {
|
||||
...gateOptions,
|
||||
host_status: {
|
||||
...gateOptions.host_status,
|
||||
location: reqHost,
|
||||
},
|
||||
what_can_i_do: gateSignInButton,
|
||||
};
|
||||
|
||||
let html = _cfRender(currentGateOptions);
|
||||
let html = _cfRender({ ...gateOptions, what_can_i_do: gateSignInButton });
|
||||
|
||||
// Inject real visitor IP into the footer "Your IP: [Click to reveal]" span
|
||||
if (req) {
|
||||
@@ -337,9 +305,9 @@ function buildGatePage(req) {
|
||||
// Patch the <title> to include the domain — matches real Cloudflare behaviour
|
||||
html = html.replace(
|
||||
'<title>502: Bad Gateway</title>',
|
||||
`<title>${reqHost} | 502: Bad gateway</title>`
|
||||
`<title>${cfg.main.url.domain} | 502: Bad gateway</title>`
|
||||
);
|
||||
html = html.replace('</body>', getGateLoginInjection(req) + '\n</body>');
|
||||
html = html.replace('</body>', gateLoginInjection + '\n</body>');
|
||||
return html;
|
||||
}
|
||||
|
||||
@@ -348,14 +316,7 @@ const nginx502 = (cfg.websrv.private_society && cfg.websrv.private_society_gate
|
||||
? null
|
||||
: nginx502Fallback;
|
||||
|
||||
// Custom gate template — resolved once at boot from config
|
||||
// Set private_society_gate: "custom" and private_society_gate_template: "your-template-name" (no .html)
|
||||
const _customGateTemplate = (cfg.websrv.private_society && cfg.websrv.private_society_gate === 'custom' && cfg.websrv.private_society_gate_template)
|
||||
? String(cfg.websrv.private_society_gate_template).replace(/\.html$/i, '')
|
||||
: null;
|
||||
|
||||
if (nginx502 === null) console.log('[BOOT] Private society gate: Cloudflare dynamic mode');
|
||||
if (_customGateTemplate) console.log(`[BOOT] Private society gate: Custom template → views/${_customGateTemplate}.html (flummpress resolves extension)`);
|
||||
// ─────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
|
||||
@@ -495,22 +456,6 @@ process.on('uncaughtException', err => {
|
||||
res.setHeader('Permissions-Policy', 'geolocation=(), microphone=(), camera=()');
|
||||
// Encourage connection reuse — helps external tools like ShareX avoid repeated TCP/TLS handshakes
|
||||
res.setHeader('Connection', 'keep-alive');
|
||||
|
||||
// Block incoming requests to .onion if Tor Hidden Service is explicitly disabled in config
|
||||
if (cfg.websrv?.enable_tor_hs === false && lib.isOnionRequest(req)) {
|
||||
res.writeHead(503).end();
|
||||
req.url.pathname = '/tor_hs_disabled_bypass';
|
||||
return;
|
||||
}
|
||||
|
||||
// Tor Onion-Location header: advertises .onion service counterpart to Tor Browser users when enabled
|
||||
if (cfg.websrv?.enable_tor_hs !== false && cfg.main?.onion && !lib.isOnionRequest(req)) {
|
||||
const p = req.url?.pathname || '/';
|
||||
const s = req.url?.search || '';
|
||||
const onionHost = cfg.main.onion.replace(/\/+$/, '');
|
||||
res.setHeader('Onion-Location', `${onionHost}${p}${s}`);
|
||||
}
|
||||
|
||||
if (isSecure) {
|
||||
res.setHeader('Strict-Transport-Security', 'max-age=31536000; includeSubDomains');
|
||||
}
|
||||
@@ -856,21 +801,18 @@ process.on('uncaughtException', err => {
|
||||
req.url.pathname = '/private_society_bypass';
|
||||
return;
|
||||
}
|
||||
// For page requests, serve the gate for all paths (custom template or fallback)
|
||||
if (_customGateTemplate) {
|
||||
res.writeHead(200, { 'Content-Type': 'text/html' }).end(tpl.render(_customGateTemplate, {}, req));
|
||||
} else if (req.url.pathname !== '/') {
|
||||
// Non-home paths: always show the static/cloudflare gate
|
||||
// For page requests, return 502 Bad Gateway for all paths except homepage (which shows the gate)
|
||||
if (req.url.pathname !== '/') {
|
||||
res.writeHead(200, { 'Content-Type': 'text/html' }).end(nginx502 ?? buildGatePage(req));
|
||||
} else if (nginx502 === null) {
|
||||
// Homepage in cloudflare dynamic mode: serve the CF gate directly
|
||||
res.writeHead(200, { 'Content-Type': 'text/html' }).end(buildGatePage(req));
|
||||
} else {
|
||||
// Homepage in plain nginx mode: fall through to index.html template
|
||||
req.url.pathname = '/private_society_bypass';
|
||||
return;
|
||||
}
|
||||
// Homepage: in cloudflare dynamic mode serve gate directly; otherwise fall through to template
|
||||
if (nginx502 === null) {
|
||||
res.writeHead(200, { 'Content-Type': 'text/html' }).end(buildGatePage(req));
|
||||
req.url.pathname = '/private_society_bypass';
|
||||
return;
|
||||
}
|
||||
req.url.pathname = '/private_society_bypass';
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -1350,7 +1292,6 @@ process.on('uncaughtException', err => {
|
||||
show_mime_picker: cfg.websrv.show_mime_picker !== false,
|
||||
private_society: cfg.websrv.private_society || false,
|
||||
private_society_gate: cfg.websrv.private_society_gate || '',
|
||||
private_society_gate_location: cfg.websrv.private_society_gate_location || 'Frankfurt',
|
||||
show_content_warning: cfg.websrv.show_content_warning !== false,
|
||||
web_url_upload: !!cfg.websrv.web_url_upload,
|
||||
enable_youtube_upload: cfg.websrv.enable_youtube_upload !== false,
|
||||
@@ -1462,39 +1403,26 @@ process.on('uncaughtException', err => {
|
||||
}
|
||||
}
|
||||
|
||||
// Resolve per-request recaptcha preference (disabled for .onion requests or when passed false)
|
||||
const effectiveReq = req || (data && data.req);
|
||||
const defaultRecaptcha = !!(cfg.recaptcha && cfg.recaptcha.enabled && cfg.recaptcha.site_key);
|
||||
let perRequestRecaptcha = defaultRecaptcha;
|
||||
|
||||
if (effectiveReq && lib.isOnionRequest(effectiveReq)) {
|
||||
perRequestRecaptcha = false;
|
||||
} else if (data && typeof data.recaptcha_enabled === 'boolean') {
|
||||
perRequestRecaptcha = data.recaptcha_enabled;
|
||||
}
|
||||
|
||||
// Build data: globals first, then caller-supplied data, then per-request i18n last
|
||||
// so t/lang always reflect the user's language, not the site default.
|
||||
// ALSO mutate globals.t, globals.lang, globals.recaptcha_enabled: flummpress spreads this.#globals LAST
|
||||
// ALSO mutate globals.t and globals.lang: flummpress spreads this.#globals LAST
|
||||
// inside render(), so globals must carry the per-request values too.
|
||||
globals.t = perRequestT;
|
||||
globals.lang = perRequestLang;
|
||||
globals.recaptcha_enabled = perRequestRecaptcha;
|
||||
|
||||
// Resolve per-request infobox preference
|
||||
// Guests always get false — the alternative infobox is a logged-in user preference only
|
||||
const activeReq = req || effectiveReq;
|
||||
const useAltInfobox = (activeReq && activeReq.session && typeof activeReq.session.use_alternative_infobox === 'boolean')
|
||||
? activeReq.session.use_alternative_infobox
|
||||
: (activeReq && !activeReq.session
|
||||
const useAltInfobox = (req && req.session && typeof req.session.use_alternative_infobox === 'boolean')
|
||||
? req.session.use_alternative_infobox
|
||||
: (req && !req.session
|
||||
? false
|
||||
: (data && typeof data.user_alternative_infobox === 'boolean'
|
||||
? data.user_alternative_infobox
|
||||
: (cfg.websrv.user_alternative_infobox !== false)));
|
||||
|
||||
const useAltSteuerung = (activeReq && activeReq.session && typeof activeReq.session.use_alternative_steuerung === 'boolean')
|
||||
? activeReq.session.use_alternative_steuerung
|
||||
: (activeReq && !activeReq.session
|
||||
const useAltSteuerung = (req && req.session && typeof req.session.use_alternative_steuerung === 'boolean')
|
||||
? req.session.use_alternative_steuerung
|
||||
: (req && !req.session
|
||||
? false
|
||||
: (data && typeof data.user_alternative_steuerung === 'boolean'
|
||||
? data.user_alternative_steuerung
|
||||
@@ -1503,12 +1431,11 @@ process.on('uncaughtException', err => {
|
||||
data = Object.assign({}, globals, data || {}, {
|
||||
t: perRequestT,
|
||||
lang: perRequestLang,
|
||||
recaptcha_enabled: perRequestRecaptcha,
|
||||
user_alternative_infobox: useAltInfobox,
|
||||
user_alternative_steuerung: useAltSteuerung,
|
||||
user_banner_enabled: cfg.websrv.user_banner_enabled !== false,
|
||||
comment_display_mode: (activeReq && activeReq.session && typeof activeReq.session.comment_display_mode === 'number')
|
||||
? activeReq.session.comment_display_mode
|
||||
comment_display_mode: (req && req.session && typeof req.session.comment_display_mode === 'number')
|
||||
? req.session.comment_display_mode
|
||||
: (data && typeof data.comment_display_mode === 'number'
|
||||
? data.comment_display_mode
|
||||
: (cfg.websrv.default_comment_display_mode || 0))
|
||||
@@ -1520,19 +1447,17 @@ process.on('uncaughtException', err => {
|
||||
data.custom_brand_image = brand[Math.floor(Math.random() * brand.length)];
|
||||
}
|
||||
|
||||
if (activeReq) {
|
||||
data.recaptcha_enabled = perRequestRecaptcha;
|
||||
if (activeReq.mode !== undefined) data.mode = activeReq.mode;
|
||||
data.theme = activeReq.theme || activeReq.cookies?.theme || cfg.websrv.theme || 'f0ck';
|
||||
if (!data.url) data.url = activeReq.url;
|
||||
data.user_strict_bool = (activeReq.session && activeReq.session.strict_mode) ? true : false;
|
||||
data.user_logged_in_bool = !!activeReq.session;
|
||||
data.csrf_token = activeReq.session?.csrf_token || '';
|
||||
data.max_file_size = lib.formatSize(cfg.main.maxfilesize * (activeReq.session?.admin ? cfg.main.adminmultiplier : 1));
|
||||
data.max_file_size_bytes = Math.floor(cfg.main.maxfilesize * (activeReq.session?.admin ? cfg.main.adminmultiplier : 1));
|
||||
if (req) {
|
||||
if (req.mode !== undefined) data.mode = req.mode;
|
||||
data.theme = req.theme || req.cookies?.theme || cfg.websrv.theme || 'f0ck';
|
||||
if (!data.url) data.url = req.url;
|
||||
data.user_strict_bool = (req.session && req.session.strict_mode) ? true : false;
|
||||
data.user_logged_in_bool = !!req.session;
|
||||
data.csrf_token = req.session?.csrf_token || '';
|
||||
data.max_file_size = lib.formatSize(cfg.main.maxfilesize * (req.session?.admin ? cfg.main.adminmultiplier : 1));
|
||||
data.max_file_size_bytes = Math.floor(cfg.main.maxfilesize * (req.session?.admin ? cfg.main.adminmultiplier : 1));
|
||||
data.web_url_upload = data.web_url_upload !== undefined ? data.web_url_upload : !!cfg.websrv.web_url_upload;
|
||||
} else {
|
||||
data.recaptcha_enabled = perRequestRecaptcha;
|
||||
data.theme = data.theme || cfg.websrv.theme || 'f0ck';
|
||||
data.user_strict_bool = false;
|
||||
data.user_logged_in_bool = false;
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
<!doctype html>
|
||||
<html theme="@if(typeof theme !== 'undefined'){{ theme }}@else{{ default_theme || 'amoled' }}@endif">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>{{ domain }}</title>
|
||||
<link rel="icon" type="image/gif" href="/s/img/favicon.gif" />
|
||||
<link rel="stylesheet" id="injected-gate-styles" href="/s/css/f0ckm.css?v={{ ts }}">
|
||||
</head>
|
||||
<body class="{{ default_layout === 'legacy' ? 'layout-legacy' : 'layout-modern' }}">
|
||||
|
||||
<div class="wrapper" style="text-align: center;">
|
||||
<h2>Example Gate</h2>
|
||||
<button type="button" onclick="openLoginGate();">Login</button>
|
||||
|
||||
<div id="gate-container" style="display:none;">
|
||||
@include(snippets/navbar)
|
||||
@include(snippets/footer)
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function openLoginGate() {
|
||||
document.getElementById('gate-container').style.display = 'block';
|
||||
const tryOpen = () => {
|
||||
const m = document.getElementById('login-modal');
|
||||
if (m) { m.style.display = 'flex'; }
|
||||
else { setTimeout(tryOpen, 50); }
|
||||
};
|
||||
tryOpen();
|
||||
}
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -319,7 +319,7 @@
|
||||
ModAction.confirm('Verify User', 'Manually verify account for <strong>' + escHTML(userName) + '</strong>?', async () => {
|
||||
var res = await fetch('/api/v2/admin/users/activate', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': window.f0ckSession?.csrf_token },
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ user_id: id })
|
||||
});
|
||||
var data = await res.json();
|
||||
@@ -339,7 +339,7 @@
|
||||
ModAction.confirm('Ban User', 'Reason for banning <strong>' + escHTML(userName) + '</strong>?', async (reason) => {
|
||||
var res = await fetch('/api/v2/admin/ban', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': window.f0ckSession?.csrf_token },
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ user_id: id, reason: reason, duration: 'permanent' })
|
||||
});
|
||||
var data = await res.json();
|
||||
@@ -359,7 +359,7 @@
|
||||
ModAction.confirm('Unban User', 'Unban account for <strong>' + escHTML(userName) + '</strong>?', async () => {
|
||||
var res = await fetch('/api/v2/admin/unban', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': window.f0ckSession?.csrf_token },
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ user_id: id })
|
||||
});
|
||||
var data = await res.json();
|
||||
@@ -379,7 +379,7 @@
|
||||
ModAction.confirm('Delete Uploads', 'Are you SURE you want to delete ALL uploads by <strong>' + escHTML(userName) + '</strong>? This cannot be undone.', async () => {
|
||||
var res = await fetch('/api/v2/admin/users/bulk-delete-items', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': window.f0ckSession?.csrf_token },
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ user_id: id, username: btn.dataset.username })
|
||||
});
|
||||
var data = await res.json();
|
||||
@@ -398,7 +398,7 @@
|
||||
ModAction.confirm('Delete Comments', 'Are you SURE you want to delete ALL comments by <strong>' + escHTML(userName) + '</strong>? This will be permanent.', async () => {
|
||||
var res = await fetch('/api/v2/admin/users/bulk-delete-comments', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': window.f0ckSession?.csrf_token },
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ user_id: id, username: btn.dataset.username })
|
||||
});
|
||||
var data = await res.json();
|
||||
@@ -422,7 +422,7 @@
|
||||
ModAction.confirm('Set Display Name', hint, async (newName) => {
|
||||
var res = await fetch('/api/v2/admin/users/set-display-name', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': window.f0ckSession?.csrf_token },
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ user_id: id, display_name: newName || '' })
|
||||
});
|
||||
var data = await res.json();
|
||||
@@ -457,7 +457,7 @@
|
||||
ModAction.confirm('Unlock Layout', 'Unlock comment layout for <strong>' + escHTML(userName) + '</strong>? They will be able to change it again.', async () => {
|
||||
var res = await fetch('/api/v2/admin/users/lock-layout', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': window.f0ckSession?.csrf_token },
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ user_id: id, lock: false })
|
||||
});
|
||||
var data = await res.json();
|
||||
@@ -481,7 +481,7 @@
|
||||
var mode = document.getElementById('force-mode-select').value;
|
||||
var res = await fetch('/api/v2/admin/users/lock-layout', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': window.f0ckSession?.csrf_token },
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ user_id: id, lock: true, mode: mode })
|
||||
});
|
||||
var data = await res.json();
|
||||
@@ -616,7 +616,7 @@
|
||||
try {
|
||||
var res = await fetch('/api/v2/admin/users/create', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': window.f0ckSession?.csrf_token },
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ username, email: email || null, password, role })
|
||||
});
|
||||
var data = await res.json();
|
||||
@@ -662,7 +662,7 @@
|
||||
var role = selectEl.value;
|
||||
var res = await fetch('/api/v2/admin/users/set-role', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': window.f0ckSession?.csrf_token },
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ user_id: id, role })
|
||||
});
|
||||
var data = await res.json();
|
||||
|
||||
9
views/chat.html
Normal file
9
views/chat.html
Normal file
@@ -0,0 +1,9 @@
|
||||
@include(snippets/header)
|
||||
<div class="pagewrapper">
|
||||
<div id="main" class="chat-page">
|
||||
<div id="site-chat-container" class="site-chat-container">
|
||||
<!-- Site chat widget is mounted here by globalchat.js -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@include(snippets/footer)
|
||||
@@ -296,7 +296,7 @@
|
||||
@if(item.src.short)
|
||||
<tr>
|
||||
<th>{{ t('info_modal.source') || 'Source' }}</th>
|
||||
<td><a href="{{ item.src.long }}" target="_blank" style="word-break: break-all;">{{ item.src.short }}</a></td>
|
||||
<td><a href="{{ item.src.long }}" target="_blank">{{ item.src.short }}</a></td>
|
||||
</tr>
|
||||
@endif
|
||||
</table>
|
||||
|
||||
@@ -238,7 +238,7 @@
|
||||
@if(item.src.short)
|
||||
<tr>
|
||||
<th>{{ t('info_modal.source') || 'Source' }}</th>
|
||||
<td><a href="{{ item.src.long }}" target="_blank" style="word-break: break-all;">{{ item.src.short }}</a></td>
|
||||
<td><a href="{{ item.src.long }}" target="_blank">{{ item.src.short }}</a></td>
|
||||
</tr>
|
||||
@endif
|
||||
</table>
|
||||
|
||||
@@ -26,6 +26,9 @@
|
||||
</div>
|
||||
@endif
|
||||
<a href="/tags" title="{{ t('nav.tags') }}"><i class="fa-solid fa-tags"></i></a>
|
||||
@if(enable_global_chat)
|
||||
<a href="/chat" title="{{ t('nav.chat') }}"><i class="fa-solid fa-comments"></i></a>
|
||||
@endif
|
||||
@if(abyss_enabled)
|
||||
<a href="/abyss" title="{{ t('nav.abyss') }}"><i class="fa-solid fa-dice-d6"></i></a>
|
||||
@endif
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
<div class="profile_head_username">
|
||||
<div style="display: flex; justify-content: space-between; align-items: flex-start; gap: 10px;">
|
||||
<div style="flex: 1; min-width: 0; word-break: break-word; line-height: 1.2; align-self: flex-start; margin-top: 0; display: flex; align-items: center; gap: 5px;" id="profile-name-container">
|
||||
<span id="profile-display-name" @if(user.username_color) style="color: {{ user.username_color }}" @endif>@if(user.admin)⚡ @elseif(user.is_moderator)🛡 @endif{!! user.display_name || user.user !!}@if(user.is_ghost) <span class="badge badge-secondary" style="font-size: 0.5em; vertical-align: middle; background-color: #5bc0de; color: #fff; padding: 2px 5px; border-radius: 3px; margin-left: 5px;">LEGACY</span>@endif @if(user.banned) <span class="badge badge-danger" tooltip="{{ user.ban_duration }}" style="font-size: 0.5em; vertical-align: middle; background-color: #d9534f; color: #fff; padding: 2px 5px; border-radius: 3px; margin-left: 5px;">BANNED</span>@endif</span>@if(user.display_name) <span style="font-size: 0.65em; color: #666; font-weight: 400; margin-left: 5px; letter-spacing: 0.5px;" id="username-bracket">({!! user.user !!})</span>@endif
|
||||
<span id="nav-display-name" @if(user.username_color) style="color: {{ user.username_color }}" @endif>@if(user.admin)⚡ @elseif(user.is_moderator)🛡 @endif{!! user.display_name || user.user !!}@if(user.is_ghost) <span class="badge badge-secondary" style="font-size: 0.5em; vertical-align: middle; background-color: #5bc0de; color: #fff; padding: 2px 5px; border-radius: 3px; margin-left: 5px;">LEGACY</span>@endif @if(user.banned) <span class="badge badge-danger" tooltip="{{ user.ban_duration }}" style="font-size: 0.5em; vertical-align: middle; background-color: #d9534f; color: #fff; padding: 2px 5px; border-radius: 3px; margin-left: 5px;">BANNED</span>@endif</span>@if(user.display_name) <span style="font-size: 0.65em; color: #666; font-weight: 400; margin-left: 5px; letter-spacing: 0.5px;" id="username-bracket">({!! user.user !!})</span>@endif
|
||||
@if(session && session.id === user.user_id)
|
||||
<button id="inline-name-edit-btn" style="background: transparent; border:none; color: var(--text-muted); cursor: pointer; font-size: 0.7em; padding: 0;" title="Edit Name & Color">
|
||||
<i class="fa-solid fa-pen"></i>
|
||||
@@ -509,27 +509,18 @@
|
||||
nameContainer.style.display = 'flex';
|
||||
nameEditContainer.style.display = 'none';
|
||||
|
||||
const updateNameNode = (el, text) => {
|
||||
if (!el) return;
|
||||
for (let i = el.childNodes.length - 1; i >= 0; i--) {
|
||||
let node = el.childNodes[i];
|
||||
const nameSpan = document.getElementById('nav-display-name');
|
||||
if (nameSpan) {
|
||||
nameSpan.style.color = color;
|
||||
for (let i = nameSpan.childNodes.length - 1; i >= 0; i--) {
|
||||
let node = nameSpan.childNodes[i];
|
||||
if (node.nodeType === Node.TEXT_NODE && node.nodeValue.trim().length > 0) {
|
||||
const match = node.nodeValue.match(new RegExp('^(\\s*)(.*)'));
|
||||
node.nodeValue = (match ? match[1] : '') + text;
|
||||
// Match and preserve any non-breaking spaces at the start (from admin/mod badges)
|
||||
const match = node.nodeValue.match(new RegExp('^(\\\\s*)(.*)'));
|
||||
node.nodeValue = (match ? match[1] : '') + (displayName ? displayName : '{{ user.user }}');
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
const targetName = displayName ? displayName : '{{ user.user }}';
|
||||
const profileSpan = document.getElementById('profile-display-name');
|
||||
if (profileSpan) {
|
||||
profileSpan.style.color = color;
|
||||
updateNameNode(profileSpan, targetName);
|
||||
}
|
||||
const navSpan = document.getElementById('nav-display-name');
|
||||
if (navSpan) {
|
||||
navSpan.style.color = color;
|
||||
updateNameNode(navSpan, targetName);
|
||||
}
|
||||
const bracket = document.getElementById('username-bracket');
|
||||
if (bracket) {
|
||||
|
||||
Reference in New Issue
Block a user