web/src/components/things/AddNewService.svelte

300 lines · 9905 bytes

  1<script lang="ts">
  2  import yaml from 'js-yaml';
  3  import { writable } from 'svelte/store';
  4  import { makeAdditionRequest } from '../../utils/data-src-delete-n-edit';
  5
  6  // Defining writable stores for each form field
  7  const listingCategory = writable('');
  8  const serviceName = writable('');
  9  const serviceUrl = writable('');
 10  const serviceIcon = writable('');
 11  const serviceDescription = writable('');
 12  const serviceGithub = writable('');
 13  const serviceTosdrId = writable('');
 14  const serviceOpenSource = writable(false);
 15  const serviceSecurityAudited = writable(false);
 16  const serviceCrypto = writable(false);
 17  const additionalInfo = writable('');
 18  
 19  $: yamlText = yaml.dump([{
 20        name: $serviceName,
 21        url: $serviceUrl,
 22        icon: $serviceIcon,
 23        description: $serviceDescription,
 24        github: $serviceGithub,
 25        tosdrId: $serviceTosdrId,
 26        openSource: $serviceOpenSource,
 27        securityAudited: $serviceSecurityAudited,
 28        acceptsCrypto: $serviceCrypto,
 29    }]);
 30
 31  $: issueUrl = makeAdditionRequest({
 32      listingCategory: $listingCategory,
 33      serviceName: $serviceName,
 34      serviceUrl: $serviceUrl,
 35      serviceIcon: $serviceIcon,
 36      serviceDescription: $serviceDescription,
 37      serviceGithub: $serviceGithub,
 38      serviceTosdrId: $serviceTosdrId,
 39      serviceOpenSource: $serviceOpenSource,
 40      serviceSecurityAudited: $serviceSecurityAudited,
 41      serviceCrypto: $serviceCrypto,
 42      additionalInfo: $additionalInfo,
 43  }, yamlText);
 44
 45  // Form submission handler
 46  function handleSubmit() {
 47      const formData = {
 48          listingCategory: $listingCategory,
 49          serviceName: $serviceName,
 50          serviceUrl: $serviceUrl,
 51          serviceIcon: $serviceIcon,
 52          serviceDescription: $serviceDescription,
 53          serviceGithub: $serviceGithub,
 54          serviceTosdrId: $serviceTosdrId,
 55          serviceOpenSource: $serviceOpenSource,
 56          serviceSecurityAudited: $serviceSecurityAudited,
 57          serviceCrypto: $serviceCrypto,
 58          additionalInfo: $additionalInfo,
 59      };
 60      const issueCreationUrl = makeAdditionRequest(formData, yamlText);
 61      window.open(issueCreationUrl, '_blank');
 62  }
 63</script>
 64
 65<p>
 66  Before completing this form, you must ensure that the service you are adding aligns
 67  with the <a href="/about#creteria">Requirements</a> for Awesome Privacy.
 68  <br />
 69  You'll need a GitHub account in order to submit this form.
 70</p>
 71
 72<form on:submit|preventDefault={handleSubmit}>
 73  <!-- Category Dropdown -->
 74  <div class="form-row">
 75    <label for="listing-category">Category</label>
 76    <select bind:value={$listingCategory} id="listing-category" required autocomplete="off">
 77      <option value="">--Please choose an option--</option>
 78      <option value="Essentials">Essentials</option>
 79      <option value="Communication">Communication</option>
 80      <option value="Security Tools">Security Tools</option>
 81      <option value="Networking">Networking</option>
 82      <option value="Productivity">Productivity</option>
 83      <option value="Utilities">Utilities</option>
 84      <option value="Operating Systems">Operating Systems</option>
 85      <option value="Development">Development</option>
 86      <option value="Home and IoT">Home and IoT</option>
 87      <option value="Finance">Finance</option>
 88      <option value="Social">Social</option>
 89      <option value="Media">Media</option>
 90      <option value="Creativity">Creativity</option>
 91    </select>
 92    <p>
 93      Choose the top-level category, which should align with
 94      the <a href="/browse">one of these</a>.
 95    </p>
 96  </div>
 97
 98  <!-- Listing Name -->
 99  <div class="form-row">
