Commit e1c0318d9b
Unsigned
Layout: unified · split
web/src/components/scafold/Footer.astro +7 −2
| @@ -1,8 +1,13 @@ | |||
| 1 | --- | ||
| 2 | const year = new Date().getFullYear(); | ||
| 3 | --- | ||
| 4 | |||
| 1 | <footer> | 5 | <footer> |
| 2 | <a href="/about">Awesome Privacy</a> is licensed under <a | 6 | <a href="/about">Awesome Privacy</a> is licensed under <a |
| 3 | href="https://github.com/Lissy93/awesome-privacy/blob/main/LICENSE">MIT</a | 7 | href="https://github.com/Lissy93/awesome-privacy/blob/main/LICENSE" |
| 8 | >CC0 1.0 Universal</a | ||
| 4 | > | 9 | > |
| 5 | © <a href="https://aliciasykes.com">Alicia Sykes</a> 2024 | Source code available | 10 | © <a href="https://aliciasykes.com">Alicia Sykes</a> 2018 - {year || 'Present'} | Source code available |
| 6 | on <a href="https://github.com/Lissy93/awesome-privacy">GitHub</a> | 11 | on <a href="https://github.com/Lissy93/awesome-privacy">GitHub</a> |
| 7 | </footer> | 12 | </footer> |
| 8 | 13 | ||
web/src/components/things/AddNewService.svelte +13 −5
| @@ -20,24 +20,31 @@ | |||
| 20 | const serviceCrypto = writable(false); | 20 | const serviceCrypto = writable(false); |
| 21 | const additionalInfo = writable(''); | 21 | const additionalInfo = writable(''); |
| 22 | 22 | ||
| 23 | let codeBlock: any; | 23 | let codeBlock: HTMLElement | undefined; |
| 24 | let interactiveActivated = false; | 24 | let interactiveActivated = false; |
| 25 | 25 | ||
| 26 | $: (yamlText, updateHighlighting()); | 26 | $: (yamlText, updateHighlighting()); |
| 27 | 27 | ||
| 28 | /* eslint-disable svelte/no-dom-manipulating -- hljs requires direct DOM access for syntax highlighting */ | ||
| 28 | function updateHighlighting() { | 29 | function updateHighlighting() { |
| 29 | if (codeBlock) { | 30 | if (codeBlock) { |
| 30 | codeBlock.textContent = yamlText; | 31 | codeBlock.textContent = yamlText; |
| 31 | codeBlock.dataset.highlighted && delete codeBlock.dataset.highlighted; | 32 | codeBlock.dataset.highlighted && delete codeBlock.dataset.highlighted; |
| 32 | if (window && (window as any).hljs) { | 33 | const hljs = ( |
| 33 | (window as any).hljs.highlightElement(codeBlock); | 34 | window as Window & { |
| 35 | hljs?: { highlightElement: (el: HTMLElement) => void }; | ||
| 36 | } | ||
| 37 | ).hljs; | ||
| 38 | if (hljs) { | ||
| 39 | hljs.highlightElement(codeBlock); | ||
| 34 | interactiveActivated = true; | 40 | interactiveActivated = true; |
| 35 | } | 41 | } |
| 36 | } | 42 | } |
| 37 | } | 43 | } |
| 44 | /* eslint-enable svelte/no-dom-manipulating */ | ||
| 38 | 45 | ||
| 39 | const filterEmptyValues = (obj: Record<string, any>) => { | 46 | const filterEmptyValues = (obj: Record<string, unknown>) => { |
| 40 | const filteredObj: Record<string, any> = {}; | 47 | const filteredObj: Record<string, unknown> = {}; |
| 41 | Object.keys(obj).forEach((key) => { | 48 | Object.keys(obj).forEach((key) => { |
| 42 | if (obj[key] || ['name', 'url', 'icon', 'description'].includes(key)) { | 49 | if (obj[key] || ['name', 'url', 'icon', 'description'].includes(key)) { |
| 43 | filteredObj[key] = obj[key]; | 50 | filteredObj[key] = obj[key]; |
| @@ -397,6 +404,7 @@ | |||
| 397 | upon approval. | 404 | upon approval. |
| 398 | </p> | 405 | </p> |
| 399 | {#if !interactiveActivated || !codeBlock} | 406 | {#if !interactiveActivated || !codeBlock} |
| 407 | <!-- eslint-disable-next-line svelte/no-at-html-tags -- yamlText is generated from user form input via yaml.dump, not arbitrary HTML --> | ||
| 400 | <pre><code class="language-yaml">{@html yamlText}</code></pre> | 408 | <pre><code class="language-yaml">{@html yamlText}</code></pre> |
| 401 | {/if} | 409 | {/if} |
| 402 | <pre><code bind:this={codeBlock} class="language-yaml"></code></pre> | 410 | <pre><code bind:this={codeBlock} class="language-yaml"></code></pre> |
web/src/components/things/AndroidDetailedInfo.astro +1 −1
| @@ -1,6 +1,6 @@ | |||
| 1 | --- | 1 | --- |
| 2 | import type { AndroidInfo } from '@utils/fetch-android-info'; | 2 | import type { AndroidInfo } from '@utils/fetch-android-info'; |
| 3 | import { formatDate, timeAgo } from '@utils/dates-n-stuff'; | 3 | import { formatDate } from '@utils/dates-n-stuff'; |
| 4 | import FontAwesome from '@components/form/FontAwesome.svelte'; | 4 | import FontAwesome from '@components/form/FontAwesome.svelte'; |
| 5 | 5 | ||
| 6 | interface Props { | 6 | interface Props { |
web/src/components/things/DiscordDetailedInfo.astro −2
| @@ -1,7 +1,5 @@ | |||
| 1 | --- | 1 | --- |
| 2 | import type { DiscordInfo } from '@utils/fetch-discord-info'; | 2 | import type { DiscordInfo } from '@utils/fetch-discord-info'; |
| 3 | import { formatDate, timeAgo } from '@utils/dates-n-stuff'; | ||
| 4 | import FontAwesome from '@components/form/FontAwesome.svelte'; | ||
| 5 | 3 | ||
| 6 | interface Props { | 4 | interface Props { |
| 7 | discordData: DiscordInfo; | 5 | discordData: DiscordInfo; |
web/src/components/things/IosAppDetailedInfo.astro +2 −2
| @@ -1,7 +1,7 @@ | |||
| 1 | --- | 1 | --- |
| 2 | 2 | ||
| 3 | import type { IoSApiResponse } from '@utils/fetch-ios-info'; | 3 | import type { IoSApiResponse } from '@utils/fetch-ios-info'; |
| 4 | import { formatDate, timeAgo } from '@utils/dates-n-stuff'; | 4 | import { formatDate } from '@utils/dates-n-stuff'; |
| 5 | import FontAwesome from "@components/form/FontAwesome.svelte" | 5 | import FontAwesome from "@components/form/FontAwesome.svelte" |
| 6 | 6 | ||
| 7 | 7 | ||
| @@ -18,7 +18,7 @@ const makeRatingPercentage = (rating: number) => (rating / 5) * 100; | |||
| 18 | 18 | ||
| 19 | const roundRatings = (rating: number) => Math.round(rating * 100) / 100; | 19 | const roundRatings = (rating: number) => Math.round(rating * 100) / 100; |
| 20 | 20 | ||
| 21 | const putCommaInNumber = (num: number | any) => { | 21 | const putCommaInNumber = (num: number | string | undefined) => { |
| 22 | if (!num) return 'Unknown'; | 22 | if (!num) return 'Unknown'; |
| 23 | return typeof num === 'number' ? num.toLocaleString() : num; | 23 | return typeof num === 'number' ? num.toLocaleString() : num; |
| 24 | } | 24 | } |
web/src/components/things/ItemGitHubMetrics.astro +14 −7
| @@ -2,13 +2,19 @@ | |||
| 2 | import FontAwesome from "@components/form/FontAwesome.svelte"; | 2 | import FontAwesome from "@components/form/FontAwesome.svelte"; |
| 3 | const { github } = Astro.props; | 3 | const { github } = Astro.props; |
| 4 | 4 | ||
| 5 | // const [user, repo] = github.split("/"); | 5 | interface GitHubRepoData { |
| 6 | stargazers_count?: number; | ||
| 7 | forks_count?: number; | ||
| 8 | open_issues_count?: number; | ||
| 9 | language?: string; | ||
| 10 | license?: { spdx_id?: string; name?: string }; | ||
| 11 | } | ||
| 6 | 12 | ||
| 7 | /** | 13 | /** |
| 8 | * For a given `user/repo` fetch repository stats from the GitHub API data | 14 | * For a given `user/repo` fetch repository stats from the GitHub API data |
| 9 | * If API key is available through env var, use it to increase rate limit | 15 | * If API key is available through env var, use it to increase rate limit |
| 10 | * Returns the response data and status code (200 == success) | 16 | * Returns the response data and status code (200 == success) |
| 11 | * @param repo | 17 | * @param repo |
| 12 | */ | 18 | */ |
| 13 | const fetchGitHubData = async (repo: string) => { | 19 | const fetchGitHubData = async (repo: string) => { |
| 14 | const apiKey = import.meta.env.GITHUB_API_KEY; | 20 | const apiKey = import.meta.env.GITHUB_API_KEY; |
| @@ -17,8 +23,8 @@ const fetchGitHubData = async (repo: string) => { | |||
| 17 | headers.append("Authorization", `token ${apiKey}`); | 23 | headers.append("Authorization", `token ${apiKey}`); |
| 18 | } | 24 | } |
| 19 | 25 | ||
| 20 | let data = {}; | 26 | let data: GitHubRepoData = {}; |
| 21 | let statusCode = 0; | 27 | let statusCode; |
| 22 | 28 | ||
| 23 | const response = await fetch(`https://api.github.com/repos/${repo}`, { | 29 | const response = await fetch(`https://api.github.com/repos/${repo}`, { |
| 24 | headers: headers, | 30 | headers: headers, |
| @@ -50,7 +56,7 @@ const fetchGitHubData = async (repo: string) => { | |||
| 50 | * Given a license object, return SPDX ID, or a formatted name | 56 | * Given a license object, return SPDX ID, or a formatted name |
| 51 | * @param license | 57 | * @param license |
| 52 | */ | 58 | */ |
| 53 | const formatLicense = (license: { spdx_id?: string, name?: string }) => { | 59 | const formatLicense = (license?: { spdx_id?: string, name?: string }) => { |
| 54 | if (!license) { | 60 | if (!license) { |
| 55 | return "Unknown"; | 61 | return "Unknown"; |
| 56 | } | 62 | } |
| @@ -65,7 +71,8 @@ const formatLicense = (license: { spdx_id?: string, name?: string }) => { | |||
| 65 | * E.g. If greater than thousand, then return in k format | 71 | * E.g. If greater than thousand, then return in k format |
| 66 | * @param num | 72 | * @param num |
| 67 | */ | 73 | */ |
| 68 | const formatBigNumber = (num: number) => { | 74 | const formatBigNumber = (num: number | undefined) => { |
| 75 | if (num == null) return 0; | ||
| 69 | if (num > 1000) { | 76 | if (num > 1000) { |
| 70 | return `${(num / 1000).toFixed(1)}k`; | 77 | return `${(num / 1000).toFixed(1)}k`; |
| 71 | } | 78 | } |
| @@ -73,7 +80,7 @@ const formatBigNumber = (num: number) => { | |||
| 73 | } | 80 | } |
| 74 | 81 | ||
| 75 | // Initiate GitHub fetch, and make available to the component | 82 | // Initiate GitHub fetch, and make available to the component |
| 76 | const stats = (await fetchGitHubData(github)) as any; | 83 | const stats = await fetchGitHubData(github); |
| 77 | 84 | ||
| 78 | const { | 85 | const { |
| 79 | stargazers_count, forks_count, open_issues_count, language, license, | 86 | stargazers_count, forks_count, open_issues_count, language, license, |
web/src/components/things/RedditDetailedInfo.astro +1 −2
| @@ -1,7 +1,6 @@ | |||
| 1 | --- | 1 | --- |
| 2 | import type { RedditData } from '@utils/fetch-reddit-info'; | 2 | import type { RedditData } from '@utils/fetch-reddit-info'; |
| 3 | import { timestampToDate, timeAgo } from '@utils/dates-n-stuff'; | 3 | import { timestampToDate } from '@utils/dates-n-stuff'; |
| 4 | import FontAwesome from '@components/form/FontAwesome.svelte'; | ||
| 5 | 4 | ||
| 6 | interface Props { | 5 | interface Props { |
| 7 | redditData: RedditData; | 6 | redditData: RedditData; |
web/src/components/things/SavedServices.svelte +1 −1
| @@ -48,7 +48,7 @@ | |||
| 48 | <div> | 48 | <div> |
| 49 | {#if $savedServices.length > 0} | 49 | {#if $savedServices.length > 0} |
| 50 | <div class="saved-services"> | 50 | <div class="saved-services"> |
| 51 | {#each $savedServices as thingy} | 51 | {#each $savedServices as thingy (thingy.service.name + thingy.section)} |
| 52 | <ServiceCard | 52 | <ServiceCard |
| 53 | categoryName={thingy.category} | 53 | categoryName={thingy.category} |
| 54 | sectionName={thingy.section} | 54 | sectionName={thingy.section} |
web/src/components/things/Search.svelte +5 −9
| @@ -2,21 +2,17 @@ | |||
| 2 | import { onMount } from 'svelte'; | 2 | import { onMount } from 'svelte'; |
| 3 | import Fuse from 'fuse.js'; | 3 | import Fuse from 'fuse.js'; |
| 4 | import { slugify } from '@utils/fetch-data'; | 4 | import { slugify } from '@utils/fetch-data'; |
| 5 | import type { | 5 | import type { Category } from '../../types/Service'; |
| 6 | Category, | ||
| 7 | Section, | ||
| 8 | Service, | ||
| 9 | ShortService, | ||
| 10 | } from '../../types/Service'; | ||
| 11 | import { formatLink } from '@utils/parse-markdown'; | 6 | import { formatLink } from '@utils/parse-markdown'; |
| 12 | import { prepareSearchItems, searchOptions } from '@utils/do-searchy-searchy'; | 7 | import { prepareSearchItems, searchOptions } from '@utils/do-searchy-searchy'; |
| 8 | import type { SearchItem } from '@utils/do-searchy-searchy'; | ||
| 13 | 9 | ||
| 14 | export let data: Category[]; | 10 | export let data: Category[]; |
| 15 | export let previousSearch: string | undefined = undefined; | 11 | export let previousSearch: string | undefined = undefined; |
| 16 | 12 | ||
| 17 | let fuse: Fuse<any>; | 13 | let fuse: Fuse<SearchItem>; |
| 18 | let searchQuery = ''; | 14 | let searchQuery = ''; |
| 19 | let results: any[] = []; | 15 | let results: SearchItem[]; |
| 20 | 16 | ||
| 21 | // Initialize Fuse.js | 17 | // Initialize Fuse.js |
| 22 | onMount(() => { | 18 | onMount(() => { |
| @@ -91,7 +87,7 @@ | |||
| 91 | {#if searchQuery.length > 0} | 87 | {#if searchQuery.length > 0} |
| 92 | <div class="suggestions"> | 88 | <div class="suggestions"> |
| 93 | <ul> | 89 | <ul> |
| 94 | {#each results as result} | 90 | {#each results as result (result.name + result.category + result.sectionName)} |
| 95 | <li class="result-row"> | 91 | <li class="result-row"> |
| 96 | <a | 92 | <a |
| 97 | href={makeResultLink( | 93 | href={makeResultLink( |
web/src/components/things/ServiceCard.astro +1 −1
| @@ -92,5 +92,5 @@ const { service, sectionName, categoryName } = Astro.props; | |||
| 92 | </div> | 92 | </div> |
| 93 | 93 | ||
| 94 | <style lang="scss"> | 94 | <style lang="scss"> |
| 95 | @import './service-card.scss'; | 95 | @use './service-card.scss'; |
| 96 | </style> | 96 | </style> |
web/src/components/things/ServiceCard.svelte +2 −1
| @@ -44,6 +44,7 @@ | |||
| 44 | src={service.icon || `https://icon.horse/icon/${formatLink(service.url)}`} | 44 | src={service.icon || `https://icon.horse/icon/${formatLink(service.url)}`} |
| 45 | /> | 45 | /> |
| 46 | <div class="service-body"> | 46 | <div class="service-body"> |
| 47 | <!-- eslint-disable-next-line svelte/no-at-html-tags -- description is from curated YAML data, not user input --> | ||
| 47 | <p>{@html service.description}</p> | 48 | <p>{@html service.description}</p> |
| 48 | </div> | 49 | </div> |
| 49 | </div> | 50 | </div> |
| @@ -64,5 +65,5 @@ | |||
| 64 | </div> | 65 | </div> |
| 65 | 66 | ||
| 66 | <style lang="scss"> | 67 | <style lang="scss"> |
| 67 | @import './service-card.scss'; | 68 | @use './service-card.scss'; |
| 68 | </style> | 69 | </style> |
web/src/layouts/Layout.astro +4 −1
| @@ -10,7 +10,7 @@ interface Props { | |||
| 10 | keywords?: string; // Overide keywords tag | 10 | keywords?: string; // Overide keywords tag |
| 11 | hideNav?: boolean; // Don't show the navbar (just homepage) | 11 | hideNav?: boolean; // Don't show the navbar (just homepage) |
| 12 | author?: string; // Author of the content | 12 | author?: string; // Author of the content |
| 13 | customSchemaJson?: any; // Custom schema item | 13 | customSchemaJson?: Record<string, unknown>; // Custom schema item |
| 14 | breadcrumbs?: Array<{ | 14 | breadcrumbs?: Array<{ |
| 15 | name: string; | 15 | name: string; |
| 16 | item: string; | 16 | item: string; |
| @@ -121,6 +121,7 @@ const makeSearchLd = () => { | |||
| 121 | { | 121 | { |
| 122 | breadcrumbs && ( | 122 | breadcrumbs && ( |
| 123 | <script | 123 | <script |
| 124 | is:inline | ||
| 124 | type="application/ld+json" | 125 | type="application/ld+json" |
| 125 | set:html={JSON.stringify(makeBreadcrumbs())} | 126 | set:html={JSON.stringify(makeBreadcrumbs())} |
| 126 | /> | 127 | /> |
| @@ -129,12 +130,14 @@ const makeSearchLd = () => { | |||
| 129 | { | 130 | { |
| 130 | customSchemaJson && ( | 131 | customSchemaJson && ( |
| 131 | <script | 132 | <script |
| 133 | is:inline | ||
| 132 | type="application/ld+json" | 134 | type="application/ld+json" |
| 133 | set:html={JSON.stringify(customSchemaJson)} | 135 | set:html={JSON.stringify(customSchemaJson)} |
| 134 | /> | 136 | /> |
| 135 | ) | 137 | ) |
| 136 | } | 138 | } |
| 137 | <script | 139 | <script |
| 140 | is:inline | ||
| 138 | type="application/ld+json" | 141 | type="application/ld+json" |
| 139 | set:html={JSON.stringify(makeSearchLd)} | 142 | set:html={JSON.stringify(makeSearchLd)} |
| 140 | /> | 143 | /> |
web/src/pages/about.astro +75 −31
| @@ -12,25 +12,44 @@ import { | |||
| 12 | appDescription, | 12 | appDescription, |
| 13 | } from '../site-config'; | 13 | } from '../site-config'; |
| 14 | 14 | ||
| 15 | const contributorsResource = async () => { | 15 | interface GitHubContributor { |
| 16 | login: string; | ||
| 17 | avatar_url: string; | ||
| 18 | html_url: string; | ||
| 19 | } | ||
| 20 | |||
| 21 | interface Sponsor { | ||
| 22 | login: string; | ||
| 23 | avatarUrl: string; | ||
| 24 | name?: string; | ||
| 25 | } | ||
| 26 | |||
| 27 | const githubHeaders: Record<string, string> = { | ||
| 28 | 'User-Agent': 'awesome-privacy', | ||
| 29 | }; | ||
| 30 | const apiKey = import.meta.env.GITHUB_API_KEY; | ||
| 31 | if (apiKey) { | ||
| 32 | githubHeaders['Authorization'] = `Bearer ${apiKey}`; | ||
| 33 | } | ||
| 34 | |||
| 35 | const contributorsResource = async (): Promise<GitHubContributor[] | null> => { | ||
| 16 | const url = | 36 | const url = |
| 17 | 'https://api.github.com/repos/lissy93/personal-security-checklist/contributors?per_page=100'; | 37 | 'https://api.github.com/repos/lissy93/personal-security-checklist/contributors?per_page=100'; |
| 18 | const response = await fetch(url); | 38 | const response = await fetch(url, { headers: githubHeaders }); |
| 19 | if (!response.ok) { | 39 | if (!response.ok) return null; |
| 20 | throw new Error('Failed to fetch contributors'); | ||
| 21 | } | ||
| 22 | return await response.json(); | 40 | return await response.json(); |
| 23 | }; | 41 | }; |
| 24 | 42 | ||
| 25 | const sponsorsResource = async () => { | 43 | const sponsorsResource = async (): Promise<Sponsor[] | null> => { |
| 26 | const url = 'https://github-sponsors.as93.workers.dev/lissy93'; | 44 | const url = 'https://github-sponsors.as93.workers.dev/lissy93'; |
| 27 | const response = await fetch(url); | 45 | const response = await fetch(url); |
| 28 | if (!response.ok) { | 46 | if (!response.ok) return null; |
| 29 | throw new Error('Failed to fetch sponsors'); | ||
| 30 | } | ||
| 31 | return await response.json(); | 47 | return await response.json(); |
| 32 | }; | 48 | }; |
| 33 | 49 | ||
| 50 | const contributors = await contributorsResource(); | ||
| 51 | const sponsors = await sponsorsResource(); | ||
| 52 | |||
| 34 | const licenseContent = async () => { | 53 | const licenseContent = async () => { |
| 35 | const url = | 54 | const url = |
| 36 | 'https://raw.githubusercontent.com/Lissy93/awesome-privacy/HEAD/LICENSE'; | 55 | 'https://raw.githubusercontent.com/Lissy93/awesome-privacy/HEAD/LICENSE'; |
| @@ -98,10 +117,10 @@ const licenseContent = async () => { | |||
| 98 | <h2 id="acknowledgements">Acknowledgements</h2> | 117 | <h2 id="acknowledgements">Acknowledgements</h2> |
| 99 | <h3 id="sponsors">Sponsors</h3> | 118 | <h3 id="sponsors">Sponsors</h3> |
| 100 | <p>Huge thanks to the following sponsors, for their ongoing support 💖</p> | 119 | <p>Huge thanks to the following sponsors, for their ongoing support 💖</p> |
| 101 | <div class="user-list"> | 120 | { |
| 102 | { | 121 | sponsors ? ( |
| 103 | sponsorsResource().then((sponsors) => { | 122 | <div class="user-list"> |
| 104 | return sponsors.map((sponsor: any) => ( | 123 | {sponsors.map((sponsor) => ( |
| 105 | <a | 124 | <a |
| 106 | class="user" | 125 | class="user" |
| 107 | href={`https://github.com/${sponsor.login}`} | 126 | href={`https://github.com/${sponsor.login}`} |
| @@ -111,10 +130,16 @@ const licenseContent = async () => { | |||
| 111 | <img src={sponsor.avatarUrl} alt={sponsor.login} /> | 130 | <img src={sponsor.avatarUrl} alt={sponsor.login} /> |
| 112 | <p>{sponsor.name || sponsor.login}</p> | 131 | <p>{sponsor.name || sponsor.login}</p> |
| 113 | </a> | 132 | </a> |
| 114 | )); | 133 | ))} |
| 115 | }) | 134 | </div> |
| 116 | } | 135 | ) : ( |
| 117 | </div> | 136 | <img |
| 137 | class="fallback-img" | ||
| 138 | src="https://readme-contribs.as93.net/sponsors/lissy93?perRow=12&shape=squircle&textColor=ffffff&limit=96" | ||
| 139 | alt="Sponsors" | ||
| 140 | /> | ||
| 141 | ) | ||
| 142 | } | ||
| 118 | 143 | ||
| 119 | <h3 id="contributors">Contributors</h3> | 144 | <h3 id="contributors">Contributors</h3> |
| 120 | <p> | 145 | <p> |
| @@ -122,23 +147,29 @@ const licenseContent = async () => { | |||
| 122 | maintain it.<br /> | 147 | maintain it.<br /> |
| 123 | Special thanks to the below, top-100 contributors 🌟 | 148 | Special thanks to the below, top-100 contributors 🌟 |
| 124 | </p> | 149 | </p> |
| 125 | <div class="user-list"> | 150 | { |
| 126 | { | 151 | contributors ? ( |
| 127 | contributorsResource().then((sponsors) => { | 152 | <div class="user-list"> |
| 128 | return sponsors.map((sponsor: any) => ( | 153 | {contributors.map((contributor) => ( |
| 129 | <a | 154 | <a |
| 130 | class="user" | 155 | class="user" |
| 131 | href={sponsor.html_url} | 156 | href={contributor.html_url} |
| 132 | target="_blank" | 157 | target="_blank" |
| 133 | rel="noreferrer" | 158 | rel="noreferrer" |
| 134 | > | 159 | > |
| 135 | <img src={sponsor.avatar_url} alt={sponsor.login} /> | 160 | <img src={contributor.avatar_url} alt={contributor.login} /> |
| 136 | <p>{sponsor.login}</p> | 161 | <p>{contributor.login}</p> |
| 137 | </a> | 162 | </a> |
| 138 | )); | 163 | ))} |
| 139 | }) | 164 | </div> |
| 140 | } | 165 | ) : ( |
| 141 | </div> | 166 | <img |
| 167 | class="fallback-img" | ||
| 168 | src="https://readme-contribs.as93.net/contributors/lissy93/awesome-privacy?perRow=12&shape=squircle&textColor=ffffff&limit=96" | ||
| 169 | alt="Contributors" | ||
| 170 | /> | ||
| 171 | ) | ||
| 172 | } | ||
| 142 | 173 | ||
| 143 | <hr /> | 174 | <hr /> |
| 144 | 175 | ||
| @@ -281,7 +312,7 @@ const licenseContent = async () => { | |||
| 281 | <style lang="scss"> | 312 | <style lang="scss"> |
| 282 | h2 { | 313 | h2 { |
| 283 | font-size: 2rem; | 314 | font-size: 2rem; |
| 284 | margin: 2rem 0 1rem 0; | 315 | margin: 1rem 0 0.5rem 0; |
| 285 | } | 316 | } |
| 286 | p { | 317 | p { |
| 287 | font-size: 1.2rem; | 318 | font-size: 1.2rem; |
| @@ -343,18 +374,25 @@ const licenseContent = async () => { | |||
| 343 | .user-list { | 374 | .user-list { |
| 344 | display: flex; | 375 | display: flex; |
| 345 | flex-wrap: wrap; | 376 | flex-wrap: wrap; |
| 346 | gap: 1rem; | 377 | gap: 0.25rem; |
| 347 | margin: 2rem 0; | 378 | margin: 2rem 0; |
| 348 | .user { | 379 | .user { |
| 349 | width: 6rem; | 380 | width: 6rem; |
| 350 | overflow: hidden; | 381 | overflow: hidden; |
| 351 | text-align: center; | 382 | text-align: center; |
| 383 | padding: 0.5rem; | ||
| 384 | border-radius: var(--curve-sm); | ||
| 385 | transition: background 0.2s ease-in-out; | ||
| 386 | &:hover { | ||
| 387 | background: var(--background-form); | ||
| 388 | } | ||
| 352 | img { | 389 | img { |
| 353 | width: 5rem; | 390 | width: 5rem; |
| 354 | height: 5rem; | 391 | height: 5rem; |
| 355 | border-radius: var(--curve-md); | 392 | border-radius: var(--curve-md); |
| 356 | } | 393 | } |
| 357 | p { | 394 | p { |
| 395 | margin: 0.5rem auto 0 auto; | ||
| 358 | font-size: 1rem; | 396 | font-size: 1rem; |
| 359 | display: -webkit-box; | 397 | display: -webkit-box; |
| 360 | -webkit-line-clamp: 1; | 398 | -webkit-line-clamp: 1; |
| @@ -364,6 +402,12 @@ const licenseContent = async () => { | |||
| 364 | } | 402 | } |
| 365 | } | 403 | } |
| 366 | 404 | ||
| 405 | .fallback-img { | ||
| 406 | max-width: 100%; | ||
| 407 | margin: 2rem 0; | ||
| 408 | border-radius: var(--curve-sm); | ||
| 409 | } | ||
| 410 | |||
| 367 | .license-content { | 411 | .license-content { |
| 368 | max-height: 500px; | 412 | max-height: 500px; |
| 369 | overflow: scroll; | 413 | overflow: scroll; |
| @@ -372,7 +416,7 @@ const licenseContent = async () => { | |||
| 372 | border-radius: var(--curve-sm); | 416 | border-radius: var(--curve-sm); |
| 373 | padding: 0.5rem; | 417 | padding: 0.5rem; |
| 374 | font-size: 0.7rem; | 418 | font-size: 0.7rem; |
| 375 | font-family: mono; | 419 | font-family: 'Lekton', monospace; |
| 376 | max-width: 100vw; | 420 | max-width: 100vw; |
| 377 | white-space: pre-line; | 421 | white-space: pre-line; |
| 378 | } | 422 | } |
web/src/pages/inventory/[...inventoryId].astro −2
| @@ -1,11 +1,9 @@ | |||
| 1 | --- | 1 | --- |
| 2 | import Layout from '@layouts/Layout.astro'; | 2 | import Layout from '@layouts/Layout.astro'; |
| 3 | import SavedServices from '@components/things/SavedServices.svelte'; | 3 | import SavedServices from '@components/things/SavedServices.svelte'; |
| 4 | import GetSharableLink from '@components/things/GetSharableLink.svelte'; | ||
| 5 | 4 | ||
| 6 | import { fetchData } from '@utils/fetch-data'; | 5 | import { fetchData } from '@utils/fetch-data'; |
| 7 | import Button from '@components/form/Button.astro'; | 6 | import Button from '@components/form/Button.astro'; |
| 8 | import EditableTitle from '@components/form/EditableTitle.svelte'; | ||
| 9 | import type { Category } from '../../types/Service'; | 7 | import type { Category } from '../../types/Service'; |
| 10 | 8 | ||
| 11 | const categories = (await fetchData())?.categories || ([] as Category[]); | 9 | const categories = (await fetchData())?.categories || ([] as Category[]); |
web/src/pages/search/[...searchTerm].astro +27 −19
| @@ -4,15 +4,14 @@ import Fuse from 'fuse.js'; | |||
| 4 | import Layout from '@layouts/Layout.astro'; | 4 | import Layout from '@layouts/Layout.astro'; |
| 5 | import { fetchData, slugify } from '@utils/fetch-data'; | 5 | import { fetchData, slugify } from '@utils/fetch-data'; |
| 6 | import { prepareSearchItems, searchOptions } from '@utils/do-searchy-searchy'; | 6 | import { prepareSearchItems, searchOptions } from '@utils/do-searchy-searchy'; |
| 7 | import type { SearchItem } from '@utils/do-searchy-searchy'; | ||
| 7 | import Search from '@components/things/Search.svelte'; | 8 | import Search from '@components/things/Search.svelte'; |
| 8 | import SmartSuggestions from '@components/things/SmartSuggestions.svelte'; | 9 | import SmartSuggestions from '@components/things/SmartSuggestions.svelte'; |
| 9 | import FontAwesome from '@components/form/FontAwesome.svelte'; | 10 | import FontAwesome from '@components/form/FontAwesome.svelte'; |
| 10 | 11 | ||
| 11 | import type { Service } from '../../types/Service'; | ||
| 12 | |||
| 13 | export const prerender = false; | 12 | export const prerender = false; |
| 14 | 13 | ||
| 15 | let fuse: Fuse<any>; | 14 | let fuse: Fuse<SearchItem>; |
| 16 | 15 | ||
| 17 | const categories = (await fetchData())?.categories; | 16 | const categories = (await fetchData())?.categories; |
| 18 | 17 | ||
| @@ -28,26 +27,35 @@ const searchResults = fuse | |||
| 28 | 27 | ||
| 29 | const services = searchResults.filter((result) => result.type === 'Service'); | 28 | const services = searchResults.filter((result) => result.type === 'Service'); |
| 30 | 29 | ||
| 30 | interface GroupedSection { | ||
| 31 | sectionName: string; | ||
| 32 | items: SearchItem[]; | ||
| 33 | } | ||
| 34 | |||
| 35 | interface GroupedCategory { | ||
| 36 | categoryName: string; | ||
| 37 | sections: Record<string, GroupedSection>; | ||
| 38 | } | ||
| 39 | |||
| 31 | const putResultsIntoGroups = () => { | 40 | const putResultsIntoGroups = () => { |
| 32 | const grouped = services.reduce((acc, item) => { | 41 | const grouped: Record<string, GroupedCategory> = {}; |
| 33 | const { category: categoryName, sectionName, ...service } = item; | ||
| 34 | 42 | ||
| 35 | if (!acc[categoryName]) { | 43 | for (const item of services) { |
| 36 | acc[categoryName] = { categoryName, sections: {} }; | 44 | const categoryName = item.category; |
| 37 | } | 45 | const sectionName = item.sectionName || ''; |
| 38 | 46 | ||
| 39 | if (!acc[categoryName].sections[sectionName]) { | 47 | if (!grouped[categoryName]) { |
| 40 | acc[categoryName].sections[sectionName] = { sectionName, items: [] }; | 48 | grouped[categoryName] = { categoryName, sections: {} }; |
| 41 | } | 49 | } |
| 42 | 50 | ||
| 43 | acc[categoryName].sections[sectionName].items.push(service); | 51 | if (!grouped[categoryName].sections[sectionName]) { |
| 52 | grouped[categoryName].sections[sectionName] = { sectionName, items: [] }; | ||
| 53 | } | ||
| 44 | 54 | ||
| 45 | return acc; | 55 | grouped[categoryName].sections[sectionName].items.push(item); |
| 46 | }, {}); | 56 | } |
| 47 | 57 | ||
| 48 | // Convert the grouped object into the desired array structure. | 58 | return Object.values(grouped).map((category) => ({ |
| 49 | // And fuck it, let's use `any` | ||
| 50 | return Object.values(grouped).map((category: any) => ({ | ||
| 51 | categoryName: category.categoryName, | 59 | categoryName: category.categoryName, |
| 52 | sections: Object.values(category.sections), | 60 | sections: Object.values(category.sections), |
| 53 | })); | 61 | })); |
| @@ -74,7 +82,7 @@ const beer = putResultsIntoGroups(); | |||
| 74 | </section> | 82 | </section> |
| 75 | <div class="results"> | 83 | <div class="results"> |
| 76 | { | 84 | { |
| 77 | beer.map((category: any) => ( | 85 | beer.map((category) => ( |
| 78 | <div class="category"> | 86 | <div class="category"> |
| 79 | <a class="category-title" href={`/${slugify(category.categoryName)}`}> | 87 | <a class="category-title" href={`/${slugify(category.categoryName)}`}> |
| 80 | <h3>{category.categoryName}</h3> | 88 | <h3>{category.categoryName}</h3> |
| @@ -83,11 +91,11 @@ const beer = putResultsIntoGroups(); | |||
| 83 | <FontAwesome iconName={slugify(category.categoryName)} /> | 91 | <FontAwesome iconName={slugify(category.categoryName)} /> |
| 84 | </span> | 92 | </span> |
| 85 | <ul class="section-list"> | 93 | <ul class="section-list"> |
| 86 | {category.sections.map((section: any) => ( | 94 | {category.sections.map((section) => ( |
| 87 | <li class="section-item"> | 95 | <li class="section-item"> |
| 88 | <h4>{section.sectionName}</h4> | 96 | <h4>{section.sectionName}</h4> |
| 89 | <ul class="service-list"> | 97 | <ul class="service-list"> |
| 90 | {section.items.map((item: Service) => ( | 98 | {section.items.map((item) => ( |
| 91 | <li> | 99 | <li> |
| 92 | <a href={item.url}>{item.name}</a> | 100 | <a href={item.url}>{item.name}</a> |
| 93 | </li> | 101 | </li> |
web/src/utils/do-searchy-searchy.test.ts +5 −4
| @@ -1,5 +1,6 @@ | |||
| 1 | import { describe, it, expect } from 'vitest'; | 1 | import { describe, it, expect } from 'vitest'; |
| 2 | import { prepareSearchItems } from './do-searchy-searchy'; | 2 | import { prepareSearchItems } from './do-searchy-searchy'; |
| 3 | import type { SearchItem } from './do-searchy-searchy'; | ||
| 3 | import type { Category } from '../types/Service'; | 4 | import type { Category } from '../types/Service'; |
| 4 | 5 | ||
| 5 | const makeCategory = (overrides: Partial<Category> = {}): Category => | 6 | const makeCategory = (overrides: Partial<Category> = {}): Category => |
| @@ -35,7 +36,7 @@ describe('prepareSearchItems', () => { | |||
| 35 | }), | 36 | }), |
| 36 | ] as Category[]; | 37 | ] as Category[]; |
| 37 | const items = prepareSearchItems(categories); | 38 | const items = prepareSearchItems(categories); |
| 38 | const section = items.find((i: { type: string }) => i.type === 'Section'); | 39 | const section = items.find((i: SearchItem) => i.type === 'Section'); |
| 39 | expect(section).toMatchObject({ | 40 | expect(section).toMatchObject({ |
| 40 | type: 'Section', | 41 | type: 'Section', |
| 41 | sectionName: 'Messaging', | 42 | sectionName: 'Messaging', |
| @@ -66,7 +67,7 @@ describe('prepareSearchItems', () => { | |||
| 66 | }), | 67 | }), |
| 67 | ] as Category[]; | 68 | ] as Category[]; |
| 68 | const items = prepareSearchItems(categories); | 69 | const items = prepareSearchItems(categories); |
| 69 | const service = items.find((i: { type: string }) => i.type === 'Service'); | 70 | const service = items.find((i: SearchItem) => i.type === 'Service'); |
| 70 | expect(service).toMatchObject({ | 71 | expect(service).toMatchObject({ |
| 71 | type: 'Service', | 72 | type: 'Service', |
| 72 | name: 'Signal', | 73 | name: 'Signal', |
| @@ -99,7 +100,7 @@ describe('prepareSearchItems', () => { | |||
| 99 | }), | 100 | }), |
| 100 | ] as Category[]; | 101 | ] as Category[]; |
| 101 | const items = prepareSearchItems(categories); | 102 | const items = prepareSearchItems(categories); |
| 102 | const cat = items.find((i: { type: string }) => i.type === 'Category'); | 103 | const cat = items.find((i: SearchItem) => i.type === 'Category'); |
| 103 | expect(cat.itemCount).toBe(3); | 104 | expect(cat?.itemCount).toBe(3); |
| 104 | }); | 105 | }); |
| 105 | }); | 106 | }); |
web/src/utils/do-searchy-searchy.ts +14 −2
| @@ -1,7 +1,19 @@ | |||
| 1 | import type { Category } from '../types/Service'; | 1 | import type { Category } from '../types/Service'; |
| 2 | 2 | ||
| 3 | export const prepareSearchItems = (categories: Category[]) => { | 3 | export interface SearchItem { |
| 4 | const items: any = []; | 4 | type: 'Category' | 'Section' | 'Service'; |
| 5 | category: string; | ||
| 6 | itemCount?: number; | ||
| 7 | sectionName?: string; | ||
| 8 | description?: string; | ||
| 9 | name?: string; | ||
| 10 | url?: string; | ||
| 11 | github?: string; | ||
| 12 | logo?: string; | ||
| 13 | } | ||
| 14 | |||
| 15 | export const prepareSearchItems = (categories: Category[]): SearchItem[] => { | ||
| 16 | const items: SearchItem[] = []; | ||
| 5 | // Add each category | 17 | // Add each category |
| 6 | categories.forEach((category) => { | 18 | categories.forEach((category) => { |
| 7 | items.push({ | 19 | items.push({ |
web/src/utils/fetch-website-info.ts +1 −1
| @@ -61,7 +61,7 @@ interface Redirection { | |||
| 61 | found: boolean; | 61 | found: boolean; |
| 62 | external: boolean; | 62 | external: boolean; |
| 63 | url: string; | 63 | url: string; |
| 64 | redirects: any[]; | 64 | redirects: string[]; |
| 65 | } | 65 | } |
| 66 | 66 | ||
| 67 | interface ResponseHeaders { | 67 | interface ResponseHeaders { |