Commit a2f36e1ce7
Unsigned
Layout: unified · split
web/src/components/things/AddNewService.svelte +38 −21
| @@ -19,6 +19,32 @@ | ||
| 19 | 19 | const serviceSecurityAudited = writable(false); |
| 20 | 20 | const serviceCrypto = writable(false); |
| 21 | 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 | } | |
| 22 | 48 | |
| 23 | 49 | $: yamlText = yaml.dump([{ |
| 24 | 50 | name: $serviceName, |
| @@ -34,7 +60,7 @@ | ||
| 34 | 60 | openSource: $serviceOpenSource, |
| 35 | 61 | securityAudited: $serviceSecurityAudited, |
| 36 | 62 | acceptsCrypto: $serviceCrypto, |
| 37 | }]); | |
| 63 | }].map(obj => filterEmptyValues(obj))); | |
| 38 | 64 | |
| 39 | 65 | $: issueUrl = makeAdditionRequest({ |
| 40 | 66 | listingCategory: $listingCategory, |
| @@ -56,28 +82,16 @@ | ||
| 56 | 82 | |
| 57 | 83 | // Form submission handler |
| 58 | 84 | function handleSubmit() { |
| 59 | const formData = { | |
| 60 | listingCategory: $listingCategory, | |
| 61 | serviceName: $serviceName, | |
| 62 | serviceUrl: $serviceUrl, | |
| 63 | serviceIcon: $serviceIcon, | |
| 64 | serviceDescription: $serviceDescription, | |
| 65 | serviceGithub: $serviceGithub, | |
| 66 | serviceTosdrId: $serviceTosdrId, | |
| 67 | serviceOpenSource: $serviceOpenSource, | |
| 68 | serviceSecurityAudited: $serviceSecurityAudited, | |
| 69 | serviceCrypto: $serviceCrypto, | |
| 70 | additionalInfo: $additionalInfo, | |
| 71 | serviceIosApp: $serviceIosApp, | |
| 72 | serviceAndroidApp: $serviceAndroidApp, | |
| 73 | serviceDiscordInvite: $serviceDiscordInvite, | |
| 74 | serviceSubreddit: $serviceSubreddit, | |
| 75 | }; | |
| 76 | const issueCreationUrl = makeAdditionRequest(formData, yamlText); | |
| 77 | window.open(issueCreationUrl, '_blank'); | |
| 85 | window.open(issueUrl, '_blank'); | |
| 78 | 86 | } |
| 79 | 87 | </script> |
| 80 | 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 | ||
| 81 | 95 | <p> |
| 82 | 96 | Before completing this form, you must ensure that the service you are adding aligns |
| 83 | 97 | with the <a href="/about#creteria">Requirements</a> for Awesome Privacy. |
| @@ -278,7 +292,10 @@ | ||
| 278 | 292 | within <a href="github.com/lissy93/awesome-privacy/blob/main/awesome-privacy.yml">awesome-privacy.yml</a> |
| 279 | 293 | upon approval. |
| 280 | 294 | </p> |
| 281 | <pre>{@html yamlText}</pre> | |
| 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> | |
| 282 | 299 | <p>Your submission will need to be reviewed by a maintainer and the community before it can be merged.</p> |
| 283 | 300 | </div> |
| 284 | 301 | |