Commit 3042c9c660
Unsigned
Layout: unified · split
docs/.vitepress/theme/components/extrepo/BrokenFilter.vue added +35
| @@ -0,0 +1,35 @@ | |||
| 1 | <script setup lang="ts"> | ||
| 2 | import { NuInputHorizontalRadioGroup } from '@nolebase/ui' | ||
| 3 | import { computed } from 'vue' | ||
| 4 | import MenuTitle from './MenuTitle.vue' | ||
| 5 | |||
| 6 | const props = defineProps<{ | ||
| 7 | modelValue: boolean | ||
| 8 | }>() | ||
| 9 | |||
| 10 | const emit = defineEmits<{ | ||
| 11 | 'update:modelValue': [value: boolean] | ||
| 12 | }>() | ||
| 13 | |||
| 14 | const options = [ | ||
| 15 | { value: 'on', title: 'On', ariaLabel: 'On', text: 'ON', name: 'ShowBroken' }, | ||
| 16 | { value: 'off', title: 'Off', ariaLabel: 'Off', text: 'OFF', name: 'ShowBroken' } | ||
| 17 | ] | ||
| 18 | |||
| 19 | const showBroken = computed({ | ||
| 20 | get: () => props.modelValue ? 'on' : 'off', | ||
| 21 | set: (value: string) => emit('update:modelValue', value === 'on') | ||
| 22 | }) | ||
| 23 | </script> | ||
| 24 | |||
| 25 | <template> | ||
| 26 | <div class="ext-broken" role="radiogroup"> | ||
| 27 | <MenuTitle icon="i-lucide:unlink" title="Show broken urls" /> | ||
| 28 | <NuInputHorizontalRadioGroup | ||
| 29 | v-model="showBroken" | ||
| 30 | bg="$vp-nolebase-enhanced-readabilities-menu-background-color" | ||
| 31 | text="sm $vp-nolebase-enhanced-readabilities-menu-text-color" | ||
| 32 | :options="options" | ||
| 33 | /> | ||
| 34 | </div> | ||
| 35 | </template> | ||
docs/.vitepress/theme/components/extrepo/ExtensionRepos.vue +6 −1
| @@ -17,6 +17,7 @@ const query = ref('') | |||
| 17 | const langFilter = ref('') | 17 | const langFilter = ref('') |
| 18 | const ratingFilter = ref<RatingFilter>('all') | 18 | const ratingFilter = ref<RatingFilter>('all') |
| 19 | const excludedContentTypes = ref<Set<string>>(new Set()) | 19 | const excludedContentTypes = ref<Set<string>>(new Set()) |
| 20 | const showBroken = ref(false) | ||
| 20 | 21 | ||
| 21 | const allSites = computed<MatchedSite[]>(() => { | 22 | const allSites = computed<MatchedSite[]>(() => { |
| 22 | const sites: MatchedSite[] = [] | 23 | const sites: MatchedSite[] = [] |
| @@ -52,6 +53,7 @@ const hasContentTypes = computed(() => availableContentTypes.value.length > 0) | |||
| 52 | const hasRatings = computed(() => allSites.value.some(site => site.rating !== 'safe')) | 53 | const hasRatings = computed(() => allSites.value.some(site => site.rating !== 'safe')) |
| 53 | const hasSuggestive = computed(() => allSites.value.some(site => site.rating === 'suggestive')) | 54 | const hasSuggestive = computed(() => allSites.value.some(site => site.rating === 'suggestive')) |
| 54 | const hasMultiLanguage = computed(() => allSites.value.some(site => site.lang.toLowerCase() === 'all')) | 55 | const hasMultiLanguage = computed(() => allSites.value.some(site => site.lang.toLowerCase() === 'all')) |
| 56 | const hasBroken = computed(() => allSites.value.some(site => site.isBroken)) | ||
| 55 | 57 | ||
| 56 | const availableLangs = computed(() => { | 58 | const availableLangs = computed(() => { |
| 57 | const codes = new Set(allSites.value.map(site => site.lang)) | 59 | const codes = new Set(allSites.value.map(site => site.lang)) |
| @@ -66,6 +68,7 @@ const isFiltering = computed(() => { | |||
| 66 | const filteredSites = computed(() => { | 68 | const filteredSites = computed(() => { |
| 67 | const q = query.value.trim().toLowerCase() | 69 | const q = query.value.trim().toLowerCase() |
| 68 | return allSites.value.filter(site => { | 70 | return allSites.value.filter(site => { |
| 71 | if (site.isBroken && !showBroken.value) return false | ||
| 69 | if (q && !site.name.toLowerCase().includes(q) && !site.url.toLowerCase().includes(q)) return false | 72 | if (q && !site.name.toLowerCase().includes(q) && !site.url.toLowerCase().includes(q)) return false |
| 70 | if (langFilter.value && site.lang !== langFilter.value) return false | 73 | if (langFilter.value && site.lang !== langFilter.value) return false |
| 71 | if (ratingFilter.value !== 'all' && site.rating !== ratingFilter.value) return false | 74 | if (ratingFilter.value !== 'all' && site.rating !== ratingFilter.value) return false |
| @@ -86,12 +89,14 @@ const filteredSites = computed(() => { | |||
| 86 | v-model:lang-filter="langFilter" | 89 | v-model:lang-filter="langFilter" |
| 87 | v-model:rating-filter="ratingFilter" | 90 | v-model:rating-filter="ratingFilter" |
| 88 | v-model:content-type-filter="excludedContentTypes" | 91 | v-model:content-type-filter="excludedContentTypes" |
| 92 | v-model:show-broken="showBroken" | ||
| 89 | :available-langs="availableLangs" | 93 | :available-langs="availableLangs" |
| 90 | :has-multi-language="hasMultiLanguage" | 94 | :has-multi-language="hasMultiLanguage" |
| 91 | :has-ratings="hasRatings" | 95 | :has-ratings="hasRatings" |
| 92 | :has-suggestive="hasSuggestive" | 96 | :has-suggestive="hasSuggestive" |
| 93 | :available-content-types="availableContentTypes" | 97 | :available-content-types="availableContentTypes" |
| 94 | :has-content-types="hasContentTypes" | 98 | :has-content-types="hasContentTypes" |
| 99 | :has-broken="hasBroken" | ||
| 95 | /> | 100 | /> |
| 96 | </div> | 101 | </div> |
| 97 | 102 | ||
| @@ -103,7 +108,7 @@ const filteredSites = computed(() => { | |||
| 103 | /> | 108 | /> |
| 104 | 109 | ||
| 105 | <div v-else> | 110 | <div v-else> |
| 106 | <RepoRow v-for="repo in repos" :key="repo.indexUrl" :repo="repo" :scheme="scheme" /> | 111 | <RepoRow v-for="repo in repos" :key="repo.indexUrl" :repo="repo" :scheme="scheme" :show-broken="showBroken" /> |
| 107 | </div> | 112 | </div> |
| 108 | </div> | 113 | </div> |
| 109 | </template> | 114 | </template> |
docs/.vitepress/theme/components/extrepo/RepoRow.vue +7 −2
| @@ -9,6 +9,7 @@ import type { Repo, RepoVariant } from './types' | |||
| 9 | const props = defineProps<{ | 9 | const props = defineProps<{ |
| 10 | repo: Repo | 10 | repo: Repo |
| 11 | scheme: string | 11 | scheme: string |
| 12 | showBroken?: boolean | ||
| 12 | }>() | 13 | }>() |
| 13 | 14 | ||
| 14 | const NOT_EXPANDABLE = new Set(['MegaRepo', 'Shotetsu Compatability']) | 15 | const NOT_EXPANDABLE = new Set(['MegaRepo', 'Shotetsu Compatability']) |
| @@ -18,7 +19,10 @@ const copied = ref(false) | |||
| 18 | const copiedLabel = ref<string | null>(null) | 19 | const copiedLabel = ref<string | null>(null) |
| 19 | const openVariants = ref<Set<string>>(new Set()) | 20 | const openVariants = ref<Set<string>>(new Set()) |
| 20 | 21 | ||
| 21 | const sites = computed(() => repoData[props.repo.indexUrl]?.sites ?? []) | 22 | const sites = computed(() => { |
| 23 | const all = repoData[props.repo.indexUrl]?.sites ?? [] | ||
| 24 | return props.showBroken ? all : all.filter(site => !site.isBroken) | ||
| 25 | }) | ||
| 22 | const isExpandable = computed(() => !NOT_EXPANDABLE.has(stripHtml(props.repo.name))) | 26 | const isExpandable = computed(() => !NOT_EXPANDABLE.has(stripHtml(props.repo.name))) |
| 23 | const installUrl = computed(() => installHref(props.scheme, props.repo)) | 27 | const installUrl = computed(() => installHref(props.scheme, props.repo)) |
| 24 | // Browse-only schemes (e.g. Kotatsu forks) have no app to deep-link into, so install, | 28 | // Browse-only schemes (e.g. Kotatsu forks) have no app to deep-link into, so install, |
| @@ -56,7 +60,8 @@ function toggleVariant(label: string) { | |||
| 56 | 60 | ||
| 57 | function variantSites(variant: RepoVariant) { | 61 | function variantSites(variant: RepoVariant) { |
| 58 | const url = mangayomiCopyValue(variant) | 62 | const url = mangayomiCopyValue(variant) |
| 59 | return url ? repoData[url]?.sites ?? [] : [] | 63 | const all = url ? repoData[url]?.sites ?? [] : [] |
| 64 | return props.showBroken ? all : all.filter(site => !site.isBroken) | ||
| 60 | } | 65 | } |
| 61 | </script> | 66 | </script> |
| 62 | 67 | ||
docs/.vitepress/theme/components/extrepo/SettingsMenu.vue +9
| @@ -1,5 +1,6 @@ | |||
| 1 | <script setup lang="ts"> | 1 | <script setup lang="ts"> |
| 2 | import { nextTick, onMounted, onUnmounted, ref } from 'vue' | 2 | import { nextTick, onMounted, onUnmounted, ref } from 'vue' |
| 3 | import BrokenFilter from './BrokenFilter.vue' | ||
| 3 | import ContentTypeFilter from './ContentTypeFilter.vue' | 4 | import ContentTypeFilter from './ContentTypeFilter.vue' |
| 4 | import LangSelect from './LangSelect.vue' | 5 | import LangSelect from './LangSelect.vue' |
| 5 | import RatingFilter from './RatingFilter.vue' | 6 | import RatingFilter from './RatingFilter.vue' |
| @@ -15,12 +16,15 @@ defineProps<{ | |||
| 15 | contentTypeFilter: Set<string> | 16 | contentTypeFilter: Set<string> |
| 16 | availableContentTypes: string[] | 17 | availableContentTypes: string[] |
| 17 | hasContentTypes: boolean | 18 | hasContentTypes: boolean |
| 19 | showBroken: boolean | ||
| 20 | hasBroken: boolean | ||
| 18 | }>() | 21 | }>() |
| 19 | 22 | ||
| 20 | defineEmits<{ | 23 | defineEmits<{ |
| 21 | 'update:langFilter': [value: string] | 24 | 'update:langFilter': [value: string] |
| 22 | 'update:ratingFilter': [value: RatingFilterValue] | 25 | 'update:ratingFilter': [value: RatingFilterValue] |
| 23 | 'update:contentTypeFilter': [value: Set<string>] | 26 | 'update:contentTypeFilter': [value: Set<string>] |
| 27 | 'update:showBroken': [value: boolean] | ||
| 24 | }>() | 28 | }>() |
| 25 | 29 | ||
| 26 | const rootRef = ref<HTMLElement>() | 30 | const rootRef = ref<HTMLElement>() |
| @@ -115,6 +119,11 @@ onUnmounted(() => { | |||
| 115 | :available-types="availableContentTypes" | 119 | :available-types="availableContentTypes" |
| 116 | @update:model-value="$emit('update:contentTypeFilter', $event)" | 120 | @update:model-value="$emit('update:contentTypeFilter', $event)" |
| 117 | /> | 121 | /> |
| 122 | <BrokenFilter | ||
| 123 | v-if="hasBroken" | ||
| 124 | :model-value="showBroken" | ||
| 125 | @update:model-value="$emit('update:showBroken', $event)" | ||
| 126 | /> | ||
| 118 | </div> | 127 | </div> |
| 119 | </Teleport> | 128 | </Teleport> |
| 120 | </div> | 129 | </div> |
docs/.vitepress/theme/components/extrepo/types.ts +1
| @@ -25,6 +25,7 @@ export interface RepoSite { | |||
| 25 | rating: Rating | 25 | rating: Rating |
| 26 | // Only for kotatsu | 26 | // Only for kotatsu |
| 27 | contentType?: string | 27 | contentType?: string |
| 28 | isBroken?: boolean | ||
| 28 | } | 29 | } |
| 29 | 30 | ||
| 30 | export interface MatchedSite extends RepoSite { | 31 | export interface MatchedSite extends RepoSite { |
docs/ext/extensionRepos.data.ts +2 −3
| @@ -13,6 +13,7 @@ export interface RepoSite { | |||
| 13 | url: string | 13 | url: string |
| 14 | rating: Rating | 14 | rating: Rating |
| 15 | contentType?: string | 15 | contentType?: string |
| 16 | isBroken?: boolean | ||
| 16 | } | 17 | } |
| 17 | 18 | ||
| 18 | export interface RepoData { | 19 | export interface RepoData { |
| @@ -390,14 +391,12 @@ function toRepoDataKotatsu(index: KotatsuIndex): RepoSite[] { | |||
| 390 | const sites: RepoSite[] = [] | 391 | const sites: RepoSite[] = [] |
| 391 | 392 | ||
| 392 | for (const site of index.sites) { | 393 | for (const site of index.sites) { |
| 393 | // Broken parsers aren't "available" sites -- skip rather than surface a dead link. | ||
| 394 | if (site.isBroken) continue | ||
| 395 | const lang = normalizeLang(site.lang) | 394 | const lang = normalizeLang(site.lang) |
| 396 | const key = `${site.name}::${lang}::${site.url}` | 395 | const key = `${site.name}::${lang}::${site.url}` |
| 397 | if (seen.has(key)) continue | 396 | if (seen.has(key)) continue |
| 398 | seen.add(key) | 397 | seen.add(key) |
| 399 | const rating: Rating = site.contentType.includes('HENTAI') ? 'nsfw' : 'safe' | 398 | const rating: Rating = site.contentType.includes('HENTAI') ? 'nsfw' : 'safe' |
| 400 | sites.push({ name: site.name, lang, icon: site.icon, url: site.url, rating, contentType: site.contentType }) | 399 | sites.push({ name: site.name, lang, icon: site.icon, url: site.url, rating, contentType: site.contentType, isBroken: site.isBroken || undefined }) |
| 401 | } | 400 | } |
| 402 | 401 | ||
| 403 | return sites | 402 | return sites |