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