web/src/components/things/AddNewService.svelte

525 lines · 14663 bytes

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