Commit 4a0d88a2a5
4a0d88a2a5d2bd09b4d25cf62912e892b8e28a8b
parent: 73467b3e7c
Unsigned
Alicia Sykes <alicia@omg.lol> · 2024-03-26 23:57 UTC
Adds inventory feature
Layout: unified · split
web/public/robots.txt
+2
| @@ -1,6 +1,8 @@ |
| 1 | 1 | User-agent: * |
| 2 | 2 | Disallow: /search/* |
| 3 | Disallow: /inventory/* |
| 3 | 4 | Allow: /search/$ |
| 5 | Allow: /inventory/$ |
| 4 | 6 | Allow: /sitemap |
| 5 | 7 | |
| 6 | 8 | Sitemap: https://awesome-privacy.xyz/sitemap-index.xml |
web/src/components/form/EditableTitle.svelte
added
+82
| @@ -0,0 +1,82 @@ |
| 1 | <script> |
| 2 | import { onMount, tick } from 'svelte'; |
| 3 | let title = 'Inventory'; // Default title |
| 4 | let editing = false; |
| 5 | |
| 6 | // Function to save the title to local storage |
| 7 | function saveTitle(newTitle) { |
| 8 | localStorage.setItem('userTitle', newTitle); |
| 9 | title = newTitle; |
| 10 | editing = false; |
| 11 | } |
| 12 | |
| 13 | onMount(async () => { |
| 14 | const storedTitle = localStorage.getItem('userTitle'); |
| 15 | if (storedTitle) { |
| 16 | title = storedTitle; |
| 17 | } |
| 18 | await tick(); // Ensures Svelte has completed initial DOM updates |
| 19 | }); |
| 20 | |
| 21 | // Function to handle key events |
| 22 | function handleKeydown(event) { |
| 23 | if (event.key === 'Enter') { |
| 24 | event.preventDefault(); // Prevent form submission |
| 25 | saveTitle(event.target.innerText); |
| 26 | event.target.blur(); // Remove focus from the element |
| 27 | } |
| 28 | if (event.key === 'Escape') { |
| 29 | editing = false; |
| 30 | event.target.innerText = title; // Revert changes |
| 31 | event.target.blur(); // Remove focus from the element |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | // Click outside to stop editing |
| 36 | function handleClickOutside(event) { |
| 37 | if (editing) { |
| 38 | saveTitle(event.target.innerText); |
| 39 | editing = false; |
| 40 | } |
| 41 | } |
| 42 | </script> |
| 43 | |
| 44 | <svelte:window on:click={handleClickOutside}/> |
| 45 | |
| 46 | <!-- svelte-ignore a11y-no-noninteractive-tabindex --> |
| 47 | <div> |
| 48 | <h2 |
| 49 | contenteditable={true} |
| 50 | class:editable={editing} |
| 51 | on:click={() => editing = true} |
| 52 | on:keydown={handleKeydown} |
| 53 | on:blur={() => saveTitle(title)} |
| 54 | tabindex="0" |
| 55 | >{title}</h2> |
| 56 | |
| 57 | <small>Click the title, to edit your inventory name</small> |
| 58 | </div> |
| 59 | |
| 60 | <style> |
| 61 | h2 { |
| 62 | font-family: "Lekton", sans-serif; |
| 63 | font-weight: bold; |
| 64 | font-size: 3rem; |
| 65 | margin: 0; |
| 66 | color: var(--accent-3); |
| 67 | cursor: pointer; |
| 68 | border-bottom: 2px solid transparent; |
| 69 | outline: none; |
| 70 | padding: 0.25rem; |
| 71 | } |
| 72 | .editable { |
| 73 | border-bottom: 2px solid var(--accent-3); /* Visual cue to show editable state */ |
| 74 | } |
| 75 | h2:focus { |
| 76 | border-bottom: 2px solid var(--accent-3); |
| 77 | } |
| 78 | small { |
| 79 | font-size: 0.8rem; |
| 80 | opacity: 0.5; |
| 81 | } |
| 82 | </style> |
web/src/components/form/FontAwesome.svelte
+1
| @@ -78,6 +78,7 @@ |
| 78 | 78 | |
| 79 | 79 | //Misc |
| 80 | 80 | ratingStar: solidIcons.faStar, |
| 81 | saveListing: solidIcons.faBookmark |
| 81 | 82 | }; |
| 82 | 83 | |
| 83 | 84 | export let iconName: string; |
web/src/components/things/DeleteListing.svelte
+2 −1
| @@ -40,7 +40,7 @@ |
| 40 | 40 | <style lang="scss"> |
| 41 | 41 | .actions { |
| 42 | 42 | position: absolute; |
| 43 | | right: 1rem; |
| 43 | right: 3.5rem; |
| 44 | 44 | top: 1rem; |
| 45 | 45 | width: 2.8rem; |
| 46 | 46 | gap: 1rem; |
| @@ -53,6 +53,7 @@ |
| 53 | 53 | transition: all 0.2s ease-in-out; |
| 54 | 54 | &:hover { |
| 55 | 55 | color: var(--accent-3); |
| 56 | opacity: 1; |
| 56 | 57 | } |
| 57 | 58 | } |
| 58 | 59 | |
web/src/components/things/GetSharableLink.svelte
added
+82
| @@ -0,0 +1,82 @@ |
| 1 | |
| 2 | <script lang="ts"> |
| 3 | |
| 4 | import { slugify } from "@utils/fetch-data"; |
| 5 | |
| 6 | let linkId = ''; |
| 7 | let done = false; |
| 8 | let error = false; |
| 9 | |
| 10 | const save = async () => { |
| 11 | const savedServices = JSON.parse(localStorage.getItem('savedServices') || '[]'); |
| 12 | const inventoryTitle = localStorage.getItem('userTitle') || 'Anon\'s Inventory'; |
| 13 | const uniqueId = Math.random().toString(36).substring(2); |
| 14 | const saveKey = `${uniqueId}_${slugify(inventoryTitle)}`; |
| 15 | const url = 'https://awesome-privacy-share-api.as93.net'; |
| 16 | const data = { key: saveKey, services: savedServices }; |
| 17 | fetch(url, { |
| 18 | method: 'PUT', |
| 19 | headers: { 'Content-Type': 'application/json' }, |
| 20 | body: JSON.stringify(data), |
| 21 | }) |
| 22 | .then(response => response.json()) |
| 23 | .then(data => { |
| 24 | linkId = data.key; |
| 25 | done = true; |
| 26 | error = false; |
| 27 | navigator.clipboard.writeText(`https://awesome-privacy.xyz/inventory/${linkId}`); |
| 28 | }) |
| 29 | .catch(error => { |
| 30 | error = true; |
| 31 | console.error('Error:', error) |
| 32 | }); |
| 33 | }; |
| 34 | |
| 35 | </script> |
| 36 | |
| 37 | <div class="share-container"> |
| 38 | {#if !done} |
| 39 | <button class="save-button" on:click={save}>Get Sharable Link</button> |
| 40 | {/if} |
| 41 | {#if done} |
| 42 | <span class="success-msg"> |
| 43 | Done! Your share link has been copied to clipboard. |
| 44 | <a href={`https://awesome-privacy.xyz/inventory/${linkId}`}> |
| 45 | Visit Link |
| 46 | </a> |
| 47 | </span> |
| 48 | {/if} |
| 49 | {#if error} |
| 50 | <span class="error-msg">Something unexpected happened</span> |
| 51 | {/if} |
| 52 | </div> |
| 53 | |
| 54 | <style lang="scss"> |
| 55 | .share-container { |
| 56 | display: flex; |
| 57 | flex-direction: column; |
| 58 | max-width: 300px; |
| 59 | } |
| 60 | .save-button { |
| 61 | background: var(--accent-3); |
| 62 | border: 1px solid var(--box-outline); |
| 63 | box-shadow: 3px 3px 0 var(--box-outline); |
| 64 | padding: 0.25rem 0.5rem; |
| 65 | border-radius: var(--curve-sm); |
| 66 | color: var(--foreground); |
| 67 | font-family: Lekton; |
| 68 | font-size: 1.2rem; |
| 69 | cursor: pointer; |
| 70 | } |
| 71 | .success-msg { |
| 72 | font-size: 1rem; |
| 73 | color: var(--success); |
| 74 | a { |
| 75 | color: var(--success); |
| 76 | } |
| 77 | } |
| 78 | .error-msg { |
| 79 | font-size: 1rem; |
| 80 | color: var(--danger); |
| 81 | } |
| 82 | </style> |
web/src/components/things/SaveListing.svelte
added
+93
| @@ -0,0 +1,93 @@ |
| 1 | <script lang="ts"> |
| 2 | import { onMount } from 'svelte'; |
| 3 | import FontAwesome from "@components/form/FontAwesome.svelte"; |
| 4 | import { slugify } from "@utils/fetch-data"; |
| 5 | |
| 6 | export let categoryName: string; |
| 7 | export let sectionName: string; |
| 8 | export let serviceName: string; |
| 9 | export let showLabel: boolean = false; |
| 10 | |
| 11 | const serviceRef = `${slugify(categoryName)}/${slugify(sectionName)}/${slugify(serviceName)}`; |
| 12 | |
| 13 | let isSaved = false; |
| 14 | |
| 15 | onMount(async () => { |
| 16 | const stored = JSON.parse(localStorage.getItem('savedServices') || '[]'); |
| 17 | if (stored.includes(serviceRef)) { |
| 18 | isSaved = true; |
| 19 | } |
| 20 | }); |
| 21 | |
| 22 | function toggleSave() { |
| 23 | const stored = JSON.parse(localStorage.getItem('savedServices') || '[]'); |
| 24 | const index = stored.indexOf(serviceRef); |
| 25 | if (index === -1) { |
| 26 | stored.push(serviceRef); |
| 27 | isSaved = true; |
| 28 | } else { |
| 29 | stored.splice(index, 1); |
| 30 | isSaved = false; |
| 31 | } |
| 32 | localStorage.setItem('savedServices', JSON.stringify(stored)); |
| 33 | } |
| 34 | </script> |
| 35 | |
| 36 | <button |
| 37 | class={`save-container ${isSaved ? 'saved' : ''} ${showLabel ? 'label-button' : ''}`} |
| 38 | title={`Save ${serviceName}`} |
| 39 | on:click={toggleSave}> |
| 40 | {#if showLabel } |
| 41 | <span>Save</span> |
| 42 | {/if} |
| 43 | <FontAwesome iconName="saveListing"/> |
| 44 | </button> |
| 45 | |
| 46 | <style lang="scss"> |
| 47 | .save-container { |
| 48 | cursor: pointer; |
| 49 | background: none; |
| 50 | border: none; |
| 51 | display: flex; |
| 52 | gap: 0.5rem; |
| 53 | align-items: center; |
| 54 | transition: all 0.2s ease-in-out; |
| 55 | span { |
| 56 | font-size: 1.2rem; |
| 57 | opacity: 0.8; |
| 58 | color: var(--foreground); |
| 59 | font-family: "Lekton"; |
| 60 | } |
| 61 | :global(svg) { |
| 62 | color: var(--foreground); |
| 63 | width: 1.2rem; |
| 64 | height: 1.2rem; |
| 65 | opacity: 0.5; |
| 66 | transition: all 0.2s ease-in-out; |
| 67 | } |
| 68 | &:hover { |
| 69 | :global(svg) { |
| 70 | color: var(--accent-3); |
| 71 | opacity: 1; |
| 72 | } |
| 73 | } |
| 74 | &.saved { |
| 75 | :global(svg) { |
| 76 | color: var(--accent-2); |
| 77 | opacity: 1; |
| 78 | } |
| 79 | } |
| 80 | &.label-button { |
| 81 | padding: 0.2rem 0.4rem; |
| 82 | border-radius: var(--curve-sm); |
| 83 | box-shadow: 3px 3px 0 var(--box-outline); |
| 84 | border: 1px solid var(--box-outline); |
| 85 | background: var(--background-form); |
| 86 | |
| 87 | &:hover { |
| 88 | |
| 89 | box-shadow: 4px 4px 0 var(--box-outline); |
| 90 | } |
| 91 | } |
| 92 | } |
| 93 | </style> |
web/src/components/things/SavedServices.svelte
added
+89
| @@ -0,0 +1,89 @@ |
| 1 | <script lang="ts"> |
| 2 | import { onMount } from 'svelte'; |
| 3 | import { writable } from 'svelte/store'; |
| 4 | |
| 5 | import type { Category, Service } from '../../types/Service'; |
| 6 | import { slugify } from "@utils/fetch-data"; |
| 7 | import ServiceCard from './ServiceCard.svelte'; |
| 8 | |
| 9 | export let allData: Category[]; |
| 10 | export let serviceList: string[] | null = null; |
| 11 | |
| 12 | interface SavedServices { |
| 13 | category: string; |
| 14 | section: string; |
| 15 | service: Service; |
| 16 | } |
| 17 | |
| 18 | const savedServices = writable<SavedServices[]>([]); |
| 19 | |
| 20 | onMount(async () => { |
| 21 | const results: SavedServices[] = []; |
| 22 | const saved = serviceList || JSON.parse(localStorage.getItem('savedServices') || '[]'); |
| 23 | saved.forEach((serviceId: string) => { |
| 24 | const parts = serviceId.split('/'); |
| 25 | const categoryName = parts[0]; |
| 26 | const sectionName = parts[1]; |
| 27 | const serviceName = parts[2]; |
| 28 | |
| 29 | const category = allData.find((category) => slugify(category.name) === categoryName); |
| 30 | if (!category) return; |
| 31 | const section = category.sections.find((section) => slugify(section.name) === sectionName); |
| 32 | if (!section) return; |
| 33 | const service = section.services.find((service) => slugify(service.name) === serviceName); |
| 34 | if (!service) return; |
| 35 | results.push({ category: category.name, section: section.name, service}); |
| 36 | }); |
| 37 | savedServices.set(results || []); |
| 38 | }); |
| 39 | |
| 40 | </script> |
| 41 | |
| 42 | <div> |
| 43 | {#if $savedServices.length > 0} |
| 44 | <div class="saved-services"> |
| 45 | {#each $savedServices as thingy} |
| 46 | <ServiceCard |
| 47 | categoryName={thingy.category} |
| 48 | sectionName={thingy.section} |
| 49 | service={thingy.service} |
| 50 | /> |
| 51 | {/each} |
| 52 | </div> |
| 53 | {:else if !serviceList} |
| 54 | <div class="nothing-yet"> |
| 55 | <p>Here you'll find a list of all the software and services you've bookmarked.</p> |
| 56 | <small> |
| 57 | All data is stored on-device, in your browser's local storage, |
| 58 | and not sent anywhere unless you choose to share it |
| 59 | </small> |
| 60 | <p class="nope">Nothing saved yet!</p> |
| 61 | </div> |
| 62 | {/if} |
| 63 | </div> |
| 64 | |
| 65 | <style lang="scss"> |
| 66 | .saved-services { |
| 67 | display: grid; |
| 68 | grid-template-columns: repeat(auto-fill, minmax(350px, 1fr)); |
| 69 | gap: 1rem; |
| 70 | margin-top: 1rem; |
| 71 | } |
| 72 | |
| 73 | .nothing-yet { |
| 74 | text-align: center; |
| 75 | p { |
| 76 | margin: 0; |
| 77 | } |
| 78 | small { |
| 79 | font-size: 0.8rem; |
| 80 | opacity: 0.6; |
| 81 | } |
| 82 | .nope { |
| 83 | font-weight: bold; |
| 84 | margin: 2rem 0; |
| 85 | opacity: 0.2; |
| 86 | font-size: 1.6rem; |
| 87 | } |
| 88 | } |
| 89 | </style> |
web/src/components/things/ServiceCard.astro
+12 −107
| @@ -3,6 +3,7 @@ |
| 3 | 3 | import { formatLink } from '@utils/parse-markdown'; |
| 4 | 4 | import type { Service } from 'src/types/Service'; |
| 5 | 5 | import FontAwesome from '@components/form/FontAwesome.svelte'; |
| 6 | import SaveListing from '@components/things/SaveListing.svelte'; |
| 6 | 7 | import { slugify } from '@utils/fetch-data'; |
| 7 | 8 | |
| 8 | 9 | interface Props { |
| @@ -39,7 +40,6 @@ const { |
| 39 | 40 | |
| 40 | 41 | |
| 41 | 42 | <div class="service" id={slugify(service.name)}> |
| 42 | | <!-- <DeleteListing client:load categoryName={categoryName} sectionName={sectionName} serviceName={service.name} /> --> |
| 43 | 43 | <div class="service-head"> |
| 44 | 44 | <a class="service-title" href={`/${slugify(categoryName)}/${slugify(sectionName)}/${slugify(service.name)}`}> |
| 45 | 45 | <h4>{service.name}</h4> |
| @@ -47,6 +47,14 @@ const { |
| 47 | 47 | {service.followWith && <p class="follow-with">({service.followWith})</p> } |
| 48 | 48 | </div> |
| 49 | 49 | |
| 50 | <div class="save-listing"> |
| 51 | <SaveListing client:visible |
| 52 | categoryName={categoryName} |
| 53 | sectionName={sectionName} |
| 54 | serviceName={service.name} |
| 55 | /> |
| 56 | </div> |
| 57 | |
| 50 | 58 | <div class="service-body"> |
| 51 | 59 | <img |
| 52 | 60 | width="40" |
| @@ -79,109 +87,6 @@ const { |
| 79 | 87 | </div> |
| 80 | 88 | </div> |
| 81 | 89 | |
| 82 | | |
| 83 | | <style lang="scss"> |
| 84 | | .service { |
| 85 | | display: flex; |
| 86 | | flex-direction: column; |
| 87 | | padding: 1rem; |
| 88 | | border: 2px solid var(--box-outline); |
| 89 | | box-shadow: 6px 6px 0 var(--box-outline); |
| 90 | | background: var(--accent-fg); |
| 91 | | border-radius: var(--curve-sm); |
| 92 | | |
| 93 | | .service-head { |
| 94 | | display: flex; |
| 95 | | align-items: center; |
| 96 | | gap: 0.5rem; |
| 97 | | h4 { |
| 98 | | margin: 0; |
| 99 | | font-size: 1.4rem; |
| 100 | | color: var(--foreground); |
| 101 | | } |
| 102 | | p { |
| 103 | | margin: 0; |
| 104 | | font-size: 1rem; |
| 105 | | opacity: 0.7; |
| 106 | | } |
| 107 | | a { |
| 108 | | text-decoration: none; |
| 109 | | } |
| 110 | | h4 { |
| 111 | | text-decoration: none; |
| 112 | | position: relative; |
| 113 | | &:after { |
| 114 | | background: none repeat scroll 0 0 transparent; |
| 115 | | bottom: 0; |
| 116 | | content: ""; |
| 117 | | display: block; |
| 118 | | height: 3px; |
| 119 | | left: 50%; |
| 120 | | position: absolute; |
| 121 | | background: var(--accent-3); |
| 122 | | transition: width 0.2s ease 0s, left 0.2s ease 0s; |
| 123 | | width: 0; |
| 124 | | } |
| 125 | | &:hover:after { |
| 126 | | width: 100%; |
| 127 | | left: 0; |
| 128 | | } |
| 129 | | } |
| 130 | | } |
| 131 | | |
| 132 | | .service-body { |
| 133 | | display: flex; |
| 134 | | align-items: center; |
| 135 | | gap: 0.5rem; |
| 136 | | img { |
| 137 | | border-radius: var(--curve-sm); |
| 138 | | font-size: 0.6rem; |
| 139 | | color: var(--accent); |
| 140 | | } |
| 141 | | :global(p) { |
| 142 | | display: -webkit-box; |
| 143 | | -webkit-line-clamp: 3; |
| 144 | | -webkit-box-orient: vertical; |
| 145 | | overflow: hidden; |
| 146 | | margin: 0.5rem 0; |
| 147 | | width: calc(100% - 2rem); |
| 148 | | overflow-x: hidden; |
| 149 | | } |
| 150 | | } |
| 151 | | |
| 152 | | .service-links { |
| 153 | | display: flex; |
| 154 | | gap: 0.5rem; |
| 155 | | justify-content: space-between; |
| 156 | | a { |
| 157 | | color: var(--accent-3); |
| 158 | | font-size: 0.8rem; |
| 159 | | display: inline-flex; |
| 160 | | align-items: center; |
| 161 | | gap: 0.25rem; |
| 162 | | opacity: 0.85; |
| 163 | | text-decoration: none; |
| 164 | | max-width: 50%; |
| 165 | | min-width: 25%; |
| 166 | | &:not(:last-child) { |
| 167 | | margin-right: 0.5rem; |
| 168 | | } |
| 169 | | &:hover { |
| 170 | | text-decoration: underline; |
| 171 | | opacity: 1; |
| 172 | | } |
| 173 | | :global(svg) { |
| 174 | | width: 1rem; |
| 175 | | height: 1rem; |
| 176 | | } |
| 177 | | span { |
| 178 | | max-width: calc(100% - 1rem); |
| 179 | | text-overflow: ellipsis; |
| 180 | | white-space: nowrap; |
| 181 | | overflow: hidden; |
| 182 | | } |
| 183 | | } |
| 184 | | } |
| 185 | | } |
| 186 | | |
| 187 | | </style> |
| 90 | <style lang="scss"> |
| 91 | @import './service-card.scss'; |
| 92 | </style> |
web/src/components/things/ServiceCard.svelte
added
+69
| @@ -0,0 +1,69 @@ |
| 1 | <script lang="ts"> |
| 2 | import FontAwesome from '@components/form/FontAwesome.svelte'; |
| 3 | import SaveListing from '@components/things/SaveListing.svelte'; |
| 4 | import { slugify } from '@utils/fetch-data'; |
| 5 | import { formatLink } from '@utils/parse-markdown'; |
| 6 | import type { Service } from 'src/types/Service'; |
| 7 | |
| 8 | export let service: Service; |
| 9 | export let categoryName: string; |
| 10 | export let sectionName: string; |
| 11 | |
| 12 | // Computed values based on props |
| 13 | let serviceRef = slugify(service.name); |
| 14 | let categorySlug = slugify(categoryName); |
| 15 | let sectionSlug = slugify(sectionName); |
| 16 | </script> |
| 17 | |
| 18 | <div class="service" id={serviceRef}> |
| 19 | <div class="service-head"> |
| 20 | <a class="service-title" href={`/${categorySlug}/${sectionSlug}/${serviceRef}`}> |
| 21 | <h4>{service.name}</h4> |
| 22 | </a> |
| 23 | {#if service.followWith} |
| 24 | <p class="follow-with">({service.followWith})</p> |
| 25 | {/if} |
| 26 | </div> |
| 27 | |
| 28 | <div class="save-listing"> |
| 29 | <SaveListing |
| 30 | categoryName={categoryName} |
| 31 | sectionName={sectionName} |
| 32 | serviceName={service.name} |
| 33 | /> |
| 34 | </div> |
| 35 | |
| 36 | <div class="service-body"> |
| 37 | <img |
| 38 | width="40" |
| 39 | height="40" |
| 40 | loading="lazy" |
| 41 | decoding="async" |
| 42 | class="service-icon" |
| 43 | alt={`${service.name} Icon`} |
| 44 | data-service-url={formatLink(service.url)} |
| 45 | src={service.icon || `https://icon.horse/icon/${formatLink(service.url)}`} |
| 46 | /> |
| 47 | <div class="service-body"> |
| 48 | <p>{@html service.description}</p> |
| 49 | </div> |
| 50 | </div> |
| 51 | |
| 52 | <div class="service-links"> |
| 53 | <a class="link" href={service.url}> |
| 54 | <FontAwesome iconName="website" /> <span>{formatLink(service.url)}</span> |
| 55 | </a> |
| 56 | {#if service.github} |
| 57 | <a class="link" href={`https://github.com/${service.github}`}> |
| 58 | <FontAwesome iconName="sourceCode" /> GitHub |
| 59 | </a> |
| 60 | {/if} |
| 61 | <a href={`/${categorySlug}/${sectionSlug}/${serviceRef}`}> |
| 62 | <FontAwesome iconName="viewReport" /> View Report ➔ |
| 63 | </a> |
| 64 | </div> |
| 65 | </div> |
| 66 | |
| 67 | <style lang="scss"> |
| 68 | @import './service-card.scss'; |
| 69 | </style> |
web/src/components/things/ServiceList.astro
+20 −1
| @@ -8,6 +8,7 @@ import DeleteListing from '@components/things/DeleteListing.svelte'; |
| 8 | 8 | import { slugify } from '@utils/fetch-data'; |
| 9 | 9 | |
| 10 | 10 | import GitHubMetrics from '@components/things/ItemGitHubMetrics.astro'; |
| 11 | import SaveListing from '@components/things/SaveListing.svelte'; |
| 11 | 12 | |
| 12 | 13 | interface Props { |
| 13 | 14 | services: Service[]; |
| @@ -54,6 +55,13 @@ const { |
| 54 | 55 | {services.map((service: Service) => ( |
| 55 | 56 | <li id={slugify(service.name)}> |
| 56 | 57 | <DeleteListing client:load categoryName={categoryName} sectionName={sectionName} serviceName={service.name} /> |
| 58 | <div class="save-listing"> |
| 59 | <SaveListing client:visible |
| 60 | categoryName={categoryName} |
| 61 | sectionName={sectionName} |
| 62 | serviceName={service.name} |
| 63 | /> |
| 64 | </div> |
| 57 | 65 | <div class="service-head"> |
| 58 | 66 | <img |
| 59 | 67 | width="40" |
| @@ -157,6 +165,11 @@ const { |
| 157 | 165 | li { |
| 158 | 166 | margin-bottom: 1rem; |
| 159 | 167 | position: relative; |
| 168 | .save-listing { |
| 169 | position: absolute; |
| 170 | right: 1rem; |
| 171 | top: 1rem; |
| 172 | } |
| 160 | 173 | .service-head { |
| 161 | 174 | display: flex; |
| 162 | 175 | align-items: center; |
| @@ -304,7 +317,13 @@ const { |
| 304 | 317 | } |
| 305 | 318 | |
| 306 | 319 | li:hover :global(.actions) { |
| 307 | | opacity: 0.5; |
| 320 | opacity: 0.6; |
| 321 | :global(a):hover { |
| 322 | opacity: 1; |
| 323 | } |
| 324 | } |
| 325 | :global(.actions a):hover { |
| 326 | opacity: 1; |
| 308 | 327 | } |
| 309 | 328 | |
| 310 | 329 | </style> |
web/src/components/things/service-card.scss
added
+110
| @@ -0,0 +1,110 @@ |
| 1 | .service { |
| 2 | display: flex; |
| 3 | flex-direction: column; |
| 4 | padding: 1rem; |
| 5 | border: 2px solid var(--box-outline); |
| 6 | box-shadow: 6px 6px 0 var(--box-outline); |
| 7 | background: var(--accent-fg); |
| 8 | border-radius: var(--curve-sm); |
| 9 | position: relative; |
| 10 | overflow: hidden; |
| 11 | |
| 12 | .service-head { |
| 13 | display: flex; |
| 14 | align-items: center; |
| 15 | gap: 0.5rem; |
| 16 | h4 { |
| 17 | margin: 0; |
| 18 | font-size: 1.4rem; |
| 19 | color: var(--foreground); |
| 20 | } |
| 21 | p { |
| 22 | margin: 0; |
| 23 | font-size: 1rem; |
| 24 | opacity: 0.7; |
| 25 | } |
| 26 | a { |
| 27 | text-decoration: none; |
| 28 | } |
| 29 | h4 { |
| 30 | text-decoration: none; |
| 31 | position: relative; |
| 32 | &:after { |
| 33 | background: none repeat scroll 0 0 transparent; |
| 34 | bottom: 0; |
| 35 | content: ""; |
| 36 | display: block; |
| 37 | height: 3px; |
| 38 | left: 50%; |
| 39 | position: absolute; |
| 40 | background: var(--accent-3); |
| 41 | transition: width 0.2s ease 0s, left 0.2s ease 0s; |
| 42 | width: 0; |
| 43 | } |
| 44 | &:hover:after { |
| 45 | width: 100%; |
| 46 | left: 0; |
| 47 | } |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | .save-listing { |
| 52 | position: absolute; |
| 53 | top: 0.5rem; |
| 54 | right: 0.5rem; |
| 55 | } |
| 56 | |
| 57 | .service-body { |
| 58 | display: flex; |
| 59 | align-items: center; |
| 60 | gap: 0.5rem; |
| 61 | img { |
| 62 | border-radius: var(--curve-sm); |
| 63 | font-size: 0.6rem; |
| 64 | color: var(--accent); |
| 65 | } |
| 66 | :global(p) { |
| 67 | display: -webkit-box; |
| 68 | -webkit-line-clamp: 3; |
| 69 | -webkit-box-orient: vertical; |
| 70 | overflow: hidden; |
| 71 | margin: 0.5rem 0; |
| 72 | width: calc(100% - 2rem); |
| 73 | overflow-x: hidden; |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | .service-links { |
| 78 | display: flex; |
| 79 | gap: 0.5rem; |
| 80 | justify-content: space-between; |
| 81 | a { |
| 82 | color: var(--accent-3); |
| 83 | font-size: 0.8rem; |
| 84 | display: inline-flex; |
| 85 | align-items: center; |
| 86 | gap: 0.25rem; |
| 87 | opacity: 0.85; |
| 88 | text-decoration: none; |
| 89 | max-width: 50%; |
| 90 | min-width: 25%; |
| 91 | &:not(:last-child) { |
| 92 | margin-right: 0.5rem; |
| 93 | } |
| 94 | &:hover { |
| 95 | text-decoration: underline; |
| 96 | opacity: 1; |
| 97 | } |
| 98 | :global(svg) { |
| 99 | width: 1rem; |
| 100 | height: 1rem; |
| 101 | } |
| 102 | span { |
| 103 | max-width: calc(100% - 1rem); |
| 104 | text-overflow: ellipsis; |
| 105 | white-space: nowrap; |
| 106 | overflow: hidden; |
| 107 | } |
| 108 | } |
| 109 | } |
| 110 | } |
web/src/pages/[...listing].astro
+16 −1
| @@ -25,6 +25,7 @@ import { parseMarkdown, formatLink } from '@utils/parse-markdown'; |
| 25 | 25 | import { site } from '@utils/config'; |
| 26 | 26 | import FontAwesome from '@components/form/FontAwesome.svelte'; |
| 27 | 27 | import Button from '@components/form/Button.astro'; |
| 28 | import SaveListing from '@components/things/SaveListing.svelte'; |
| 28 | 29 | |
| 29 | 30 | interface Props extends Service { |
| 30 | 31 | slug: string; |
| @@ -184,7 +185,15 @@ const getApiEndpoint = () => { |
| 184 | 185 | ➔ <a href={`/${slugify(categoryName)}/${slugify(parentSection.name)}`}>{parentSection.name}</a> |
| 185 | 186 | ➔ <a href={`/${slugify(categoryName)}/${slugify(parentSection.name)}/${slugify(name)}`}>{name}</a> |
| 186 | 187 | </span> |
| 187 | | </div> |
| 188 | </div> |
| 189 | <div class="save-listing"> |
| 190 | <SaveListing client:visible |
| 191 | categoryName={categoryName} |
| 192 | sectionName={parentSection.name} |
| 193 | serviceName={name} |
| 194 | showLabel={true} |
| 195 | /> |
| 196 | </div> |
| 188 | 197 | <div class="intro"> |
| 189 | 198 | <img |
| 190 | 199 | width="60" |
| @@ -485,6 +494,12 @@ h3 { |
| 485 | 494 | } |
| 486 | 495 | } |
| 487 | 496 | |
| 497 | .save-listing { |
| 498 | position: absolute; |
| 499 | top: 3rem; |
| 500 | right: 1rem; |
| 501 | } |
| 502 | |
| 488 | 503 | h4 { |
| 489 | 504 | font-size: 1.4rem; |
| 490 | 505 | margin-bottom: 0; |
web/src/pages/all.astro
+10 −9
| @@ -94,6 +94,8 @@ const toggleSidebar = () => { |
| 94 | 94 | <p> |
| 95 | 95 | <strong>⚠️ This section is still a work in progress ⚠️</strong><br /> |
| 96 | 96 | Check back soon, or help us complete it by submiting a pull request on GitHub. |
| 97 | <br /> |
| 98 | <span class="quick-submit">Or submit an entry <a href="/submit">here</a></span> |
| 97 | 99 | </p> |
| 98 | 100 | </div> |
| 99 | 101 | ) : null} |
| @@ -119,10 +121,6 @@ main { |
| 119 | 121 | justify-content: space-between; |
| 120 | 122 | } |
| 121 | 123 | |
| 122 | | // .narrow { |
| 123 | | // width: 70%; |
| 124 | | // } |
| 125 | | |
| 126 | 124 | .hidden { |
| 127 | 125 | display: none; |
| 128 | 126 | } |
| @@ -243,22 +241,25 @@ h3 { |
| 243 | 241 | } |
| 244 | 242 | |
| 245 | 243 | .nothing-yet { |
| 246 | | width: 80vw; |
| 244 | width: 100%; |
| 247 | 245 | margin: 0 auto; |
| 248 | 246 | background: var(--accent-fg); |
| 249 | 247 | border: 2px solid var(--box-outline); |
| 250 | 248 | box-shadow: 6px 6px 0 var(--box-outline); |
| 251 | 249 | border-radius: var(--curve-sm); |
| 252 | | |
| 253 | 250 | display: flex; |
| 254 | | width: 80vw; |
| 255 | | max-width: 28rem; |
| 251 | |
| 256 | 252 | p { |
| 257 | 253 | font-size: 1.2rem; |
| 258 | 254 | opacity: 0.8; |
| 259 | 255 | font-style: italic; |
| 260 | 256 | text-align: center; |
| 261 | | margin-bottom: 3rem; |
| 257 | margin: 4rem auto; |
| 258 | } |
| 259 | .quick-submit { |
| 260 | margin-top: 1rem; |
| 261 | font-size: 0.8rem; |
| 262 | opacity: 0.8; |
| 262 | 263 | } |
| 263 | 264 | } |
| 264 | 265 | |
web/src/pages/browse.astro
+1 −1
| @@ -19,7 +19,7 @@ const categories: Category[] = (await fetchData())?.categories; |
| 19 | 19 | <p id="press-enter-msg" class="press-enter">Press enter for deep search</p> |
| 20 | 20 | </span> |
| 21 | 21 | </div> |
| 22 | | <p class="sitemap-link">You can also view <a href="/sitemap">all pages</a> or <a href="/all">all listings</a></p> |
| 22 | <p class="sitemap-link">Not sure what you're looking for? Take a look through <a href="/all">all listings</a></p> |
| 23 | 23 | |
| 24 | 24 | <ul class="categories"> |
| 25 | 25 | {categories.map((category) => ( |
web/src/pages/index.astro
+5
| @@ -4,6 +4,7 @@ import Layout from '@layouts/Layout.astro'; |
| 4 | 4 | import Hero from '@components/Hero.astro'; |
| 5 | 5 | import Search from '@components/things/Search.svelte'; |
| 6 | 6 | import SectionList from '@components/things/SectionList.astro'; |
| 7 | import SavedServices from '@components/things/SavedServices.svelte'; |
| 7 | 8 | |
| 8 | 9 | import { fetchData } from '@utils/fetch-data'; |
| 9 | 10 | import Button from '@components/form/Button.astro'; |
| @@ -38,6 +39,10 @@ const description = 'Privacy is a fundamental human right; ' |
| 38 | 39 | <span>Or, just</span> |
| 39 | 40 | <Button url="/all" text="View Everything" /> |
| 40 | 41 | </div> |
| 42 | |
| 43 | <h2><a href="/inventory">Saved Items</a></h2> |
| 44 | <SavedServices allData={categories} client:load /> |
| 45 | |
| 41 | 46 | <h2> |
| 42 | 47 | <a href="/about">About</a> |
| 43 | 48 | </h2> |
web/src/pages/inventory/[...inventoryId].astro
added
+101
| @@ -0,0 +1,101 @@ |
| 1 | --- |
| 2 | |
| 3 | import Layout from '@layouts/Layout.astro'; |
| 4 | import SavedServices from '@components/things/SavedServices.svelte'; |
| 5 | import GetSharableLink from '@components/things/GetSharableLink.svelte'; |
| 6 | |
| 7 | import { fetchData } from '@utils/fetch-data'; |
| 8 | import Button from '@components/form/Button.astro'; |
| 9 | import EditableTitle from '@components/form/EditableTitle.svelte'; |
| 10 | import type { Category } from '../../types/Service'; |
| 11 | |
| 12 | const categories = (await fetchData())?.categories || [] as Category[]; |
| 13 | |
| 14 | export const prerender = false; |
| 15 | |
| 16 | const inventoryId = Astro.params.inventoryId || 'Inventory'; |
| 17 | let cheekyLilError = ''; |
| 18 | |
| 19 | function makeTitle(input: string): string { |
| 20 | return (input.includes('_') ? input : `mystry_${input}`) |
| 21 | .split('_')[1] |
| 22 | .replace(/-/g, ' ') |
| 23 | .replace(/\b\w/g, (match) => match.toUpperCase()); |
| 24 | } |
| 25 | |
| 26 | const serviceList = await fetch(`https://awesome-privacy-share-api.as93.net/${inventoryId}`).then((res) => res.json()) || []; |
| 27 | |
| 28 | if (serviceList.error) { |
| 29 | cheekyLilError = serviceList.error; |
| 30 | } |
| 31 | |
| 32 | --- |
| 33 | |
| 34 | <Layout title="Saved Services"> |
| 35 | <main> |
| 36 | <h2>{makeTitle(inventoryId)}</h2> |
| 37 | {cheekyLilError && ( |
| 38 | <div class="error"> |
| 39 | <p class="oh-deary-me">An error occoured</p> |
| 40 | <p class="what-the-fuck-happened">{cheekyLilError}</p> |
| 41 | <p class="what-next"> |
| 42 | We're sorry about that.<br /> |
| 43 | Try going <a href="/">back home</a>, |
| 44 | or <a href="https://github.com/Lissy93/awesome-privacy/issues/new/choose">raising a ticket</a> on |
| 45 | GitHub. |
| 46 | </p> |
| 47 | </div> |
| 48 | )} |
| 49 | <SavedServices allData={categories} serviceList={serviceList} client:load /> |
| 50 | <div class="buttons"> |
| 51 | <p>Not found what you're looking for?</p> |
| 52 | <Button url="/all">Browse Services</Button> |
| 53 | </div> |
| 54 | </main> |
| 55 | </Layout> |
| 56 | |
| 57 | <style lang="scss"> |
| 58 | main { |
| 59 | margin: 0 auto 2rem auto; |
| 60 | padding: 1rem; |
| 61 | width: 1200px; |
| 62 | max-width: calc(100% - 5rem); |
| 63 | display: flex; |
| 64 | justify-content: space-between; |
| 65 | flex-direction: column; |
| 66 | min-height: calc(100vh - 12rem); |
| 67 | font-size: 1.25rem; |
| 68 | h2 { |
| 69 | font-family: "Lekton", sans-serif; |
| 70 | font-weight: bold; |
| 71 | font-size: 3rem; |
| 72 | margin: 0; |
| 73 | color: var(--accent-3); |
| 74 | } |
| 75 | .buttons { |
| 76 | margin: 1rem auto; |
| 77 | display: flex; |
| 78 | flex-direction: column; |
| 79 | } |
| 80 | .error { |
| 81 | text-align: center; |
| 82 | font-size: 1.4rem; |
| 83 | .oh-deary-me { |
| 84 | font-size: 1.8rem; |
| 85 | margin: 0.2rem auto; |
| 86 | } |
| 87 | .what-the-fuck-happened { |
| 88 | color: var(--danger); |
| 89 | margin: 0.2rem auto; |
| 90 | } |
| 91 | .what-next { |
| 92 | font-size: 1rem; |
| 93 | margin-top: 3rem; |
| 94 | opacity: 0.6; |
| 95 | a { |
| 96 | color: var(--foreground); |
| 97 | } |
| 98 | } |
| 99 | } |
| 100 | } |
| 101 | </style> |
web/src/pages/inventory/index.astro
added
+61
| @@ -0,0 +1,61 @@ |
| 1 | --- |
| 2 | |
| 3 | import Layout from '@layouts/Layout.astro'; |
| 4 | import SavedServices from '@components/things/SavedServices.svelte'; |
| 5 | import GetSharableLink from '@components/things/GetSharableLink.svelte'; |
| 6 | |
| 7 | import { fetchData } from '@utils/fetch-data'; |
| 8 | import Button from '@components/form/Button.astro'; |
| 9 | import EditableTitle from '@components/form/EditableTitle.svelte'; |
| 10 | import type { Category } from '../../types/Service'; |
| 11 | |
| 12 | const categories = (await fetchData())?.categories || [] as Category[]; |
| 13 | |
| 14 | --- |
| 15 | |
| 16 | <Layout title="Saved Services"> |
| 17 | <main> |
| 18 | <div class="top-row"> |
| 19 | <!-- <h2>Inventory</h2> --> |
| 20 | <EditableTitle client:load /> |
| 21 | <GetSharableLink client:load /> |
| 22 | </div> |
| 23 | <SavedServices allData={categories} client:load /> |
| 24 | <div class="buttons"> |
| 25 | <p>Not found what you're looking for?</p> |
| 26 | <Button url="/all">Browse Services</Button> |
| 27 | </div> |
| 28 | </main> |
| 29 | </Layout> |
| 30 | |
| 31 | <style lang="scss"> |
| 32 | main { |
| 33 | margin: 0 auto 2rem auto; |
| 34 | padding: 1rem; |
| 35 | width: 1200px; |
| 36 | max-width: calc(100% - 5rem); |
| 37 | display: flex; |
| 38 | justify-content: space-between; |
| 39 | flex-direction: column; |
| 40 | min-height: calc(100vh - 12rem); |
| 41 | font-size: 1.25rem; |
| 42 | .top-row { |
| 43 | display: flex; |
| 44 | justify-content: space-between; |
| 45 | align-items: center; |
| 46 | margin-bottom: 1rem; |
| 47 | } |
| 48 | h2 { |
| 49 | font-family: "Lekton", sans-serif; |
| 50 | font-weight: bold; |
| 51 | font-size: 3rem; |
| 52 | margin: 0; |
| 53 | color: var(--accent-3); |
| 54 | } |
| 55 | .buttons { |
| 56 | margin: 1rem auto; |
| 57 | display: flex; |
| 58 | flex-direction: column; |
| 59 | } |
| 60 | } |
| 61 | </style> |
web/src/pages/sitemap.astro
+9 −6
| @@ -25,13 +25,19 @@ const categories = (await fetchData() as AwesomePrivacy)?.categories || []; |
| 25 | 25 | <a href="/">Home</a> |
| 26 | 26 | </li> |
| 27 | 27 | <li> |
| 28 | | <a href="/submit">Submit Listing</a> |
| 28 | <a href="/search">Search</a> |
| 29 | 29 | </li> |
| 30 | 30 | <li> |
| 31 | | <a href="/api">API</a> |
| 31 | <a href="/all">View All</a> |
| 32 | 32 | </li> |
| 33 | 33 | <li> |
| 34 | | <a href="/search">Search</a> |
| 34 | <a href="/inventory">My Inventory</a> |
| 35 | </li> |
| 36 | <li> |
| 37 | <a href="/submit">Submit Listing</a> |
| 38 | </li> |
| 39 | <li> |
| 40 | <a href="/api">API</a> |
| 35 | 41 | </li> |
| 36 | 42 | <li> |
| 37 | 43 | <a href="/browse">Categories</a> |
| @@ -59,9 +65,6 @@ const categories = (await fetchData() as AwesomePrivacy)?.categories || []; |
| 59 | 65 | ))} |
| 60 | 66 | </ul> |
| 61 | 67 | </li> |
| 62 | | <li> |
| 63 | | <a href="/all">View Summary of All</a> |
| 64 | | </li> |
| 65 | 68 | <li> |
| 66 | 69 | <a href="/about">About</a> |
| 67 | 70 | <ul> |