Commit e2de4194d5
Unsigned
Layout: unified · split
web/src/components/form/Icon.astro +20
| @@ -54,6 +54,26 @@ const getSvgPath = (icon: string) => { | |||
| 54 | vp: '0 0 512 512', | 54 | vp: '0 0 512 512', |
| 55 | path: 'M232 60.8V447.4c-66.9-37.8-108.8-94.3-134.1-152.6C71 232.9 63.1 169.5 64.1 126L232 60.8zm48 386.5V60.8L448 126c1 43.5-6.9 106.9-33.8 168.8C388.8 353.1 346.9 409.5 280 447.3zM495.5 113l-1.2-20.5L475.1 85 267.6 4.5 256 0 244.4 4.5 36.9 85 17.8 92.5 16.6 113c-2.9 49.9 4.9 126.3 37.3 200.9c32.7 75.2 91 150 189.4 192.6L256 512l12.7-5.5c98.4-42.6 156.7-117.3 189.4-192.6c32.4-74.7 40.2-151 37.3-200.9z', | 55 | path: 'M232 60.8V447.4c-66.9-37.8-108.8-94.3-134.1-152.6C71 232.9 63.1 169.5 64.1 126L232 60.8zm48 386.5V60.8L448 126c1 43.5-6.9 106.9-33.8 168.8C388.8 353.1 346.9 409.5 280 447.3zM495.5 113l-1.2-20.5L475.1 85 267.6 4.5 256 0 244.4 4.5 36.9 85 17.8 92.5 16.6 113c-2.9 49.9 4.9 126.3 37.3 200.9c32.7 75.2 91 150 189.4 192.6L256 512l12.7-5.5c98.4-42.6 156.7-117.3 189.4-192.6c32.4-74.7 40.2-151 37.3-200.9z', |
| 56 | }; | 56 | }; |
| 57 | case 'addition': | ||
| 58 | return { | ||
| 59 | vp: '0 0 640 640', | ||
| 60 | path: 'M352 128C352 110.3 337.7 96 320 96C302.3 96 288 110.3 288 128L288 288L128 288C110.3 288 96 302.3 96 320C96 337.7 110.3 352 128 352L288 352L288 512C288 529.7 302.3 544 320 544C337.7 544 352 529.7 352 512L352 352L512 352C529.7 352 544 337.7 544 320C544 302.3 529.7 288 512 288L352 288L352 128z', | ||
| 61 | }; | ||
| 62 | case 'removal': | ||
| 63 | return { | ||
| 64 | vp: '0 0 640 640', | ||
| 65 | path: 'M96 320C96 302.3 110.3 288 128 288L512 288C529.7 288 544 302.3 544 320C544 337.7 529.7 352 512 352L128 352C110.3 352 96 337.7 96 320z', | ||
| 66 | }; | ||
| 67 | case 'amendment': | ||
| 68 | return { | ||
| 69 | vp: '0 0 640 640', | ||
| 70 | path: 'M100.4 417.2C104.5 402.6 112.2 389.3 123 378.5L304.2 197.3L338.1 163.4C354.7 180 389.4 214.7 442.1 267.4L476 301.3L442.1 335.2L260.9 516.4C250.2 527.1 236.8 534.9 222.2 539L94.4 574.6C86.1 576.9 77.1 574.6 71 568.4C64.9 562.2 62.6 553.3 64.9 545L100.4 417.2zM156 413.5C151.6 418.2 148.4 423.9 146.7 430.1L122.6 517L209.5 492.9C215.9 491.1 221.7 487.8 226.5 483.2L155.9 413.5zM510 267.4C493.4 250.8 458.7 216.1 406 163.4L372 129.5C398.5 103 413.4 88.1 416.9 84.6C430.4 71 448.8 63.4 468 63.4C487.2 63.4 505.6 71 519.1 84.6L554.8 120.3C568.4 133.9 576 152.3 576 171.4C576 190.5 568.4 209 554.8 222.5C551.3 226 536.4 240.9 509.9 267.4z', | ||
| 71 | }; | ||
| 72 | case 'rejection': | ||
| 73 | return { | ||
| 74 | vp: '0 0 640 640', | ||
| 75 | path: 'M504.6 148.5C515.9 134.9 514.1 114.7 500.5 103.4C486.9 92.1 466.7 93.9 455.4 107.5L320 270L184.6 107.5C173.3 93.9 153.1 92.1 139.5 103.4C125.9 114.7 124.1 134.9 135.4 148.5L278.3 320L135.4 491.5C124.1 505.1 125.9 525.3 139.5 536.6C153.1 547.9 173.3 546.1 184.6 532.5L320 370L455.4 532.5C466.7 546.1 486.9 547.9 500.5 536.6C514.1 525.3 515.9 505.1 504.6 491.5L361.7 320L504.6 148.5z', | ||
| 76 | }; | ||
| 57 | // Add more icons as needed... | 77 | // Add more icons as needed... |
| 58 | default: | 78 | default: |
| 59 | return { vb: '', path: '' }; // Default path or a placeholder icon | 79 | return { vb: '', path: '' }; // Default path or a placeholder icon |
web/src/components/scafold/NavBar.astro +1
| @@ -12,6 +12,7 @@ import ThemeSwitcher from '@components/form/ThemeSwitcher.svelte'; | |||
| 12 | <a href="/browse">Browse</a> | 12 | <a href="/browse">Browse</a> |
| 13 | <a href="/search">Search</a> | 13 | <a href="/search">Search</a> |
| 14 | <a href="/about">About</a> | 14 | <a href="/about">About</a> |
| 15 | <a href="/changelog">Changelog</a> | ||
| 15 | <a href="https://github.com/lissy93/awesome-privacy">GitHub</a> | 16 | <a href="https://github.com/lissy93/awesome-privacy">GitHub</a> |
| 16 | <div class="theme-switcher"> | 17 | <div class="theme-switcher"> |
| 17 | <ThemeSwitcher client:load /> | 18 | <ThemeSwitcher client:load /> |
web/src/components/things/ChangelogTimeline.svelte added +401
| @@ -0,0 +1,401 @@ | |||
| 1 | <script lang="ts"> | ||
| 2 | import type { ChangelogEntry, ServiceChange, Rejection, ChangelogPr } from '../../utils/fetch-changelog'; | ||
| 3 | import { slugify } from '@utils/fetch-data'; | ||
| 4 | |||
| 5 | export let entries: ChangelogEntry[] = []; | ||
| 6 | export let rejections: Rejection[] = []; | ||
| 7 | |||
| 8 | type Filter = 'added' | 'removed' | 'modified' | 'rejected'; | ||
| 9 | |||
| 10 | const filterDefs: { key: Filter; label: string; icon: string }[] = [ | ||
| 11 | { key: 'added', label: 'Additions', icon: '+' }, | ||
| 12 | { key: 'removed', label: 'Removals', icon: '−' }, | ||
| 13 | { key: 'modified', label: 'Amendments', icon: '✎' }, | ||
| 14 | { key: 'rejected', label: 'Rejections', icon: '✕' }, | ||
| 15 | ]; | ||
| 16 | |||
| 17 | let on: Record<Filter, boolean> = { added: true, removed: true, modified: true, rejected: true }; | ||
| 18 | let searchQuery = ''; | ||
| 19 | |||
| 20 | function toggle(key: Filter) { on = { ...on, [key]: !on[key] }; } | ||
| 21 | |||
| 22 | type TimelineItem = | ||
| 23 | | { kind: 'entry'; date: string; sha: string; pr?: ChangelogPr | null; data: ChangelogEntry } | ||
| 24 | | { kind: 'rejection'; date: string; sha: string; pr: ChangelogPr; data: Rejection }; | ||
| 25 | |||
| 26 | const svc = (e: ChangelogEntry) => { | ||
| 27 | const s = e.changes?.services; | ||
| 28 | return { added: s?.added || [], removed: s?.removed || [], modified: s?.modified || [] }; | ||
| 29 | }; | ||
| 30 | const sec = (e: ChangelogEntry) => { | ||
| 31 | const s = e.changes?.sections; | ||
| 32 | return { added: s?.added || [], removed: s?.removed || [] }; | ||
| 33 | }; | ||
| 34 | const cat = (e: ChangelogEntry) => { | ||
| 35 | const c = e.changes?.categories; | ||
| 36 | return { added: c?.added || [], removed: c?.removed || [] }; | ||
| 37 | }; | ||
| 38 | |||
| 39 | function matchesFilters(item: TimelineItem, f: Record<Filter, boolean>): boolean { | ||
| 40 | if (item.kind === 'rejection') return f.rejected; | ||
| 41 | const s = svc(item.data), sc = sec(item.data), ct = cat(item.data); | ||
| 42 | return (f.added && (s.added.length > 0 || sc.added.length > 0 || ct.added.length > 0)) | ||
| 43 | || (f.removed && (s.removed.length > 0 || sc.removed.length > 0 || ct.removed.length > 0)) | ||
| 44 | || (f.modified && s.modified.length > 0); | ||
| 45 | } | ||
| 46 | |||
| 47 | function matchesSearch(item: TimelineItem, query: string): boolean { | ||
| 48 | if (!query) return true; | ||
| 49 | const q = query.toLowerCase(); | ||
| 50 | if (item.kind === 'rejection') { | ||
| 51 | return item.data.title.toLowerCase().includes(q) | ||
| 52 | || (item.pr.author?.toLowerCase().includes(q) ?? false); | ||
| 53 | } | ||
| 54 | const all = [...svc(item.data).added, ...svc(item.data).removed, ...svc(item.data).modified]; | ||
| 55 | return all.some(c => c.name.toLowerCase().includes(q) | ||
| 56 | || `${c.category} ${c.section}`.toLowerCase().includes(q)) | ||
| 57 | || (item.pr?.author?.toLowerCase().includes(q) ?? false); | ||
| 58 | } | ||
| 59 | |||
| 60 | const pl = (n: number, word: string) => `${n} ${word}${n > 1 ? 's' : ''}`; | ||
| 61 | |||
| 62 | function summarize(entry: ChangelogEntry): string { | ||
| 63 | const s = svc(entry), sc = sec(entry); | ||
| 64 | const parts: string[] = []; | ||
| 65 | if (s.added.length) parts.push(pl(s.added.length, 'addition')); | ||
| 66 | if (s.removed.length) parts.push(pl(s.removed.length, 'removal')); | ||
| 67 | if (s.modified.length) parts.push(pl(s.modified.length, 'amendment')); | ||
| 68 | if (sc.added.length) parts.push(pl(sc.added.length, 'new section')); | ||
| 69 | if (sc.removed.length) parts.push(pl(sc.removed.length, 'section removal')); | ||
| 70 | return parts.join(', ') || 'Changes'; | ||
| 71 | } | ||
| 72 | |||
| 73 | function serviceLink(s: ServiceChange, isRemoval: boolean): string { | ||
| 74 | const c = slugify(s.category), sc = slugify(s.section); | ||
| 75 | return isRemoval ? `/${c}/${sc}` : `/${c}/${sc}/${slugify(s.name)}`; | ||
| 76 | } | ||
| 77 | |||
| 78 | type ChangeRow = { badge: string; cls: string; name: string; href: string; path: string; fields?: string[] }; | ||
| 79 | |||
| 80 | function changeRows(e: ChangelogEntry): ChangeRow[] { | ||
| 81 | const s = svc(e), sc = sec(e), ct = cat(e); | ||
| 82 | return [ | ||
| 83 | ...s.added.map(v => ({ badge: 'Added', cls: 'add', name: v.name, href: serviceLink(v, false), path: `into ${v.category} › ${v.section}` })), | ||
| 84 | ...s.removed.map(v => ({ badge: 'Removed', cls: 'rem', name: v.name, href: serviceLink(v, true), path: `from ${v.category} › ${v.section}` })), | ||
| 85 | ...s.modified.map(v => ({ badge: 'Amended', cls: 'mod', name: v.name, href: serviceLink(v, false), path: `in ${v.category} › ${v.section}`, fields: v.fields })), | ||
| 86 | ...sc.added.map(v => ({ badge: 'New Section', cls: 'add', name: v.name, href: `/${slugify(v.category)}/${slugify(v.name)}` })), | ||
| 87 | ...sc.removed.map(v => ({ badge: 'Section Removed', cls: 'rem', name: v.name, href: '' })), | ||
| 88 | ...ct.added.map(v => ({ badge: 'New Category', cls: 'add', name: v, href: '' })), | ||
| 89 | ...ct.removed.map(v => ({ badge: 'Category Removed', cls: 'rem', name: v, href: '' })), | ||
| 90 | ]; | ||
| 91 | } | ||
| 92 | |||
| 93 | $: allItems = [ | ||
| 94 | ...entries.map((e): TimelineItem => ({ kind: 'entry', date: e.date, sha: e.sha, pr: e.pr, data: e })), | ||
| 95 | ...rejections.map((r): TimelineItem => ({ kind: 'rejection', date: r.date, sha: `rej-${r.pr.number}`, pr: r.pr, data: r })), | ||
| 96 | ].sort((a, b) => b.date.localeCompare(a.date)); | ||
| 97 | |||
| 98 | $: filtered = allItems.filter(item => matchesFilters(item, on) && matchesSearch(item, searchQuery)); | ||
| 99 | |||
| 100 | $: grouped = filtered.reduce<Record<string, TimelineItem[]>>((acc, item) => { | ||
| 101 | const d = new Date(item.date + 'T00:00:00Z'); | ||
| 102 | const key = d.toLocaleDateString('en-US', { year: 'numeric', month: 'long', timeZone: 'UTC' }); | ||
| 103 | (acc[key] ??= []).push(item); | ||
| 104 | return acc; | ||
| 105 | }, {}); | ||
| 106 | |||
| 107 | function formatDate(dateStr: string): string { | ||
| 108 | return new Date(dateStr + 'T00:00:00Z') | ||
| 109 | .toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric', timeZone: 'UTC' }); | ||
| 110 | } | ||
| 111 | </script> | ||
| 112 | |||
| 113 | <details class="controls"> | ||
| 114 | <summary>Search & Filter</summary> | ||
| 115 | <div class="controls-body"> | ||
| 116 | <input class="search" type="text" placeholder="Search..." bind:value={searchQuery} /> | ||
| 117 | <div class="filters"> | ||
| 118 | {#each filterDefs as f (f.key)} | ||
| 119 | <button class="pill {f.key}" class:active={on[f.key]} on:click={() => toggle(f.key)}> | ||
| 120 | <span class="icon">{f.icon}</span>{f.label} | ||
| 121 | </button> | ||
| 122 | {/each} | ||
| 123 | </div> | ||
| 124 | </div> | ||
| 125 | </details> | ||
| 126 | |||
| 127 | {#if filtered.length === 0} | ||
| 128 | <p class="empty">No matching changes found.</p> | ||
| 129 | {/if} | ||
| 130 | |||
| 131 | {#each Object.entries(grouped) as [month, monthItems] (month)} | ||
| 132 | <h3 class="month-header">{month}</h3> | ||
| 133 | {#each monthItems as item (item.sha)} | ||
| 134 | <article class="entry"> | ||
| 135 | <time class="entry-date">{formatDate(item.date)}</time> | ||
| 136 | <div class="entry-body"> | ||
| 137 | <div class="summary"> | ||
| 138 | {#if item.pr?.authorAvatar} | ||
| 139 | <a href={`https://github.com/${item.pr.author}`} target="_blank" rel="noreferrer"> | ||
| 140 | <img class="avatar" src={item.pr.authorAvatar} alt="" width="20" height="20" loading="lazy" /> | ||
| 141 | </a> | ||
| 142 | {/if} | ||
| 143 | {#if item.pr?.author} | ||
| 144 | <span class="author"><a href={`https://github.com/${item.pr.author}`} target="_blank" rel="noreferrer">@{item.pr.author}</a></span> | ||
| 145 | {/if} | ||
| 146 | <span class="summary-text"> | ||
| 147 | {item.kind === 'rejection' ? 'Submission Reviewed' : summarize(item.data)} | ||
| 148 | </span> | ||
| 149 | {#if item.pr} | ||
| 150 | <a class="pr-link" href={item.pr.url} target="_blank" rel="noreferrer">#{item.pr.number}</a> | ||
| 151 | {/if} | ||
| 152 | </div> | ||
| 153 | |||
| 154 | <div class="changes"> | ||
| 155 | {#if item.kind === 'rejection'} | ||
| 156 | <div class="change"> | ||
| 157 | <span class="badge rej">Rejected</span> | ||
| 158 | <a class="svc-name" href={item.pr.url} target="_blank" rel="noreferrer">{item.data.title}</a> | ||
| 159 | <span class="path">Not merged</span> | ||
| 160 | </div> | ||
| 161 | {:else} | ||
| 162 | {#each changeRows(item.data) as row (`${row.cls}/${row.path}/${row.name}`)} | ||
| 163 | <div class="change"> | ||
| 164 | <span class="badge {row.cls}">{row.badge}</span> | ||
| 165 | {#if row.href} | ||
| 166 | <a class="svc-name" class:removed={row.cls === 'rem'} href={row.href}>{row.name}</a> | ||
| 167 | {:else} | ||
| 168 | <strong>{row.name}</strong> | ||
| 169 | {/if} | ||
| 170 | {#if row.fields}<span class="fields">updated {row.fields.join(', ')}</span>{/if} | ||
| 171 | {#if row.path && !row.fields}<span class="path">{row.path}</span>{/if} | ||
| 172 | </div> | ||
| 173 | {/each} | ||
| 174 | {/if} | ||
| 175 | </div> | ||
| 176 | </div> | ||
| 177 | </article> | ||
| 178 | {/each} | ||
| 179 | {/each} | ||
| 180 | |||
| 181 | <style lang="scss"> | ||
| 182 | .controls { | ||
| 183 | margin-bottom: 1rem; | ||
| 184 | |||
| 185 | summary { | ||
| 186 | cursor: pointer; | ||
| 187 | width: fit-content; | ||
| 188 | font-family: 'Lekton', sans-serif; | ||
| 189 | opacity: 0.6; | ||
| 190 | &:hover { | ||
| 191 | opacity: 1; | ||
| 192 | } | ||
| 193 | } | ||
| 194 | |||
| 195 | .controls-body { | ||
| 196 | display: flex; | ||
| 197 | align-items: flex-end; | ||
| 198 | justify-content: space-between; | ||
| 199 | gap: 1rem; | ||
| 200 | margin-top: 0.5rem; | ||
| 201 | } | ||
| 202 | |||
| 203 | .search { | ||
| 204 | width: 200px; | ||
| 205 | padding: 0.35rem 0.75rem; | ||
| 206 | border: 2px solid var(--box-outline); | ||
| 207 | border-radius: var(--curve-lg); | ||
| 208 | box-shadow: 2px 2px 0 var(--box-outline); | ||
| 209 | background: var(--accent-fg); | ||
| 210 | color: var(--foreground); | ||
| 211 | &:focus { | ||
| 212 | outline: none; | ||
| 213 | border-color: var(--accent); | ||
| 214 | box-shadow: 2px 2px 0 var(--accent); | ||
| 215 | } | ||
| 216 | &::placeholder { | ||
| 217 | opacity: 0.5; | ||
| 218 | } | ||
| 219 | } | ||
| 220 | |||
| 221 | .filters { | ||
| 222 | display: flex; | ||
| 223 | gap: 0.3rem; | ||
| 224 | flex-wrap: wrap; | ||
| 225 | } | ||
| 226 | |||
| 227 | .pill { | ||
| 228 | display: flex; | ||
| 229 | align-items: center; | ||
| 230 | gap: 0.25rem; | ||
| 231 | padding: 0.15rem 0.5rem; | ||
| 232 | border: 1px solid transparent; | ||
| 233 | border-radius: var(--curve-md); | ||
| 234 | background: var(--background); | ||
| 235 | color: var(--foreground); | ||
| 236 | cursor: pointer; | ||
| 237 | font-family: 'Lekton', sans-serif; | ||
| 238 | font-size: 0.75rem; | ||
| 239 | opacity: 0.5; | ||
| 240 | transition: opacity 0.2s ease-in-out; | ||
| 241 | |||
| 242 | .icon { | ||
| 243 | font-size: 0.85rem; | ||
| 244 | line-height: 1; | ||
| 245 | } | ||
| 246 | &.active { | ||
| 247 | opacity: 1; | ||
| 248 | border-color: currentColor; | ||
| 249 | } | ||
| 250 | &.added { | ||
| 251 | &.active { color: var(--changelog-add); } | ||
| 252 | &:hover { background: color-mix(in srgb, var(--changelog-add) 10%, transparent); } | ||
| 253 | } | ||
| 254 | &.removed { | ||
| 255 | &.active { color: var(--changelog-rem); } | ||
| 256 | &:hover { background: color-mix(in srgb, var(--changelog-rem) 10%, transparent); } | ||
| 257 | } | ||
| 258 | &.modified { | ||
| 259 | &.active { color: var(--changelog-mod); } | ||
| 260 | &:hover { background: color-mix(in srgb, var(--changelog-mod) 10%, transparent); } | ||
| 261 | } | ||
| 262 | &.rejected { | ||
| 263 | &.active { color: var(--changelog-rej); } | ||
| 264 | &:hover { background: color-mix(in srgb, var(--changelog-rej) 10%, transparent); } | ||
| 265 | } | ||
| 266 | } | ||
| 267 | } | ||
| 268 | |||
| 269 | .empty { | ||
| 270 | text-align: center; | ||
| 271 | opacity: 0.6; | ||
| 272 | margin: 2rem 0; | ||
| 273 | } | ||
| 274 | |||
| 275 | .month-header { | ||
| 276 | font-size: 1.3rem; | ||
| 277 | margin: 1.5rem 0 0.5rem 0; | ||
| 278 | padding-bottom: 0.3rem; | ||
| 279 | border-bottom: 1px solid var(--accent-3); | ||
| 280 | color: var(--accent-3); | ||
| 281 | font-family: 'Lekton', sans-serif; | ||
| 282 | } | ||
| 283 | |||
| 284 | .entry { | ||
| 285 | display: flex; | ||
| 286 | gap: 1rem; | ||
| 287 | padding: 0.6rem 0; | ||
| 288 | border-bottom: 1px solid rgba(255, 255, 255, 0.05); | ||
| 289 | &:last-child { | ||
| 290 | border-bottom: none; | ||
| 291 | } | ||
| 292 | |||
| 293 | .entry-date { | ||
| 294 | min-width: 7rem; | ||
| 295 | opacity: 0.75; | ||
| 296 | padding-top: 0.15rem; | ||
| 297 | font-family: 'Lekton', sans-serif; | ||
| 298 | } | ||
| 299 | |||
| 300 | .entry-body { | ||
| 301 | flex: 1; | ||
| 302 | min-width: 0; | ||
| 303 | } | ||
| 304 | } | ||
| 305 | |||
| 306 | .summary { | ||
| 307 | display: flex; | ||
| 308 | align-items: center; | ||
| 309 | gap: 0.4rem; | ||
| 310 | flex-wrap: wrap; | ||
| 311 | margin-bottom: 0.3rem; | ||
| 312 | font-size: 0.85rem; | ||
| 313 | opacity: 0.8; | ||
| 314 | .author a { | ||
| 315 | color: var(--foreground); | ||
| 316 | &:hover { | ||
| 317 | color: var(--accent); | ||
| 318 | } | ||
| 319 | } | ||
| 320 | .avatar { | ||
| 321 | border-radius: 50%; | ||
| 322 | } | ||
| 323 | .pr-link { | ||
| 324 | padding: 0 0.4rem; | ||
| 325 | border-radius: var(--curve-sm); | ||
| 326 | background: var(--accent-3); | ||
| 327 | color: var(--foreground); | ||
| 328 | text-decoration: none; | ||
| 329 | font-family: 'Lekton', sans-serif; | ||
| 330 | &:hover { | ||
| 331 | opacity: 0.85; | ||
| 332 | } | ||
| 333 | } | ||
| 334 | } | ||
| 335 | |||
| 336 | .changes { | ||
| 337 | display: flex; | ||
| 338 | flex-direction: column; | ||
| 339 | gap: 0.2rem; | ||
| 340 | .change { | ||
| 341 | display: flex; | ||
| 342 | align-items: baseline; | ||
| 343 | gap: 0.4rem; | ||
| 344 | flex-wrap: wrap; | ||
| 345 | } | ||
| 346 | } | ||
| 347 | |||
| 348 | .badge { | ||
| 349 | font-size: 0.8rem; | ||
| 350 | padding: 0.05rem 0.35rem; | ||
| 351 | border-radius: var(--curve-sm); | ||
| 352 | font-family: 'Lekton', sans-serif; | ||
| 353 | text-transform: uppercase; | ||
| 354 | font-weight: bold; | ||
| 355 | &.add { | ||
| 356 | background: color-mix(in srgb, var(--changelog-add) 33%, transparent); | ||
| 357 | color: var(--changelog-add); | ||
| 358 | } | ||
| 359 | &.rem { | ||
| 360 | background: color-mix(in srgb, var(--changelog-rem) 33%, transparent); | ||
| 361 | color: var(--changelog-rem); | ||
| 362 | } | ||
| 363 | &.mod { | ||
| 364 | background: color-mix(in srgb, var(--changelog-mod) 33%, transparent); | ||
| 365 | color: var(--changelog-mod); | ||
| 366 | } | ||
| 367 | &.rej { | ||
| 368 | background: color-mix(in srgb, var(--changelog-rej) 33%, transparent); | ||
| 369 | color: var(--changelog-rej); | ||
| 370 | } | ||
| 371 | } | ||
| 372 | |||
| 373 | .svc-name { | ||
| 374 | font-weight: 500; | ||
| 375 | color: var(--foreground); | ||
| 376 | text-decoration: none; | ||
| 377 | } | ||
| 378 | a.svc-name:hover { | ||
| 379 | color: var(--accent); | ||
| 380 | text-decoration: underline; | ||
| 381 | } | ||
| 382 | |||
| 383 | .path, | ||
| 384 | .fields { | ||
| 385 | font-size: 0.8rem; | ||
| 386 | opacity: 0.6; | ||
| 387 | } | ||
| 388 | .fields { | ||
| 389 | font-style: italic; | ||
| 390 | } | ||
| 391 | |||
| 392 | @media (max-width: 600px) { | ||
| 393 | .entry { | ||
| 394 | flex-direction: column; | ||
| 395 | gap: 0.2rem; | ||
| 396 | .entry-date { | ||
| 397 | min-width: unset; | ||
| 398 | } | ||
| 399 | } | ||
| 400 | } | ||
| 401 | </style> | ||
web/src/components/things/DataActions.svelte +74
| @@ -7,9 +7,17 @@ | |||
| 7 | } from '@utils/data-src-delete-n-edit'; | 7 | } from '@utils/data-src-delete-n-edit'; |
| 8 | import FontAwesome from '@components/form/FontAwesome.svelte'; | 8 | import FontAwesome from '@components/form/FontAwesome.svelte'; |
| 9 | 9 | ||
| 10 | import type { ChangelogPr } from '../../utils/fetch-changelog'; | ||
| 11 | |||
| 10 | export let categoryName: string; | 12 | export let categoryName: string; |
| 11 | export let sectionName: string; | 13 | export let sectionName: string; |
| 12 | export let serviceName: string; | 14 | export let serviceName: string; |
| 15 | export let history: Array<{ | ||
| 16 | date: string; | ||
| 17 | type: 'added' | 'removed' | 'modified'; | ||
| 18 | fields?: string[]; | ||
| 19 | pr?: ChangelogPr | null; | ||
| 20 | }> = []; | ||
| 13 | 21 | ||
| 14 | let lineNumbers: { start: number; end: number } | null = null; | 22 | let lineNumbers: { start: number; end: number } | null = null; |
| 15 | let yamlContent = ''; | 23 | let yamlContent = ''; |
| @@ -38,6 +46,29 @@ | |||
| 38 | }); | 46 | }); |
| 39 | </script> | 47 | </script> |
| 40 | 48 | ||
| 49 | {#if history.length > 0} | ||
| 50 | <h4>Change History</h4> | ||
| 51 | <ul class="history"> | ||
| 52 | {#each history as h (h.date + h.type)} | ||
| 53 | <li> | ||
| 54 | <span class="history-badge {h.type}"> | ||
| 55 | {h.type === 'added' ? 'Added' : h.type === 'removed' ? 'Removed' : 'Amended'} | ||
| 56 | </span> | ||
| 57 | <time>{new Date(h.date + 'T00:00:00Z').toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric', timeZone: 'UTC' })}</time> | ||
| 58 | {#if h.fields}<span class="history-fields">({h.fields.join(', ')})</span>{/if} | ||
| 59 | {#if h.pr?.author} | ||
| 60 | <span class="history-author">by | ||
| 61 | <a href={`https://github.com/${h.pr.author}`} target="_blank" rel="noreferrer">@{h.pr.author}</a> | ||
| 62 | </span> | ||
| 63 | {/if} | ||
| 64 | {#if h.pr} | ||
| 65 | <a class="history-pr" href={h.pr.url} target="_blank" rel="noreferrer">#{h.pr.number}</a> | ||
| 66 | {/if} | ||
| 67 | </li> | ||
| 68 | {/each} | ||
| 69 | </ul> | ||
| 70 | {/if} | ||
| 71 | |||
| 41 | {#if lineNumbers} | 72 | {#if lineNumbers} |
| 42 | <h4>Edit {serviceName} Data</h4> | 73 | <h4>Edit {serviceName} Data</h4> |
| 43 | <p> | 74 | <p> |
| @@ -126,6 +157,49 @@ | |||
| 126 | } | 157 | } |
| 127 | } | 158 | } |
| 128 | 159 | ||
| 160 | .history { | ||
| 161 | list-style: none; | ||
| 162 | padding: 0; | ||
| 163 | margin: 0.5rem 0 1rem 0; | ||
| 164 | li { | ||
| 165 | display: flex; | ||
| 166 | align-items: baseline; | ||
| 167 | gap: 0.4rem; | ||
| 168 | flex-wrap: wrap; | ||
| 169 | padding: 0.3rem 0; | ||
| 170 | font-size: 0.95rem; | ||
| 171 | border-bottom: 1px solid rgba(255, 255, 255, 0.05); | ||
| 172 | &:last-child { border-bottom: none; } | ||
| 173 | } | ||
| 174 | time { opacity: 0.6; font-family: 'Lekton', sans-serif; font-size: 0.85rem; } | ||
| 175 | } | ||
| 176 | .history-badge { | ||
| 177 | font-size: 0.7rem; | ||
| 178 | padding: 0.05rem 0.35rem; | ||
| 179 | border-radius: var(--curve-sm); | ||
| 180 | font-family: 'Lekton', sans-serif; | ||
| 181 | text-transform: uppercase; | ||
| 182 | font-weight: bold; | ||
| 183 | &.added { background: color-mix(in srgb, var(--changelog-add) 33%, transparent); color: var(--changelog-add); } | ||
| 184 | &.removed { background: color-mix(in srgb, var(--changelog-rem) 33%, transparent); color: var(--changelog-rem); } | ||
| 185 | &.modified { background: color-mix(in srgb, var(--changelog-mod) 33%, transparent); color: var(--changelog-mod); } | ||
| 186 | } | ||
| 187 | .history-fields { font-size: 0.8rem; opacity: 0.5; font-style: italic; } | ||
| 188 | .history-author { | ||
| 189 | font-size: 0.85rem; opacity: 0.7; | ||
| 190 | a { color: var(--foreground); &:hover { color: var(--accent); } } | ||
| 191 | } | ||
| 192 | .history-pr { | ||
| 193 | font-size: 0.75rem; | ||
| 194 | padding: 0.05rem 0.3rem; | ||
| 195 | border-radius: var(--curve-sm); | ||
| 196 | background: var(--accent-3); | ||
| 197 | color: var(--accent-fg); | ||
| 198 | text-decoration: none; | ||
| 199 | font-family: 'Lekton', sans-serif; | ||
| 200 | &:hover { opacity: 0.85; } | ||
| 201 | } | ||
| 202 | |||
| 129 | .yaml-embed { | 203 | .yaml-embed { |
| 130 | width: 100%; | 204 | width: 100%; |
| 131 | height: 370px; | 205 | height: 370px; |
web/src/pages/[...listing].astro +19
| @@ -14,6 +14,7 @@ import SocialShare from '@components/form/Social.astro'; | |||
| 14 | import DataActions from '@components/things/DataActions.svelte'; | 14 | import DataActions from '@components/things/DataActions.svelte'; |
| 15 | import type { AwesomePrivacy, Section, Service } from '../types/Service'; | 15 | import type { AwesomePrivacy, Section, Service } from '../types/Service'; |
| 16 | import { fetchData, slugify } from '@utils/fetch-data'; | 16 | import { fetchData, slugify } from '@utils/fetch-data'; |
| 17 | import { fetchChangelog } from '@utils/fetch-changelog'; | ||
| 17 | import { fetchGitHubStats } from '@utils/fetch-repo-info'; | 18 | import { fetchGitHubStats } from '@utils/fetch-repo-info'; |
| 18 | import { fetchTosdrPrivacy } from '@utils/fetch-privacy-policy'; | 19 | import { fetchTosdrPrivacy } from '@utils/fetch-privacy-policy'; |
| 19 | import { fetchWebsiteInfo } from '@utils/fetch-website-info'; | 20 | import { fetchWebsiteInfo } from '@utils/fetch-website-info'; |
| @@ -176,6 +177,23 @@ const websiteData = | |||
| 176 | ? await fetchWebsiteInfo(url) | 177 | ? await fetchWebsiteInfo(url) |
| 177 | : null; | 178 | : null; |
| 178 | 179 | ||
| 180 | // Filter changelog entries relevant to this service | ||
| 181 | const serviceHistory = await fetchChangelog().then(({ entries }) => { | ||
| 182 | const isMatch = (c: { name: string; category: string; section: string }) => | ||
| 183 | c.name === name && c.category === categoryName && c.section === parentSection.name; | ||
| 184 | const results: Array<{ date: string; type: 'added' | 'removed' | 'modified'; fields?: string[]; pr?: import('@utils/fetch-changelog').ChangelogPr | null }> = []; | ||
| 185 | for (const e of entries) { | ||
| 186 | const s = e.changes?.services; | ||
| 187 | const added = (s?.added || []).find(isMatch); | ||
| 188 | const removed = (s?.removed || []).find(isMatch); | ||
| 189 | const modified = (s?.modified || []).find(isMatch); | ||
| 190 | if (added) results.push({ date: e.date, type: 'added', pr: e.pr }); | ||
| 191 | else if (removed) results.push({ date: e.date, type: 'removed', pr: e.pr }); | ||
| 192 | else if (modified) results.push({ date: e.date, type: 'modified', fields: modified.fields, pr: e.pr }); | ||
| 193 | } | ||
| 194 | return results; | ||
| 195 | }); | ||
| 196 | |||
| 179 | const findPrivacyPolicyLink = () => { | 197 | const findPrivacyPolicyLink = () => { |
| 180 | if (!privacyData) return null; | 198 | if (!privacyData) return null; |
| 181 | // const docs = privacyData?.parameters?.documents; | 199 | // const docs = privacyData?.parameters?.documents; |
| @@ -466,6 +484,7 @@ const getApiEndpoint = () => { | |||
| 466 | categoryName={categoryName} | 484 | categoryName={categoryName} |
| 467 | sectionName={parentSection.name} | 485 | sectionName={parentSection.name} |
| 468 | serviceName={name} | 486 | serviceName={name} |
| 487 | history={serviceHistory} | ||
| 469 | /> | 488 | /> |
| 470 | <h4>API</h4> | 489 | <h4>API</h4> |
| 471 | <p> | 490 | <p> |
web/src/pages/changelog.astro added +41
| @@ -0,0 +1,41 @@ | |||
| 1 | --- | ||
| 2 | import Layout from '@layouts/Layout.astro'; | ||
| 3 | import Main from '@components/scafold/MainCard.astro'; | ||
| 4 | import ChangelogTimeline from '@components/things/ChangelogTimeline.svelte'; | ||
| 5 | import { fetchChangelog } from '@utils/fetch-changelog'; | ||
| 6 | |||
| 7 | const changelog = await fetchChangelog(); | ||
| 8 | --- | ||
| 9 | |||
| 10 | <Layout title="Changelog | Awesome Privacy" description="A transparent log of all additions, removals, and amendments to the Awesome Privacy list."> | ||
| 11 | <div class="changelog-page"> | ||
| 12 | <Main> | ||
| 13 | <h2>Changelog</h2> | ||
| 14 | <p> | ||
| 15 | All data in awesome-privacy is managed via Git, | ||
| 16 | so that we have a complete and transparent changelog | ||
| 17 | of exactly what was added when and by whom. | ||
| 18 | </p> | ||
| 19 | {changelog.entries.length > 0 ? ( | ||
| 20 | <ChangelogTimeline client:load entries={changelog.entries} rejections={changelog.rejections || []} /> | ||
| 21 | ) : ( | ||
| 22 | <p class="fallback">Changelog data is currently unavailable.</p> | ||
| 23 | )} | ||
| 24 | </Main> | ||
| 25 | </div> | ||
| 26 | </Layout> | ||
| 27 | |||
| 28 | <style lang="scss"> | ||
| 29 | h2 { | ||
| 30 | font-size: 2rem; | ||
| 31 | margin: 0; | ||
| 32 | } | ||
| 33 | p { | ||
| 34 | font-size: 1.2rem; | ||
| 35 | margin: 0 0 1rem 0; | ||
| 36 | } | ||
| 37 | .fallback { | ||
| 38 | text-align: center; | ||
| 39 | opacity: 0.6; | ||
| 40 | } | ||
| 41 | </style> | ||
web/src/styles/values.css +5
| @@ -24,6 +24,11 @@ html { | |||
| 24 | 24 | ||
| 25 | --box-outline: #000; | 25 | --box-outline: #000; |
| 26 | 26 | ||
| 27 | --changelog-add: #6fdd8b; | ||
| 28 | --changelog-rem: #fdcc0b; | ||
| 29 | --changelog-mod: #42c1ff; | ||
| 30 | --changelog-rej: #ff2d55; | ||
| 31 | |||
| 27 | &[data-theme='light'] { | 32 | &[data-theme='light'] { |
| 28 | --accent: #f45397; | 33 | --accent: #f45397; |
| 29 | --accent-fg: #fff; | 34 | --accent-fg: #fff; |
web/src/utils/fetch-changelog.ts added +67
| @@ -0,0 +1,67 @@ | |||
| 1 | import { error } from './logger'; | ||
| 2 | |||
| 3 | const changelogUrl = | ||
| 4 | 'https://raw.githubusercontent.com/Lissy93/awesome-privacy/main/.github/changelog.json'; | ||
| 5 | // 'https://gist.githubusercontent.com/Lissy93/ddae176f3f21a0d3c0251f5f6cbd3b09/raw/0d5f8fbbb642be62af94fae8f83ed55b48ed355c/changelog.json'; | ||
| 6 | |||
| 7 | export interface ChangelogPr { | ||
| 8 | number: number; | ||
| 9 | url: string; | ||
| 10 | author?: string; | ||
| 11 | authorAvatar?: string; | ||
| 12 | } | ||
| 13 | |||
| 14 | export interface ServiceChange { | ||
| 15 | name: string; | ||
| 16 | category: string; | ||
| 17 | section: string; | ||
| 18 | fields?: string[]; | ||
| 19 | } | ||
| 20 | |||
| 21 | export interface ChangelogEntry { | ||
| 22 | date: string; | ||
| 23 | sha: string; | ||
| 24 | pr?: ChangelogPr | null; | ||
| 25 | changes: { | ||
| 26 | services?: { | ||
| 27 | added?: ServiceChange[]; | ||
| 28 | removed?: ServiceChange[]; | ||
| 29 | modified?: ServiceChange[]; | ||
| 30 | }; | ||
| 31 | sections?: { | ||
| 32 | added?: { name: string; category: string }[]; | ||
| 33 | removed?: { name: string; category: string }[]; | ||
| 34 | }; | ||
| 35 | categories?: { | ||
| 36 | added?: string[]; | ||
| 37 | removed?: string[]; | ||
| 38 | }; | ||
| 39 | }; | ||
| 40 | } | ||
| 41 | |||
| 42 | export interface Rejection { | ||
| 43 | date: string; | ||
| 44 | title: string; | ||
| 45 | pr: ChangelogPr; | ||
| 46 | } | ||
| 47 | |||
| 48 | export interface Changelog { | ||
| 49 | generatedAt: string; | ||
| 50 | entries: ChangelogEntry[]; | ||
| 51 | rejections?: Rejection[]; | ||
| 52 | } | ||
| 53 | |||
| 54 | export const fetchChangelog = async (): Promise<Changelog> => { | ||
| 55 | try { | ||
| 56 | const res = await fetch(changelogUrl); | ||
| 57 | if (!res.ok) { | ||
| 58 | error('Changelog', `HTTP ${res.status} fetching changelog.json`); | ||
| 59 | return { generatedAt: '', entries: [] }; | ||
| 60 | } | ||
| 61 | const data: Changelog = await res.json(); | ||
| 62 | return data; | ||
| 63 | } catch (err) { | ||
| 64 | error('Changelog', `Failed to fetch changelog.json: ${err}`); | ||
| 65 | return { generatedAt: '', entries: [] }; | ||
| 66 | } | ||
| 67 | }; | ||