100    <label for="service-name">Listing Name</label>
101    <input type="text" bind:value={$serviceName} id="service-name" required autocomplete="off">
102    <p>Enter the name of the app, software or service</p>
103  </div>
104
105  <!-- Listing URL -->
106  <div class="form-row">
107    <label for="service-url">Listing URL</label>
108    <input type="url" bind:value={$serviceUrl} id="service-url" required autocomplete="off">
109    <p>Enter the fully-qualified domain name of the homepage for this listing</p>
110  </div>
111  
112  <!-- Listing Icon -->
113  <div class="form-row">
114    <label for="service-icon">Listing Icon</label>
115    <input type="url" bind:value={$serviceIcon} id="service-icon" required autocomplete="off">
116    <p>Paste a URL to a square logo for the service. Dimensions must be no less than 64x64, and no more than 512x512 pixels</p>
117  </div>
118
119  <!-- Listing Description -->
120  <div class="form-row">
121    <label for="service-description">Listing Description</label>
122    <textarea bind:value={$serviceDescription} id="service-description" required autocomplete="off"></textarea>
123    <p>Please provide a description for this listing. Keep it factual and objective. Markdown is supported.</p>
124  </div>
125
126  <!-- GitHub Repository -->
127  <div class="form-row">
128    <label for="service-github">GitHub Repository</label>
129    <input type="text" bind:value={$serviceGithub} id="service-github" required autocomplete="off">
130    <p>Share a link to where the project's source is located</p>
131  </div>
132
133  <!-- ToS;DR ID -->
134  <div class="form-row">
135    <label for="service-tosdr-id">ToS;DR ID</label>
136    <input type="number" bind:value={$serviceTosdrId} id="service-tosdr-id" autocomplete="off">
137    <p>
138      Has the Privacy policy been documented by <a href="https://tosdr.org/">tosdr.org</a>?
139      If so, please include the report reference below (this is a 3 or 4-digit numerical ID).
140      Skip section if not applicable.
141    </p>
142  </div>
143
144    <!-- Open Source Checkbox -->
145  <div class="form-row">
146    <label for="service-open-source">Is Open Source?</label>
147    <input type="checkbox" bind:checked={$serviceOpenSource} id="service-open-source">
148    <p>Is this service fully open source? Aka, can it be compiled from source by the user, or self-hosted?</p>
149  </div>
150
151  <!-- Security Audited Checkbox -->
152  <div class="form-row">
153    <label for="service-security-audited">Security Audited?</label>
154    <input type="checkbox" bind:checked={$serviceSecurityAudited} id="service-security-audited">
155    <p>Has this service been independently security audited by an accredited auditor?</p>
156  </div>
157
158  <!-- Accepts Crypto Checkbox -->
159  <div class="form-row">
160    <label for="service-crypto">Accepts Anon Payment?</label>
161    <input type="checkbox" bind:checked={$serviceCrypto} id="service-crypto">
162    <p>If this is a hosted and paid for service, does it accept anonymous payment methods, including crypto (e.g., Monero)?</p>
163  </div>
164
165  <div class="final-info">
166    <p>
167      Finally, please provide any supporting material, including:
168    </p>
169    <ul>
170      <li>
171        A justification of why this app/service should be included in the list
172      </li>
173      <li>
174        Links to any published security audit, if they exist
175      </li>
176      <li>
177        Links to the services privacy policy, terms of service and other relevant
178        documents where applicable
179      </li>
180      <li>
181        Your affiliation with the service.
182        For transparency, you must disclose if you are associated
183        with them or any similar items in any way
184      </li>
185      <li>Links to relevant discussions, past issues/PRs related to this service</li>
186    </ul>
187    <textarea bind:value={$additionalInfo} id="additional-info" rows="5"></textarea>
188  </div>
189
190  <button type="submit">Submit</button>
191  <a href={issueUrl} target="_blank" class="open-in-gh">Open in GitHub Issues</a>
192</form>
193
194<div class="output-yaml">
195  <p>Below is the YAML content, which will be appended to the appropriate section
196    within <a href="github.com/lissy93/awesome-privacy/blob/main/awesome-privacy.yml">awesome-privacy.yml</a>
197    upon approval.
198  </p>
199  <pre>{@html yamlText}</pre>
200  <p>Your submission will need to be reviewed by a maintainer and the community before it can be merged.</p>
201</div>
202
203<style lang="scss">
204  .form-row {
205    display: grid;
206    grid-template-columns: 1fr 3fr 2fr;
207    gap: 1rem;
208    padding: 0.5rem 0;
209    &:not(:last-child) {
210      border-bottom: 1px solid var(--transparent-accent);
211    }
212    p {
213      margin: 0;
214      font-size: 0.8rem;
215      opacity: 0.6;
216    }
217  }
218
219  .final-info {
220    display: flex;
221    flex-direction: column;
222    padding: 1rem 0;
223    gap: 1rem;
224    p {
225      margin: 0.5rem 0;
226    }
227    ul {
228      padding-left: 0.25rem;
229      margin: 0 0 0.5rem 0;
230      font-size: 0.8rem;
231      opacity: 0.6;
232      list-style: circle;
233    }
234  }
235
236  input, textarea {
237    width: 100%;
238    border: 1px solid var(--accent-3);
239    border-radius: var(--curve-md);
240    font-size: 1.2rem;
241    padding: 0.5rem 0;
242    &:focus {
243      outline: none;
244      border: 2px solid var(--accent);
245    }
246  }
247  input {
248    height: fit-content;
249    &[type="number"]::-webkit-outer-spin-button,
250    &[type="number"]::-webkit-inner-spin-button {
251        -webkit-appearance: none;
252        margin: 0;
253    }
254    &[type="number"] {
255        -moz-appearance: textfield;
256    }
257    &[type="checkbox"] {
258      width: 2rem;
259      height: 2rem;
260    }
261  }
262  textarea {
263    resize: vertical;
264  }
265  .open-in-gh {
266    margin: 0 auto;
267    font-size: 0.8rem;
268    opacity: 0.6;
269    display: block;
270    text-align: center;
271  }
272
273  button {
274    cursor: pointer;
275    background: var(--accent-3);
276    color: var(--accent-fg);
277    padding: 0.5rem 2rem;
278    border: 1px solid var(--foreground);
279    box-shadow: 3px 3px 0 var(--foreground);
280    border-radius: var(--curve-lg);
281    font-size: 1.8rem;
282    font-family: "Lekton", sans-serif;
283    margin: 1rem auto;
284    display: flex;
285    transition: all 0.2s ease-in-out;
286    &:hover {
287      background: var(--accent);
288    }
289  }
290
291  .output-yaml {
292    pre {
293      font-family: 'Courier New', Courier, monospace;
294      background: #cecbf780;
295      padding: 0.2rem 0.4rem;
296      border-radius: var(--curve-sm);
297      font-size: 0.9rem;
298    }
299  }
300</style>