web/src/components/things/AddNewService.svelte
571 lines · 16427 bytes
1<script lang="ts">
2 import * as yaml from 'js-yaml';
3 import { makeAdditionRequest } from '../../utils/data-src-delete-n-edit';
4
5 let { isDisabled = false }: { isDisabled?: boolean } = $props();
6
7 // Form state
8 let listingCategory = $state('');
9 let serviceName = $state('');
10 let serviceUrl = $state('');
11 let serviceIcon = $state('');
12 let serviceDescription = $state('');
13 let serviceGithub = $state('');
14 let serviceTosdrId = $state('');
15 let serviceIosApp = $state('');
16 let serviceAndroidApp = $state('');
17 let serviceDiscordInvite = $state('');
18 let serviceSubreddit = $state('');
19 let serviceOpenSource = $state(false);
20 let serviceSecurityAudited = $state(false);
21 let serviceCrypto = $state(false);
22 let additionalInfo = $state('');
23
24 let codeBlock: HTMLElement | undefined = $state();
25 let interactiveActivated = $state(false);
26
27 const filterEmptyValues = (obj: Record<string, unknown>) => {
28 const filteredObj: Record<string, unknown> = {};
29 Object.keys(obj).forEach((key) => {
30 if (obj[key] || ['name', 'url', 'icon', 'description'].includes(key)) {
31 filteredObj[key] = obj[key];
32 }
33 });
34 return filteredObj;
35 };
36
37 const yamlText = $derived(
38 yaml.dump(
39 [
40 {
41 name: serviceName,
42 url: serviceUrl,
43 icon: serviceIcon,
44 description: serviceDescription,
45 github: serviceGithub,
46 tosdrId: serviceTosdrId,
47 iosApp: serviceIosApp,
48 androidApp: serviceAndroidApp,
49 discordInvite: serviceDiscordInvite,
50 subreddit: serviceSubreddit,
51 openSource: serviceOpenSource,
52 securityAudited: serviceSecurityAudited,
53 acceptsCrypto: serviceCrypto,
54 },
55 ].map((obj) => filterEmptyValues(obj)),
56 ),
57 );
58
59 const issueUrl = $derived(
60 makeAdditionRequest(
61 {
62 listingCategory,
63 serviceName,
64 serviceUrl,
65 serviceIcon,
66 serviceDescription,
67 serviceGithub,
68 serviceTosdrId,
69 serviceIosApp,
70 serviceAndroidApp,
71 serviceDiscordInvite,
72 serviceSubreddit,
73 serviceOpenSource,
74 serviceSecurityAudited,
75 serviceCrypto,
76 additionalInfo,
77 },
78 yamlText,
79 ),
80 );
81
82 /* eslint-disable svelte/no-dom-manipulating -- hljs requires direct DOM access for syntax highlighting */
83 $effect(() => {
84 if (!codeBlock) return;
85 codeBlock.textContent = yamlText;
86 if (codeBlock.dataset.highlighted) delete codeBlock.dataset.highlighted;
87 const hljs = (
88 window as Window & {
89 hljs?: { highlightElement: (el: HTMLElement) => void };
90 }
91 ).hljs;
92 if (hljs) {
93 hljs.highlightElement(codeBlock);
94 interactiveActivated = true;
95 }
96 });
97 /* eslint-enable svelte/no-dom-manipulating */
98
99 function handleSubmit(event: Event) {
100 event.preventDefault();
101 window.open(issueUrl, '_blank');
102 }
103</script>
104
105<svelte:head>
106 <link
107 rel="stylesheet"
108 href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/an-old-hope.min.css"
109 />
110 <script
111 src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"
112 ></script>
113 <script
114 src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/yaml.min.js"
115 ></script>
116</svelte:head>
117
118<p>
119 Before completing this form, you must ensure that the service you are adding
120 aligns with the <a href="/about/#creteria">Requirements</a> for Awesome
121 Privacy.
122 <br />
123 You'll need a GitHub account in order to submit this form.
124</p>
125
126{#if isDisabled}
127 <div class="disabled-notice" role="alert">
128 Additions via this form have been temporarily disabled due to excess spam
129 and AI additions. Please follow the <a
130 href="https://github.com/lissy93/awesome-privacy/blob/main/.github/CONTRIBUTING.md"
131 >contributing</a
132 >
133 instructions and submit a PR instead. For more info, see
134 <a href="https://github.com/lissy93/awesome-privacy/discussions/596"
135 >this thread</a
136 >.
137 </div>
138{/if}
139
140<div class="form-wrapper">
141 {#if isDisabled}
142 <div
143 class="disabled-overlay"
144 title="This form has been temporarily disabled due to spam"
145 ></div>
146 {/if}
147 <form onsubmit={handleSubmit}>
148 <h3>Basics</h3>
149 <p class="sub-title-description">All fields here are required.</p>
150
151 <!-- Category Dropdown -->
152 <div class="form-row">
153 <label for="listing-category">Category</label>
154 <select
155 bind:value={listingCategory}
156 id="listing-category"
157 required
158 autocomplete="off"
159 >
160 <option value="">--Please choose an option--</option>
161 <option value="Essentials">Essentials</option>
162 <option value="Communication">Communication</option>
163 <option value="Security Tools">Security Tools</option>
164 <option value="Networking">Networking</option>
165 <option value="Productivity">Productivity</option>
166 <option value="Utilities">Utilities</option>
167 <option value="Operating Systems">Operating Systems</option>
168 <option value="Development">Development</option>
169 <option value="Home and IoT">Home and IoT</option>
170 <option value="Finance">Finance</option>
171 <option value="Social">Social</option>
172 <option value="Media">Media</option>
173 <option value="Creativity">Creativity</option>
174 </select>
175 <p>
176 Choose the top-level category, which should align with the <a
177 href="/browse/">one of these</a
178 >.
179 </p>
180 </div>
181
182 <!-- Listing Name -->
183 <div class="form-row">
184 <label for="service-name">Listing Name</label>
185 <input
186 type="text"
187 bind:value={serviceName}
188 id="service-name"
189 required
190 autocomplete="off"
191 />
192 <p>Enter the name of the app, software or service</p>
193 </div>
194
195 <!-- Listing URL -->
196 <div class="form-row">
197 <label for="service-url">Listing URL</label>
198 <input
199 type="url"
200 bind:value={serviceUrl}
201 id="service-url"
202 required
203 autocomplete="off"
204 />
205 <p>
206 Enter the fully-qualified domain name of the homepage for this listing
207 </p>
208 </div>
209
210 <!-- Listing Icon -->
211 <div class="form-row">
212 <label for="service-icon">Listing Icon</label>
213 <input
214 type="url"
215 bind:value={serviceIcon}
216 id="service-icon"
217 required
218 autocomplete="off"
219 />
220 <p>
221 Paste a URL to a square logo for the service. Dimensions must be no less
222 than 64x64, and no more than 512x512 pixels
223 </p>
224 </div>
225
226 <!-- Listing Description -->
227 <div class="form-row">
228 <label for="service-description">Listing Description</label>
229 <textarea
230 bind:value={serviceDescription}
231 id="service-description"
232 required
233 autocomplete="off"></textarea>
234 <p>
235 Please provide a description for this listing. Keep it factual and
236 objective. Markdown is supported.
237 </p>
238 </div>
239
240 <!-- Section 2 -->
241 <h3>Third-Party Referencing</h3>
242 <p class="sub-title-description">
243 In order to create a comprehensive listing, we combine the data inputted
244 above with other sources, to give additional context and help users make
245 informed decisions. Metrics from these services are fetched automatically
246 at build-time from our API.
247 <br />
248 All fields are optional, but the more information you provide, the better!
249 </p>
250
251 <!-- GitHub Repository -->
252 <div class="form-row">
253 <label for="service-github">GitHub Repository</label>
254 <input
255 type="text"
256 bind:value={serviceGithub}
257 id="service-github"
258 required
259 autocomplete="off"
260 />
261 <p>
262 Share a link to where the project's source is located.<br />
263 Use the format [user]/[repo] e.g, lissy93/dashy
264 </p>
265 </div>
266
267 <!-- ToS;DR ID -->
268 <div class="form-row">
269 <label for="service-tosdr-id">ToS;DR ID</label>
270 <input
271 type="number"
272 bind:value={serviceTosdrId}
273 id="service-tosdr-id"
274 autocomplete="off"
275 />
276 <p>
277 Has the Privacy policy been documented by <a href="https://tosdr.org/"
278 >tosdr.org</a
279 >? If so, please include the report reference below (this is a 3 or
280 4-digit numerical ID). Skip section if not applicable.
281 </p>
282 </div>
283
284 <!-- Apple App Store URL -->
285 <div class="form-row">
286 <label for="service-tosdr-id">iOS App</label>
287 <input
288 type="url"
289 bind:value={serviceIosApp}
290 id="service-ios-app"
291 autocomplete="off"
292 />
293 <p>
294 Paste the link to the mobile app on the Apple App Store.<br />
295 E.g. https://apps.apple.com/us/app/bitwarden-password-manager/id1137397744
296 </p>
297 </div>
298
299 <!-- Google Play App Store URL -->
300 <div class="form-row">
301 <label for="service-tosdr-id">Android App</label>
302 <input
303 type="url"
304 bind:value={serviceAndroidApp}
305 id="service-android-app"
306 autocomplete="off"
307 />
308 <p>
309 Paste the link to the mobile app on the Google Play Store.<br />
310 E.g. https://play.google.com/store/apps/details?id=com.x8bit.bitwarden
311 </p>
312 </div>
313
314 <!-- Discord Server Invite Code -->
315 <div class="form-row">
316 <label for="service-tosdr-id">Discord Invite</label>
317 <input
318 type="text"
319 bind:value={serviceDiscordInvite}
320 id="service-discord-invite"
321 autocomplete="off"
322 />
323 <p>
324 Paste the invite code to the Discord server for this service.<br />
325 E.g. If the invite URL is https://discord.com/invite/4JMAauFZBq the code is
326 4JMAauFZBq
327 </p>
328 </div>
329
330 <!-- Reddit sub name -->
331 <div class="form-row">
332 <label for="service-tosdr-id">Subreddit</label>
333 <input
334 type="text"
335 bind:value={serviceSubreddit}
336 id="service-subreddit"
337 autocomplete="off"
338 />
339 <p>
340 If the service has a subreddit, please provide the name here.<br />
341 Don't include `r/` in the name, nor the full URL - just the sub name.
342 </p>
343 </div>
344
345 <!-- Section 3 - Checklist and details -->
346 <h3>Privacy Checklist</h3>
347 <p class="sub-title-description">
348 Finally, check the boxes that apply to the service you are submitting, and
349 then provide any additional information to back this up in the text area
350 below.
351 </p>
352
353 <!-- Open Source Checkbox -->
354 <div class="form-row">
355 <label for="service-open-source">Is Open Source?</label>
356 <input
357 type="checkbox"
358 bind:checked={serviceOpenSource}
359 id="service-open-source"
360 />
361 <p>
362 Is this service fully open source? Aka, can it be compiled from source
363 by the user, or self-hosted?
364 </p>
365 </div>
366
367 <!-- Security Audited Checkbox -->
368 <div class="form-row">
369 <label for="service-security-audited">Security Audited?</label>
370 <input
371 type="checkbox"
372 bind:checked={serviceSecurityAudited}
373 id="service-security-audited"
374 />
375 <p>
376 Has this service been independently security audited by an accredited
377 auditor?
378 </p>
379 </div>
380
381 <!-- Accepts Crypto Checkbox -->
382 <div class="form-row">
383 <label for="service-crypto">Accepts Anon Payment?</label>
384 <input type="checkbox" bind:checked={serviceCrypto} id="service-crypto" />
385 <p>
386 If this is a hosted and paid for service, does it accept anonymous
387 payment methods, including crypto (e.g., Monero)?
388 </p>
389 </div>
390
391 <div class="final-info">
392 <p>Finally, please provide any supporting material, including:</p>
393 <ul>
394 <li>
395 A justification of why this app/service should be included in the list
396 </li>
397 <li>Links to any published security audit, if they exist</li>
398 <li>
399 Links to the services privacy policy, terms of service and other
400 relevant documents where applicable
401 </li>
402 <li>
403 Your affiliation with the service. For transparency, you must disclose
404 if you are associated with them or any similar items in any way
405 </li>
406 <li>
407 Links to relevant discussions, past issues/PRs related to this service
408 </li>
409 </ul>
410 <textarea bind:value={additionalInfo} id="additional-info" rows="5"
411 ></textarea>
412 </div>
413
414 <button type="submit">Submit</button>
415 <a href={issueUrl} target="_blank" class="open-in-gh"
416 >Open in GitHub Issues</a
417 >
418 </form>
419</div>
420
421<div class="output-yaml">
422 <p>
423 Below is the YAML content, which will be appended to the appropriate section
424 within <a
425 href="github.com/lissy93/awesome-privacy/blob/main/awesome-privacy.yml"
426 >awesome-privacy.yml</a
427 >
428 upon approval.
429 </p>
430 {#if !interactiveActivated || !codeBlock}
431 <!-- eslint-disable-next-line svelte/no-at-html-tags -- yamlText is generated from user form input via yaml.dump, not arbitrary HTML -->
432 <pre><code class="language-yaml">{@html yamlText}</code></pre>
433 {/if}
434 <pre><code bind:this={codeBlock} class="language-yaml"></code></pre>
435 <p>
436 Your submission will need to be reviewed by a maintainer and the community
437 before it can be merged.
438 </p>
439</div>
440
441<style lang="scss">
442 .disabled-notice {
443 padding: var(--space-md);
444 margin: var(--space-sm) auto var(--space-md) auto;
445 border: var(--border-heavy);
446 box-shadow: var(--shadow-sm);
447 background: var(--surface);
448 border-radius: var(--curve-sm);
449 background: color-mix(in srgb, var(--changelog-rem) 20%, transparent);
450 }
451
452 .form-wrapper {
453 position: relative;
454 }
455
456 .disabled-overlay {
457 position: absolute;
458 inset: 0;
459 z-index: 10;
460 cursor: not-allowed;
461 background: rgba(128, 128, 128, 0.35);
462 border-radius: var(--curve-sm);
463 }
464
465 .form-row {
466 display: grid;
467 grid-template-columns: 1fr 3fr 2fr;
468 gap: var(--space-md);
469 padding: var(--space-sm) 0;
470 &:not(:last-child) {
471 border-bottom: 1px solid var(--transparent-accent);
472 }
473 p {
474 margin: 0;
475 font-size: var(--text-sm);
476 opacity: var(--opacity-muted);
477 }
478 }
479
480 .final-info {
481 display: flex;
482 flex-direction: column;
483 padding: var(--space-md) 0;
484 gap: var(--space-md);
485 p {
486 margin: var(--space-sm) 0;
487 }
488 ul {
489 padding-left: var(--space-xs);
490 margin: 0 0 var(--space-sm) 0;
491 font-size: var(--text-sm);
492 opacity: var(--opacity-muted);
493 list-style: circle;
494 }
495 }
496
497 input,
498 textarea,
499 select {
500 width: 100%;
501 border: 1px solid var(--accent-3);
502 border-radius: var(--curve-md);
503 font-size: var(--text-md);
504 padding: var(--space-sm) var(--space-xs);
505 background: var(--background-form);
506 color: var(--foreground);
507 &:focus {
508 outline: none;
509 border: 1px solid var(--accent);
510 }
511 }
512 input {
513 height: fit-content;
514 &[type='number']::-webkit-outer-spin-button,
515 &[type='number']::-webkit-inner-spin-button {
516 -webkit-appearance: none;
517 margin: 0;
518 }
519 &[type='number'] {
520 -moz-appearance: textfield;
521 }
522 &[type='checkbox'] {
523 width: 2rem;
524 height: 2rem;
525 background: var(--background-form);
526 }
527 }
528 textarea {
529 resize: vertical;
530 }
531 .open-in-gh {
532 margin: 0 auto;
533 font-size: var(--text-sm);
534 display: block;
535 text-align: center;
536 }
537
538 button {
539 cursor: pointer;
540 background: var(--accent-3);
541 color: var(--accent-3-fg);
542 padding: var(--space-sm) var(--space-lg);
543 border: var(--border-light);
544 box-shadow: var(--shadow-sm);
545 border-radius: var(--curve-lg);
546 font-size: var(--text-2xl);
547 font-family: var(--font-subtitle);
548 margin: var(--space-md) auto;
549 display: flex;
550 transition: var(--transition-normal);
551 &:hover {
552 background: var(--accent);
553 }
554 }
555
556 .sub-title-description {
557 margin-top: 0;
558 font-size: var(--text-sm);
559 opacity: var(--opacity-muted);
560 }
561
562 .output-yaml {
563 pre {
564 font-family: var(--font-code);
565 background: var(--background-form);
566 padding: 0.2rem 0.4rem;
567 border-radius: var(--curve-sm);
568 font-size: var(--text-sm);
569 }
570 }
571</style>