Changeset e2c3d09 in Klonkt
- Timestamp:
- 07/31/2026 12:33:18 PM (6 weeks ago)
- Branches:
- main
- Children:
- 2dd1dc4
- Parents:
- 859b1707
- Location:
- src
- Files:
-
- 1 added
- 8 edited
-
config/paths.js (added)
-
routes/account.js (modified) (2 diffs)
-
routes/activitypub.js (modified) (2 diffs)
-
routes/admin-audio.js (modified) (2 diffs)
-
routes/admin-media.js (modified) (2 diffs)
-
routes/admin-playlists.js (modified) (1 diff)
-
routes/admin-settings.js (modified) (3 diffs)
-
routes/admin-sites.js (modified) (2 diffs)
-
routes/posts.js (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/routes/account.js
r859b1707 re2c3d09 16 16 import path from 'path'; 17 17 import fs from 'fs'; 18 import { fileURLToPath } from 'url';19 18 import bcrypt from 'bcryptjs'; 20 19 import multer from 'multer'; … … 28 27 import { toWebp } from '../services/ImageWebpService.js'; 29 28 import { SUPPORTED } from '../services/i18n.js'; 30 31 const __dirname = path.dirname(fileURLToPath(import.meta.url)); 32 const AVATAR_DIR = path.resolve( 33 process.env.AVATAR_PATH || path.join(__dirname, '..', '..', 'storage', 'media', 'avatars') 34 ); 29 import { mediaDir } from '../config/paths.js'; 30 31 const AVATAR_DIR = mediaDir('AVATAR_PATH', 'avatars'); 35 32 fs.mkdirSync(AVATAR_DIR, { recursive: true }); 36 33 -
src/routes/activitypub.js
r859b1707 re2c3d09 23 23 import path from 'path'; 24 24 import fs from 'fs'; 25 import { fileURLToPath } from 'url';26 25 import { randomUUID } from 'crypto'; 26 import { mediaDir } from '../config/paths.js'; 27 27 28 28 const router = express.Router(); … … 422 422 // AP convention) into the same store the reply editor uses, and gets back 423 423 // { url, mediaType, name } to attach on a note (e.g. the help-buoy capture). 424 const AP_MEDIA_DIR = path.resolve( 425 process.env.REPLY_MEDIA_PATH || 426 path.join(path.dirname(fileURLToPath(import.meta.url)), '..', '..', 'storage', 'media', 'reply-media') 427 ); 424 const AP_MEDIA_DIR = mediaDir('REPLY_MEDIA_PATH', 'reply-media'); 428 425 fs.mkdirSync(AP_MEDIA_DIR, { recursive: true }); 429 426 const AP_MEDIA_EXT = new Set(['.jpg', '.jpeg', '.png', '.webp', '.gif', '.mp3', '.m4a', '.ogg', '.opus', '.flac', '.wav', '.mp4', '.webm', '.mov']); -
src/routes/admin-audio.js
r859b1707 re2c3d09 22 22 import { transcodeToMp3, retagMp3 } from '../services/AudioTranscoder.js'; 23 23 import { audioUrl } from '../services/AudioStreamService.js'; 24 import { mediaDir } from '../config/paths.js'; 24 25 25 26 const __dirname = path.dirname(fileURLToPath(import.meta.url)); … … 30 31 process.env.AUDIO_PATH || path.join(__dirname, '..', '..', 'storage', 'audio') 31 32 ); 32 const COVER_DIR = path.resolve( 33 process.env.COVER_PATH || path.join(__dirname, '..', '..', 'storage', 'media', 'audio-covers') 34 ); 33 const COVER_DIR = mediaDir('COVER_PATH', 'audio-covers'); 35 34 fs.mkdirSync(AUDIO_DIR, { recursive: true }); 36 35 fs.mkdirSync(COVER_DIR, { recursive: true }); -
src/routes/admin-media.js
r859b1707 re2c3d09 10 10 import path from 'path'; 11 11 import fs from 'fs'; 12 import { fileURLToPath } from 'url';13 12 import db from '../config/database.js'; 14 13 import { renderPage } from '../middleware/render.js'; 15 14 import { requireGod } from '../middleware/auth.js'; 16 15 import { audioEnabled } from '../config/features.js'; 16 import { mediaDir } from '../config/paths.js'; 17 17 18 const __dirname = path.dirname(fileURLToPath(import.meta.url)); 19 const POST_IMAGES_DIR = path.resolve( 20 process.env.POST_IMAGES_PATH || path.join(__dirname, '..', '..', 'storage', 'media', 'post-images') 21 ); 18 const POST_IMAGES_DIR = mediaDir('POST_IMAGES_PATH', 'post-images'); 22 19 23 20 const router = express.Router(); … … 27 24 // C2S uploads (Shaer's composer and the help buoy) land here; the videos among 28 25 // them are what the Video tab shows. 29 const REPLY_MEDIA_DIR = path.resolve( 30 process.env.REPLY_MEDIA_PATH || path.join(__dirname, '..', '..', 'storage', 'media', 'reply-media') 31 ); 26 const REPLY_MEDIA_DIR = mediaDir('REPLY_MEDIA_PATH', 'reply-media'); 32 27 const isSibling = (f) => /-v\.(mp4|jpg)$/i.test(f); // an animated cover's video/poster sibling 33 28 -
src/routes/admin-playlists.js
r859b1707 re2c3d09 23 23 import { requireGod } from '../middleware/auth.js'; 24 24 import PlaylistService from '../services/PlaylistService.js'; 25 import { mediaDir } from '../config/paths.js'; 25 26 26 27 // Cover storage — same convention as track covers so a single physical 27 28 // directory holds all album/track artwork. Existing covers in the DB 28 29 // already point at /media/audio-covers/<filename> so we reuse the path. 29 const __dirname = path.dirname(new URL(import.meta.url).pathname); 30 const COVER_DIR = path.resolve( 31 process.env.COVER_PATH || path.join(__dirname, '..', '..', 'storage', 'media', 'audio-covers') 32 ); 30 const COVER_DIR = mediaDir('COVER_PATH', 'audio-covers'); 33 31 fs.mkdirSync(COVER_DIR, { recursive: true }); 34 32 -
src/routes/admin-settings.js
r859b1707 re2c3d09 16 16 import path from 'path'; 17 17 import fs from 'fs'; 18 import { fileURLToPath } from 'url';19 18 import multer from 'multer'; 20 19 import { v4 as uuid } from 'uuid'; … … 26 25 import { entitlementStatus, premiumUnlocked } from '../services/PatreonService.js'; 27 26 import { toWebp } from '../services/ImageWebpService.js'; 27 import { mediaDir } from '../config/paths.js'; 28 28 29 29 const router = express.Router(); … … 36 36 } 37 37 38 const __dirname = path.dirname(fileURLToPath(import.meta.url));39 38 // Hero uploads land in storage/media/hero → accessible as /media/hero/<file> 40 39 // (the /media static handler serves storage/media). Same model as avatars. 41 const HERO_DIR = path.resolve( 42 process.env.HERO_PATH || path.join(__dirname, '..', '..', 'storage', 'media', 'hero') 43 ); 40 const HERO_DIR = mediaDir('HERO_PATH', 'hero'); 44 41 fs.mkdirSync(HERO_DIR, { recursive: true }); 45 42 -
src/routes/admin-sites.js
r859b1707 re2c3d09 17 17 import path from 'path'; 18 18 import fs from 'fs'; 19 import { fileURLToPath } from 'url';20 19 import multer from 'multer'; 21 20 import { v4 as uuid } from 'uuid'; … … 26 25 import { listPlatforms, PLATFORMS } from '../services/PlatformIcons.js'; 27 26 import { toWebp } from '../services/ImageWebpService.js'; 28 29 const __dirname = path.dirname(fileURLToPath(import.meta.url)); 27 import { mediaDir } from '../config/paths.js'; 28 30 29 31 30 // Profile photos share the avatar directory with user avatars — same physical 32 31 // folder, same URL prefix. Filenames are uuid-prefixed so site photos and 33 32 // user avatars never collide. 34 const PHOTO_DIR = path.resolve( 35 process.env.AVATAR_PATH || path.join(__dirname, '..', '..', 'storage', 'media', 'avatars') 36 ); 33 const PHOTO_DIR = mediaDir('AVATAR_PATH', 'avatars'); 37 34 fs.mkdirSync(PHOTO_DIR, { recursive: true }); 38 35 -
src/routes/posts.js
r859b1707 re2c3d09 3 3 import path from 'path'; 4 4 import fs from 'fs'; 5 import { fileURLToPath } from 'url';6 5 import multer from 'multer'; 7 6 import ejs from 'ejs'; … … 25 24 import { verifyBlob } from '../services/CryptoBox.js'; 26 25 import MusicMeta from '../services/MusicMeta.js'; 27 28 const __dirname = path.dirname(fileURLToPath(import.meta.url)); 29 const POST_IMAGES_DIR = path.resolve( 30 process.env.POST_IMAGES_PATH || 31 path.join(__dirname, '..', '..', 'storage', 'media', 'post-images') 32 ); 26 import { mediaDir } from '../config/paths.js'; 27 28 const POST_IMAGES_DIR = mediaDir('POST_IMAGES_PATH', 'post-images'); 33 29 fs.mkdirSync(POST_IMAGES_DIR, { recursive: true }); 34 30 … … 38 34 // Rich replies: media dropped/pasted into the reply editor. Images, audio and 39 35 // video, stored as-is (no transcode; a reply attachment is not a track). 40 const REPLY_MEDIA_DIR = path.resolve( 41 process.env.REPLY_MEDIA_PATH || 42 path.join(__dirname, '..', '..', 'storage', 'media', 'reply-media') 43 ); 36 const REPLY_MEDIA_DIR = mediaDir('REPLY_MEDIA_PATH', 'reply-media'); 44 37 fs.mkdirSync(REPLY_MEDIA_DIR, { recursive: true }); 45 38 const ALLOWED_REPLY_MEDIA_EXT = new Set([
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)