itube-specs 0.0.1001 → 0.0.1004
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/SITE_UPDATES.md +32 -0
- package/composables/use-generate-link.ts +6 -7
- package/composables/use-niches.ts +3 -1
- package/config/__tests__/niches.test.ts +27 -5
- package/config/niches.ts +37 -6
- package/package.json +4 -1
- package/public/img/model-placeholder/gay-dark-portrait.avif +0 -0
- package/public/img/model-placeholder/gay-dark-portrait.webp +0 -0
- package/public/img/model-placeholder/gay-light-portrait.avif +0 -0
- package/public/img/model-placeholder/gay-light-portrait.webp +0 -0
- package/public/img/model-placeholder/shemale-dark-portrait.avif +0 -0
- package/public/img/model-placeholder/shemale-dark-portrait.webp +0 -0
- package/public/img/model-placeholder/shemale-dark-square.avif +0 -0
- package/public/img/model-placeholder/shemale-dark-square.webp +0 -0
- package/public/img/model-placeholder/shemale-light-portrait.avif +0 -0
- package/public/img/model-placeholder/shemale-light-portrait.webp +0 -0
- package/public/img/model-placeholder/shemale-light-square.avif +0 -0
- package/public/img/model-placeholder/shemale-light-square.webp +0 -0
- package/public/img/model-placeholder/straight-dark-portrait.avif +0 -0
- package/public/img/model-placeholder/straight-dark-portrait.webp +0 -0
- package/public/img/model-placeholder/straight-dark-square.avif +0 -0
- package/public/img/model-placeholder/straight-dark-square.webp +0 -0
- package/public/img/model-placeholder/straight-light-portrait.avif +0 -0
- package/public/img/model-placeholder/straight-light-portrait.webp +0 -0
- package/public/img/model-placeholder/straight-light-square.avif +0 -0
- package/public/img/model-placeholder/straight-light-square.webp +0 -0
- package/scripts/site-updates.mjs +46 -0
- package/utils/niche-helper.ts +11 -4
package/SITE_UPDATES.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Что сделать в сайтах после обновления слоя
|
|
2
|
+
|
|
3
|
+
Только то, что каждый сайт должен сделать у себя после `npm run spec`: объявить новую сущность, поправить
|
|
4
|
+
свою логику, удалить файлы, переехавшие в слой. Описание изменений слоя — в истории git, не здесь.
|
|
5
|
+
|
|
6
|
+
Сайт после `npm run spec` видит записи между своей прошлой и новой версией:
|
|
7
|
+
`node node_modules/itube-specs/scripts/site-updates.mjs`.
|
|
8
|
+
|
|
9
|
+
Пишет тот, кто меняет слой, в том же коммите. Новые записи — сверху, в секцию `## Unreleased` (одна на все
|
|
10
|
+
коммиты до бампа); `npm run patch` сам проставит ей номер версии. Формат пункта: что сделать и где,
|
|
11
|
+
кому именно (всем / сайтам с N), что будет, если не сделать.
|
|
12
|
+
|
|
13
|
+
## 0.0.1001 — 2026-10-06
|
|
14
|
+
|
|
15
|
+
- **Всем:** удалить свои `public/img/model-placeholder-{portrait,square}.{webp,avif}` и
|
|
16
|
+
`model-placeholder-female-*`, если есть. Заглушки моделей теперь в слое
|
|
17
|
+
(`public/img/model-placeholder/<niche>-<theme>-<shape>`), старые пути слой больше не запрашивает.
|
|
18
|
+
Свой вариант картинки — файлом с тем же новым путём в `public/` сайта.
|
|
19
|
+
|
|
20
|
+
## 0.0.1000 — 2026-10-06
|
|
21
|
+
|
|
22
|
+
- **Сайтам с несколькими нишами, у которых ниша в URL не равна её коду** (`/gays` вместо `/gay`): одна
|
|
23
|
+
константа слагов → `nicheSlugs` в `app.config.ts` и `slugs` в `addNicheAliases` (`NEW_SITE_CHECKLIST.md` §3a).
|
|
24
|
+
Остальным — ничего.
|
|
25
|
+
|
|
26
|
+
## 0.0.999 — 2026-10-06
|
|
27
|
+
|
|
28
|
+
- **Всем:** флага нет в `config/feature-flags.config.ts` — фича выключена, дефолтов у слоя нет. Перечислить
|
|
29
|
+
все флаги явно по карте в `NEW_SITE_CHECKLIST.md` §4. Заглушки без бекенда (`FeatureFollowEnabled`,
|
|
30
|
+
`FeatureHistoryEnabled`, `FeatureFavoritesEnabled`, `FeatureWatchLaterEnabled`, `FeatureLiveEnabled`) — на
|
|
31
|
+
боевом сайте включать только осознанно; при выключенном флаге их страницы отдают 404.
|
|
32
|
+
- **Всем:** `FeatureMomentsEnabled` и `SponsoredEnabled` слой не читает — можно убрать.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Language, Niche } from '../runtime';
|
|
2
|
-
import { nicheSlug, type NicheSlugs } from '../config/niches';
|
|
2
|
+
import { nicheSlug, withNichePrefix, type NicheSlugs } from '../config/niches';
|
|
3
3
|
import { NicheHelper } from '../utils/niche-helper';
|
|
4
4
|
|
|
5
5
|
/** Возвращает generateLink — генерирует путь с учётом текущей ниши и локали. */
|
|
@@ -26,13 +26,12 @@ export const useGenerateLink = () => {
|
|
|
26
26
|
const nicheFreeRoots = (appConfig.nicheFreeRoots as string[] | undefined) || [];
|
|
27
27
|
const isNicheFree = nicheFreeRoots.some(root => cleanPath === root || cleanPath.startsWith(`${root}/`));
|
|
28
28
|
|
|
29
|
-
const withNiche =
|
|
30
|
-
!niche.value || niche.value === defaultNiche || isOneNiche || isNicheFree
|
|
31
|
-
? cleanPath
|
|
32
|
-
: `/${nicheSlug(niche.value, appConfig.nicheSlugs as NicheSlugs | undefined)}${cleanPath}`;
|
|
33
|
-
|
|
34
29
|
const locale = localeArg || undefined;
|
|
35
|
-
|
|
30
|
+
const localized = localePath(cleanPath, locale);
|
|
31
|
+
|
|
32
|
+
if (!niche.value || niche.value === defaultNiche || isOneNiche || isNicheFree) return localized;
|
|
33
|
+
|
|
34
|
+
return withNichePrefix(localized, `/${nicheSlug(niche.value, appConfig.nicheSlugs as NicheSlugs | undefined)}`, localePath('/', locale));
|
|
36
35
|
};
|
|
37
36
|
|
|
38
37
|
return { generateLink };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Niche } from '../runtime';
|
|
2
|
+
import { withNichePrefix } from '../config/niches';
|
|
2
3
|
import { NicheHelper } from '../utils/niche-helper';
|
|
3
4
|
|
|
4
5
|
/** Иконка из assets/icons/common под каждую нишу. */
|
|
@@ -40,7 +41,8 @@ export const useNiches = () => {
|
|
|
40
41
|
function changeNiche(name: Niche) {
|
|
41
42
|
if (name === current.value) return;
|
|
42
43
|
current.value = name;
|
|
43
|
-
|
|
44
|
+
const root = localePath('/');
|
|
45
|
+
window.location.href = withNichePrefix(root, NicheHelper.getNichePath(name), root);
|
|
44
46
|
}
|
|
45
47
|
|
|
46
48
|
return { niches, currentNiche, changeNiche };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { addNicheAliases, nicheFromPath, nicheFromSlug, nicheRoutePrefix, nicheSlug } from '../niches';
|
|
2
|
+
import { addNicheAliases, nicheFromPath, nicheFromSlug, nicheRoutePrefix, nicheSlug, nichePath, withNichePrefix } from '../niches';
|
|
3
3
|
|
|
4
4
|
const CONFIG = { niches: ['straight', 'gay', 'shemale'], defaultNiche: 'straight', contentRoots: ['/', '/videos', '/models'] };
|
|
5
5
|
|
|
@@ -19,9 +19,9 @@ describe('niches', () => {
|
|
|
19
19
|
];
|
|
20
20
|
addNicheAliases(pages, CONFIG);
|
|
21
21
|
|
|
22
|
-
expect(pages[0]?.alias).toEqual(['
|
|
23
|
-
expect(pages[1]?.alias).toEqual(['/v/:slug', '/:
|
|
24
|
-
expect(pages[2]?.alias).toEqual(['
|
|
22
|
+
expect(pages[0]?.alias).toEqual(['/gay', '/shemale']);
|
|
23
|
+
expect(pages[1]?.alias).toEqual(['/v/:slug', '/gay/videos/:slug', '/shemale/videos/:slug']);
|
|
24
|
+
expect(pages[2]?.alias).toEqual(['/gay/models', '/shemale/models']);
|
|
25
25
|
expect(pages[3]?.alias).toBeUndefined();
|
|
26
26
|
expect(pages[4]?.alias).toBeUndefined();
|
|
27
27
|
});
|
|
@@ -32,7 +32,29 @@ describe('niches', () => {
|
|
|
32
32
|
|
|
33
33
|
const pages = [{ path: '/videos/:slug' }];
|
|
34
34
|
addNicheAliases(pages, { ...CONFIG, slugs });
|
|
35
|
-
expect(pages[0]?.alias).toEqual(['/:
|
|
35
|
+
expect(pages[0]?.alias).toEqual(['/gays/videos/:slug', '/shemale/videos/:slug']);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('префикс пути ниши: слаг, у дефолтной и одной ниши пусто', () => {
|
|
39
|
+
const slugs = { gay: 'gays' };
|
|
40
|
+
expect(nichePath('gay', { ...CONFIG, slugs })).toBe('/gays');
|
|
41
|
+
expect(nichePath('shemale', { ...CONFIG, slugs })).toBe('/shemale');
|
|
42
|
+
expect(nichePath('straight', CONFIG)).toBe('');
|
|
43
|
+
expect(nichePath(undefined, CONFIG)).toBe('');
|
|
44
|
+
expect(nichePath('gay', { niches: ['gay'], defaultNiche: 'straight' })).toBe('');
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('префикс ниши в локализованном пути — после языка', () => {
|
|
48
|
+
expect(withNichePrefix('/models', '/gays')).toBe('/gays/models');
|
|
49
|
+
expect(withNichePrefix('/', '/gays')).toBe('/gays');
|
|
50
|
+
expect(withNichePrefix('/?page=2', '/gays')).toBe('/gays?page=2');
|
|
51
|
+
expect(withNichePrefix('/ru/models', '/gays', '/ru')).toBe('/ru/gays/models');
|
|
52
|
+
expect(withNichePrefix('/ru', '/gays', '/ru')).toBe('/ru/gays');
|
|
53
|
+
expect(withNichePrefix('/ru?page=2', '/gays', '/ru')).toBe('/ru/gays?page=2');
|
|
54
|
+
expect(withNichePrefix('/rubber', '/gays', '/ru')).toBe('/gays/rubber');
|
|
55
|
+
expect(withNichePrefix('/models', '')).toBe('/models');
|
|
56
|
+
expect(withNichePrefix('https://ru.example.com/models', '/gays')).toBe('https://ru.example.com/gays/models');
|
|
57
|
+
expect(withNichePrefix('https://ru.example.com', '/gays')).toBe('https://ru.example.com/gays');
|
|
36
58
|
});
|
|
37
59
|
|
|
38
60
|
it('слаг ↔ ниша', () => {
|
package/config/niches.ts
CHANGED
|
@@ -79,19 +79,50 @@ function isUnderRoot(path: string, roots: readonly string[]): boolean {
|
|
|
79
79
|
|
|
80
80
|
/**
|
|
81
81
|
* Клонирует контентные разделы под нишевые префиксы — алиасом той же записи роута:
|
|
82
|
-
* `/videos/:slug` начинает отвечать и на `/gay/videos/:slug`.
|
|
83
|
-
*
|
|
82
|
+
* `/videos/:slug` начинает отвечать и на `/gay/videos/:slug`. Алиасы статичные, по одному на нишу:
|
|
83
|
+
* у алиаса vue-router требует те же параметры, что у оригинала, поэтому параметр `:niche` сюда нельзя.
|
|
84
|
+
* Сайту с одной нишей ничего не добавляет. Мутирует переданный список — так устроен хук `pages:extend`.
|
|
84
85
|
*/
|
|
85
86
|
export function addNicheAliases(pages: INicheAliasablePage[], config: INicheRouting): void {
|
|
86
|
-
const
|
|
87
|
-
if (!
|
|
87
|
+
const prefixes = prefixedNiches(config).map(niche => `/${nicheSlug(niche, config.slugs)}`);
|
|
88
|
+
if (!prefixes.length) return;
|
|
88
89
|
|
|
89
90
|
for (const page of pages) {
|
|
90
91
|
if (!page.path || !isUnderRoot(page.path, config.contentRoots)) continue;
|
|
91
92
|
|
|
92
|
-
const
|
|
93
|
+
const aliases = prefixes.map(prefix => (page.path === '/' ? prefix : `${prefix}${page.path}`));
|
|
93
94
|
const current = Array.isArray(page.alias) ? page.alias : page.alias ? [page.alias] : [];
|
|
94
95
|
|
|
95
|
-
page.alias = [...current,
|
|
96
|
+
page.alias = [...current, ...aliases];
|
|
96
97
|
}
|
|
97
98
|
}
|
|
99
|
+
|
|
100
|
+
/** Префикс пути ниши (`/gays`). У дефолтной ниши и у сайта с одной нишей — пусто. */
|
|
101
|
+
export function nichePath(niche: string | undefined, { niches, defaultNiche, slugs }: Pick<INicheRouting, 'niches' | 'defaultNiche' | 'slugs'>): string {
|
|
102
|
+
if (!niche || niches.length <= 1 || niche === defaultNiche) return '';
|
|
103
|
+
|
|
104
|
+
return `/${nicheSlug(niche, slugs)}`;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const ORIGIN_RE = /^https?:\/\/[^/?#]+/;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Вставляет префикс ниши в уже локализованный путь — после языкового префикса: `/ru/models` → `/ru/gays/models`.
|
|
111
|
+
* Префикс ниши добавляется после `localePath`, а не до: на нишевом пути i18n находит роут по алиасу и
|
|
112
|
+
* пересобирает путь по имени роута — то есть без ниши (так же `switchLocalePath`). `localeRoot` —
|
|
113
|
+
* `localePath('/')` той же локали. Абсолютный URL (локали на поддоменах) — префикс в его путь.
|
|
114
|
+
*/
|
|
115
|
+
export function withNichePrefix(localizedPath: string, nichePath: string, localeRoot = '/'): string {
|
|
116
|
+
if (!nichePath) return localizedPath;
|
|
117
|
+
|
|
118
|
+
const origin = localizedPath.match(ORIGIN_RE)?.[0] || '';
|
|
119
|
+
if (origin) return `${origin}${withNichePrefix(localizedPath.slice(origin.length) || '/', nichePath, localeRoot)}`;
|
|
120
|
+
|
|
121
|
+
const localeRootPath = localeRoot.replace(ORIGIN_RE, '').replace(/\/$/, '');
|
|
122
|
+
const afterRoot = localizedPath.slice(localeRootPath.length);
|
|
123
|
+
const root = localeRootPath && localizedPath.startsWith(localeRootPath) && (!afterRoot || /^[/?#]/.test(afterRoot)) ? localeRootPath : '';
|
|
124
|
+
const rest = localizedPath.slice(root.length);
|
|
125
|
+
const tail = rest === '/' ? '' : rest.startsWith('/?') || rest.startsWith('/#') ? rest.slice(1) : rest;
|
|
126
|
+
|
|
127
|
+
return `${root}${nichePath}${tail}`;
|
|
128
|
+
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "itube-specs",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.1004",
|
|
5
5
|
"main": "./nuxt.config.ts",
|
|
6
6
|
"types": "./types/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"prepublishOnly": "npm install && npx nuxi prepare",
|
|
9
9
|
"patch": "npm version patch",
|
|
10
|
+
"version": "node scripts/site-updates-release.mjs && git add SITE_UPDATES.md",
|
|
10
11
|
"lint": "eslint . --max-warnings=0",
|
|
11
12
|
"lint:fix": "eslint . --fix",
|
|
12
13
|
"lint:css": "stylelint \"**/*.{scss,vue}\" --max-warnings=0 --allow-empty-input",
|
|
@@ -80,6 +81,8 @@
|
|
|
80
81
|
"i18n/locales/",
|
|
81
82
|
"scripts/i18n-check.mjs",
|
|
82
83
|
"scripts/i18n-sheet.mjs",
|
|
84
|
+
"scripts/site-updates.mjs",
|
|
85
|
+
"SITE_UPDATES.md",
|
|
83
86
|
"nuxt.config.ts",
|
|
84
87
|
"DOCS/"
|
|
85
88
|
],
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// Для сайта, после `npm run spec`: печатает записи SITE_UPDATES.md слоя, вышедшие после версии,
|
|
2
|
+
// которая стояла в закоммиченном package.json сайта. Запуск из корня сайта.
|
|
3
|
+
// Явно: `node node_modules/itube-specs/scripts/site-updates.mjs <старая-версия>`.
|
|
4
|
+
|
|
5
|
+
import { execSync } from 'node:child_process';
|
|
6
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
7
|
+
|
|
8
|
+
const FILE = 'node_modules/itube-specs/SITE_UPDATES.md';
|
|
9
|
+
|
|
10
|
+
const toParts = version => version.replace(/^[^\d]*/, '').split('.').map(Number);
|
|
11
|
+
const isNewer = (a, b) => {
|
|
12
|
+
const [x, y] = [toParts(a), toParts(b)];
|
|
13
|
+
for (let i = 0; i < 3; i++) if ((x[i] || 0) !== (y[i] || 0)) return (x[i] || 0) > (y[i] || 0);
|
|
14
|
+
return false;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
function previousVersion() {
|
|
18
|
+
if (process.argv[2]) return process.argv[2];
|
|
19
|
+
try {
|
|
20
|
+
const pkg = JSON.parse(execSync('git show HEAD:package.json', { encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }));
|
|
21
|
+
return pkg.dependencies?.['itube-specs'] || pkg.devDependencies?.['itube-specs'] || '';
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
return '';
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (!existsSync(FILE)) process.exit(0);
|
|
29
|
+
|
|
30
|
+
const from = previousVersion();
|
|
31
|
+
const installed = JSON.parse(readFileSync('node_modules/itube-specs/package.json', 'utf8')).version;
|
|
32
|
+
|
|
33
|
+
const sections = readFileSync(FILE, 'utf8').split(/^(?=## )/m).filter(part => part.startsWith('## '));
|
|
34
|
+
const pending = sections.filter((section) => {
|
|
35
|
+
const version = section.match(/^## (\d+\.\d+\.\d+)/)?.[1];
|
|
36
|
+
return version && (!from || isNewer(version, from)) && !isNewer(version, installed);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
if (!pending.length) {
|
|
40
|
+
console.log(`site-updates: ${from || '?'} → ${installed}, действий для сайта нет.`);
|
|
41
|
+
process.exit(0);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
console.log(`\nsite-updates: ${from || '?'} → ${installed}. Что сделать в этом сайте (от старых к новым):\n`);
|
|
45
|
+
console.log(pending.reverse().map(section => section.trim()).join('\n\n'));
|
|
46
|
+
console.log('');
|
package/utils/niche-helper.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Niche } from '../runtime';
|
|
2
|
-
import {
|
|
2
|
+
import { nichePath, type NicheSlugs } from '../config/niches';
|
|
3
3
|
|
|
4
4
|
/** Хелпер для работы с нишами */
|
|
5
5
|
export class NicheHelper {
|
|
@@ -21,10 +21,17 @@ export class NicheHelper {
|
|
|
21
21
|
* сайта с одной нишей — пусто.
|
|
22
22
|
*/
|
|
23
23
|
public static getNichePath(niche: Niche = NicheHelper.getCurrentNiche()): string {
|
|
24
|
+
return nichePath(niche, NicheHelper.getNicheRouting());
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Ниши сайта, дефолтная и слаги — то, что нужно `nichePath` и прочим хелперам `itube-specs/config`. */
|
|
28
|
+
public static getNicheRouting(): { niches: Niche[], defaultNiche: Niche, slugs?: NicheSlugs } {
|
|
24
29
|
const appConfig = useAppConfig();
|
|
25
|
-
const isOneNiche = ((appConfig.niches as Niche[] | undefined) || []).length <= 1;
|
|
26
|
-
if (!niche || isOneNiche || niche === NicheHelper.getSiteDefaultNiche()) return '';
|
|
27
30
|
|
|
28
|
-
return
|
|
31
|
+
return {
|
|
32
|
+
niches: (appConfig.niches as Niche[] | undefined) || [],
|
|
33
|
+
defaultNiche: NicheHelper.getSiteDefaultNiche(),
|
|
34
|
+
slugs: appConfig.nicheSlugs as NicheSlugs | undefined,
|
|
35
|
+
};
|
|
29
36
|
}
|
|
30
37
|
}
|