Commit 826dde6c84

826dde6c84a5038e25dffda3475500252c882953

parent: daa641eb2b

Unsigned

Alicia Sykes <alicia@omg.lol> · 2024-03-28 17:22 UTC

UX improvments, fix search, display links, improve layout, semantic search results, global site theme switching, and more

Layout: unified · split

web/src/components/scafold/MainCard.astro +1 −1
@@ -8,7 +8,7 @@
88 main {
99 margin: 2rem auto;
1010 padding: 1rem;
11 width: 1000px;
11 width: 1200px;
1212 max-width: calc(100% - 5rem);
1313 border: 2px solid var(--box-outline);
1414 box-shadow: 6px 6px 0 var(--box-outline);
web/src/components/scafold/NavBar.astro +8 −1
@@ -1,5 +1,6 @@
11---
22import FontAwesome from "@components/form/FontAwesome.svelte"
3import ThemeSwitcher from "@components/form/ThemeSwitcher.svelte"
34
45---
56
@@ -13,6 +14,9 @@ import FontAwesome from "@components/form/FontAwesome.svelte"
1314 <a href="/search">Search</a>
1415 <a href="/about">About</a>
1516 <a href="https://github.com/lissy93/awesome-privacy">GitHub</a>
17 <div class="theme-switcher">
18 <ThemeSwitcher client:load />
19 </div>
1620 </nav>
1721</div>
1822
@@ -62,7 +66,6 @@ import FontAwesome from "@components/form/FontAwesome.svelte"
6266 font-family: "Lekton", sans-serif;
6367 font-weight: bold;
6468 color: var(--foreground);
65 border-left: 2px solid var(--accent-3);
6669 transition: background 0.3s, transform 0.3s, box-shadow 0.3s;
6770 transition-timing-function: ease-in-out;
6871 &:hover {
@@ -85,6 +88,10 @@ import FontAwesome from "@components/form/FontAwesome.svelte"
8588 }
8689 }
8790 }
91 .theme-switcher {
92 transform: scale(0.7);
93 margin: 0.2rem auto;
94 }
8895 }
8996 .homepage, nav {
9097 @media(max-width: 768px) {
web/src/components/things/PrivacyPolicyDetails.astro +13 −1
@@ -20,6 +20,18 @@ const getIconName = (clasification: string) => {
2020 return '';
2121}
2222
23// If two or more objects in privacyPolicy.points have the same title, remove the duplicates
24const removeDuplicates = () => {
25 const seen = new Set();
26 return priv.points = priv.points.filter((point) => {
27 if (seen.has(point.title)) {
28 return false;
29 }
30 seen.add(point.title);
31 return true;
32 });
33}
34
2335---
2436
2537{priv && (
@@ -29,7 +41,7 @@ const getIconName = (clasification: string) => {
2941 <div class="left">
3042 <h4>Privacy Policy Summary</h4>
3143 <ul class="no-point">
32 {priv.points.map((point) => (
44 {removeDuplicates().map((point) => (
3345 <li class={`clasification ${point.case.classification}`}>
3446 <FontAwesome iconName={getIconName(point.case.classification)} />
3547 {point.title}
web/src/components/things/RedditDetailedInfo.astro +36 −28
@@ -11,35 +11,35 @@ interface Props {
1111
1212const { redditData } = Astro.props;
1313
14
1514---
1615
1716<div class="reddit-info-wrapper">
18 <h3>Reddit</h3>
19
20 <p class="website-title">
21 <img src={redditData.info.icon} width="16" />
22 {redditData.info.title || redditData.info.name}
23 </p>
24 <p class="website-description">{redditData.info.description}</p>
25 {redditData.info.banner && (<img class="banner" width="300" src={redditData.info.banner} alt="Banner" />)}
26 <ul class="list-table">
27 {redditData.info.dateCreated && (
28 <li>
29 <span class="lbl">Created at</span>
30 <span class="val">{timestampToDate(redditData.info.dateCreated * 1000)}</span>
31 </li>
32 )}
33 <li>
34 <span class="lbl">Members</span>
35 <span class="val">{redditData.info.subscribers}</span>
36 </li>
37 <li>
38 <span class="lbl">Join</span>
39 <span class="val"><a href={`https://reddit.com/${redditData.info.name}`}>{redditData.info.name}</a></span>
40 </li>
41 </ul>
42
17 <div class="left">
18 <h3>Reddit</h3>
19 <p class="website-title">
20 <img src={redditData.info.icon} width="16" />
21 {redditData.info.title || redditData.info.name}
22 </p>
23 <p class="website-description">{redditData.info.description}</p>
24 {redditData.info.banner && (<img class="banner" width="300" src={redditData.info.banner} alt="Banner" />)}
25 <ul class="list-table">
26 {redditData.info.dateCreated && (
27 <li>
28 <span class="lbl">Created at</span>
29 <span class="val">{timestampToDate(redditData.info.dateCreated * 1000)}</span>
30 </li>
31 )}
32 <li>
33 <span class="lbl">Members</span>
34 <span class="val">{redditData.info.subscribers}</span>
35 </li>
36 <li>
37 <span class="lbl">Join</span>
38 <span class="val"><a href={`https://reddit.com/${redditData.info.name}`}>{redditData.info.name}</a></span>
39 </li>
40 </ul>
41 </div>
42 <div class="right">
4343 <h4>Posts</h4>
4444 <ul class="posts">
4545 {redditData.posts.map((post) => (
@@ -49,14 +49,22 @@ const { redditData } = Astro.props;
4949 </li>
5050 ))}
5151 </ul>
52 </div>
5253</div>
5354
5455
5556<style lang="scss">
5657.reddit-info-wrapper {
5758 display: flex;
58 flex-direction: column;
59 max-width: 500px;
59 flex-wrap: wrap;
60 justify-content: space-between;
61 gap: 1rem;
62 .left, .right {
63 width: calc(50% - 1rem);
64 @media screen and (max-width: 768px){
65 width: 100%;
66 }
67 }
6068}
6169
6270.banner {
web/src/components/things/Search.svelte +1 −1
@@ -168,7 +168,7 @@
168168 transform: translateY(-0.5rem);
169169 max-height: 500px;
170170 overflow-y: scroll;
171
171 background: var(--background-form);
172172 li.result-row {
173173 padding: 0.5rem 1rem;
174174 margin: 0.5rem 0;
web/src/layouts/Layout.astro +54 −4
@@ -9,6 +9,11 @@ interface Props {
99 keywords?: string; // Overide keywords tag
1010 hideNav?: boolean; // Don't show the navbar (just homepage)
1111 author?: string; // Author of the content
12 customSchemaJson?: any; // Custom schema item
13 breadcrumbs?: Array<{
14 name: string;
15 item: string;
16 }>
1217}
1318
1419const {
@@ -16,9 +21,41 @@ const {
1621 description='Your guide to finding privacy-respecting alternatives to popular software and services.',
1722 keywords='security, privacy, awesome privacy, data collection, free software, open source, privacy tools, privacy respecting software',
1823 hideNav=false,
19 author='Alicia Sykes'
24 author='Alicia Sykes',
25 breadcrumbs,
26 customSchemaJson,
2027} = Astro.props;
2128
29const makeBreadcrumbs = () => {
30 if (!breadcrumbs) return null;
31 return {
32 "@context": "https://schema.org",
33 "@type": "BreadcrumbList",
34 "itemListElement": breadcrumbs.map((breadcrumb, index) => ({
35 "@type": "ListItem",
36 "position": index + 1,
37 "name": breadcrumb.name,
38 "item": `https://awesome-privacy.xyz/${breadcrumb.item}`
39 }))
40 }
41}
42
43const makeSearchLd = () => {
44 return {
45 "@context": "https://schema.org",
46 "@type": "WebSite",
47 "url": "https://awesome-privacy.xyz/",
48 "potentialAction": [{
49 "@type": "SearchAction",
50 "target": {
51 "@type": "EntryPoint",
52 "urlTemplate": "https://awesome-privacy.xyz/search?q={search_term_string}"
53 },
54 "query-input": "required name=search_term_string"
55 }]
56 }
57};
58
2259---
2360
2461<!doctype html>
@@ -36,8 +73,8 @@ const {
3673 <!-- Page info, viewport, Astro credit -->
3774 <meta charset="UTF-8" />
3875 <meta name="viewport" content="width=device-width, initial-scale=1.0">
39 <meta name="viewport" content="width=device-width" />
4076 <meta name="generator" content={Astro.generator} />
77 <meta name="robots" content="index, follow">
4178
4279 <!-- Icons and colors -->
4380 <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
@@ -45,16 +82,20 @@ const {
4582 <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
4683
4784 <!-- Social media meta tags (Open Graphh + Twitter) -->
85 <meta property="og:site_name" content="Awesome Privacy">
4886 <meta property="og:type" content="website">
4987 <meta property="og:url" content="https://awesome-privacy.xyz">
5088 <meta property="og:title" content={title}>
5189 <meta property="og:description" content={description}>
52 <meta property="og:image" content="/banner.png">
90 <meta property="og:image" content="https://awesome-privacy.xyz/banner.png">
5391 <meta name="twitter:card" content="summary_large_image">
5492 <meta name="twitter:url" content="https://awesome-privacy.xyz">
5593 <meta name="twitter:title" content={title}>
5694 <meta name="twitter:description" content={description}>
57 <meta name="twitter:image" content="/banner.png">
95 <meta name="twitter:image" content="https://awesome-privacy.xyz/banner.png">
96 <meta name="twitter:site" content="@Lissy_Sykes">
97 <meta name="twitter:creator" content="@Lissy_Sykes">
98
5899
59100 <!-- Non-tracking hit counter -->
60101 <script defer is:inline
@@ -62,6 +103,15 @@ const {
62103 data-domain="awesome-privacy.xyz"
63104 src="https://no-track.as93.net/js/script.js">
64105 </script>
106
107 <!-- Schema.org markup for Google -->
108 {breadcrumbs && (
109 <script type="application/ld+json" set:html={JSON.stringify(makeBreadcrumbs())} />
110 )}
111 {customSchemaJson && (
112 <script type="application/ld+json" set:html={JSON.stringify(customSchemaJson)} />
113 )}
114 <script type="application/ld+json" set:html={JSON.stringify(makeSearchLd)} />
65115 </head>
66116 <body>
67117 {!hideNav && <NavBar /> }
web/src/pages/[...listing].astro +26 −3
@@ -47,6 +47,7 @@ const {
4747 androidApp,
4848 icon,
4949 followWith,
50 links,
5051 securityAudited,
5152 openSource,
5253 acceptsCrypto,
@@ -84,6 +85,15 @@ const makePageTitle = () => {
8485 return `${name} | ${parentSection.name} | ${categoryName} | Awesome Privacy`;
8586};
8687
88const makeBreadcrumbs = () => {
89 return [
90 { name: 'Home', item: '/' },
91 { name: categoryName, item: slugify(categoryName) },
92 { name: parentSection.name, item: `${slugify(categoryName)}/${slugify(parentSection.name)}` },
93 { name: name, item: `${slugify(categoryName)}/${slugify(parentSection.name)}/${slugify(name)}` },
94 ];
95};
96
8797/**
8898 * Make a string page intro, for the description tag
8999 */
@@ -171,7 +181,12 @@ const getApiEndpoint = () => {
171181
172182---
173183
174<Layout title={makePageTitle()} keywords={makeKeyWordTag()} description={makeDescriptionTag()} >
184<Layout
185 title={makePageTitle()}
186 keywords={makeKeyWordTag()}
187 description={makeDescriptionTag()}
188 breadcrumbs={makeBreadcrumbs()}
189>
175190 <main>
176191 <section>
177192 <div class="service-head">
@@ -259,6 +274,14 @@ const getApiEndpoint = () => {
259274 <a href={`https://web-check.xyz/results/${formatLink(url)}`}>{`web-check.xyz/results/${formatLink(url).split('/')[0]}`}</a>
260275 </li>
261276 )}
277 { links && links.length > 0 && (
278 links.map((link) => (
279 <li>
280 <b>{link.title}</b>
281 <a href={link.url}>{link.url}</a>
282 </li>
283 ))
284 )}
262285 </ul>
263286 </div>
264287 </div>
@@ -420,7 +443,7 @@ const getApiEndpoint = () => {
420443main {
421444 margin: 2rem auto;
422445 padding: 1rem;
423 width: 1000px;
446 width: 1200px;
424447 max-width: calc(100% - 5rem);
425448 position: relative;
426449 @media(max-width: 768px) {
@@ -539,7 +562,7 @@ h4 {
539562 b {
540563 font-size: 1rem;
541564 font-weight: 400;
542 min-width: 85px;
565 min-width: 100px;
543566 display: inline-block;
544567 @media(max-width: 768px) {
545568 width: auto;
web/src/pages/[...section].astro +62 −1
@@ -54,6 +54,14 @@ const makePageTitle = () => {
5454 return `${title} | Awesome Privacy`;
5555};
5656
57const makeBreadcrumbs = () => {
58 return [
59 { name: 'Home', item: '/' },
60 { name: categoryName, item: slugify(categoryName) },
61 { name: title, item: `${slugify(categoryName)}/${slugify(title)}` },
62 ];
63};
64
5765/**
5866 * Make a string page intro, for the description tag
5967 */
@@ -72,6 +80,27 @@ const makeDescriptionTag = () => {
7280 return description;
7381};
7482
83const makeCarasolData = () => {
84 return {
85 "@context": "https://schema.org",
86 "@type": "ItemList",
87 "itemListElement": [
88 services.map((service, index) => ({
89 "@type": "ListItem",
90 "position": index + 1,
91 "url": `https://awesomeprivacy.com/${slugify(categoryName)}/${slugify(title)}/${slugify(service.name)}`,
92 "item": {
93 "@type": "Service",
94 "name": service.name,
95 "description": service.description,
96 "image": service.icon,
97 "url": `https://awesomeprivacy.com/${slugify(categoryName)}/${slugify(title)}/${slugify(service.name)}`
98 }
99 })),
100 ]
101 }
102};
103
75104export async function getStaticPaths() {
76105 const pages = await fetchData().then((data) => {
77106 const results: Array<Props> = [];
@@ -110,9 +139,23 @@ const { previous, next } = makePaginationLinks();
110139
111140---
112141
113<Layout title={makePageTitle()} keywords={makeKeyWordTag()} description={makeDescriptionTag()} >
142<Layout
143 title={makePageTitle()}
144 keywords={makeKeyWordTag()}
145 description={makeDescriptionTag()}
146 breadcrumbs={makeBreadcrumbs()}
147 customSchemaJson={makeCarasolData()}
148>
114149 <Main>
115150
151 <div class="breadcrumbs">
152 <span>
153 <a href="/">Awesome Privacy</a>
154 ➔ <a href={`/${slugify(categoryName)}`}>{categoryName}</a>
155 ➔ <a href={`/${slugify(categoryName)}/${slugify(title)}`}>{title}</a>
156 </span>
157 </div>
158
116159 <h2>{title}</h2>
117160
118161 {intro && (
@@ -311,5 +354,23 @@ h2 {
311354 opacity: 0.7;
312355}
313356
357.breadcrumbs {
358 opacity: 0.5;
359 font-size: 0.8rem;
360 position: absolute;
361 right: 1rem;
362 top: 1rem;
363 a {
364 color: var(--foreground);
365 transition: all 0.15s ease-in-out;
366
367 &:hover {
368 color: var(--accent);
369 }
370 }
371 @media(max-width: 768px) {
372 display: none;
373 }
374}
314375
315376</style>
web/src/pages/[category].astro +55 −1
@@ -37,6 +37,33 @@ export async function getStaticPaths() {
3737 });
3838}
3939
40const makeCarasolData = () => {
41 return {
42 "@context": "https://schema.org",
43 "@type": "ItemList",
44 "itemListElement": [
45 sections.map((section, index) => ({
46 "@type": "ListItem",
47 "position": index + 1,
48 "url": `https://awesomeprivacy.com/${slugify(title)}/${slugify(section.name)}`,
49 "item": {
50 "@type": "Service",
51 "name": section.name,
52 "url": `https://awesomeprivacy.com/${slugify(title)}/${slugify(section.name)}`,
53 }
54 })),
55 ]
56 }
57};
58
59const makeBreadcrumbs = () => {
60 return [
61 { name: 'Home', item: '/' },
62 { name: title, item: slugify(title) },
63 ];
64};
65
66
4067const makePaginationLinks = () => {
4168 const index = categories.findIndex(category => category.name === title);
4269 const previousCategory = index > 0 ? categories[index - 1].name : null;
@@ -48,8 +75,14 @@ const { previous, next } = makePaginationLinks();
4875
4976---
5077
51<Layout title={`${title} | Awesome Privacy`}>
78<Layout title={`${title} | Awesome Privacy`} breadcrumbs={makeBreadcrumbs()} customSchemaJson={makeCarasolData()}>
5279 <Main>
80 <div class="breadcrumbs">
81 <span>
82 <a href="/">Awesome Privacy</a>
83 ➔ <a href={`/${slugify(title)}`}>{title}</a>
84 </span>
85 </div>
5386 <SectionList title={title} sections={sections} bigTitle={true} />
5487 <a href={`/all#${slugify(title)}`}>Browse All</a>
5588 <div class="pagination-navigation">
@@ -100,4 +133,25 @@ const { previous, next } = makePaginationLinks();
100133 opacity: 0.5;
101134 }
102135}
136
137
138.breadcrumbs {
139 opacity: 0.5;
140 font-size: 0.8rem;
141 position: absolute;
142 right: 1rem;
143 top: 1rem;
144 a {
145 color: var(--foreground);
146 transition: all 0.15s ease-in-out;
147
148 &:hover {
149 color: var(--accent);
150 }
151 }
152 @media(max-width: 768px) {
153 display: none;
154 }
155}
156
103157</style>
web/src/pages/about.astro −4
@@ -402,10 +402,6 @@ h3 {
402402 }
403403
404404 }
405 :global(ul li:hover strong) {
406 transition: color 0.2s ease-in-out;
407 color: var(--accent-3);
408 }
409405 :global(h3) {
410406 font-size: 1.6rem;
411407 margin-bottom: 0;
web/src/pages/browse.astro +45 −57
@@ -36,78 +36,66 @@ const categories: Category[] = (await fetchData())?.categories;
3636</Layout>
3737
3838<script>
39// Time for some good ol' fashioned vanilla JS...
40// I reccomend you not to look at this code for too long, it's not pretty.
41const filterInput = document.querySelector('input');
42const categories = document.querySelectorAll<HTMLElement>('.category');
43const pressEnterMsg = document.getElementById('press-enter-msg') as HTMLElement | null;
44const noResults = document.querySelector('.no-results') as HTMLElement | null;
45
46if (!pressEnterMsg || !noResults) {
47 throw new Error('No pressEnterMsg or noResults');
48};
49
50filterInput?.addEventListener('input', (e) => {
51 let resultsCount = 0;
52 const filter = (e.target as HTMLInputElement).value.toLowerCase();
53 if (filter.length > 0) {
54 pressEnterMsg.style.visibility = 'visible';
55 } else {
56 pressEnterMsg.style.visibility = 'hidden';
57 }
58 categories.forEach((category) => {
59 const titleElement = category.querySelector('.category-title');
60 const title = titleElement ? titleElement.textContent?.toLowerCase() : '';
61 const sections = category.querySelectorAll<HTMLElement>('.section');
62 let count = 0;
63 sections.forEach((section) => {
64 const sectionTitle = section.textContent?.toLowerCase();
65 if (sectionTitle?.includes(filter)) {
66 section.style.display = 'block';
67 count++;
68 resultsCount++;
69 } else {
70 section.style.display = 'none';
71 }
72 });
73 if (title && title.includes(filter)) {
74 category.style.display = 'inline-flex';
75 resultsCount++;
76 } else if (count === 0) {
77 category.style.display = 'none';
39 // Time for some good ol' fashioned vanilla JS...
40 // I reccomend you not to look at this code for too long, it's not pretty.
41 document.addEventListener('DOMContentLoaded', function() {
42 const searchInput = document.getElementById('searchInput');
43 const categories = document.querySelectorAll('.category');
44 const pressEnterMsg = document.getElementById('press-enter-msg');
45 const noResults = document.querySelector('.no-results');
46
47 if (!pressEnterMsg || !noResults || !searchInput) {
48 console.error('Essential element missing!');
49 return;
7850 }
79 });
80 noResults.style.display = resultsCount === 0 ? 'block' : 'none';
81});
8251
83if (typeof window !== 'undefined') {
84 document.addEventListener('DOMContentLoaded', function() {
85 const searchInput = document.getElementById('searchInput') as HTMLInputElement | null;
86 if (searchInput === null) return;
87 searchInput.addEventListener('keydown', function(event) {
52 searchInput.addEventListener('input', (e) => {
53 let resultsCount = 0;
54 const filter = e.target.value.trim().toLowerCase();
55 pressEnterMsg.style.visibility = filter ? 'visible' : 'hidden';
56
57 categories.forEach((category) => {
58 const titleElement = category.querySelector('.category-title');
59 const title = titleElement ? titleElement.textContent?.toLowerCase() : '';
60 const sections = category.querySelectorAll('.section');
61 let sectionCount = 0;
62
63 sections.forEach((section) => {
64 const sectionTitle = section.textContent?.toLowerCase();
65 if (sectionTitle?.includes(filter)) {
66 section.style.display = 'block';
67 sectionCount++;
68 } else {
69 section.style.display = 'none';
70 }
71 });
72
73 category.style.display = title.includes(filter) || sectionCount > 0 ? 'inline-flex' : 'none';
74 resultsCount += title.includes(filter) ? 1 : sectionCount;
75 });
76
77 noResults.style.display = resultsCount === 0 ? 'block' : 'none';
78 });
79
80 searchInput.addEventListener('keydown', (event) => {
8881 if (event.key === 'Enter') {
8982 event.preventDefault();
90 const searchTerm = encodeURIComponent(searchInput.value);
91 window.location.href = `/search/${searchTerm}`;
83 window.location.href = `/search/${encodeURIComponent(searchInput.value.trim())}`;
9284 }
9385 if (event.key === 'Escape') {
9486 searchInput.value = '';
9587 searchInput.blur();
9688 pressEnterMsg.style.visibility = 'hidden';
97 categories.forEach((category) => {
98 category.style.display = 'inline-flex';
99 const sections = category.querySelectorAll<HTMLElement>('.section');
100 sections.forEach((section) => {
101 section.style.display = 'block';
102 });
103 });
89 // Reset display styles
90 categories.forEach(category => category.style.display = 'inline-flex');
91 document.querySelectorAll('.section').forEach(section => section.style.display = 'block');
10492 }
10593 });
10694 });
107}
10895</script>
10996
11097
98
11199<style lang="scss">
112100
113101.head-wrap {
web/src/styles/values.css +1
@@ -47,6 +47,7 @@
4747 --background: #feecff;
4848 --bg-gradient-comp-1: #feecff;
4949 --bg-gradient-comp-2: #e1e4fb;
50 --background-form: #fff;
5051 }
5152}
5253
web/src/types/Service.ts +4
@@ -12,6 +12,10 @@ export interface Service {
1212 url: string;
1313 github?: string;
1414 icon?: string;
15 links?: Array<{
16 title: string;
17 url: string;
18 }>;
1519 followWith?: string;
1620 securityAudited?: boolean;
1721 openSource?: boolean;
web/src/utils/fetch-data.ts +2 −2
@@ -13,5 +13,5 @@ export const fetchData = async (): Promise<AwesomePrivacy> => {
1313}
1414
1515export const slugify = (title: string) => {
16 return (title || '').toLowerCase().replace(/\s/g, '-');
17};
16 return (title || '').toLowerCase().replace(/\s/g, '-').replace(/\+|&/g, 'and');
17};