Commit 7fef7d3edd

7fef7d3edda6c5eb61dbcee3193631125d10a278

parent: 282e3bc060

Unsigned

Alicia Sykes <alicia@omg.lol> · 2024-03-07 16:52 UTC

Adds edit functionality

Layout: unified · split

web/src/components/Hero.astro +1 −1
@@ -5,7 +5,7 @@ import FontAwesome from "@components/form/FontAwesome.svelte"
5<div class="hero"> 5<div class="hero">
6 <h1>Awesome Privacy</h1> 6 <h1>Awesome Privacy</h1>
7 <p class="intro"> 7 <p class="intro">
8 Your guide to finding privacy-respecting alternatives to popular software and services. 8 Your guide to finding and comparing privacy-respecting alternatives to popular software and services.
9 </p> 9 </p>
10 <div class="github-link-wrap"> 10 <div class="github-link-wrap">
11 <a href="https://github.com/lissy93/awesome-privacy"> 11 <a href="https://github.com/lissy93/awesome-privacy">
web/src/components/form/Button.astro +2 −1
@@ -4,11 +4,12 @@ const {
4 text, 4 text,
5 url, 5 url,
6 className, 6 className,
7 title,
7} = Astro.props; 8} = Astro.props;
8 9
9--- 10---
10 11
11<div class={`button ${className || ''}`}> 12<div class={`button ${className || ''}`} title={title}>
12 <a href={url}>{text}<slot /></a> 13 <a href={url}>{text}<slot /></a>
13</div> 14</div>
14 15
web/src/components/form/FontAwesome.svelte +1
@@ -26,6 +26,7 @@
26 // Service actions 26 // Service actions
27 delete: solidIcons.faTrash, 27 delete: solidIcons.faTrash,
28 edit: solidIcons.faPenToSquare, 28 edit: solidIcons.faPenToSquare,
29 add: solidIcons.faPlusHexagon,
29 30
30 // Website Detailed Stats 31 // Website Detailed Stats
31 blacklistFound: solidIcons.faDoNotEnter, 32 blacklistFound: solidIcons.faDoNotEnter,
web/src/components/things/AddNewService.svelte added +300
@@ -0,0 +1,300 @@
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>
web/src/components/things/DataActions.svelte +3
@@ -64,6 +64,9 @@
64 href={makeEditRequest(categoryName, sectionName, serviceName, yamlContent)}> 64 href={makeEditRequest(categoryName, sectionName, serviceName, yamlContent)}>
65 <FontAwesome iconName="edit" /> Submit Edit to {serviceName} 65 <FontAwesome iconName="edit" /> Submit Edit to {serviceName}
66 </a> 66 </a>
67 <a class="button-link" href="/edit">
68 <FontAwesome iconName="add" /> Add alternative
69 </a>
67</div> 70</div>
68 71
69{/if} 72{/if}
web/src/components/things/DeleteListing.svelte +10 −2
@@ -1,7 +1,7 @@
1 1
2<script lang="ts"> 2<script lang="ts">
3 import FontAwesome from '@components/form/FontAwesome.svelte'; 3 import FontAwesome from '@components/form/FontAwesome.svelte';
4 import { fetchSrcData, makeRemovalRequest, makeEditRequest } from '@utils/data-src-delete-n-edit'; 4 import { fetchSrcData, makeRemovalRequest } from '@utils/data-src-delete-n-edit';
5 import { onMount } from 'svelte'; 5 import { onMount } from 'svelte';
6 6
7 7
@@ -9,18 +9,26 @@
9 export let sectionName: string; 9 export let sectionName: string;
10 export let serviceName: string; 10 export let serviceName: string;
11 11
12 const apYaml = 'https://github.com/lissy93/awesome-privacy/blob/main/awesome-privacy.yml';
13
12 let yamlContent = ''; 14 let yamlContent = '';
15 let editLink = apYaml;
13 16
14 onMount(async () => { 17 onMount(async () => {
15 const results = await fetchSrcData(categoryName, sectionName, serviceName); 18 const results = await fetchSrcData(categoryName, sectionName, serviceName);
16 yamlContent = results.yamlContent; 19 yamlContent = results.yamlContent;
20
21 const lineNumbers = results.lineNumbers || null;
22 const numberRange = lineNumbers ? `#L${lineNumbers.start}-L${lineNumbers.end}` : '';
23 const yamlLink = 'https://github.com/lissy93/awesome-privacy/blob/main/awesome-privacy.yml';
24 editLink = `${yamlLink}${numberRange}`;
17 }); 25 });
18 26
19</script> 27</script>
20 28
21<div class="actions"> 29<div class="actions">
22 <a title="Edit" target="_blank" 30 <a title="Edit" target="_blank"
23 href={makeEditRequest(categoryName, sectionName, serviceName, yamlContent)}> 31 href={editLink}>
24 <FontAwesome iconName="edit" /> 32 <FontAwesome iconName="edit" />
25 </a> 33 </a>
26 <a title="Delete" target="_blank" 34 <a title="Delete" target="_blank"
web/src/components/things/GitHubDetailedInfo.astro +1
@@ -57,6 +57,7 @@ function generateChartData(languages: Record<string, number>): string {
57 'cpp': '#00599C', 57 'cpp': '#00599C',
58 'C++': '#00599C', 58 'C++': '#00599C',
59 'Dockerfile': '#2496ED', 59 'Dockerfile': '#2496ED',
60 'SCSS': '#CC6699',
60 }; 61 };
61 62
62 // Arrays to hold the data, labels, and colors 63 // Arrays to hold the data, labels, and colors
web/src/components/things/ServiceList.astro +4 −2
@@ -49,7 +49,7 @@ const {
49 49
50 50
51<section> 51<section>
52 {services ? ( 52 {services && services.length > 0 ? (
53 <ul> 53 <ul>
54 {services.map((service: Service) => ( 54 {services.map((service: Service) => (
55 <li id={slugify(service.name)}> 55 <li id={slugify(service.name)}>
@@ -126,7 +126,9 @@ const {
126 </p> 126 </p>
127 )} 127 )}
128 128
129 {buttonLink && ( <Button className="view-all" text="View More..." url={buttonLink} /> )} 129 {buttonLink && (
130 <Button title={`View all ${categoryName}`} className="view-all" text="View More..." url={buttonLink} />
131 )}
130</section> 132</section>
131 133
132 134
web/src/components/things/WebsiteDetailedInfo.astro +5 −1
@@ -26,7 +26,7 @@ const categoryLabels: {[key: string]: string} = {
26}; 26};
27 27
28const siteCategories = Object.entries(websiteInfo.site_category) 28const siteCategories = Object.entries(websiteInfo.site_category)
29 .filter(([key, value]) => value) 29 .filter(([_key, value]) => value)
30 .map(([key]) => categoryLabels[key]); 30 .map(([key]) => categoryLabels[key]);
31 31
32const securityChecks = analyzeSecurityChecks(websiteInfo.security_checks); 32const securityChecks = analyzeSecurityChecks(websiteInfo.security_checks);
@@ -311,6 +311,10 @@ h4 {
311 width: 180px; 311 width: 180px;
312 float: right; 312 float: right;
313 font-size: 1rem; 313 font-size: 1rem;
314 transform: scale(0.8);
315 opacity: 0.85;
316 transition: all 0.2s ease-in-out;
317 &:hover { transform: scale(0.85); opacity: 1; }
314 :global(.button) { 318 :global(.button) {
315 background: var(--accent-3); 319 background: var(--accent-3);
316 } 320 }
web/src/pages/[...listing].astro +1 −1
@@ -183,7 +183,7 @@ const getApiEndpoint = () => {
183 { url && ( 183 { url && (
184 <li> 184 <li>
185 <b>Web info:</b> 185 <b>Web info:</b>
186 <a href={`https://web-check.xyz/results/${formatLink(url)}`}>{`web-check.xyz/results/${formatLink(url)}`}</a> 186 <a href={`https://web-check.xyz/results/${formatLink(url)}`}>{`web-check.xyz/results/${formatLink(url).split('/')[0]}`}</a>
187 </li> 187 </li>
188 )} 188 )}
189 </ul> 189 </ul>
web/src/pages/about.astro +1 −1
@@ -43,7 +43,7 @@ as Git makes it possible to maintain a full log of what was changed, when, by wh
43 43
44### Augmention 44### Augmention
45The data is augmented with some extra info, to add additional context to each service. 45The data is augmented with some extra info, to add additional context to each service.
46The aim of this is to give you a broader picture of each service, to help you make a more informed decision. 46The aim of this is to give you a broader picture of each listing, to help you make a more informed decision.
47Currently, this extra data is pulled from: 47Currently, this extra data is pulled from:
48 48
49- **GitHub API** - To fetch info about each project's repository 49- **GitHub API** - To fetch info about each project's repository
web/src/pages/api/line-numbers.json.ts +6 −4
@@ -1,7 +1,7 @@
1import type { APIRoute } from 'astro'; 1import type { APIRoute } from 'astro';
2import yaml from 'js-yaml'; 2import yaml from 'js-yaml';
3 3
4import type { AwesomePrivacy, Service } from '../../types/Service'; 4import type { AwesomePrivacy, Service, Category } from '../../types/Service';
5 5
6interface LineNumberRange { 6interface LineNumberRange {
7 start: number; 7 start: number;
@@ -25,13 +25,15 @@ const awesomePrivacyYamlPath = 'https://raw.githubusercontent.com/Lissy93/awesom
25 * Given a service object and an array of string lines from the raw YAML 25 * Given a service object and an array of string lines from the raw YAML
26 * Find the starting and ending line number for that service 26 * Find the starting and ending line number for that service
27 */ 27 */
28const calculateServiceRange = (service: Service, yamlLines: string[]): LineNumberRange | null => { 28const calculateServiceRange = (service: Service, category: Category, yamlLines: string[]): LineNumberRange | null => {
29 const lookFor = `- name: ${service.name}`; 29 const lookFor = `- name: ${service.name}`;
30 const start = yamlLines.findIndex(line => line.includes(lookFor)) + 1; 30 const categoryStart = yamlLines.findIndex(line => line.includes(category.name));
31 const start = yamlLines.slice(categoryStart).findIndex(line => line.includes(lookFor)) + categoryStart + 1;
31 if (start === -1) return null; 32 if (start === -1) return null;
32 const detectEnd = (line: string) => { 33 const detectEnd = (line: string) => {
33 return line.trim().length === 0 34 return line.trim().length === 0
34 || line.startsWith(' - ') 35 || line.startsWith(' - ')
36 || line.includes('- name:')
35 || line.includes('notableMentions:') 37 || line.includes('notableMentions:')
36 || line.includes('furtherInfo:') 38 || line.includes('furtherInfo:')
37 || line.includes('wordOfWarning:') 39 || line.includes('wordOfWarning:')
@@ -61,7 +63,7 @@ const makeResults = (yamlObject: AwesomePrivacy, yamlLines: string[]): LineNumbe
61 organizedData[category.name][section.name] = {}; 63 organizedData[category.name][section.name] = {};
62 section.services.forEach((service) => { 64 section.services.forEach((service) => {
63 organizedData[category.name][section.name][service.name] = { 65 organizedData[category.name][section.name][service.name] = {
64 lineNumbers: calculateServiceRange(service, yamlLines), 66 lineNumbers: calculateServiceRange(service, category, yamlLines),
65 yaml: convertJsonIntoYaml(service), 67 yaml: convertJsonIntoYaml(service),
66 }; 68 };
67 }); 69 });
web/src/pages/edit.astro added +80
@@ -0,0 +1,80 @@
1---
2
3
4import Layout from '@layouts/Layout.astro';
5import AddNewService from '@components/things/AddNewService.svelte';
6import type { AwesomePrivacy, Section } from '../types/Service';
7import { fetchData, slugify } from '@utils/fetch-data';
8import FontAwesome from '@components/form/FontAwesome.svelte';
9
10const categories = (await fetchData() as AwesomePrivacy)?.categories || [];
11
12---
13
14<Layout title="Awesome Privacy">
15 <section>
16 <h2>About our Data</h2>
17 <p>
18 All data on Awesome Privacy is community maintained via Git.
19 <br />
20 You can make edits/additions/removals by editing the
21 <a href="github.com/lissy93/awesome-privacy/blob/main/awesome-privacy.yml">awesome-privacy.yml</a> file.
22 To learn more, see the <a href="/about#our-data">about page</a>.
23 </p>
24 </section>
25 <section>
26 <h2>Submit an Addition</h2>
27 <AddNewService client:load />
28 </section>
29
30 <section>
31 <h2>Submit a Removal Request</h2>
32 <p>
33 You can submit a removal request by browsing to a given service's page,
34 and clicking the "Request Removal" button.
35 This will open a form where you can justify your reasoning, to get it
36 deleted from the <a href="github.com/lissy93/awesome-privacy/blob/main/awesome-privacy.yml">awesome-privacy.yml</a> file.
37 </p>
38 </section>
39
40 <section>
41 <h2>Edit a Listing</h2>
42 <p>
43 Edits are welcome! All data is located in
44 <a href="github.com/lissy93/awesome-privacy/blob/main/awesome-privacy.yml">awesome-privacy.yml</a>.
45 <br>
46 To modify an entry, navigate to it's page, scroll to the bottom, and click "Edit".
47 This will take you to directly to the relevant lines in the file, where you can make your changes.
48 </p>
49 </section>
50
51</Layout>
52
53<style lang="scss">
54
55section {
56 margin: 2rem auto;
57 padding: 1rem;
58 width: 1000px;
59 max-width: calc(100% - 5rem);
60 display: flex;
61 flex-direction: column;
62 justify-content: space-between;
63 padding: 0 2rem;
64 border: 2px solid var(--foreground);
65 box-shadow: 6px 6px 0 var(--foreground);
66 background: var(--accent-fg);
67 @media(max-width: 768px) {
68 max-width: 95%;
69 padding: 0.5rem;
70 margin: 0 auto;
71 }
72 p {
73 margin-top: 0;
74 }
75 h2 {
76 margin-bottom: 0.5rem;
77 }
78}
79
80</style>
web/src/utils/data-src-delete-n-edit.ts +52
@@ -24,6 +24,58 @@ export const makeEditRequest = (categoryName: string, sectionName: string, servi
24 return `${issueCreate}${baseOptions}${removalData}`; 24 return `${issueCreate}${baseOptions}${removalData}`;
25}; 25};
26 26
27export const makeAdditionRequest = (formData: {
28 listingCategory: string;
29 serviceName: string;
30 serviceUrl: string;
31 serviceIcon: string;
32 serviceDescription: string;
33 serviceGithub: string;
34 serviceTosdrId: string;
35 serviceOpenSource: boolean;
36 serviceSecurityAudited: boolean;
37 serviceCrypto: boolean;
38 additionalInfo: string;
39}, yamlText?: string) => {
40
41 const userInfo = formData.additionalInfo.split('\n').map(line => `> ${line}`).join('\n');
42 const additionalInfoText: string = `\n${userInfo}`
43 + `\n\n**YAML Content for Addition**\n\n\`\`\`yaml\n${yamlText || '# nothing yet'}\n\`\`\`\n`
44 + `\n\n<sup>This ticket was submitted via `
45 + `<a href="https://awesome-privacy.xyz/edit">awesome-privacy.xyz/edit</a></sup>`;
46
47 const issueTitle = `[ADDITION] ${formData.serviceName} (Complete)`;
48 const queryParams = new URLSearchParams({
49 'assignees': 'lissy93,liss-bot',
50 'labels': '',
51 'projects': '',
52 'template': 'complete-addition.yml',
53 'title': issueTitle,
54 'listing-category': formData.listingCategory,
55 'service-name': formData.serviceName,
56 'service-url': formData.serviceUrl,
57 'service-icon': formData.serviceIcon,
58 'service-description': formData.serviceDescription,
59 'service-github': formData.serviceGithub,
60 'service-tosdr-id': formData.serviceTosdrId,
61 'service-opensource': formData.serviceOpenSource ? 'true' : 'false',
62 'service-security-audited': formData.serviceSecurityAudited ? 'true' : 'false',
63 'service-crypto': formData.serviceCrypto ? 'true' : 'false',
64 'additional-info': additionalInfoText,
65 });
66 const issueCreateUrl = 'https://github.com/Lissy93/awesome-privacy/issues/new';
67 return `${issueCreateUrl}?${queryParams.toString()}`;
68};
69
70
71export const makeSourceYamlLink = async (categoryName: string, sectionName: string, serviceName: string) => {
72 const sourceData = await fetchSrcData(categoryName, sectionName, serviceName);
73 const lineNumbers = sourceData.lineNumbers || null;
74 const numberRange = lineNumbers ? `L${lineNumbers.start}-L${lineNumbers.end}` : '';
75 const yamlLink = 'https://github.com/lissy93/awesome-privacy/blob/main/awesome-privacy.yml';
76 return `${yamlLink}${numberRange}`;
77};
78
27export const fetchSrcData = async (categoryName: string, sectionName: string, serviceName: string) => { 79export const fetchSrcData = async (categoryName: string, sectionName: string, serviceName: string) => {
28 const lineNumberData = await fetch('/api/line-numbers.json') 80 const lineNumberData = await fetch('/api/line-numbers.json')
29 .then((res) => res.json()); 81 .then((res) => res.json());