mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-19 22:46:20 -05:00
Repos keeps local mirrors of git repositories, cloned over https and kept up to date on a schedule. - A Repo is a Collection (kind='repo') plus a `repository` row. The new `git` downloader clones it, then updates it (weekly by default, or Never: the clone is kept as it is and only updated on request). - Repos are saved in `repos/<tag>/<name>` (the Repos Directory, ignored by default) or a directory the user chooses. An existing clone can be imported where it is. repos.yaml is the source of truth. - A GitHub-like page shows each repo's README, files, and history, with a ZIP download. READMEs are searchable under the global search's Other tab. - git is hardened against hostile repos and configs: https only, pinned addresses with no private addresses (for the repo and its submodules), sanitized configs, no hooks or links, and only clones WROLPi made or imported are updated. - Tagging a Repo moves its clone as one directory. Repo changes wait for repos.yaml to be imported at startup. - The file mover groups unindexed files with no primary file as one FileGroup, and never replaces a file at the destination. A failed tag move restores the Collection's tag. A Collection's directory cannot leave the media directory. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
211 lines
8 KiB
JavaScript
211 lines
8 KiB
JavaScript
export const API_URI = process.env && process.env.REACT_APP_API_URI ? process.env.REACT_APP_API_URI : `https://${window.location.host}/api`;
|
|
export const VIDEOS_API = `${API_URI}/videos`;
|
|
export const ARCHIVES_API = `${API_URI}/archive`;
|
|
export const COLLECTIONS_API = `${API_URI}/collections`;
|
|
export const ZIM_API = `${API_URI}/zim`;
|
|
export const REPOS_API = `${API_URI}/repos`;
|
|
export const DEFAULT_LIMIT = 20;
|
|
export const NAME = process.env && process.env.REACT_APP_NAME ? process.env.REACT_APP_NAME : null;
|
|
|
|
// Other services on a WROLPi.
|
|
const port = window.location.port ? `${window.location.port.replace(/^/, '')}` : '';
|
|
export const FILES_MEDIA_URI = `https://${window.location.hostname}${port ? ':' + port : ''}/media/`;
|
|
export const MAP_VIEWER_URI = `https://${window.location.hostname}:8084`;
|
|
export const ZIM_VIEWER_URI = `https://${window.location.hostname}:8085`;
|
|
export const HELP_VIEWER_URI = `https://${window.location.hostname}:8086`;
|
|
// Docker: 8080; native: 80 (default, no port needed).
|
|
const controllerPort = window.location.port === '8443' ? ':8080' : '';
|
|
export const CONTROLLER_URI = `http://${window.location.hostname}${controllerPort}`;
|
|
export const API_ARCHIVE_UPLOAD_URI = `http://${window.location.hostname}:8081/api/archive/upload`;
|
|
|
|
export let defaultFileOrder = '-published_datetime'; // Most recently published files first.
|
|
export let defaultSearchOrder = 'rank'; // Most relevant files first.
|
|
|
|
// Download frequencies.
|
|
export const nullOption = {key: null, text: '', value: null};
|
|
export const onceOption = {key: 0, text: 'Once', value: 0};
|
|
export const hourlyOption = {key: 3600, text: 'Hourly', value: 3600};
|
|
export const threeHoursOption = {key: 10800, text: '3 hours', value: 10800};
|
|
export const twelveHoursOption = {key: 43200, text: '12 hours', value: 43200};
|
|
export const dailyOption = {key: 86400, text: 'Daily', value: 86400};
|
|
export const weeklyOption = {key: 604800, text: 'Weekly', value: 604800};
|
|
export const biweeklyOption = {key: 1209600, text: 'Biweekly', value: 1209600};
|
|
export const days30Option = {key: 2592000, text: '30 Days', value: 2592000};
|
|
export const days90Option = {key: 7776000, text: '90 Days', value: 7776000};
|
|
export const days180Option = {key: 15552000, text: '180 Days', value: 15552000};
|
|
|
|
export const frequencyOptions = [
|
|
dailyOption,
|
|
weeklyOption,
|
|
biweeklyOption,
|
|
days30Option,
|
|
days90Option,
|
|
];
|
|
|
|
export const longFrequencyOptions = [
|
|
dailyOption,
|
|
weeklyOption,
|
|
biweeklyOption,
|
|
days30Option,
|
|
days90Option,
|
|
days180Option,
|
|
];
|
|
|
|
export const channelFrequencyOptions = [
|
|
onceOption, // A Channel/Playlist can be downloaded once.
|
|
...longFrequencyOptions,
|
|
]
|
|
|
|
export const extendedFrequencyOptions = [
|
|
onceOption,
|
|
hourlyOption,
|
|
threeHoursOption,
|
|
twelveHoursOption,
|
|
...longFrequencyOptions,
|
|
];
|
|
|
|
export const allFrequencyOptions = {
|
|
[nullOption.value]: nullOption,
|
|
[onceOption.value]: onceOption,
|
|
[hourlyOption.value]: hourlyOption,
|
|
[threeHoursOption.value]: threeHoursOption,
|
|
[twelveHoursOption.value]: twelveHoursOption,
|
|
[dailyOption.value]: dailyOption,
|
|
[weeklyOption.value]: weeklyOption,
|
|
[biweeklyOption.value]: biweeklyOption,
|
|
[days30Option.value]: days30Option,
|
|
[days90Option.value]: days90Option,
|
|
[days180Option.value]: days180Option,
|
|
};
|
|
|
|
/*
|
|
* The named colors a user can pick for the navigation bar, and the fixed hex each one is.
|
|
*
|
|
* Fixed, and deliberately not tokens: these are the colors of the favicon files in
|
|
* `public/favicon-<color>.svg`, which `scripts/generate-favicons.js` writes from this very
|
|
* object, and of the `theme-color` meta tag the mobile browser paints its own chrome with.
|
|
* Neither can read a CSS variable, so both need a literal that cannot drift from the bar.
|
|
*
|
|
* The palette is a colorblind-friendly one and is shared with `themes/navColors.ts`, which
|
|
* measures a legible foreground against each.
|
|
*/
|
|
export const navColorHexMap = {
|
|
red: '#db2828',
|
|
orange: '#f2711c',
|
|
yellow: '#fbbd08',
|
|
olive: '#b5cc18',
|
|
green: '#21ba45',
|
|
teal: '#00b5ad',
|
|
blue: '#2185d0',
|
|
violet: '#6435c9',
|
|
purple: '#a333c8',
|
|
pink: '#e03997',
|
|
brown: '#a5673f',
|
|
grey: '#767676',
|
|
}
|
|
|
|
export const validUrlRegex = /^(http|https):\/\/[^ "]+$/;
|
|
|
|
export const downloadOrderOptions = [
|
|
{key: 'newest', text: 'Newest', value: 'newest'},
|
|
{key: 'oldest', text: 'Oldest', value: 'oldest'},
|
|
{key: 'views', text: 'Most Views', value: 'views'},
|
|
];
|
|
|
|
export const downloadResolutionOptions = [
|
|
{key: '360p', text: '360p', value: '360p'},
|
|
{key: '480p', text: '480p', value: '480p'},
|
|
{key: '720p', text: '720p', value: '720p'},
|
|
{key: '1080p', text: '1080p', value: '1080p'},
|
|
{key: '1440p', text: '1440p', value: '1440p'},
|
|
{key: '2160p', text: '2160p', value: '2160p'},
|
|
{key: 'maximum', text: 'Maximum', value: 'maximum'},
|
|
]
|
|
|
|
export const defaultVideoResolutionOptions = ['1080p', '720p', '480p', 'maximum'];
|
|
|
|
export const downloadFormatOptions = [
|
|
{key: 'mp4', text: '.mp4', value: 'mp4'},
|
|
{key: 'mkv', text: '.mkv', value: 'mkv'},
|
|
{key: 'ogg', text: '.ogg', value: 'ogg'},
|
|
{key: 'webm', text: '.webm', value: 'webm'},
|
|
]
|
|
|
|
export const defaultVideoFormatOption = 'mp4';
|
|
|
|
export const downloadAudioFormatOptions = [
|
|
{key: 'mp3', text: '.mp3', value: 'mp3'},
|
|
{key: 'opus', text: '.opus', value: 'opus'},
|
|
{key: 'm4a', text: '.m4a', value: 'm4a'},
|
|
{key: 'flac', text: '.flac', value: 'flac'},
|
|
{key: 'vorbis', text: '.ogg', value: 'vorbis'},
|
|
{key: 'wav', text: '.wav', value: 'wav'},
|
|
];
|
|
|
|
export const defaultAudioFormatOption = 'mp3';
|
|
|
|
export const downloadVideoCodecOptions = [
|
|
{key: 'h264', text: 'h264 (avc1)', value: 'h264'},
|
|
{key: 'vp9', text: 'vp9', value: 'vp9'},
|
|
{key: 'av1', text: 'av1', value: 'av1'},
|
|
{key: 'vp8', text: 'vp8', value: 'vp8'},
|
|
{key: 'hevc', text: 'hevc (h265)', value: 'hevc'},
|
|
];
|
|
|
|
export const downloadAudioCodecOptions = [
|
|
{key: 'aac', text: 'aac', value: 'aac'},
|
|
{key: 'opus', text: 'opus', value: 'opus'},
|
|
{key: 'mp3', text: 'mp3', value: 'mp3'},
|
|
{key: 'vorbis', text: 'vorbis', value: 'vorbis'},
|
|
];
|
|
|
|
// Codecs WROLPi's ffmpeg step can produce. Mirrors TRANSCODE_VIDEO_TARGETS / TRANSCODE_AUDIO_TARGETS /
|
|
// TRANSCODE_CONTAINERS in modules/videos/transcode.py; the API rejects anything else.
|
|
export const TRANSCODE_COPY = 'copy';
|
|
// REMOVE_VIDEO in modules/videos/transcode.py: drop the video stream, the result is an audio file.
|
|
export const TRANSCODE_REMOVE_VIDEO = 'none';
|
|
export const transcodeVideoCodecOptions = [
|
|
{value: TRANSCODE_COPY, label: 'Keep (copy)'},
|
|
{value: 'h264', label: 'h264 (avc1)'},
|
|
{value: TRANSCODE_REMOVE_VIDEO, label: 'Remove video (audio only)'},
|
|
];
|
|
// REMOVE_AUDIO in modules/videos/transcode.py: drop the audio stream, the result is a silent video.
|
|
export const TRANSCODE_REMOVE_AUDIO = 'none';
|
|
export const transcodeAudioCodecOptions = [
|
|
{value: TRANSCODE_COPY, label: 'Keep (copy)'},
|
|
{value: 'aac', label: 'aac'},
|
|
{value: 'opus', label: 'opus'},
|
|
{value: 'mp3', label: 'mp3'},
|
|
{value: TRANSCODE_REMOVE_AUDIO, label: 'Remove audio (silent video)'},
|
|
];
|
|
// Containers for output with a video stream ...
|
|
export const transcodeContainerOptions = [
|
|
{value: 'mp4', label: 'mp4'},
|
|
{value: 'mkv', label: 'mkv'},
|
|
];
|
|
// ... and for audio-only output. AUDIO_CONTAINER_CODECS in transcode.py says what each holds.
|
|
export const transcodeAudioContainerOptions = [
|
|
{value: 'm4a', label: 'm4a (aac)'},
|
|
{value: 'ogg', label: 'ogg (opus)'},
|
|
{value: 'mp3', label: 'mp3'},
|
|
];
|
|
|
|
/** The audio container a player expects for a codec (default_audio_container in transcode.py). */
|
|
export function audioContainerForCodec(codec) {
|
|
if (codec === 'mp3') return 'mp3';
|
|
if (['opus', 'vorbis', 'flac'].includes(codec)) return 'ogg';
|
|
return 'm4a';
|
|
}
|
|
|
|
export const Downloaders = {
|
|
Archive: 'archive',
|
|
File: 'file',
|
|
KiwixCatalog: 'kiwix_catalog',
|
|
KiwixZim: 'kiwix_zim',
|
|
MapCatalog: 'map_catalog',
|
|
MapExtract: 'map_extract',
|
|
RSS: 'rss',
|
|
ScrapeHtml: 'scrape_html',
|
|
Video: 'video',
|
|
VideoChannel: 'video_channel',
|
|
};
|