diff --git a/migrations/f0ckm_schema.sql b/migrations/f0ckm_schema.sql index 32009f4..e0c76f1 100644 --- a/migrations/f0ckm_schema.sql +++ b/migrations/f0ckm_schema.sql @@ -580,6 +580,48 @@ ALTER SEQUENCE public.comments_id_seq OWNER TO f0ckm; ALTER SEQUENCE public.comments_id_seq OWNED BY public.comments.id; +-- +-- Name: comment_files; Type: TABLE; Schema: public; Owner: f0ckm +-- + +CREATE TABLE public.comment_files ( + id integer NOT NULL, + comment_id integer, + user_id integer NOT NULL, + dest character varying(40) NOT NULL, + mime character varying(100) NOT NULL, + size integer NOT NULL, + checksum character varying(255) NOT NULL, + phash text, + original_filename text, + created_at timestamp with time zone DEFAULT now() +); + + +ALTER TABLE public.comment_files OWNER TO f0ckm; + +-- +-- Name: comment_files_id_seq; Type: SEQUENCE; Schema: public; Owner: f0ckm +-- + +CREATE SEQUENCE public.comment_files_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER SEQUENCE public.comment_files_id_seq OWNER TO f0ckm; + +-- +-- Name: comment_files_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: f0ckm +-- + +ALTER SEQUENCE public.comment_files_id_seq OWNED BY public.comment_files.id; + + -- -- Name: custom_emojis; Type: TABLE; Schema: public; Owner: f0ckm -- diff --git a/public/s/css/f0ckm.css b/public/s/css/f0ckm.css index 3a5b2b4..08a8aae 100644 --- a/public/s/css/f0ckm.css +++ b/public/s/css/f0ckm.css @@ -2354,6 +2354,144 @@ body.layout-modern .item-sidebar-left .tag-controls { font-weight: bold; } +/* ─── Comment File Upload ─────────────────────────────────────────────────── */ + +.comment-attach-btn { + background: none; + border: 1px solid var(--nav-border-color); + color: #888; + cursor: pointer; + padding: 4px 8px; + display: flex; + align-items: center; + justify-content: center; + transition: color 0.15s, border-color 0.15s; + font-size: 14px; +} + +.comment-attach-btn:hover { + color: var(--accent); + border-color: var(--accent); +} + +.comment-file-preview { + display: flex; + flex-wrap: wrap; + gap: 6px; + padding: 0; +} + +.comment-file-preview:empty { + display: none; +} + +.cf-preview-item { + position: relative; + display: flex; + align-items: center; + gap: 6px; + background: rgba(255, 255, 255, 0.06); + border: 1px solid rgba(255, 255, 255, 0.1); + padding: 4px 6px; + max-width: 220px; +} + +.cf-preview-item img, +.cf-preview-item video { + width: 48px; + height: 48px; + object-fit: cover; + flex-shrink: 0; +} + +.cf-preview-item i.fa-music { + width: 48px; + height: 48px; + display: flex; + align-items: center; + justify-content: center; + background: rgba(255, 255, 255, 0.05); + color: var(--accent); + font-size: 20px; + flex-shrink: 0; +} + +.cf-filename { + font-size: 0.75em; + color: #aaa; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + max-width: 110px; +} + +.cf-remove-btn { + background: none; + border: none; + color: #888; + cursor: pointer; + padding: 2px; + font-size: 12px; + flex-shrink: 0; + transition: color 0.15s; +} + +.cf-remove-btn:hover { + color: #ff4444; +} + +.cf-preview-item.cf-uploading { + opacity: 0.6; +} + +.cf-preview-item.cf-uploading .fa-spinner { + width: 48px; + height: 48px; + display: flex; + align-items: center; + justify-content: center; + font-size: 18px; + color: var(--accent); +} + +/* ─── Comment Attachments (rendered below comment content) ────────────────── */ + +.comment-attachments { + display: flex; + flex-wrap: wrap; + gap: 6px; + margin-top: 8px; +} + +.cf-attachment { + display: inline-block; + max-width: 100%; +} + +.cf-attachment.cf-image img { + max-width: 300px; + max-height: 220px; + object-fit: contain; + border: 1px solid rgba(255, 255, 255, 0.08); + cursor: pointer; + transition: opacity 0.15s; +} + +.cf-attachment.cf-image img:hover { + opacity: 0.85; +} + +.cf-attachment.cf-video video { + max-width: 400px; + max-height: 280px; + border: 1px solid rgba(255, 255, 255, 0.08); +} + +.cf-attachment.cf-audio audio { + width: 100%; + max-width: 350px; +} + .comments-list { display: flex; @@ -8092,7 +8230,7 @@ span.badge.badge-current { .comment-content img:not(.emoji) { display: block; - + cursor: pointer; } /* Smaller emojis in the narrow left sidebar */ diff --git a/public/s/js/comments.js b/public/s/js/comments.js index 5dc0e15..9b3a4f8 100644 --- a/public/s/js/comments.js +++ b/public/s/js/comments.js @@ -1858,6 +1858,7 @@ class CommentSystem { ${timeAgo}
${content}
+ ${this.renderCommentAttachments(comment.files)}